Skip to content

Instantly share code, notes, and snippets.

@mattwynne
Forked from bgswan/mock_problems.rb
Created January 2, 2011 14:02
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattwynne/762553 to your computer and use it in GitHub Desktop.
Save mattwynne/762553 to your computer and use it in GitHub Desktop.
# this would be in a helper somewhere
def stub_find(entity)
result = mock_model(entity)
entity.stub(:find).with(result.id).and_return(result)
result
end
let(:params) do
{:these => 'params'}
end
it "updates the requested book" do
mock_book = stub_find(Book)
mock_book.should_receive(:update_attributes).with(params)
put :update, :id => book.id, :book => params
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment