Very very cool. So while GivenScenario is useful for chaining scenarios, if you want to spec out a process you can also do it this way. Very cool.
Nathan Sutton [EMAIL PROTECTED] rspec edge revision 2894 rspec_on_rails edge revision 2894 rails edge revision 8146 On Nov 16, 2007, at 1:03 AM, David Chelimsky wrote: > On Nov 15, 2007 7:17 PM, Nathan Sutton <[EMAIL PROTECTED]> wrote: >> >> You mentioned on your blog when talking about stories: >> http://dannorth.net/whats-in-a-story >> >> That you can chain events like this: >> Scenario >> Given >> When >> Then >> When >> Then >> When >> Then >> etc... >> >> Is this possible in rspec? > > Totally! > >> >> >> Nathan Sutton >> [EMAIL PROTECTED] >> rspec edge revision 2894 >> rspec_on_rails edge revision 2894 >> rails edge revision 8146 >> >> >> >> >> >> On Nov 15, 2007, at 2:04 PM, Dan North wrote: >> >> >> Hi Nathan. >> >> You can reuse a scenario as a given in another scenario: >> >> Scenario "passing go" >> Given "I am not in jail" >> When "I pass go" >> Then "I collect $200" >> >> Scenario "landing on someone's hotel after passing go" >> GivenScenario "passing go" # matches the scenario name >> When "I land on someone's hotel" >> Then "I receive the $200 before I have to pay out for the hotel" >> >> >> For the second scenario, the story runner reruns the whole first >> scenario >> and keeps the same object instance for running the remaining steps. >> This >> means that any state you set up (@variables, mixins, etc.) are >> available for >> the other steps. It's useful for incrementally building up >> something like a >> workflow or a state engine. >> >> Cheers, >> Dan >> >> On Nov 15, 2007 3:01 AM, Nathan Sutton <[EMAIL PROTECTED]> wrote: >>> I'm writing a plain text story (testing the waters) and I have >>> scenarios that I need to chain in my specs. >>> >>> Here is what I have so far: >>> >>> Story: User purchasing tshirts >>> As a user >>> I want to checkout >>> So that I can purchase shirts >>> >>> Scenario: User goes to checkout with nothing in cart >>> Given a user >>> And user has an empty cart >>> When user goes to checkout >>> Then user should see the page: site index >>> And page should include the text: you have nothing in your cart >>> >>> Scenario: Logged-in user goes to checkout >>> Given a logged-in user >>> And user has a cart with items in it >>> When user goes to checkout >>> Then user should see the page: address entry >>> >>> Scenario: Anonymous user goes to checkout >>> Given an anonymous user >>> And user has a cart with items in it >>> When user goes to checkout >>> Then user should see the who are you page >>> >>> Scenario: Anonymous user continues as guest from 'who are you' page >>> Given an anonymous user >>> And user has a cart with items in it >>> And user is at the page: who are you >>> When user continues as a guest >>> Then user should see the page: address entry >>> And page should include the text: guest >>> >>> Scenario: Anonymous user decides to sign-up at 'who are you' page >>> Given an anonymous user >>> And user has a cart with items in it >>> And user is at the page: who are you >>> When user goes to sign-up >>> Then user should see the page: sign-up >>> >>> Scenario: Registered user decides to login at 'who are you' page >>> Given an anonymous user >>> And user has a cart with items in it >>> >>> And user is at the page: who are you >>> When user goes to login >>> Then user should see the page: login >>> >>> Scenario: Registered user logs in and is returned to checkout >>> Given an anonymous user >>> And user has a cart with items in it >>> and user is at the page: login >>> When user logs in >>> Then user should see the page: address entry >>> >>> Scenario: Anonymous user signs-up and is returned to checkout >>> Given an anonymous user >>> And user has a cart with items in it >>> And user is at the page: sign-up >>> When user signs-up >>> Then user should see the page: address entry >>> >>> The parts that I need to chain are the last four scenarios. I >>> want to >>> make sure that when they leave to signup and log in that they're >>> returned to the next step in checkout. How would I go about doing >>> this in the stories? Would that just be another given? >>> >>> Also, how do the rest look, sane? >>> >>> Thanks, >>> >>> Nate >>> _______________________________________________ >>> rspec-users mailing list >>> [email protected] >>> http://rubyforge.org/mailman/listinfo/rspec-users >>> >> >> _______________________________________________ >> rspec-users mailing list >> [email protected] >> http://rubyforge.org/mailman/listinfo/rspec-users >> >> _______________________________________________ >> rspec-users mailing list >> [email protected] >> http://rubyforge.org/mailman/listinfo/rspec-users >> > _______________________________________________ > rspec-users mailing list > [email protected] > http://rubyforge.org/mailman/listinfo/rspec-users _______________________________________________ rspec-users mailing list [email protected] http://rubyforge.org/mailman/listinfo/rspec-users
