diff --git a/lib/capybara/dsl.rb b/lib/capybara/dsl.rb index e6e75f7f..61198d9b 100644 --- a/lib/capybara/dsl.rb +++ b/lib/capybara/dsl.rb @@ -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 ## diff --git a/spec/dsl_spec.rb b/spec/dsl_spec.rb index b1c21654..1fea4dd9 100644 --- a/spec/dsl_spec.rb +++ b/spec/dsl_spec.rb @@ -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 }