Skip to content

Commit

Permalink
Set Capybara.app at spec run time, not at definition time
Browse files Browse the repository at this point in the history
This bug got triggered on Travis.
  • Loading branch information
joliss committed Jan 3, 2012
1 parent 363b43a commit 9fd6c85
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
3 changes: 0 additions & 3 deletions spec/dsl_spec.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
require 'spec_helper'

require 'capybara/dsl'

describe Capybara::DSL do

before do
Capybara.app = TestApp
end
Expand Down Expand Up @@ -257,5 +255,4 @@
foo.using_wait_time(6)
end
end

end
3 changes: 1 addition & 2 deletions spec/rspec/features_spec.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
require 'spec_helper'
require 'capybara/rspec'

Capybara.app = TestApp

RSpec.configuration.before(:each, :example_group => {:file_path => __FILE__}) do
@in_filtered_hook = true
end

feature "Capybara's feature DSL" do
background do
Capybara.app = TestApp
@in_background = true
end

Expand Down
7 changes: 4 additions & 3 deletions spec/rspec/matchers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@
require 'capybara/dsl'
require 'capybara/rspec/matchers'

Capybara.app = TestApp

describe Capybara::RSpecMatchers do
include Capybara::DSL
include Capybara::RSpecMatchers

before :each do
Capybara.app = TestApp
end

describe "have_css matcher" do
it "gives proper description" do
have_css('h1').description.should == "has css \"h1\""
Expand Down Expand Up @@ -564,4 +566,3 @@
end
end
end

8 changes: 6 additions & 2 deletions spec/rspec_spec.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
require 'spec_helper'

Capybara.app = TestApp

describe 'capybara/rspec', :type => :request do
before :each do
Capybara.app = TestApp
end

it "should include Capybara in rspec" do
visit('/foo')
page.body.should include('Another World')
Expand Down Expand Up @@ -41,12 +43,14 @@

describe 'capybara/rspec', :type => :other do
it "should not include Capybara" do
Capybara.app = TestApp
expect { visit('/') }.to raise_error(NoMethodError)
end
end

feature "Feature DSL" do
scenario "is pulled in" do
Capybara.app = TestApp
visit('/foo')
page.body.should include('Another World')
end
Expand Down

0 comments on commit 9fd6c85

Please sign in to comment.