# When i use rspec(with built-in mock framework) ,errof occurs

**URL:** <https://www.ruby-forum.com/t/when-i-use-rspec-with-built-in-mock-framework-errof-occurs/150510>\
**Category:** Rails\
**Created:** [October 9, 2008, 10:36am UTC](https://www.ruby-forum.com/t/when-i-use-rspec-with-built-in-mock-framework-errof-occurs/150510 "2008-10-09T10:36:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![guofeng](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/839c29/32.png) [@guofeng](https://www.ruby-forum.com/u/guofeng)\
**Post date:** [October 9, 2008, 10:36am UTC](https://www.ruby-forum.com/t/when-i-use-rspec-with-built-in-mock-framework-errof-occurs/150510/1 "2008-10-09T10:36:15Z")

</div>

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”})

---

<div class="post-metadata">

**Author:** ![guofeng](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/839c29/32.png) [@guofeng](https://www.ruby-forum.com/u/guofeng)\
**Post date:** [October 9, 2008, 1:45pm UTC](https://www.ruby-forum.com/t/when-i-use-rspec-with-built-in-mock-framework-errof-occurs/150510/2 "2008-10-09T13:45:01Z")

</div>

Everything in the params hash is a string when it comes through the  
controller. If you’re passing the entire params hash to  
AwardingBody.new,  
the params hash looks like {‘these’ =\> ‘params’}. Thus, if you change  
your  
expectation to {‘these’ =\> ‘params’}, it will be satisfied.

In the future, it’s probably best to post RSpec questions to the  
rspec-users  
mailing list: [http://rubyforge.org/mailman/listinfo/rspec-users](http://rubyforge.org/mailman/listinfo/rspec-users) .

Regards,  
Craig
