Forum: Ruby on Rails Can I unit test backgroundrb workers?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Joerg D. (Guest)
on 2007-04-10 17:19
Can I unit test a background worker model, and if so ... how?

For now I can only test the worker if I go through the MiddleMan - but
is it possible to not use the MiddleMan to test my workers?

Thanks
Joerg
Jon (Guest)
on 2007-04-10 17:46
(Received via mailing list)
On Apr 10, 2:19 pm, Joerg D. <removed_email_address@domain.invalid>
wrote:
> Can I unit test a background worker model, and if so ... how?
>
> For now I can only test the worker if I go through the MiddleMan - but
> is it possible to not use the MiddleMan to test my workers?

I typically move all my interesting worker code to a separate helper
class, leaving the worker as a simple stub that calls that helper.
You can then unit test the helper, without having any dependencies on
BDRb
Joerg D. (Guest)
on 2007-04-10 17:53
I'm currently doing exactly that ... but I'd feel more comfortable if
the code in the stub gets tested/run as well.

On the same note ... how do I functional test this (with a polling
action to see whether the task has completed?)

Thanks so far!

Joerg

> I typically move all my interesting worker code to a separate helper
> class, leaving the worker as a simple stub that calls that helper.
> You can then unit test the helper, without having any dependencies on
> BDRb
This topic is locked and can not be replied to.