From 7c9af60e5c26941dc9ec6a263f5fc5fe10050cba Mon Sep 17 00:00:00 2001 From: eileencodes Date: Mon, 6 Mar 2017 12:33:34 -0500 Subject: Call system test driver per-instance rather than globally Previously the system test subclasses would call `driven_by` when the app booted and not again when the test was initialized which resulted in the driver from whichever class was called last to be used in tests. In rails/rails#28144 the `driven_by` method was changed to run `use` on setup and `reset` on teardown. While this was a viable fix this really pointed to the problem that system test `driven_by` was a global setting, rather than a per-class setting. To alieviate this problem calling the driver should be done on an instance level, rather than on the global level. I added an `initialize` method to `SystemTestCase` which will call `use` on the superclass driver. Running the server has been moved to `start_application` so that it only needs to be called once on boot and no options from `driven_by` were being passed to it. This required a largish rewrite of the tests. Each test needs to utilize the subclass so that it can properly test the drivers. `ActionDispatch::SystemTestCase` shouldn't be called directly anymore. --- actionpack/lib/action_dispatch/system_testing/driver.rb | 5 ----- .../action_dispatch/system_testing/test_helpers/screenshot_helper.rb | 2 +- 2 files changed, 1 insertion(+), 6 deletions(-) (limited to 'actionpack/lib/action_dispatch/system_testing') diff --git a/actionpack/lib/action_dispatch/system_testing/driver.rb b/actionpack/lib/action_dispatch/system_testing/driver.rb index 65e43d3584..72d132d64f 100644 --- a/actionpack/lib/action_dispatch/system_testing/driver.rb +++ b/actionpack/lib/action_dispatch/system_testing/driver.rb @@ -12,10 +12,6 @@ module ActionDispatch setup end - def reset - Capybara.current_driver = @current - end - private def selenium? @name == :selenium @@ -31,7 +27,6 @@ module ActionDispatch def setup Capybara.current_driver = @name - @current = Capybara.current_driver end end end diff --git a/actionpack/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb b/actionpack/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb index e37f6d02aa..6de8fb74dc 100644 --- a/actionpack/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb +++ b/actionpack/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb @@ -57,7 +57,7 @@ module ActionDispatch end def supports_screenshot? - page.driver.public_methods(false).include?(:save_screenshot) + Capybara.current_driver != :rack_test end end end -- cgit v1.2.3