[rspec-users] removing Mocha; 'spec spec' fails but the specific model file passes

David Chelimsky dchelimsky at gmail.com
Sat Jun 13 20:35:13 EDT 2009

On Sat, Jun 13, 2009 at 4:30 PM, Doug<dgoldie15 at gmail.com> wrote:
> I happened to mix ryan bates' authentication scaffold with
> rspec_scaffold on a  demo project.
> and ran into the problem of mixing mock frameworks...ryan uses mocha.
> So, as a learning experience, I choose to redo ryan's tests without
> mocha but ran into a strange problem with tests of the User model.
> With debugging you can see....
> If you run just the user_spec.rb file, everything is fine....rspec
> goes through the User model.
> However, if you run all the specs, it is somehow still using mocha
> instead of the User model.
> How is this possible since I removed the configuration for mocha.?

In rails 2.3, activesupport/lib/active_support/test_case.rb requires
mocha. That's the base class for all of the rails test cases, and
consequently, rspec example groups as well.

> In spec_helper.rb, I commented out the   line: #
> config.mock_with :mocha
> I also saw a require 'mocha' statement in test_helper that I removed.
> ---------------------------------------------------------------------------------------------------------------------
> 11:41 /c/work/quizmaker_demo (questions)$ spec spec
> ...................................c:/work/quizmaker_demo/spec/models/
> user_spec.rb:86
> User.authenticate('nonexisting', 'secret').should be_nil
> (rdb:1) s
> c:/tools/ruby/ruby186/lib/ruby/gems/1.8/gems/mocha-0.9.5/lib/mocha/
> class_method.rb:40
> stubbee.__metaclass__.class_eval("def #{method}(*args, &block);
> mocha.method_missing(:#{method}, *a
> (rdb:1) c
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users

More information about the rspec-users mailing list