From 69db87f9c6ff1863c7408047431c31ec4a8cd8ef Mon Sep 17 00:00:00 2001 From: cryptogopher Date: Wed, 14 Feb 2024 01:50:47 +0100 Subject: [PATCH] Include date/time and seed in screenshot filename --- config/initializers/system_test_case.rb | 3 +++ .../test_helpers/custom_screenshot_helper_unique_id.rb | 7 +++++++ 2 files changed, 10 insertions(+) create mode 100644 config/initializers/system_test_case.rb create mode 100644 lib/core_ext/action_dispatch/system_testing/test_helpers/custom_screenshot_helper_unique_id.rb diff --git a/config/initializers/system_test_case.rb b/config/initializers/system_test_case.rb new file mode 100644 index 0000000..9e3ef71 --- /dev/null +++ b/config/initializers/system_test_case.rb @@ -0,0 +1,3 @@ +ActiveSupport.on_load :action_dispatch_system_test_case do + prepend CoreExt::ActionDispatch::SystemTesting::TestHelpers::CustomScreenshotHelperUniqueId +end diff --git a/lib/core_ext/action_dispatch/system_testing/test_helpers/custom_screenshot_helper_unique_id.rb b/lib/core_ext/action_dispatch/system_testing/test_helpers/custom_screenshot_helper_unique_id.rb new file mode 100644 index 0000000..3798c38 --- /dev/null +++ b/lib/core_ext/action_dispatch/system_testing/test_helpers/custom_screenshot_helper_unique_id.rb @@ -0,0 +1,7 @@ +module CoreExt::ActionDispatch::SystemTesting::TestHelpers::CustomScreenshotHelperUniqueId + private + + def unique + Time.current.strftime("%Y-%m-%d %H:%M:%S.%9N_#{Minitest.seed}") + end +end