1
0
Fork 0
mirror of https://github.com/teamcapybara/capybara.git synced 2022-11-09 12:08:07 -05:00

Closes issue #452. #using_driver now restores the driver to what it was before the block rather than default_driver.

This commit is contained in:
Carol Nichols 2011-08-18 21:41:07 -04:00
parent ec2ff46220
commit 9b0447f203
2 changed files with 13 additions and 1 deletions

View file

@ -49,10 +49,11 @@ module Capybara
# Yield a block using a specific driver
#
def using_driver(driver)
previous_driver = Capybara.current_driver
Capybara.current_driver = driver
yield
ensure
Capybara.use_default_driver
@current_driver = previous_driver
end
##

View file

@ -76,6 +76,17 @@ describe Capybara::DSL do
Capybara.current_driver.should == Capybara.default_driver
end
it 'should return the driver to what it was previously' do
Capybara.current_driver = :selenium
Capybara.using_driver(:culerity) do
Capybara.using_driver(:rack_test) do
Capybara.current_driver.should == :rack_test
end
Capybara.current_driver.should == :culerity
end
Capybara.current_driver.should == :selenium
end
it 'should yield the passed block' do
called = false
Capybara.using_driver(:selenium) { called = true }