[rspec-users] Reuse of Cucumber Features
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!
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the rspec-users