aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/system_testing/test_helpers/setup_and_teardown.rb
diff options
context:
space:
mode:
authorRichard Macklin <richard.github@nrm.com>2019-04-20 19:09:50 -0700
committerRichard Macklin <richard.github@nrm.com>2019-04-20 19:32:30 -0700
commitef12ccfd8bc42d88611dea1190988214836b951c (patch)
treef4c74e4219da33f8f4ed019cea5629d2a348fd4c /actionpack/lib/action_dispatch/system_testing/test_helpers/setup_and_teardown.rb
parent80b7d58f34a965fc0269ab7e0efa86d39b86be56 (diff)
downloadrails-ef12ccfd8bc42d88611dea1190988214836b951c.tar.gz
rails-ef12ccfd8bc42d88611dea1190988214836b951c.tar.bz2
rails-ef12ccfd8bc42d88611dea1190988214836b951c.zip
Make system tests take failed screenshots in `before_teardown` hook
Previously we were calling the `take_failed_screenshot` method in an `after_teardown` hook. However, this means that other teardown hooks have to be executed before we take the screenshot. Since there can be dynamic updates to the page after the assertion fails and before we take a screenshot, it seems desirable to minimize that gap as much as possible. Taking the screenshot in a `before_teardown` rather than an `after_teardown` helps with that, and has a side benefit of allowing us to remove the nested `ensure` commented on here: https://github.com/rails/rails/pull/34411#discussion_r232819478
Diffstat (limited to 'actionpack/lib/action_dispatch/system_testing/test_helpers/setup_and_teardown.rb')
-rw-r--r--actionpack/lib/action_dispatch/system_testing/test_helpers/setup_and_teardown.rb12
1 files changed, 7 insertions, 5 deletions
diff --git a/actionpack/lib/action_dispatch/system_testing/test_helpers/setup_and_teardown.rb b/actionpack/lib/action_dispatch/system_testing/test_helpers/setup_and_teardown.rb
index 600e9c733b..7080dbe022 100644
--- a/actionpack/lib/action_dispatch/system_testing/test_helpers/setup_and_teardown.rb
+++ b/actionpack/lib/action_dispatch/system_testing/test_helpers/setup_and_teardown.rb
@@ -16,12 +16,14 @@ module ActionDispatch
super
end
+ def before_teardown
+ take_failed_screenshot
+ ensure
+ super
+ end
+
def after_teardown
- begin
- take_failed_screenshot
- ensure
- Capybara.reset_sessions!
- end
+ Capybara.reset_sessions!
ensure
super
end