aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/lib/action_dispatch')
-rw-r--r--actionpack/lib/action_dispatch/system_test_case.rb17
-rw-r--r--actionpack/lib/action_dispatch/system_testing/driver.rb5
-rw-r--r--actionpack/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb2
3 files changed, 13 insertions, 11 deletions
diff --git a/actionpack/lib/action_dispatch/system_test_case.rb b/actionpack/lib/action_dispatch/system_test_case.rb
index d872fca6bf..1bf47d2556 100644
--- a/actionpack/lib/action_dispatch/system_test_case.rb
+++ b/actionpack/lib/action_dispatch/system_test_case.rb
@@ -83,12 +83,19 @@ module ActionDispatch
include SystemTesting::TestHelpers::SetupAndTeardown
include SystemTesting::TestHelpers::ScreenshotHelper
+ def initialize(*) # :nodoc:
+ super
+ self.class.superclass.driver.use
+ end
+
def self.start_application # :nodoc:
Capybara.app = Rack::Builder.new do
map "/" do
run Rails.application
end
end
+
+ SystemTesting::Server.new.run
end
# System Test configuration options
@@ -104,12 +111,12 @@ module ActionDispatch
#
# driven_by :selenium, screen_size: [800, 800]
def self.driven_by(driver, using: :chrome, screen_size: [1400, 1400])
- driver = SystemTesting::Driver.new(driver, using: using, screen_size: screen_size)
-
- setup { driver.use }
- teardown { driver.reset }
+ @driver = SystemTesting::Driver.new(driver, using: using, screen_size: screen_size)
+ end
- SystemTesting::Server.new.run
+ # Returns the driver object for the initialized system test
+ def self.driver
+ @driver ||= SystemTestCase.driven_by(:selenium)
end
end
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