Skip to content

Commit

Permalink
Move expectation to regex for flexibility
Browse files Browse the repository at this point in the history
  • Loading branch information
wspurgin committed Aug 9, 2023
1 parent 8ab8234 commit 8af5b52
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions spec/rspec/sidekiq/matchers/enqueue_sidekiq_job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,20 +56,17 @@
end

it "fails if no job with args are found" do
jids = []
expect do
expect {
jids << worker.perform_async
worker.perform_async
}.to enqueue_sidekiq_job.with("some_arg")
end.to raise_error { |error|
expect(error.message).to eq(<<~MSG.strip)
expected to have an enqueued Sidekiq::Job job
with arguments:
-["some_arg"]
but have enqueued only jobs
-JID:#{jids[0]} with arguments:
-[]
MSG
lines = error.message.split("\n")
expect(lines).to include(
match(/expected to have an enqueued .* job/),
match(/with arguments:/),
match(/-\["some_arg"\]/)
)
}
end
end
Expand Down

0 comments on commit 8af5b52

Please sign in to comment.