[rspec-users] Reuse of Cucumber Features

Rick DeNatale rick.denatale at gmail.com
Thu Apr 9 09:19:05 EDT 2009

On Thu, Apr 9, 2009 at 3:57 AM, Matt Wynne <matt at mattwynne.net> wrote:
> Another way to remove duplication (and noise) from Cucumber steps is the
> hide the details in the Ruby code that implements the step, and write a much
> more general step in the feature file like this:
>        Given there are 3 flights departing on the same day
>        And the flights all leave at different times
>        And there is another flight leaving on the following day
>        When the earliest flight is delayed by 5 mins
>        Then the flights on the first day should all be delayed by 5 minutes
>        And the flight on the second day should be unaffected
> These kind of steps can be clearer to read, but the trade-off is that your
> underlying step code gets more complex as you start writing logic to deliver
> these specific scenarios. Still, if you're clever about it, these
> 'declarative' steps can still be pretty re-usable.
I've gone down a similar road before, albeit with the old story runner
rather than Cucumber, and I'm not sure how far I'd push it.

That trade-off starts to get onerous.  You spend a lot of time debugging
your steps to convince yourself that "the flight on the second day" maps to
"another flight leaving on the following day" when you reuse the steps in
other cases.  I found myself wanting to do meta bdd on my story code!

Rick DeNatale

Blog: http://talklikeaduck.denhaven2.com/
Twitter: http://twitter.com/RickDeNatale
WWR: http://www.workingwithrails.com/person/9021-rick-denatale
LinkedIn: http://www.linkedin.com/in/rickdenatale
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20090409/f5e189d4/attachment.html>

More information about the rspec-users mailing list