diff options
Diffstat (limited to 'actionpack/test')
4 files changed, 23 insertions, 31 deletions
diff --git a/actionpack/test/abstract_unit.rb b/actionpack/test/abstract_unit.rb index 459b0d6c54..4185ce1a1f 100644 --- a/actionpack/test/abstract_unit.rb +++ b/actionpack/test/abstract_unit.rb @@ -439,3 +439,11 @@ class ActiveSupport::TestCase skip message if defined?(JRUBY_VERSION) end end + +class DrivenByRackTest < ActionDispatch::SystemTestCase + driven_by :rack_test +end + +class DrivenBySeleniumWithChrome < ActionDispatch::SystemTestCase + driven_by :selenium, using: :chrome +end diff --git a/actionpack/test/dispatch/system_testing/driver_test.rb b/actionpack/test/dispatch/system_testing/driver_test.rb index 96d598a7a3..8f8777b19f 100644 --- a/actionpack/test/dispatch/system_testing/driver_test.rb +++ b/actionpack/test/dispatch/system_testing/driver_test.rb @@ -8,10 +8,10 @@ class DriverTest < ActiveSupport::TestCase end test "initializing the driver with a browser" do - driver = ActionDispatch::SystemTesting::Driver.new(:selenium, using: :chrome, screen_size: [ 1400, 1400 ]) + driver = ActionDispatch::SystemTesting::Driver.new(:selenium, using: :chrome, screen_size: [1400, 1400]) assert_equal :selenium, driver.instance_variable_get(:@name) - assert_equal :chrome, driver.instance_variable_get(:@using) - assert_equal [ 1400, 1400 ], driver.instance_variable_get(:@screen_size) + assert_equal :chrome, driver.instance_variable_get(:@browser) + assert_equal [1400, 1400], driver.instance_variable_get(:@screen_size) end test "selenium? returns false if driver is poltergeist" do diff --git a/actionpack/test/dispatch/system_testing/screenshot_helper_test.rb b/actionpack/test/dispatch/system_testing/screenshot_helper_test.rb index d6b501b3ac..a83818fd80 100644 --- a/actionpack/test/dispatch/system_testing/screenshot_helper_test.rb +++ b/actionpack/test/dispatch/system_testing/screenshot_helper_test.rb @@ -4,13 +4,13 @@ require "capybara/dsl" class ScreenshotHelperTest < ActiveSupport::TestCase test "image path is saved in tmp directory" do - new_test = ActionDispatch::SystemTestCase.new("x") + new_test = DrivenBySeleniumWithChrome.new("x") assert_equal "tmp/screenshots/x.png", new_test.send(:image_path) end test "image path includes failures text if test did not pass" do - new_test = ActionDispatch::SystemTestCase.new("x") + new_test = DrivenBySeleniumWithChrome.new("x") new_test.stub :passed?, false do assert_equal "tmp/screenshots/failures_x.png", new_test.send(:image_path) @@ -18,7 +18,7 @@ class ScreenshotHelperTest < ActiveSupport::TestCase end test "image path does not include failures text if test skipped" do - new_test = ActionDispatch::SystemTestCase.new("x") + new_test = DrivenBySeleniumWithChrome.new("x") new_test.stub :passed?, false do new_test.stub :skipped?, true do @@ -26,28 +26,16 @@ class ScreenshotHelperTest < ActiveSupport::TestCase end end end +end +class RackTestScreenshotsTest < DrivenByRackTest test "rack_test driver does not support screenshot" do - begin - original_driver = Capybara.current_driver - Capybara.current_driver = :rack_test - - new_test = ActionDispatch::SystemTestCase.new("x") - assert_not new_test.send(:supports_screenshot?) - ensure - Capybara.current_driver = original_driver - end + assert_not self.send(:supports_screenshot?) end +end +class SeleniumScreenshotsTest < DrivenBySeleniumWithChrome test "selenium driver supports screenshot" do - begin - original_driver = Capybara.current_driver - Capybara.current_driver = :selenium - - new_test = ActionDispatch::SystemTestCase.new("x") - assert new_test.send(:supports_screenshot?) - ensure - Capybara.current_driver = original_driver - end + assert self.send(:supports_screenshot?) end end diff --git a/actionpack/test/dispatch/system_testing/system_test_case_test.rb b/actionpack/test/dispatch/system_testing/system_test_case_test.rb index c9003e3841..1a9421c098 100644 --- a/actionpack/test/dispatch/system_testing/system_test_case_test.rb +++ b/actionpack/test/dispatch/system_testing/system_test_case_test.rb @@ -1,17 +1,13 @@ require "abstract_unit" -class DrivenByRackTestTest < ActionDispatch::SystemTestCase - driven_by :rack_test - +class SetDriverToRackTestTest < DrivenByRackTest test "uses rack_test" do assert_equal :rack_test, Capybara.current_driver end end -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 end end |