No release in over 3 years
RSpec matcher to check enqueueing of Sidekiq jobs
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

enqueue_sidekiq_job RSpec block matcher

Installation

# Gemfile
group :test do
  gem 'rspec-enqueue_sidekiq_job'
end

Usage

Checks if a certain job was enqueued in a block.

expect { AwesomeWorker.perform_async }
  .to enqueue_sidekiq_job(AwesomeWorker)

Specifying arguments

expect { AwesomeWorker.perform_async(42, 'David')
  .to enqueue_sidekiq_job(AwesomeWorker).with(42, 'David')

Testing scheduled jobs

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)

Specifying counts

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