diff options
author | Maxim Perepelitsa <n0xff@outlook.com> | 2018-11-09 01:03:04 +0700 |
---|---|---|
committer | Maxim Perepelitsa <n0xff@outlook.com> | 2018-11-13 03:30:41 +0700 |
commit | 59895db44b73b9a333387eee2078fda8feec9ce5 (patch) | |
tree | ac7602eb1d043c489fbeadd06b1b8dc30f609153 /railties/test | |
parent | 4fe27cdc15b88fed5ae725a886b7e96202f649a8 (diff) | |
download | rails-59895db44b73b9a333387eee2078fda8feec9ce5.tar.gz rails-59895db44b73b9a333387eee2078fda8feec9ce5.tar.bz2 rails-59895db44b73b9a333387eee2078fda8feec9ce5.zip |
Reset sessions on failed system test screenshot
Reset Capybara sessions if `take_failed_screenshot` raise exception
in system test `after_teardown`.
Diffstat (limited to 'railties/test')
-rw-r--r-- | railties/test/application/test_runner_test.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/railties/test/application/test_runner_test.rb b/railties/test/application/test_runner_test.rb index 5c34b205c9..e98a41fb26 100644 --- a/railties/test/application/test_runner_test.rb +++ b/railties/test/application/test_runner_test.rb @@ -703,6 +703,31 @@ module ApplicationTests end end + def test_reset_sessions_on_failed_system_test_screenshot + app_file "test/system/reset_sessions_on_failed_system_test_screenshot_test.rb", <<~RUBY + require "application_system_test_case" + + class ResetSessionsOnFailedSystemTestScreenshotTest < ApplicationSystemTestCase + ActionDispatch::SystemTestCase.class_eval do + def take_failed_screenshot + raise Capybara::CapybaraError + end + end + + Capybara.instance_eval do + def reset_sessions! + puts "Capybara.reset_sessions! called" + end + end + + test "dummy" do + end + end + RUBY + output = run_test_command("test/system/reset_sessions_on_failed_system_test_screenshot_test.rb") + assert_match "Capybara.reset_sessions! called", output + end + def test_system_tests_are_not_run_with_the_default_test_command app_file "test/system/dummy_test.rb", <<-RUBY require "application_system_test_case" |