Search code examples
ruby-on-railsrubytestingsidekiq

Sidekiq + Rails: Delayed Extension Default Worker


I'm using Sidekiq in my Rails app to asynchronously perform some tasks. I've created workers for some of my more complex operations, but there are a lot of simple cases where I call Class.delay.some_method. I'd like to write tests to make sure these jobs are getting enqueued correctly.

When I create a worker to perform these jobs, I can check the queueing by making assertions about SomeWorker.jobs in my specs. Is there a way to do something similar when I call #delay on a class directly? If it makes any difference, the class inherits from ActiveRecord::Base.


Solution

  • assert_equal 1, Sidekiq::Extensions::DelayedClass.jobs.size