From d44a4e259491a8f1c4a1afd4510aef8a04269422 Mon Sep 17 00:00:00 2001 From: Peter Boling Date: Wed, 27 Nov 2024 03:19:02 +0700 Subject: [PATCH] Worker is dead term (#229) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * ✏️ Fix spelling * 🐛 Queue always nil in default_retries_exhausted_message - worker is no longer used in most scenarios - See: https://github.com/sidekiq/sidekiq/wiki/Best-Practices#4-use-precise-terminology - keys are string, symbol lookups fail - Add test --- .../helpers/within_sidekiq_retries_exhausted_block.rb | 6 +++--- spec/rspec/sidekiq/helpers/retries_exhausted_spec.rb | 9 +++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/rspec/sidekiq/helpers/within_sidekiq_retries_exhausted_block.rb b/lib/rspec/sidekiq/helpers/within_sidekiq_retries_exhausted_block.rb index 30e8eec..d27b41b 100644 --- a/lib/rspec/sidekiq/helpers/within_sidekiq_retries_exhausted_block.rb +++ b/lib/rspec/sidekiq/helpers/within_sidekiq_retries_exhausted_block.rb @@ -10,15 +10,15 @@ def within_sidekiq_retries_exhausted_block(user_msg = {}, exception = default_re def default_retries_exhausted_message { - 'queue' => get_sidekiq_options[:worker], + 'queue' => get_sidekiq_options['queue'], 'class' => name, 'args' => [], - 'error_message' => 'An error occured' + 'error_message' => 'An error occurred' } end def default_retries_exhausted_exception - StandardError.new('An error occured') + StandardError.new('An error occurred') end end end diff --git a/spec/rspec/sidekiq/helpers/retries_exhausted_spec.rb b/spec/rspec/sidekiq/helpers/retries_exhausted_spec.rb index 7e4811d..26cc2dc 100644 --- a/spec/rspec/sidekiq/helpers/retries_exhausted_spec.rb +++ b/spec/rspec/sidekiq/helpers/retries_exhausted_spec.rb @@ -20,6 +20,15 @@ def self.baz(exception) end end + it 'has an exhausted message' do + expect(FooClass.default_retries_exhausted_message).to eq({ + "args" => [], + "class" => "FooClass", + "error_message" => "An error occurred", + "queue" => "data", + }) + end + it 'executes whatever is within the block' do FooClass.within_sidekiq_retries_exhausted_block { expect(FooClass).to receive(:bar).with('hello') } end