[rspec-users] Assumption tests

David Chelimsky dchelimsky at gmail.com
Sat Oct 20 16:29:32 EDT 2007


On 10/20/07, Scott Taylor <mailing_lists at railsnewbie.com> wrote:
> > These two specs are basically the same, and I can tell you that I
> > would likely NOT write the first one, but I would very likely write
> > the second one. This means that my decision is based on the
> > implementation, which might bug our purist BDD sensibilities.
>
> >
> > Which brings us to an important point. As is software in general, BDD
> > is all about balance. It requires thought. It requires weighing
> > opposing forces and making a practical decision.
> >
>
> Doesn't bug me, at all.  What bugs me is that this sort of mocking is
> not in some other mock library or plugin, which would do this pattern
> for me.

How would such a library know whether you want to store your
FooCollection's Foos in an Array or submit it to a FooService? How
would it know the APIs of all potention FooServices?

Perhaps there are solutions for specific libraries - e.g.
ActiveRecord, but even then you're going to have to specify structure
in advance (has_many vs has_many through) and consequently change your
specs when you decide to change your model.

> These common patterns (for Rails) should be abstracted away
> (as some have been doing with Rails' association proxy).  There is no
> reason that all of those implementation details *of another library*
> need to be crowding the intention of my specs.  Until this happens, I
> need to know all of these details about how another library works,
> which, for me, is too far off the scale (no balance there)...

We're all looking forward to your matcher libraries :)

Cheers,
David


More information about the rspec-users mailing list