开发者

Can I disable some BackgroundRb workers during tests?

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

Ho开发者_运维知识库w 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})


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜