[rspec-users] rspec 'mock' method not found

Andy Koch andy.koch at pc-doctor.com
Mon Nov 3 16:38:22 EST 2008


Hi,

I'm having trouble with "mock" and I can't seem to find any reason for 
this.  The error...
********************
1)
NoMethodError in 'UserObserver should not call 
UserMailer.deliver_activation if user wasn't recently activated'
undefined method `mock' for 
Spec::Rails::Example::ModelExampleGroup::Subclass_3:Class
./spec/models/user_observer_spec.rb:6:
/var/lib/gems/1.8/gems/activesupport-2.1.2/lib/active_support/callbacks.rb:177:in 
`call'
/var/lib/gems/1.8/gems/activesupport-2.1.2/lib/active_support/callbacks.rb:177:in 
`evaluate_method'
/var/lib/gems/1.8/gems/activesupport-2.1.2/lib/active_support/callbacks.rb:161:in 
`call'
/var/lib/gems/1.8/gems/activesupport-2.1.2/lib/active_support/callbacks.rb:90:in 
`run'
/var/lib/gems/1.8/gems/activesupport-2.1.2/lib/active_support/callbacks.rb:90:in 
`each'
/var/lib/gems/1.8/gems/activesupport-2.1.2/lib/active_support/callbacks.rb:90:in 
`send'
/var/lib/gems/1.8/gems/activesupport-2.1.2/lib/active_support/callbacks.rb:90:in 
`run'
/var/lib/gems/1.8/gems/activesupport-2.1.2/lib/active_support/callbacks.rb:272:in 
`run_callbacks'
spec/models/user_mailer_spec.rb:42:
********************

And the code....
********************
require File.dirname(__FILE__) + '/../spec_helper'

context "A UserObserver" do
  setup do
    @user = mock(User)
    @user_observer = UserObserver.instance
  end

....<snip>....
end
********************

I've not found any other people with a similar issue via Google yet.

Any help is much appreciated.

-- 
Andy Koch



More information about the rspec-users mailing list