From 02045d2306c8c66ead10c68aa90c10d329b09563 Mon Sep 17 00:00:00 2001 From: Thomas Walpole Date: Fri, 22 Nov 2013 15:59:51 -0800 Subject: [PATCH] Make sure browser gets cleared when Capybara::Selenium::Driver#quit is called --- lib/capybara/selenium/driver.rb | 2 ++ spec/selenium_spec.rb | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/lib/capybara/selenium/driver.rb b/lib/capybara/selenium/driver.rb index 3da2cfaa..3f815d3b 100644 --- a/lib/capybara/selenium/driver.rb +++ b/lib/capybara/selenium/driver.rb @@ -152,6 +152,8 @@ class Capybara::Selenium::Driver < Capybara::Driver::Base @browser.quit if @browser rescue Errno::ECONNREFUSED # Browser must have already gone + ensure + @browser = nil end def invalid_element_errors diff --git a/spec/selenium_spec.rb b/spec/selenium_spec.rb index 6b94d590..57e0628f 100644 --- a/spec/selenium_spec.rb +++ b/spec/selenium_spec.rb @@ -57,3 +57,20 @@ describe Capybara::Session do end end end + +describe Capybara::Selenium::Driver do + before do + @driver = Capybara::Selenium::Driver.new(TestApp, browser: :firefox) + end + + describe '#quit' do + it "should reset browser when quit" do + @driver.browser.should be + @driver.quit + #access instance variable directly so we don't create a new browser instance + @driver.instance_variable_get(:@browser).should be_nil + end + end +end + +