Derek Haynes
2006-Jun-16 16:47 UTC
[Rails] BackgrounDRb / Testing Error: uninitialized constant BackgrounDRb
I''m digging into BackgrounDRb and having some problems testing a worker class. The following line in my test (created from script/generate worker Test) throws an error: worker = TestWorker.new(:test_string => "testing...") Error: /activesupport/lib/active_support/dependencies.rb:123:in `const_missing'': uninitialized constant BackgrounDRb (NameError) from /Users/itsderek23/Projects/drb_test/config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:131:in `const_missing'' from /Users/itsderek23/Projects/drb_test/config/../lib/workers/web_poll_worker.rb:5 from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `require'' from /Users/itsderek23/Projects/drb_test/config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:147:in `require'' from test/unit/test_worker_test.rb:2 Line 5 refers to: class TestWorkerTest < Test::Unit::TestCase Anyone have any clues on what I''m missing? -- Derek Haynes HighGroove Studios - http://www.highgroove.com San Mateo, CA | Atlanta, GA Keeping it Simple. 650.276.0908
Derek Haynes
2006-Jun-16 16:53 UTC
[Rails] Re: BackgrounDRb / Testing Error: uninitialized constant BackgrounDRb
I noticed that backgroundrb was placed in script/backgroundrb/lib, but not in lib...after adding it to /lib, I get the following error: NameError: uninitialized constant BACKGROUNDRB_LOGGER /Users/itsderek23/Projects/drb_test/config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:123:in `const_missing'' /Users/itsderek23/Projects/drb_test/config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:133:in `const_missing'' /Users/itsderek23/Projects/drb_test/config/../lib/backgroundrb.rb:27:in `initialize'' test/unit/test_worker_test.rb:16:in `test_do_work'' Where line 16 refers to: worker = TestWorker.new(:test_string => "testing...") On 6/16/06, Derek Haynes <derek.haynes@highgroove.com> wrote:> I''m digging into BackgrounDRb and having some problems testing a worker class. > > The following line in my test (created from script/generate worker > Test) throws an error: > > worker = TestWorker.new(:test_string => "testing...") > > Error: > > /activesupport/lib/active_support/dependencies.rb:123:in > `const_missing'': uninitialized constant BackgrounDRb (NameError) > from /Users/itsderek23/Projects/drb_test/config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:131:in > `const_missing'' > from /Users/itsderek23/Projects/drb_test/config/../lib/workers/web_poll_worker.rb:5 > from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in > `require'' > from /Users/itsderek23/Projects/drb_test/config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:147:in > `require'' > from test/unit/test_worker_test.rb:2 > > Line 5 refers to: class TestWorkerTest < Test::Unit::TestCase > > Anyone have any clues on what I''m missing? > > -- > Derek Haynes > HighGroove Studios - http://www.highgroove.com > San Mateo, CA | Atlanta, GA > Keeping it Simple. > 650.276.0908 >-- Derek Haynes HighGroove Studios - http://www.highgroove.com San Mateo, CA | Atlanta, GA Keeping it Simple. 650.276.0908
Ezra Zygmuntowicz
2006-Jun-16 17:15 UTC
[Rails] Re: BackgrounDRb / Testing Error: uninitialized constant BackgrounDRb
Hey Derek- Yeah I need to include some more instructions on testing your worker classes. THis has come up already. I will have a new release here before railconf that will address this issue. For now you need to require script/backgroundrb/lib/backgroundrb.rb in your test case. You can actually test your workers through the MiddleMan class without running it as a drb server. Just use it as a standard object. Have a look at the tests for the plugin itself and you can see how I test it without running a server. I will come up with some better docs and a better generated test class as soon as I get a chance. -Ezra
Derek Haynes
2006-Jun-16 19:06 UTC
[Rails] Re: BackgrounDRb / Testing Error: uninitialized constant BackgrounDRb
Ezra, Thanks for all your work on this great plugin. I added the following to my test_helper.rb file: require File.expand_path(File.dirname(__FILE__) + "/../script/backgroundrb/lib/backgroundrb.rb") ...but I''m still getting the "uninitialized constant BACKGROUNDRB_LOGGER" error. I took a look at the plugin tests. It appears the problem arises when testing a worker class that is a subclass of BackgrounDRb::Rails. I can''t find where BACKGROUNDRB_LOGGER is set - am I missing something there? Thanks again, Derek On 6/16/06, Ezra Zygmuntowicz <ezmobius@gmail.com> wrote:> Hey Derek- > > Yeah I need to include some more instructions on testing your worker > classes. THis has come up already. I will have a new release here > before railconf that will address this issue. For now you need to > require script/backgroundrb/lib/backgroundrb.rb in your test case. > You can actually test your workers through the MiddleMan class > without running it as a drb server. Just use it as a standard object. > Have a look at the tests for the plugin itself and you can see how I > test it without running a server. > > I will come up with some better docs and a better generated test > class as soon as I get a chance. > > -Ezra > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Derek Haynes HighGroove Studios - http://www.highgroove.com San Mateo, CA | Atlanta, GA Keeping it Simple. 650.276.0908
Ezra Zygmuntowicz
2006-Jun-16 19:37 UTC
[Rails] Re: BackgrounDRb / Testing Error: uninitialized constant BackgrounDRb
On Jun 16, 2006, at 12:06 PM, Derek Haynes wrote:> Ezra, > > Thanks for all your work on this great plugin. > > I added the following to my test_helper.rb file: > require File.expand_path(File.dirname(__FILE__) + > "/../script/backgroundrb/lib/backgroundrb.rb") > > ...but I''m still getting the "uninitialized constant > BACKGROUNDRB_LOGGER" error. > > I took a look at the plugin tests. It appears the problem arises when > testing a worker class that is a subclass of BackgrounDRb::Rails. I > can''t find where BACKGROUNDRB_LOGGER is set - am I missing something > there? > > Thanks again, > > Derek >Derek- Ok I just checked in a new version that should fix these issues. I moved the logger setup into the same file as the MiddleMan class setup and added the require to the test generator. So svn up and reinstall the base system and you should be good to go,. Thanks for the bug reports- -Ezra
Derek Haynes
2006-Jun-16 20:13 UTC
[Rails] Re: BackgrounDRb / Testing Error: uninitialized constant BackgrounDRb
Thanks Ezra! Works great! - Derek On 6/16/06, Ezra Zygmuntowicz <ezmobius@gmail.com> wrote:> > On Jun 16, 2006, at 12:06 PM, Derek Haynes wrote: > > > Ezra, > > > > Thanks for all your work on this great plugin. > > > > I added the following to my test_helper.rb file: > > require File.expand_path(File.dirname(__FILE__) + > > "/../script/backgroundrb/lib/backgroundrb.rb") > > > > ...but I''m still getting the "uninitialized constant > > BACKGROUNDRB_LOGGER" error. > > > > I took a look at the plugin tests. It appears the problem arises when > > testing a worker class that is a subclass of BackgrounDRb::Rails. I > > can''t find where BACKGROUNDRB_LOGGER is set - am I missing something > > there? > > > > Thanks again, > > > > Derek > > > > > Derek- > > Ok I just checked in a new version that should fix these issues. I > moved the logger setup into the same file as the MiddleMan class > setup and added the require to the test generator. So svn up and > reinstall the base system and you should be good to go,. > > > Thanks for the bug reports- > -Ezra > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Derek Haynes HighGroove Studios - http://www.highgroove.com San Mateo, CA | Atlanta, GA Keeping it Simple. 650.276.0908