I have this in my test
Project.should_receive(:find).with(@project).and_return(@project)
but when object receive that method call two times
should_receive
, as opposed to any_instance
, expects that the class receives message the specified number of times.
any_instance
on the other hand is generally used for stubbing a method.
So the first case is an expectation that we would like to test, while the second one is getting past a method to the next line so we can move on.