From 3ae7fe40bd5b7756032a91d5c19fd22c8f2537e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20Barri=C3=A9?= Date: Wed, 22 Jan 2025 14:01:20 +0100 Subject: [PATCH] Make test expectations about backtraces pass in Ruby 3.4 --- test/jobs/maintenance_tasks/task_job_test.rb | 6 +++--- test/system/maintenance_tasks/runs_test.rb | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test/jobs/maintenance_tasks/task_job_test.rb b/test/jobs/maintenance_tasks/task_job_test.rb index 55195a64..2ceb9ed4 100644 --- a/test/jobs/maintenance_tasks/task_job_test.rb +++ b/test/jobs/maintenance_tasks/task_job_test.rb @@ -163,7 +163,7 @@ class TaskJobTest < ActiveJob::TestCase assert_equal "ArgumentError", run.error_class assert_equal "Something went wrong", run.error_message - expected_backtrace = "app/tasks/maintenance/error_task.rb:10:in `process'" + expected_backtrace = %r{app/tasks/maintenance/error_task\.rb:10:in ('Maintenance::ErrorTask#|`)process'} assert_match expected_backtrace, run.backtrace.first assert_equal Time.now, run.ended_at assert_equal "1", run.cursor @@ -511,7 +511,7 @@ class << self # Simulate cancel happening after we've already checked @run.cancelling? @run.expects(:cancelling?).at_least(2).with do - next true if caller.any?(/`instrument_status_change'\z/) # avoid endless loop + next true if caller.any?(/\binstrument_status_change'\z/) # avoid endless loop Run.find(@run.id).cancel end.returns(false).then.returns(true) @@ -526,7 +526,7 @@ class << self # Simulate pause happening after we've already checked @run.pausing? @run.expects(:pausing?).at_least(2).with do - next true if caller.any?(/`instrument_status_change'\z/) # avoid endless loop + next true if caller.any?(/\binstrument_status_change'\z/) # avoid endless loop Run.find(@run.id).pausing! end.returns(false).then.returns(true) diff --git a/test/system/maintenance_tasks/runs_test.rb b/test/system/maintenance_tasks/runs_test.rb index de6fafdc..8fa5e4d9 100644 --- a/test/system/maintenance_tasks/runs_test.rb +++ b/test/system/maintenance_tasks/runs_test.rb @@ -211,7 +211,7 @@ class RunsTest < ApplicationSystemTestCase assert_text "Ran for less than 5 seconds until an error happened less than a minute ago." assert_text "ArgumentError" assert_text "Something went wrong" - assert_text "app/tasks/maintenance/error_task.rb:10:in `process'" + assert_text %r{app/tasks/maintenance/error_task\.rb:10:in ('Maintenance::ErrorTask#|`)process'} click_on "Resume"