Forum: Ruby on Rails When i use rspec(with built-in mock framework) ,errof occurs

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
C7b7ddf91aa9dd80fc7d65ec86ae0274?d=identicon&s=25 Guofeng Ma (guofeng)
on 2008-10-09 10:36
I use rspec_scaffold generate a example as below:

      it "should expose a newly created awarding_body as @awarding_body"
=> true))

         post :create,  :awarding_body => {:these => 'params'}
        assigns(:awarding_body).should == (mock_awarding_body)

after execute the example , a error occurs as below :

Mock 'Class' expected :new with ({:these=>"params"}) but received it
with ({"the
B14575f0ca69f10938fdd67e7156e0e1?d=identicon&s=25 Craig Demyanovich (Guest)
on 2008-10-09 13:45
(Received via mailing list)
Everything in the params hash is a string when it comes through the
controller. If you're passing the entire params hash to,
the params hash looks like {'these' => 'params'}. Thus, if you change
expectation to {'these' => 'params'}, it will be satisfied.

In the future, it's probably best to post RSpec questions to the
mailing list: .

This topic is locked and can not be replied to.