Fix skips in Action Pack

We can't run this test on Ruby 2.7 due to minitest being locked in the
Gemfile to an older version, so we should use that as a condition
instead of skipping if minitest doesn't have metadata.
This commit is contained in:
Hartley McGuire 2023-11-28 20:26:31 -05:00
parent b8433879bc
commit ec3d392e20
No known key found for this signature in database
GPG Key ID: E823FC1403858A82
1 changed files with 11 additions and 10 deletions

View File

@ -152,17 +152,18 @@ class ScreenshotHelperTest < ActiveSupport::TestCase
assert_match %r|url=artifact://.+?tmp/screenshots/1_x\.png|, display_image_actual
end
test "take_failed_screenshot persists the image path in the test metadata" do
skip "Older versions of Minitest don't support test metadata." unless Minitest::Runnable.method_defined?(:metadata)
# minitest doesn't support metadata in the version locked on Ruby 2.7
if RUBY_VERSION > "3.0"
test "take_failed_screenshot persists the image path in the test metadata" do
Rails.stub :root, Pathname.getwd do
@new_test.stub :passed?, false do
Capybara::Session.stub :instance_created?, true do
@new_test.stub :save_image, nil do
@new_test.stub :show, -> (_) { } do
@new_test.take_failed_screenshot
Rails.stub :root, Pathname.getwd do
@new_test.stub :passed?, false do
Capybara::Session.stub :instance_created?, true do
@new_test.stub :save_image, nil do
@new_test.stub :show, -> (_) { } do
@new_test.take_failed_screenshot
assert_equal @new_test.send(:relative_image_path), @new_test.metadata[:failure_screenshot_path]
assert_equal @new_test.send(:relative_image_path), @new_test.metadata[:failure_screenshot_path]
end
end
end
end