[rspec-users] Re-use scenarios from another story file?

David Salgado david at digitalronin.com
Sat Jul 5 08:42:39 EDT 2008

Many thanks for the advice, guys.


2008/7/5 Ben Mabey <ben at benmabey.com>:

> Zach Dennis wrote:
>> A short experience report regarding this thread:
>> Early on when stories were introduced to rspec's code base I started using
>> them, and I tried some different techniques to see what the sweet spot was
>> for using stories in actual development. To do some of this I made
>> modifications to rspec (this was before stories were released officially)
>> In my experience I found that trying to build up a highly re-usable set of
>> steps caused a lot more overhead, both in the creation of new features and
>> in the maintenance of ongoing development or changes to existing features.
>> In practice has been much easier for me to build reusability in the form of
>> helper methods which sit behind steps, and even to allow yourself to have
>> very simple (even one line) step definitions.
>> One problem I noticed I ran into was that I spent too much time trying to
>> organize and group reusable sets of steps. This made it difficult when one
>> story changed in how it did something, but another one did not, and it made
>> my stories rely on several step files (ie: steps_for => [:site_navigation,
>> :project_navigation, :project_creation, etc.]). Sometimes I would end up
>> having to reorganize, or split one step into two, and then go find all
>> places where things would be affected by this, etc.
>> I also found that by focusing on this kind of step reusability I was
>> writing much more granular stories (ie: implicit story style). When trying
>> out what is now known as the declarative story style I have found that
>> introducing new features and changing existing features takes much less time
>> when all of my steps for a story are in as few as possible step files
>> (typically just one step file). When I notice that two stories both have a
>> scenario where the implementation of a step is the same, I pull that out
>> into a helper much like David suggested. Now if one of those stories
>> changes, you can change its step w/o affecting any others.
>> In summary, don't focus on step reusability across stories, instead pull
>> out helpers while allowing the steps to be defined separately for their
>> respecive stories. This will make it easier to introduce new features and
>> maintain/change existing features over the lifetime of the app.
>> HTH,
>> Zach
> +1.  I have had the exact same experience.  Reusing story steps too
> aggressively tends to lead to awkward stories that have a higher maintenance
> cost for several reasons.
> -Ben
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20080705/705f085e/attachment-0001.html>

More information about the rspec-users mailing list