S Ahmed
2011-May-03 19:27 UTC
[rspec-users] when mocking, does it scan the method being tested for outside calls?
Say I want to test this method: def modify_user_status(user_id) .. .. user = User.find(user_id) .. .. end Now could I mock the call to User.find()? I''m just trying to understand, when I run the test, and say I mocked the call to User.find, then rspec realizes this and replaces it with the mocked call. Is this correct? -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20110503/623fae7a/attachment-0001.html>
David Chelimsky
2011-May-07 14:02 UTC
[rspec-users] when mocking, does it scan the method being tested for outside calls?
On May 3, 2011, at 2:27 PM, S Ahmed wrote:> Say I want to test this method: > > > def modify_user_status(user_id) > .. > .. > > user = User.find(user_id) > .. > .. > end > > > Now could I mock the call to User.find()? > > I''m just trying to understand, when I run the test, and say I mocked the call to User.find, then rspec realizes this and replaces it with the mocked call. > > Is this correct?Please post the example so we have something specific to talk about.