Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to test Devise Async with Sidekiq?

Thanks in advance! Sidekiq is working just fine, but I cannot manage to test it with Devise Async, or should I say that I cannot test the latter?

According to Sidekiq's documentation, when test mode is set to fake!, any job given to a worker is pushed to an array named jobs of that same worker. So it is trivial to test the increase of this array.

But, with Devise Async, it is not so trivial, although its backend includes Sidekiq::Worker. Here's a small list of things that I tried to test:

  • Devise::Async::Backend::Sidekiq.jobs
  • Devise::Mailer.deliveries
  • ActionMailer::Base.deliveries
  • Devise::Async::Backend::Worker.jobs

None of these testing subjects points an increase in size. Since Devise sends its emails as models callbacks, I tried testing both in a model and in a controller spec. Using Factory Girl and Database Cleaner, I also tried both modes: transaction and truncation. Needless to say that I also tried both modes of Sidekiq: fake! and inline!.

What am I missing?

like image 341
Paulo Oliveira Avatar asked Nov 21 '14 18:11

Paulo Oliveira


1 Answers

As mentioned in the documentation, you can check the queue size as

Sidekiq::Extensions::DelayedMailer.jobs.size
like image 65
abhinavmsra Avatar answered Oct 18 '22 06:10

abhinavmsra