# Can I unit test backgroundrb workers?

**URL:** <https://www.ruby-forum.com/t/can-i-unit-test-backgroundrb-workers/91566>\
**Category:** Rails\
**Created:** [April 10, 2007, 3:19pm UTC](https://www.ruby-forum.com/t/can-i-unit-test-backgroundrb-workers/91566 "2007-04-10T15:19:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![joergd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/51bf81/32.png) [@joergd](https://www.ruby-forum.com/u/joergd)\
**Post date:** [April 10, 2007, 3:19pm UTC](https://www.ruby-forum.com/t/can-i-unit-test-backgroundrb-workers/91566/1 "2007-04-10T15:19:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![joergd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/51bf81/32.png) [@joergd](https://www.ruby-forum.com/u/joergd)\
**Post date:** [April 10, 2007, 3:46pm UTC](https://www.ruby-forum.com/t/can-i-unit-test-backgroundrb-workers/91566/2 "2007-04-10T15:46:05Z")

</div>

On Apr 10, 2:19 pm, Joerg D. [removed\_email\_address@domain.invalid](mailto: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

---

<div class="post-metadata">

**Author:** ![joergd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/51bf81/32.png) [@joergd](https://www.ruby-forum.com/u/joergd)\
**Post date:** [April 10, 2007, 3:53pm UTC](https://www.ruby-forum.com/t/can-i-unit-test-backgroundrb-workers/91566/3 "2007-04-10T15:53:18Z")

</div>

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
