[rspec-users] Mocking: brittle specs and tight coupling?
ashley.moran at patchspace.co.uk
Tue Apr 21 16:43:39 EDT 2009
On 12 Apr 2009, at 05:19, Phlip wrote:
> There's a third alternative: Your sliding scale is really a pyramid
> with a peak.
> The third alternative is you never _need_ to mock, yet both your
> tests and target code are highly decoupled. _That_ is the goal.
> Under TDD, you get that by avoiding a design smell called "expensive
> setup". Your scale assumes that something actually must be set up -
> either mocks, or end-to-end class models. The best tests only need a
> few stubbed objects, each easy to construct.
> The spaghetti is the design you don't want. The meatball is the
> design you want. Each chopstick is a simple test, and the angle
> between the chopsticks represents the _difference_ between the two
> tests. If each test is simple yet is set up differently, then the
> simplest code which can pass both simple tests approaches the most
> elegant design.
Sorry for the late reply epicfail. I've been trying to visualise what
you mean here. Can you give me a more concrete example of what you
mean by "meatball-alone" vs "spaghetti-laden" design?
BTW, as a pretty strict almost-carnivorous grain-avoider, I approve of
your analogy =)
More information about the rspec-users