[mocha-developer] SslRequirements plugin and mocha

Zack Chandler zackchandler at gmail.com
Tue Jan 23 18:19:34 EST 2007

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


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.


More information about the mocha-developer mailing list