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
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to