rspec-sidekiq
rspec-sidekiq copied to clipboard
How to expect to have_enqueued_sidekiq_job with specific queue? - [setting queue name at runtime]
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'