On Wed, Aug 20, 2008 at 8:32 AM, Jim Morris <[EMAIL PROTECTED]> wrote: > Aslak Hellesøy wrote: > >>> >>> I'd like to have a before story and after story as well as a before >>> scenario and after scenario. >>> >>> Right now I do global setup for a story, and cleanup when the story is >>> done. I also do a setup before each scenario as well. >>> >>> It would be nice to have the ability to do both. >> >> Can you give me a code example? (In Cucumber it's Feature, not Story) >> > > An example of how I would use it or an example of how to do it? >
Of how you would use it. Assume that you have something like this for scenario-level before/after: class MySteps < Cucumber::Steps # Same as Story runnner steps_for(:my) Before do # This block will run before all scenarios that use steps from MySteps # Any scenarios not using any of these will not have this block run end Given /bla bla/ do end end Aslak > Right now I use the listeners to call a before_story and after_story and > before_scenario. > > My Stories (Features) test the database as well as the return values of > various calls, so the before_story sets up the database accessors via > Sequel, putting them in global variables so I can easily access them from > anywhere. > > In the before_scenario I for instance make sure the user is logged out and > the database is cleared. > > -- > Jim Morris, http://blog.wolfman.com > _______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users