Plain Text Stories Chaining Scenarios

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

Reads like haiku :stuck_out_tongue:

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 2:04 PM, Dan N. [email protected] wrote:

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.

FYI - this is not yet supported in Plain Text Stories. You can do it
as Dan suggests above, but not in plain text. Just an oversight that
will get addressed before the release.

Cheers,
David

Oh yeah, Dave shared that with me last night. This is VERY cool and
should be shouted about from the hilltops. It allows reusing of paths
through the environment when it forks at steps.

I love it.

Thanks,
Nate

You mentioned on your blog when talking about stories:

That you can chain events like this:
Scenario
Given
When
Then
When
Then
When
Then
etc…

Is this possible in rspec?

Nathan S.
[email protected]
rspec edge revision 2894
rspec_on_rails edge revision 2894
rails edge revision 8146

On Nov 15, 2007 7:17 PM, Nathan S. [email protected] wrote:

Then
When
Then
etc…

Is this possible in rspec?

Totally!

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 S.
[email protected]
rspec edge revision 2894
rspec_on_rails edge revision 2894
rails edge revision 8146