Skip to content

Commit

Permalink
Add spec to method Util#worker_name (#757)
Browse files Browse the repository at this point in the history
Co-authored-by: Pablo Cantero <[email protected]>
  • Loading branch information
juneira and phstc authored Jan 31, 2024
1 parent 0815dd2 commit e558906
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions spec/shoryuken/util_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,34 @@

describe '#worker_name' do
let(:sqs_msg) do
double Shoryuken::Message, message_id: 'fc754df7-9cc2-4c41-96ca-5996a44b771e', message_attributes: {}
double Shoryuken::Message, message_id: 'fc754df7-9cc2-4c41-96ca-5996a44b771e', message_attributes: message_attributes
end

it 'returns Shoryuken worker name' do
expect(subject.worker_name(TestWorker, sqs_msg)).to eq 'TestWorker'
context 'when has integration with ActiveJob' do
before do
allow(Shoryuken).to receive(:active_job?).and_return(true)
end

let(:message_attributes) do
{ 'shoryuken_class' => { string_value: ActiveJob::QueueAdapters::ShoryukenAdapter::JobWrapper.to_s } }
end

let(:body) do
{ 'job_class' => 'TestJob' }
end

it 'returns ActiveJob worker name' do
expect(subject.worker_name(TestWorker, sqs_msg, body)).to eq 'ActiveJob/TestJob'
end
end

it 'returns ActiveJob worker name'
context 'when has not integration with ActiveJob' do
let(:message_attributes) { {} }

it 'returns Shoryuken worker name' do
expect(subject.worker_name(TestWorker, sqs_msg)).to eq 'TestWorker'
end
end
end

describe '#fire_event' do
Expand Down

0 comments on commit e558906

Please sign in to comment.