[rspec-users] Working outside-in with Cucumber and RSpec

Matt Wynne matt at mattwynne.net
Sat Oct 25 06:12:39 EDT 2008

There are screencasts on peepcode and also Pat Maddox has done one,  
but I think they may be a bit out of date, and more focussed on just  
the mechanics of getting up and running with the old story runner  
rather than the workflow once you get going.

Ben Mabey's blog[1] has some useful experiences to draw on.

In answer to your question though, if this isn't too vague, I think  
this really sums it up:

Start with a plain-text feature, then implement the steps behind it  
one by one. As you implement each step you'll find you need the system  
to do something. Maybe your step says "Given there is a User". Do you  
have a User class yet? Then you'd better make one. Each time you  
change the system itself (as opposed to the steps), drive out that  
change by writing rspec examples that fail because you haven't written  
the code yet. This is crucial: resist the urge to touch the code until  
you have a failing spec. You can then use the usual TDD cycle to  
change the classes that make up the system, then finally surface back  
up to the feature, run it, and see what you need to do next.

The point of the cucumber features is not to exhaustively cover every  
single path in your code - that's the job of the specs (examples). The  
features give you a safety net to tell you that it all fits together.

Does that make any more sense or have I just regurgetated Aslak's  
words from the Cucumber readme?!


On 25 Oct 2008, at 10:34, Tom Stuart wrote:

> Hi,
> Going to dive into Cucumber soon, and just reading through all the  
> docs now.
> Can anyone point to an example of writing Cucumber features first  
> and then "when you get down to nitty gritty details, drop down one  
> abstraction level and use RSpec to write some specs for your  
> classes" (as per Cucumber wiki)? I'm trying to get a good feeling  
> for the process of starting with a feature, dropping straight down  
> to implementing code, and then somehow coming halfway back up and  
> filling in the specs. Which levels of granularity are we talking  
> about here? If you write a feature and then write enough code to  
> make the feature pass, how do the specs still have traction to drive  
> the design?
> Cheers,
> -Tom
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users

More information about the rspec-users mailing list