On 23 August 2011 22:46, David Chelimsky <[email protected]> wrote:

>
> ^^ Change the class name Part to the variable part ^^:
>
>   part.should_receive(:update_attributes).with('title' => 'Brake
> pads').and_return(part)
>
> It's the part object, not the Part class that will receive
> update_attributes.
>
> HTH,
> David
>

Hi, David,
Thanks for that. Makes sense that the update_attributes message is to be
received by the  instantiated object and not the class.

I made the following change and yet, I get an error implying that the
update_attributes message is never called.


-----------------  Spec extract starts --------------------------------

    context 'saves updates to an existing part object successfully' do
        before do
            part = double('part')
        end
        it 'does its job in saving the update' do
            part.should_receive(:update_attributes).and_return(true)
            Part.should_receive(:find).with(1).and_return(part)
            put :update, :id => 1, :part => {'title' => 'Brake pads'}
            flash[:notice].should eq('Part was successfully updated.')
        end
    end

-----------------  Spec extract ends  --------------------------------

and the error reads:


------- Error extract begins -----------------

  1) PartsController saves updates to an existing part object successfully
does its job in saving the update
     Failure/Error: part.should_receive(:update_attributes).and_return(true)
       (Mock "Part_1006").update_attributes(any args)
           expected: 1 time
           received: 0 times
     # ./spec/controllers/parts_controller_spec.rb:56

Finished in 0.25365 seconds
8 examples, 1 failure, 1 pending


------- Error extract ends  -----------------

-- 
You received this message because you are subscribed to the Google Groups 
"rspec" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rspec?hl=en.

Reply via email to