Guofeng Ma
2008-Oct-09 08:36 UTC
When i use rspec(with built-in mock framework) ,errof 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"}) -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Craig Demyanovich
2008-Oct-09 11:44 UTC
Re: When i use rspec(with built-in mock framework) ,errof occurs
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 . Regards, Craig --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Maybe Matching Threads
- About received unexpected message :code with (no args)
- RSpec and resource_controller plugin
- Does RSpec work nicely with UUID primary keys?
- My first rspec reports "undefined method `key?' for #<String:0x46b1df0>"
- restful_authentication rspec failures "Mysql::Error: Incorrect datetime value:"