aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/system_test_case.rb
diff options
context:
space:
mode:
authorLucas Mazza <lucastmazza@gmail.com>2017-02-23 22:48:12 -0300
committerLucas Mazza <lucastmazza@gmail.com>2017-02-24 13:22:22 -0300
commit704853b58be60b307261da9b9990a4c87c68860e (patch)
treec5d4a6fa67a50a6f4427679701794adb6b68061e /actionpack/lib/action_dispatch/system_test_case.rb
parent4ed704740b7ccc8ac9cfb7b5ec62d55ac178ec97 (diff)
downloadrails-704853b58be60b307261da9b9990a4c87c68860e.tar.gz
rails-704853b58be60b307261da9b9990a4c87c68860e.tar.bz2
rails-704853b58be60b307261da9b9990a4c87c68860e.zip
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.
Diffstat (limited to 'actionpack/lib/action_dispatch/system_test_case.rb')
-rw-r--r--actionpack/lib/action_dispatch/system_test_case.rb11
1 files changed, 9 insertions, 2 deletions
diff --git a/actionpack/lib/action_dispatch/system_test_case.rb b/actionpack/lib/action_dispatch/system_test_case.rb
index 70a5b75781..d6388d8fb7 100644
--- a/actionpack/lib/action_dispatch/system_test_case.rb
+++ b/actionpack/lib/action_dispatch/system_test_case.rb
@@ -105,9 +105,16 @@ module ActionDispatch
#
# driven_by :selenium, screen_size: [800, 800]
def self.driven_by(driver, using: :chrome, screen_size: [1400, 1400])
- SystemTesting::Driver.new(driver).run
+ driver = if selenium?(driver)
+ SystemTesting::Browser.new(using, screen_size)
+ else
+ SystemTesting::Driver.new(driver)
+ end
+
+ setup { driver.use }
+ teardown { driver.reset }
+
SystemTesting::Server.new.run
- SystemTesting::Browser.new(using, screen_size).run if selenium?(driver)
end
def self.selenium?(driver) # :nodoc: