Please sign in to comment.
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.
- Loading branch information...
Showing with 36 additions and 42 deletions.
- +12 −5 actionpack/lib/action_dispatch/system_test_case.rb
- +0 −5 actionpack/lib/action_dispatch/system_testing/driver.rb
- +1 −1 actionpack/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb
- +8 −0 actionpack/test/abstract_unit.rb
- +3 −3 actionpack/test/dispatch/system_testing/driver_test.rb
- +9 −21 actionpack/test/dispatch/system_testing/screenshot_helper_test.rb
- +3 −7 actionpack/test/dispatch/system_testing/system_test_case_test.rb
|@@ -1,17 +1,13 @@|
|class DrivenByRackTestTest < ActionDispatch::SystemTestCase|
|class SetDriverToRackTestTest < DrivenByRackTest|
|test "uses rack_test" do|
|assert_equal :rack_test, Capybara.current_driver|
|class DrivenBySeleniumWithChromeTest < ActionDispatch::SystemTestCase|
|driven_by :selenium, using: :chrome|
|class SetDriverToSeleniumTest < DrivenBySeleniumWithChrome|
|test "uses selenium" do|
|assert_equal :chrome, Capybara.current_driver|
|assert_equal :selenium, Capybara.current_driver|