Guofeng Ma
2008-Oct-09 09:40 UTC
[rspec-users] About received unexpected message :code with (no args)
I use rspec_scaffold to generate a part of examples as below: it "should expose a newly created awarding_body as @awarding_body" do AwardingBody.should_receive(:new).with({''these'' => ''params''}).and_return(mock_awarding_body(:save => true)) post :create, :awarding_body => {:these => ''params''} assigns(:awarding_body).should equal(mock_awarding_body) end After i execute the example, below error occurs: Mock ''AwardingBody_1193'' received unexpected message :code with (no args) how to deal with it? -- Posted via http://www.ruby-forum.com/.
David Chelimsky
2008-Oct-09 10:24 UTC
[rspec-users] About received unexpected message :code with (no args)
On Thu, Oct 9, 2008 at 4:40 AM, Guofeng Ma <lists at ruby-forum.com> wrote:> > I use rspec_scaffold to generate a part of examples as below: > > it "should expose a newly created awarding_body as @awarding_body" do > AwardingBody.should_receive(:new).with({''these'' => > ''params''}).and_return(mock_awarding_body(:save => true)) > post :create, :awarding_body => {:these => ''params''} > assigns(:awarding_body).should equal(mock_awarding_body) > end > > > After i execute the example, below error occurs: > > Mock ''AwardingBody_1193'' received unexpected message :code with (no > args) > > > how to deal with it?That is very odd. Did you have an AwardingBody model, view, or controller before you ran ''script/generate rspec_scaffold AwardingBody''? Did you make any changes to the code after running it? Or did you just do this: script/generate rspec_scaffold AwardingBody rake db:migrate rake spec
Seemingly Similar Threads
- When i use rspec(with built-in mock framework) ,errof occurs
- map.resources :foo_items, :as => :foo confusing my controller specs
- rspec_resource error
- undefined method `mock_model'' for [RSpec example]:#<Class:0x25550a8>
- removing Mocha; 'spec spec' fails but the specific model file passes