Forum: RSpec About received unexpected message :code with (no args)

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
C7b7ddf91aa9dd80fc7d65ec86ae0274?d=identicon&s=25 Guofeng Ma (guofeng)
on 2008-10-09 11:40
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?
5d38ab152e1e3e219512a9859fcd93af?d=identicon&s=25 David Chelimsky (Guest)
on 2008-10-09 12:24
(Received via mailing list)
On Thu, Oct 9, 2008 at 4:40 AM, Guofeng Ma <lists@ruby-forum.com> wrote:
>
> 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
This topic is locked and can not be replied to.