Ivan Zamylin
Ivan Zamylin

Reputation: 1748

Testing resque-scheduler

In resque-scheduler, how do I rspec-test that some job is queued EVERY 30 seconds?

Here is my resque-scheduler.yml file:

hipchat_schedule:
 queue: hipchat
 every: 30s
 class: HipChatPolling

There is very useful resque_spec gem, but I am not sure if it can do test for every-clause.

Upvotes: 4

Views: 1686

Answers (1)

Gabor Garami
Gabor Garami

Reputation: 1265

First, I think this is tested - and have to be tested - by resque-scheduler gem (or to be precise, in the rufus-scheduler gem), not on your side. If scheduling is not happened then it is not a bug in your application, but a bug in the gem.

But, if you want to test it anyway, you have two way to do it:

  • Make some testable change in the job and check it with tests (e.g. touch a file, log start times somewhere, etc
  • Monitor Resque's queue and wait until job class appear twice, and calculate an elapsed time between two apperance.

Note, to do this, you have to be sure Resque.inline setting is disabled before the test!

Upvotes: 3

Related Questions