On Fri, Mar 14, 2008 at 8:12 PM, Rick DeNatale <[EMAIL PROTECTED]> wrote:
> I'm trying to use stories to drive some high-level design.
>
>
>  I've got some branching scenarios where I want to follow a scenario,
>  to establish a base situation, and then have different scenarios which
>  'branch' out from that state, possibly several levels deep.
>
>  I asked a bit about this a few days ago, and David pointed out the
>  rather undocumented GivenScenario which seems to give the basic
>  ability to do what I'm after.  So far it's been working fairly well,
>  but I've run into a few quirks.
>
>  1)  I've been working through my scenarios, and I'd commented out the
>  later ones to cut down on the 'pending' output while I develop the
>  steps.  I'd get one scenario working and then go on to the next.  So
>  at one point my plain text story looked something like this:
>
>      Scenario A
>           Given ...
>            When ...
>            Then ...
>
>    #Scenario B
>    #   GivenScenario A
>    #   Given ...
>    #    ...
>
>  And I got Scenario A working and uncommented the next scenario, or so I 
> thought:
>    Scenario A
>           Given ...
>            When ...
>            Then ...
>
>    #Scenario B
>       GivenScenario A
>       Given ...
>
>  It took me a while to debug the resulting infinite loop.  Perhaps
>  GivenScenario should check to see that it's not asking for the CURRENT
>  scenario.

Patches welcome :)

>
>  2)  Having figured that out and moving on,  I now have another
>  problem, which is what's the best way to clean up the database so that
>  Scenario A can run again if it assumes that the stuff it put in the DB
>  isn't there each time it runs. Cleaning the DB after running the
>  scenario won't work since it defeats the purpose of using the scenario
>  as a pre-condition.  Cleaning it before is more difficult,
>  particularly if I'm using parameterized steps.  It would be nice if I
>  could somehow use database transactions, but I don't see a nice way to
>  do that either.

This should just work. If you look at story_adapter.rb, which defines
the RailsStory class (maybe we should align :) ) you'll see that the
transaction is opened when the scenario starts and rolled back when it
is finished. GivenScenario should not result in a call to any of the
scenario finished methods (scenario_succeeded, _pending, _failed), so
it should get rolled back.

If that's not happening, please do file a ticket.

Cheers,
David

>
>  Has anyone faced issues like these? Any ideas?
>
>  --
>  Rick DeNatale
>
>  My blog on Ruby
>  http://talklikeaduck.denhaven2.com/
>  _______________________________________________
>  rspec-users mailing list
>  rspec-users@rubyforge.org
>  http://rubyforge.org/mailman/listinfo/rspec-users
>
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to