[rspec-users] Recommendations on multi-view scenarios?

Matt Wynne matt at mattwynne.net
Mon May 18 14:26:00 EDT 2009


On 18 May 2009, at 16:02, Denis Haskin wrote:

> I'm trying to find out best practices for a multi-view scenario.   
> Take the classic example of ecommerce, where you might first enter  
> address information, then credit card information, then confirm it  
> all and the purchase is made.
>
> Seems to me this has to be done with a separate scenario for each  
> view?
>
> The whole process would be:
>
> Scenario: I purchase a widget by paying for it with a credit card
> Given I am logged in as Sheila
> And I have a widget in my cart that costs $5
> When I press "Checkout"
> And enter my address information
> And press "OK"
> And enter my credit card information
> And press "OK"
> And press "OK"
> Then my credit card balance should be reduced by $5
> And I have a completed transaction in my order history
>
> But that seems really really wrong.  So I assume it needs to be like  
> this?
>
> Scenario: I purchase a widget by entering my address information
> Given I am logged in as Sheila
> And I have a widget in my cart that costs $5
> When I press "Checkout"
> And enter complete address information
> And press "OK"
> Then I do not get an error message
> And I am on the "credit card information" page
>
> Scenario: I purchase a widget by entering my credit card information
> Given I am logged in as Sheila
> And I have a widget in my cart that costs $5
> And I am on the "credit card information page"
> When I enter valid credit card information
> And press OK"
> Then I do not get an error message
> And I am on the "confirm purchase" page
> ...etc...
>
> Yes?  No?  Examples?

This is a common question. See http://www.benmabey.com/2008/05/19/imperative-vs-declarative-scenarios-in-user-stories/ 
  and also http://wiki.github.com/aslakhellesoy/cucumber/calling-steps-from-step-definitions

Matt Wynne
http://blog.mattwynne.net
http://www.songkick.com



More information about the rspec-users mailing list