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

Ken Chien ken.chien at gmail.com
Tue Aug 23 08:19:10 EDT 2011


I think you were closer when you had:
------- Source code extract starts -----------------
   context 'saves updates to an existing part object successfully' do
       before do
           part =
double('part').stub(:update_
attributes).and_return(true)
       end

       it 'does its job in saving the update' do
            Part.should_receive(:find).with(1).and_return(part)
           Part.should_receive(:update).with('title' => 'Brake
pads').and_return(part)
           put :update, :id => 1, :part => {'title' => 'Brake pads'}
        end
   end
------- Source code extract ends -----------------

However, you were setting part equal to the return value from
"stub(:update_attributes).and_return(true)" which returns a Proc, not a
double.
Instead, try this:

let(:part) { double('part') }

   it 'does its job in saving the update' do
        part.stub(:update_attributes).and_return(true)  # <--- moved this
from the before method

          Part.should_receive(:find).with(1).and_return(part)
           Part.should_receive(:update).with('title' => 'Brake
pads').and_return(part)
           put :update, :id => 1, :part => {'title' => 'Brake pads'}
        end
   end
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20110823/39c4728d/attachment.html>


More information about the rspec-users mailing list