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

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 :cleanup!, :reset!
alias_method :reset_session!, :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 # Raise errors encountered in the server

View file

@ -72,4 +72,13 @@ RSpec.describe Capybara::Session do
expect(Capybara.session_name).to eq 'sess1' expect(Capybara.session_name).to eq 'sess1'
end end
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 end