Skip to content

Instantly share code, notes, and snippets.

@mmmries
Created June 13, 2013 21:14
Show Gist options
  • Save mmmries/5777434 to your computer and use it in GitHub Desktop.
Save mmmries/5777434 to your computer and use it in GitHub Desktop.
rspec test that a request makes certain changes to a model. How can I do something like this?
describe "my request" do
it "should update the model" do
Model.any_instance.should_receive(:save) do
self.changes.should include(:attribute)
self.attribute.should == 'value'
end
xhr :put, model_path(model), {attribute: 'value'}
end
end
@mmmries
Copy link
Author

mmmries commented Jun 14, 2013

I like that a lot. Having a direct reference to the object means I can easily assert a lot of things.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment