views:

42

answers:

1

I have a BackgroundRb worker in charge of dispatching some emails.

How should I tell this worker not to run during tests? Does the framework include some configuration parameter or stub worker I could use?

MiddleMan.worker(:emails_worker).async_send_mails(:arg => {:emails => emails})
+1  A: 

I would say stub it out in your tests.

If you are using rspec (sorry what I know best) then I would:

Middleman.stub!(:worker)

in your before block and it will let you call it, and you can test that it is called like so

Middleman.should_receive(:worker).with(YOUR_ARGS_HERE)

but it will not run.

On a side note I would also say that BackgroundRb is not up to date technology and there are much better background worker solutions now. I would say look into something like delayed job.

railsninja
Thanks for the advice, I will look into it right now :)
Julien