0

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})
Julien
  • 1,158
  • 9
  • 19

1 Answers1

1

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.

nitecoder
  • 5,496
  • 1
  • 28
  • 35