[rspec-users] Route is valid but not found :(

David Chelimsky dchelimsky at gmail.com
Tue Aug 23 08:46:23 EDT 2011


On Aug 23, 2011, at 7:22 AM, Gordon Yeong wrote:

> I found out why it was not working.
> 
> The line, 'Part.should_receive(:update_attributes).with('title' => 'Brake pads').and_return(part)' should not be there because the controller specs should not care about implementation (ie. how things are processed, rather just what is done).  I realised this when I looked at my specs for creation of new objects.
> 
> I commented the line and the spec now passes as expected.
> 
> 
> ------------ Spec extract starts -------------------------
> 
>     context 'saves updates to an existing part object successfully' do
>         it 'does its job in saving the update' do
>             Part.should_receive(:find).with(1).and_return(part)
>         #   Part.should_receive(:update_attributes).with('title' => 'Brake pads').and_return(part)

^^ 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




>             put :update, :id => 1, :part => {'title' => 'Brake pads'}
>             flash[:notice].should eq('Part was successfully updated.')
>         end
>     end
> 
> ------------ Spec extract ends  -------------------------
> 
> Thank you for your help, Justin!
> 
> Gordon Yeong :)
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users

Cheers,
David



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20110823/5f923f2a/attachment-0001.html>


More information about the rspec-users mailing list