Hi. I''m loving mocha but have ran into a problem with using the mocha plugin with a project that has the SslRequirement plugin. It seems there is some conflict between the two? Any ideas? $ ruby test/functional/calendar_controller_test.rb /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.0/lib/active_support/dependencies.rb:478:in `const_missing'': uninitialized constant ApplicationController::SslRequirement (NameError) from /Users/zackchandler/dev/shasta/config/../app/controllers/application.rb:6 from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `require'' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.0/lib/active_support/dependencies.rb:496:in `require'' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.0/lib/active_support/dependencies.rb:343:in `new_constants_in'' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.0/lib/active_support/dependencies.rb:496:in `require'' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.0/lib/active_support/dependencies.rb:105:in `require_or_load'' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.0/lib/active_support/dependencies.rb:61:in `depend_on'' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.0/lib/active_support/dependencies.rb:443:in `require_dependency'' ... 12 levels... from /usr/local/lib/ruby/gems/1.8/gems/rails-1.2.1/lib/initializer.rb:43:in `run'' from /Users/zackchandler/dev/shasta/config/environment.rb:13 from ./test/functional/../test_helper.rb:2 from test/functional/calendar_controller_test.rb:1 Thanks, Zack
On 1/23/07, Zack Chandler <zackchandler at gmail.com> wrote:> Hi. I''m loving mocha but have ran into a problem with using the mocha > plugin with a project that has the SslRequirement plugin. It seems > there is some conflict between the two? Any ideas? > > $ ruby test/functional/calendar_controller_test.rb > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.0/lib/active_support/dependencies.rb:478:in > `const_missing'': uninitialized constant > ApplicationController::SslRequirement (NameError) > from /Users/zackchandler/dev/shasta/config/../app/controllers/application.rb:6<snipped> Hi Zack, I''ve recreated the problem with Rails 1.2.1 and Mocha 0.4.0. The problem can be traced to the require ''test_help'' line in the init.rb file in the mocha plugin. A very limited experiment seems to indicate the it is safe to remove this line. Can I ask that you try to remove it temporarily and see if your tests still pass (particularly the tests that use mocha?) Hopefully, we''ll be able to look at the full implications of this tomorrow. As an aside, you can recreate this problem without installing the mocha plugin. Simply create a new folder (called anything you like, I chose dummy_plugin) in vendor/plugins. Within that folder, add an init.rb file containing the following line: require ''test_help'' With this in place, you should see the error you mention. Hope this makes sense/helps. Chris
On 1/23/07, Chris Roos <chrisjroos at gmail.com> wrote:> On 1/23/07, Zack Chandler <zackchandler at gmail.com> wrote: > > Hi. I''m loving mocha but have ran into a problem with using the mocha > > plugin with a project that has the SslRequirement plugin. It seems > > there is some conflict between the two? Any ideas? > > > > $ ruby test/functional/calendar_controller_test.rb > > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.0/lib/active_support/dependencies.rb:478:in > > `const_missing'': uninitialized constant > > ApplicationController::SslRequirement (NameError) > > from /Users/zackchandler/dev/shasta/config/../app/controllers/application.rb:6 > > <snipped> > > Hi Zack, > > I''ve recreated the problem with Rails 1.2.1 and Mocha 0.4.0. > > The problem can be traced to the require ''test_help'' line in the > init.rb file in the mocha plugin. A very limited experiment seems to > indicate the it is safe to remove this line. Can I ask that you try > to remove it temporarily and see if your tests still pass > (particularly the tests that use mocha?) Hopefully, we''ll be able to > look at the full implications of this tomorrow. > > As an aside, you can recreate this problem without installing the > mocha plugin. Simply create a new folder (called anything you like, I > chose dummy_plugin) in vendor/plugins. Within that folder, add an > init.rb file containing the following line: > > require ''test_help'' > > With this in place, you should see the error you mention. > > Hope this makes sense/helps. > > Chris > _______________________________________________ > mocha-developer mailing list > mocha-developer at rubyforge.org > http://rubyforge.org/mailman/listinfo/mocha-developer >Chris, Yes the line require ''test_help'' in mocha''s init.rb seems to be the issue. If I remove it everything works fine. If you look at how rails sets up the test_helper.rb file you can see that the top lines are always: ENV["RAILS_ENV"] = "test" require File.expand_path(File.dirname(__FILE__) + "/../config/environment") require ''test_help'' Unit and functional tests include as the top line: require File.dirname(__FILE__) + ''/../test_helper'' So test_help gets sucked in every time tests are run - I doubt mocha needs to require it again. Thanks for getting back on this. Nice work on mocha. Zack