From: Gaspard Bucher Date: 2008-11-20T06:08:50+09:00 Subject: Re: I don't like specs, should I change my point of view ? On Wed, Nov 19, 2008 at 7:44 PM, Avdi Grimm wrote: > On Tue, Nov 18, 2008 at 9:06 PM, Ken Bloom wrote: >> I've read that before. Can anyone defend rspec against that attack? What >> does rspec do better? I want to get a better idea of why they invented >> this quasi-English framework. > > There's information about the "why" here: > http://behaviour-driven.org/BehaviourDrivenDevelopment > > BDD is, as you've identified, just testing with a slightly different > vocabulary. But vocabulary is important: it influences how you think > about the problem. > > I've seen a lot of TDD code fall into the rut of "let's test method A, > now let's test method B, now let's test method C". BDD encourages a > different focus and a different organization: "let's talk about how > this object should behave in situation A. Now let's talk about how > the object should behave in situation B." The granularity is based on > contextual behavior, rather than on methods. > > The very best TDD unit tests I've seen have provided a well-organized > breakdown of the expected inputs and outputs of each method in a > class, and were usable as documentation by a programmer. > Documentation, not a document. By contrast, the very best BDD specs > I've seen have read almost like a prose document describing the > system's behavior, one you could read aloud to a client and have them > understand and either agree or disagree. > > -- > Avdi > > Depending on what I am doing, I start by writing the end-user documentation (prose, phrases, examples, drawings, pictures) explaining the behaviour of an object, with the different possible approaches, etc. This document is refined until everything seems to fall naturally in place. Then I divide the problem into small objectives by writing unit tests. And finally I write the code. I think this approach is very close to BDD with one simple but important difference: I can write *nice*, searchable, illustrated documentation with real, sometimes funny, phrases. I find RSpec to be a poor middle man: not good enough for literature, too verbose/intrusive for simple tests. gaspard