From 704853b58be60b307261da9b9990a4c87c68860e Mon Sep 17 00:00:00 2001 From: Lucas Mazza Date: Thu, 23 Feb 2017 22:48:12 -0300 Subject: Change `SystemTestCase.driven_by` to use `setup`/`teardown` hooks Previously, `driven_by` would change the Capybara configuration when the test case is loaded, and having multiple test classes with different `driven_by` configs would fail as the last loaded would be effective. --- actionpack/lib/action_dispatch/system_testing/browser.rb | 13 ++++++------- actionpack/lib/action_dispatch/system_testing/driver.rb | 12 ++++++------ 2 files changed, 12 insertions(+), 13 deletions(-) (limited to 'actionpack/lib/action_dispatch/system_testing') diff --git a/actionpack/lib/action_dispatch/system_testing/browser.rb b/actionpack/lib/action_dispatch/system_testing/browser.rb index c9a6628516..14ea06459d 100644 --- a/actionpack/lib/action_dispatch/system_testing/browser.rb +++ b/actionpack/lib/action_dispatch/system_testing/browser.rb @@ -1,14 +1,17 @@ +require "action_dispatch/system_testing/driver" + module ActionDispatch module SystemTesting - class Browser # :nodoc: + class Browser < Driver # :nodoc: def initialize(name, screen_size) + super(name) @name = name @screen_size = screen_size end - def run + def use register - setup + super end private @@ -19,10 +22,6 @@ module ActionDispatch end end end - - def setup - Capybara.default_driver = @name.to_sym - end end end end diff --git a/actionpack/lib/action_dispatch/system_testing/driver.rb b/actionpack/lib/action_dispatch/system_testing/driver.rb index 7c2ad84e19..8decb54419 100644 --- a/actionpack/lib/action_dispatch/system_testing/driver.rb +++ b/actionpack/lib/action_dispatch/system_testing/driver.rb @@ -5,14 +5,14 @@ module ActionDispatch @name = name end - def run - register + def use + @current = Capybara.current_driver + Capybara.current_driver = @name end - private - def register - Capybara.default_driver = @name - end + def reset + Capybara.current_driver = @current + end end end end -- cgit v1.2.3