# Gemfile
group :test do
gem 'rspec-enqueue_sidekiq_job'
end
Checks if a certain job was enqueued in a block.
expect { AwesomeWorker.perform_async }
.to enqueue_sidekiq_job(AwesomeWorker)
expect { AwesomeWorker.perform_async(42, 'David')
.to enqueue_sidekiq_job(AwesomeWorker).with(42, 'David')
Use chainable matchers #at
and #in
:
time = 5.minutes.from_now
expect { AwesomeWorker.perform_at(time) }
.to enqueue_sidekiq_job(AwesomeWorker).at(time)
interval = 5.minutes
expect { AwesomeWorker.perform_in(interval) }
.to enqueue_sidekiq_job(AwesomeWorker).in(5.minutes)
enqueue_sidekiq_job
implies "exactly once" by default. But you can adjust that.
expect {
2.times { AwesomeWorker.perform_async }
}.to enqueue_sidekiq_job(AwesomeWorker).twice
expect {
3.times { AwesomeWorker.perform_async }
}.to enqueue_sidekiq_job(AwesomeWorker).exactly(3).times