wspurgin / rspec-sidekiq

RSpec for Sidekiq
https://github.com/wspurgin/rspec-sidekiq
Other
651 stars 133 forks source link

How to expect to have_enqueued_sidekiq_job with specific queue? - [setting queue name at runtime] #184

Closed RichardsonWTR closed 11 months ago

RichardsonWTR commented 2 years ago

My class decides the queue name dynamically depending on business rules.

How to expect that my class has enqueued the specific job with the specific arguments in the specific queue?

One way to to this could be with this API

expect(AwesomeJob).to have_enqueued_sidekiq_job('Awesome', true).at(time).on('my_queue')

Why ?

Because my code is enqueuing the job in a command like this one:

AwesomeJob.set(queue: queue_name).perform_async('Awesome', true)

One way to accomplish this

One way that I've found to accomplish this is (But I don't think its elegant):

expect(AwesomeJob.jobs.last['queue']).to eq 'my_queue'
wspurgin commented 11 months ago

Heyo 👋 This repo was in a bit of limbo for the last year or two. I think this is a nice feature to add. I like the on syntax. Someone made an attempt a few years back in #164 with to but it needs revisiting. I'll look into add this to the v4 milestone