On Tue, Aug 19, 2008 at 6:38 AM, Jonathan Kinney <[EMAIL PROTECTED]>wrote:

> I noticed that the examples on the rspec website for model code
> http://rspec.info/documentation/rails/writing/models.html have no mocks or
> stubs. However both the controller example and view example do have mocks
> and stubs implemented. I was having some problems getting mocks to work in
> my model (using mock_model and passing in a hash or stubs) but I'm wondering
> if I shouldn't be mocking or stubbing in my model at all?
>

In a model spec, clearly you don't want to mock any part of the model under
test, because then you're not testing it. However, anything else (including
other models) is fair game. Mocks are used specifically to avoid testing
something, usually because you (or someone else) is testing it elsewhere.
Mocks make sure that the object under test is behaving correctly in its
interactions with other code - but (in a unit spec, at least), you don't
want to redundantly or expensively also test that other code.

That's my take, at least

///ark
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to