What does this default RSpec statement mean?
User.should_receive(:update_attributes).with({'these' => 'params'})
What does that statement mean? these
isn't instantiated anywhere as meaning anything.
The whole statement is this :
describe "with valid params" do
it "updates the requested user" do
User.should_receive(:find).with("37") { mock_user }
User.should_receive(:update_attributes).with({'these' => 'params'})
put :update, :id => "37", :user => {'these' => 'params'}
end
I say this because I'm getting an e开发者_如何学编程rror :
unknown attribute: these
Which is coming from aforementioned scenario..
It is saying that the method update_attributes
should be invoked on the User
model with an argument of {'these' => 'params'}
during whatever test is being run.
Basically the following is expected to happen during the execution:
User.update_attributes({'these' => 'params'})
More here: http://rspec.info/documentation/mocks/message_expectations.html
You don't have to replace the hash ({'these' => 'params'}). Think of it as a contract. I have said that when I PUT, the following hash should be received by my objects update_attributes model. In the next line, you call the update method and the contract is checked.
精彩评论