docbrown/spec/support/initializers/monkeypatch_action_dispatch_screenshot_helper.rb
Zach Attas 52277ea0ba
Adds csv formatter only in CI and makes screenshot names unique with timestamp (#7838)
* adds csv formatter only in CI and adds --format progress to rspec in CI

* addressing feedback

* adds more functionality to csv reporter, and makes screenshots taken from rspec/retry have unique names

* induces intentional fails (will revert after testing)

* induces intentional fails (will revert after testing)

* makes screenshot timestamp more precise and tweaks intentional fails (again willremove later)

* restores spec files to normal and tweaks screenshot microseconds

* remove the putses at end of CSVFormatter
2020-05-20 10:40:55 +02:00

13 lines
775 B
Ruby

# https://github.com/mattheworiordan/capybara-screenshot/issues/225
# https://stackoverflow.com/questions/44336581/turn-off-screenshots-in-rails-system-tests
# https://github.com/rails/rails/blob/master/actionpack/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb#L64
# Without this monkeypatch, if there's multiple screenshots taken due to rspec/retry, each new screenshot
# will overwrite the last one. This monkeypatch makes the screenshot name unique so they won't overwrite each other
require "action_dispatch/system_testing/test_helpers/screenshot_helper"
::ActionDispatch::SystemTesting::TestHelpers::ScreenshotHelper.module_eval do
private
def image_name
"#{method_name}_#{Time.current.utc.strftime('%Y-%m-%dT%H:-%M-%S-%3NZ')}"
end
end