[rspec-users] Mocks? Really?
tom at experthuman.com
Thu Dec 6 12:11:26 EST 2007
On 6 Dec 2007, at 16:56, Andy Goundry wrote:
> This is handy and keeps the view test isolated from changes to your
> models, but is that really the point?
Yes, that's part of the whole idea of using mocks. (Similarly, two
interacting models will be isolated from each other's implementation.)
> What if someone later changes
> the model and updates the model tests so that they pass but do not
> realize that they've then broken the view?
This is an engineering problem. For example, perhaps you could have
one helper that's used to manufacture mock Projects, and use it in the
view specs and the model specs; changes to the attributes of Project
(and the corresponding changes to its spec) will then require that
helper to be updated so that the model specs still pass, and the view
spec will fail accordingly.
> somehow i want my view tests to tell me that the views are no longer
> going to behave as expected
Your view specs tell you that your views will behave as expected
_under the assumption that_ your model objects behave as expected.
That assumption needs to be checked elsewhere (in the model spec).
More information about the rspec-users