forked from teamcapybara/capybara
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add RSpec support in Capybara itself, closes teamcapybara#187
Just the basics of including Capybara and setting up some metadata to switch between drivers.
- Loading branch information
Anders Törnqvist
committed
Dec 10, 2010
1 parent
05d9697
commit aa46894
Showing
3 changed files
with
101 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
require 'capybara' | ||
require 'capybara/dsl' | ||
|
||
Rspec.configure do |config| | ||
config.include Capybara | ||
config.after do | ||
Capybara.reset_sessions! | ||
Capybara.use_default_driver | ||
end | ||
config.before do | ||
Capybara.current_driver = Capybara.javascript_driver if example.metadata[:js] | ||
Capybara.current_driver = example.metadata[:driver] if example.metadata[:driver] | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
require 'spec_helper' | ||
require 'capybara/rspec' | ||
|
||
Capybara.app = TestApp | ||
|
||
describe 'capybara/rspec' do | ||
it "should include Capybara in rpsec" do | ||
visit('/foo') | ||
page.body.should include('Another World') | ||
end | ||
|
||
context "resetting session" do | ||
it "sets a cookie in one example..." do | ||
visit('/set_cookie') | ||
page.body.should include('Cookie set to test_cookie') | ||
end | ||
|
||
it "...then it is not availbable in the next" do | ||
visit('/get_cookie') | ||
page.body.should_not include('test_cookie') | ||
end | ||
end | ||
|
||
context "setting the current driver" do | ||
it "sets the current driver in one example..." do | ||
Capybara.current_driver = :selenium | ||
end | ||
|
||
it "...then it has returned to the default in the next example" do | ||
Capybara.current_driver.should == :rack_test | ||
end | ||
end | ||
|
||
it "switches to the javascript driver when giving it as metadata", :js => true do | ||
Capybara.current_driver.should == :selenium | ||
end | ||
|
||
it "switches to the given driver when giving it as metadata", :driver => :culerity do | ||
Capybara.current_driver.should == :culerity | ||
end | ||
end |