[Backgroundrb-devel] Testing worker classes

James Hughes hughes.james at gmail.com
Wed Jul 19 18:24:40 EDT 2006


Does it make sense to test a worker class by calling
Middleman.new_worker? Or should I just be testing the functionality in
the do_work method, with, say, a mock object. This seems like a really
ugly DRY violation: you'd need to keep the code in the mock and the
real worker in sync.

That's the philosophical half of my question. In fact, until someone
tells me why I shouldn't, I am trying to call new_worker from a test
method in the test class generated by the worker generator. I'm

NoMethodError: undefined method `[]' for #<DRb::DRbUnknown:0xb72c7128>

I note in another thread that this  is due to DRbundumped not being
included in the class that is causing the error. I took this to mean
that I need "include DRbundumped" in my test class, but that didn't
work. I'm not sure where else I should include it. I know that
eventually I'll need to put it in the non-test class that calls
new_worker, but I'm not there yet. Is testing workers just a

Here's the test method:

  def test_task_is_triggered
    job_key = MiddleMan.new_worker :class => :task_checker_worker,
       :args =>  tasks(:should_be_triggered)
    @job_keys << job_key
   #     ...assertions go here...


James Hughes
Web application developer
Vancouver, BC

"Developing a coherent political analysis is in many respects
contingent upon an ability to connect one context to another, a
process not dissimilar to playing the kid's game of dot-to-dot."
 - Ward Churchill, from '"A Government of Laws"?'

More information about the Backgroundrb-devel mailing list