Add Session#quit

This commit is contained in:
Thomas Walpole 2018-11-28 16:21:29 -08:00
parent 9ce269c3ba
commit 0fe411a6da
2 changed files with 21 additions and 0 deletions

View File

@ -134,6 +134,18 @@ module Capybara
alias_method :cleanup!, :reset!
alias_method :reset_session!, :reset!
##
#
# Disconnect from the current driver. A new driver will be instantiated on the next interaction
#
#
def quit
@driver.quit if @driver.respond_to? :quit
@driver = nil
@touched = false
@server&.reset_error!
end
##
#
# Raise errors encountered in the server

View File

@ -72,4 +72,13 @@ RSpec.describe Capybara::Session do
expect(Capybara.session_name).to eq 'sess1'
end
end
context 'quit' do
it 'will reset the driver' do
session = Capybara::Session.new(:rack_test, TestApp)
driver = session.driver
session.quit
expect(session.driver).not_to eql driver
end
end
end