Thursday, January 24, 2013

Rspec matchers for Sidekiq

I've been writing a lot of specs lately to make sure my code properly enqueues Sidekiq jobs. I ended up duplicating a lot of code, and after reading the Rspec custom matcher documentation, I decided to DRY up the tests using some of my own matchers. The code is here in my "power tools" gem. Enjoy!

The tests end up looking like this:
  MyWorker.should have_queued_job(2)
  Collector.should have_queued_job_at(,1,23,14,00),2)

No comments: