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.
34791e1d8c4def65f9b93294638a7e04?d=identicon&s=25 Joerg Diekmann (joergd)
on 2007-04-10 15: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
A9e5ce6f28587baa2a566eb4f2d76c13?d=identicon&s=25 Jon (Guest)
on 2007-04-10 15:46
(Received via mailing list)
On Apr 10, 2:19 pm, Joerg Diekmann <rails-mailing-l...@andreas-s.net>
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
34791e1d8c4def65f9b93294638a7e04?d=identicon&s=25 Joerg Diekmann (joergd)
on 2007-04-10 15: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.