views:

40

answers:

1
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 error :

unknown attribute: these

Which is coming from aforementioned scenario..

+2  A: 

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

Beerlington
Right, but what is `these` and what is `params`?
Trip
That's just an example hash. You would replace it with whatever your controller is expecting. For example, you might be updating the user's name, so it would be `with({:first_name => "something", :last_name => "else"})`
Beerlington