[Backgroundrb-devel] Testing your workers

hemant gethemant at gmail.com
Wed Dec 6 15:38:15 EST 2006


This has been asked before, never well attended perhaps.

Any thoughts on testing your workers?

Current implementation is broken. An empty test case like this:

require File.dirname(__FILE__) + '/../test_helper'
require "#{RAILS_ROOT}/lib/workers/market_summary_worker"
require "#{RAILS_ROOT}/vendor/plugins/backgroundrb/lib/backgroundrb.rb"
require 'drb'

class MarketSummaryWorkerTest < Test::Unit::TestCase

  # Replace this with your real tests.
  def test_truth
    assert MarketSummaryWorker.included_modules.include?(DRbUndumped)
  end
end

Throws error:
------------
/usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:123:in
`const_missing': uninitialized constant Worker (NameError)
        from /home/hemant/ubac_webfront/config/../lib/workers/market_summary_worker.rb:9
        from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in
`require'
        from /usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in
`require'
        from test/unit/market_summary_worker_test.rb:2
----------------

So, I added couple of more files to the require and:
-------------------
require File.dirname(__FILE__) + '/../test_helper'

BACKGROUNDRB_CODE = File.dirname(__FILE__) +
'/../../vendor/plugins/backgroundrb'

$LOAD_PATH << File.join(BACKGROUNDRB_CODE + '/lib')
$LOAD_PATH << File.join(BACKGROUNDRB_CODE + '/server/lib')
$LOAD_PATH << File.join(BACKGROUNDRB_CODE + '/server/lib/backgroundrb')

require 'backgroundrb_server'
require "backgroundrb"
require "worker_rails"
require File.dirname(__FILE__) + '/../../lib/workers/add_analyst_worker'

require 'drb'
----------------


Now the error I get is:

---------------------
./test/unit/../../vendor/plugins/backgroundrb/server/lib/backgroundrb/middleman.rb:158:in
`register_worker_class': You have a nil object when you didn't expect
it! (NoMethodError)
You might have expected an instance of Array.
The error occured while evaluating nil.include? from
./test/unit/../../vendor/plugins/backgroundrb/server/lib/backgroundrb/worker.rb:17:in
`register'
        from ./test/unit/../../lib/workers/add_analyst_worker.rb:117
        from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in
`require'
        from /usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in
`require'
        from test/unit/add_analyst_worker_test.rb:12
----------------------

So, I would imagine testing support is quite lame here.  Can anyone
point me, in the direction, what else I should require in the testcase
so that at least an empty test case executes?






-- 
There was only one Road; that it was like a great river: its springs
were at every doorstep, and every path was its tributary.


More information about the Backgroundrb-devel mailing list