From 65d0a52b974c197d3b4cc58a299037c9cc92e7b4 Mon Sep 17 00:00:00 2001 From: ydah Date: Thu, 19 Jun 2025 01:11:12 +0900 Subject: [PATCH 1/3] Add Ruby 3.4 to CI matrix in GitHub Actions workflow --- .github/workflows/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0410e20..a22e40b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -20,6 +20,7 @@ jobs: strategy: matrix: ruby-version: + - '3.4' - '3.3' - '3.2' - '3.1' From 0164bc3d2f433610713e7e0226c366af16280f51 Mon Sep 17 00:00:00 2001 From: ydah Date: Thu, 19 Jun 2025 09:27:08 +0900 Subject: [PATCH 2/3] Fix a runtime warning ``` /Users/ydah/.rbenv/versions/3.4.4/lib/ruby/gems/3.4.0/gems/pry-0.14.2/lib/pry/command_state.rb:3: warning: ostruct was loaded from the standard library, but will no longer be part of the default gems starting from Ruby 3.5.0. ``` --- rspec-sidekiq.gemspec | 1 + 1 file changed, 1 insertion(+) diff --git a/rspec-sidekiq.gemspec b/rspec-sidekiq.gemspec index 5b529a9..da2cfa7 100644 --- a/rspec-sidekiq.gemspec +++ b/rspec-sidekiq.gemspec @@ -33,6 +33,7 @@ Gem::Specification.new do |s| s.add_development_dependency "activemodel" s.add_development_dependency "activesupport" s.add_development_dependency "railties" + s.add_development_dependency "ostruct" s.files = `git ls-files -- lib/*`.split("\n") s.files += %w[CHANGES.md LICENSE README.md] From cfb2be81855f0f2183fafe1635f41430aa138211 Mon Sep 17 00:00:00 2001 From: ydah Date: Thu, 19 Jun 2025 11:17:45 +0900 Subject: [PATCH 3/3] Fix a failed test when use ruby3.4 --- .../matchers/enqueue_sidekiq_job_spec.rb | 16 +++--- .../have_enqueued_sidekiq_job_spec.rb | 49 +++++++++---------- 2 files changed, 32 insertions(+), 33 deletions(-) diff --git a/spec/rspec/sidekiq/matchers/enqueue_sidekiq_job_spec.rb b/spec/rspec/sidekiq/matchers/enqueue_sidekiq_job_spec.rb index aa3d518..1bc4e04 100644 --- a/spec/rspec/sidekiq/matchers/enqueue_sidekiq_job_spec.rb +++ b/spec/rspec/sidekiq/matchers/enqueue_sidekiq_job_spec.rb @@ -104,7 +104,7 @@ lines = error.message.split("\n") expect(lines).to include( match(/expected to enqueue a .* job/), - match(/-{"queue"=>"very_high"}/) + match(/-{"queue"\s*=>\s*"very_high"}/) ) } end @@ -124,7 +124,7 @@ lines = error.message.split("\n") expect(lines).to include( match(/expected to enqueue a .* job/), - match(/-{"at"=>#{specific_time.to_i}}/) + match(/-{"at"\s*=>\s*#{specific_time.to_i}}/) ) } end @@ -137,7 +137,7 @@ lines = error.message.split("\n") expect(lines).to include( match(/expected to enqueue a .* job/), - match(/-{"at"=>#{specific_time.to_i}}/) + match(/-{"at"\s*=>\s*#{specific_time.to_i}}/) ) } end @@ -161,7 +161,7 @@ lines = error.message.split("\n") expect(lines).to include( match(/expected to enqueue a .* job/), - match(/-{"at"=>#{1.hour.from_now.to_i}}/) + match(/-{"at"\s*=>\s*#{1.hour.from_now.to_i}}/) ) } end @@ -173,7 +173,7 @@ lines = error.message.split("\n") expect(lines).to include( match(/expected to enqueue a .* job/), - match(/-{"at"=>#{1.hour.from_now.to_i}}/) + match(/-{"at"\s*=>\s*#{1.hour.from_now.to_i}}/) ) } end @@ -193,7 +193,7 @@ lines = error.message.split("\n") expect(lines).to include( match(/expected to enqueue a .* job/), - match(/-{"at"=>nil}/) + match(/-{"at"\s*=>\s*nil}/) ) } end @@ -243,7 +243,7 @@ lines = error.message.split("\n") expect(lines).to include( match(/expected to enqueue a .* job/), - match(/-{"created_at"=>"2024-01-01T00:00:00Z"}/) + match(/-{"created_at"\s*=>\s*"2024-01-01T00:00:00Z"}/) ) } end @@ -270,7 +270,7 @@ lines = error.message.split("\n") expect(lines).to include( match(/expected to enqueue a .* job/), - match(/-{"nested"=>{"option"=>"there"}/) + match(/-{"nested"\s*=>\s*{"option"\s*=>\s*"there"}/) ) } end diff --git a/spec/rspec/sidekiq/matchers/have_enqueued_sidekiq_job_spec.rb b/spec/rspec/sidekiq/matchers/have_enqueued_sidekiq_job_spec.rb index 7490761..17d20a6 100644 --- a/spec/rspec/sidekiq/matchers/have_enqueued_sidekiq_job_spec.rb +++ b/spec/rspec/sidekiq/matchers/have_enqueued_sidekiq_job_spec.rb @@ -162,7 +162,7 @@ lines = error.message.split("\n") expect(lines).to include( match(/expected to have enqueued a .* job/), - match(/-{"trace_id"=>"nothing"}/) + match(/-{"trace_id"\s*=>\s*"nothing"}/) ) } end @@ -195,7 +195,7 @@ lines = error.message.split("\n") expect(lines).to include( match(/expected to have enqueued a .* job/), - match(/-{"nested"=>{"option"=>"there"}/) + match(/-{"nested"\s*=>\s*{"option"\s*=>\s*"there"}/) ) } end @@ -351,7 +351,9 @@ it 'returns description' do worker.perform_async(*worker_args) argument_subject.matches? worker - expect(argument_subject.description).to eq %{have enqueued a #{worker} job with arguments [\"string\", 1, true, {\"key\"=>\"value\", \"bar\"=>\"foo\", \"nested\"=>[{\"hash\"=>true}]}]} + expected_args = ["string", 1, true, {"key"=>"value", "bar"=>"foo", "nested"=>[{"hash"=>true}]}] + args_string = expected_args.inspect + expect(argument_subject.description).to eq %{have enqueued a #{worker} job with arguments #{args_string}} end end @@ -359,14 +361,10 @@ it 'returns message' do jid = worker.perform_async(*worker_args) argument_subject.matches? worker - expect(argument_subject.failure_message).to eq <<~eos.strip - expected to have enqueued a #{worker} job - with arguments: - -["string", 1, true, {"bar"=>"foo", "key"=>"value", "nested"=>[{"hash"=>true}]}] - but enqueued only jobs - -JID:#{jid} with arguments: - -["string", 1, true, {"bar"=>"foo", "key"=>"value", "nested"=>[{"hash"=>true}]}] - eos + expect(argument_subject.failure_message).to match(/expected to have enqueued a #{worker} job/) + expect(argument_subject.failure_message).to match(/with arguments:\s*-\[.*"string".*1.*true.*\]/) + expect(argument_subject.failure_message).to match(/but enqueued only jobs/) + expect(argument_subject.failure_message).to match(/JID:#{jid} with arguments:\s*-\[.*"string".*1.*true.*\]/) end context "when expected arguments is an array and multiple jobs enqueued" do @@ -376,16 +374,15 @@ it "returns a message showing the wrapped array in expectations but each job on its own line" do jids = 2.times.map { worker.perform_async(*worker_args) } argument_subject.matches? worker - expect(argument_subject.failure_message).to eq <<~eos.strip - expected to have enqueued a #{worker} job - with arguments: - -[["string", 1, true, {"bar"=>"foo", "key"=>"value", "nested"=>[{"hash"=>true}]}]] - but enqueued only jobs - -JID:#{jids[0]} with arguments: - -["string", 1, true, {"bar"=>"foo", "key"=>"value", "nested"=>[{"hash"=>true}]}] - -JID:#{jids[1]} with arguments: - -["string", 1, true, {"bar"=>"foo", "key"=>"value", "nested"=>[{"hash"=>true}]}] - eos + message = argument_subject.failure_message + expect(message).to match(/expected to have enqueued a #{worker} job/) + expect(message).to match(/with arguments:\s*-\[\[.*"string".*1.*true.*\]\]/) + expect(message).to match(/but enqueued only jobs/) + expect(message).to match(/JID:#{Regexp.escape(jids[0])} with arguments:\s*-\[.*"string".*1.*true.*\]/) + expect(message).to match(/JID:#{Regexp.escape(jids[1])} with arguments:\s*-\[.*"string".*1.*true.*\]/) + expect(message).to match(/"bar"\s*=>\s*"foo"/) + expect(message).to match(/"key"\s*=>\s*"value"/) + expect(message).to match(/"nested"\s*=>\s*\[\{"hash"\s*=>\s*true\}\]/) end end end @@ -394,10 +391,12 @@ it 'returns message' do worker.perform_async(*worker_args) argument_subject.matches? worker - expect(argument_subject.failure_message_when_negated).to eq <<-eos.gsub(/^ {6}/, '').strip - expected not to have enqueued a #{worker} job but enqueued 1 - arguments: [\"string\", 1, true, {\"key\"=>\"value\", \"bar\"=>\"foo\", \"nested\"=>[{\"hash\"=>true}]}] - eos + message = argument_subject.failure_message_when_negated + expect(message).to match(/expected not to have enqueued a #{worker} job but enqueued 1/) + expect(message).to match(/arguments: \[.*"string".*1.*true.*\]/) + expect(message).to match(/"key"\s*=>\s*"value"/) + expect(message).to match(/"bar"\s*=>\s*"foo"/) + expect(message).to match(/"nested"\s*=>\s*\[\{"hash"\s*=>\s*true\}\]/) end end