Hi,

On Tue, Mar 27, 2012 at 22:10, Mike Mazur <mma...@gmail.com> wrote:
> In May last year, the controller specs generated with `rspec g
> scaffold` were changed to use real model objects instead of
> `mock_model`.
>
> I'm curious why this change was made?

As soon I sent this email off, I noticed this text in the template:

# Compared to earlier versions of this generator, there is very limited use of
# stubs and message expectations in this spec.  Stubs are only used when there
# is no simpler way to get a handle on the object needed for the example.
# Message expectations are only used when there is no simpler way to specify
# that an instance is receiving a specific message.

That explains things a bit, but I'm still curious!

One might argue that the earlier approach (with `mock_model`) may be
better for at least two reasons:

- looser coupling between specs and models
- faster spec execution (ie: don't have to create a real ActiveRecord instance)

I imagine RSpec is treading the fine line between ideal "best
practices" (ie: minimize coupling) and being more pragmatic and easier
to understand by the average developer. What's the current thinking on
this topic?

Thanks,
Mike
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to