mirror of
https://github.com/teamcapybara/capybara.git
synced 2022-11-09 12:08:07 -05:00
Merge pull request #461 from clnclarinet/issue-452
Closes issue #452. #using_driver now restores the driver to what it was b
This commit is contained in:
commit
1a2c576175
2 changed files with 13 additions and 1 deletions
|
@ -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
|
||||
|
||||
##
|
||||
|
|
|
@ -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 }
|
||||
|
|
Loading…
Reference in a new issue