Forum: Ruby on Rails what's diffrence between ({:these=>"params"}) and ({"these"

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:05
When i use rspec(with built-in mock framework) ,error occurs.
I use rspec_scaffold generate a example 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 == (mock_awarding_body)
      end




After execute the example , a error occurs as below :

Mock 'Class' expected :new with ({:these=>"params"}) but received it
with ({"the
se"=>"params"})
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2008-10-09 11:09
(Received via mailing list)
On 9 Oct 2008, at 10:05, Guofeng Ma wrote:

>
> Mock 'Class' expected :new with ({:these=>"params"}) but received it
> with ({"the
> se"=>"params"})

Probably because actioncontroller magics the params hash into a hash
with string keys, not symbol keys.

Fred
This topic is locked and can not be replied to.