[rspec-users] Mocks? Really?

Zach Dennis zach.dennis at gmail.com
Wed Dec 26 15:44:38 EST 2007


On Dec 26, 2007 3:23 PM, Pat Maddox <pergesu at gmail.com> wrote:
> On Dec 23, 2007 2:27 PM, Zach Dennis <zach.dennis at gmail.com> wrote:
> > I know the questioned are directed towards Dan so I hope you don't me
> > chiming in. My comments are inline.
>
> Thanks a lot for your comments, I really appreciate them.  I've been
> dying to respond to this for the past several days, but haven't had
> internet access.
>
>
> > On Dec 15, 2007 2:17 AM, Pat Maddox <pergesu at gmail.com> wrote:
> > >
> > > On Dec 8, 2007 4:06 AM, Dan North <tastapod at gmail.com> wrote:
> > > > I prefer the mantra "mock roles, not objects", in other words, mock things
> > > > that have behaviour (services, components, resources, whatever your
> > > > preferred term is) rather than stubbing out domain objects themselves. If
> > > > you have to mock domain objects it's usually a smell that your domain
> > > > implementation is too tightly coupled to some infrastructure.
> > >
> > > Assuming you could easily write Rails specs using the real domain
> > > objects, but not hit the database, would you "never" mock domain
> > > objects (where "never" means you deviate only in extraordinary
> > > circumstances)?  I'm mostly curious in the interaction between
> > > controller and model...if you use real models, then changes to the
> > > model code could very well lead to failing controller specs, even
> > > though the controller's logic is still correct.
> >
> > In Java you don't mock domain objects because you want to program
> > toward an interface rather then a single concrete implementation.
> > Conceptually this still applies in Ruby, but because of differences
> > between the languages it isn't a 1 to 1 mapping in practice.
>
> I must be misunderstanding you here, because you say you "don't mock
> domain objects," and the rest of your email suggests that you mock
> basically everything.
>

I'll respond more later, but wanted to point out that that should be
"In Java you mock domain objects because you want to ...". I don't
know how the "n't" got in there. ;)

Zach Dennis
http://www.continuousthinking.com


More information about the rspec-users mailing list