[rspec-users] Before and After blocks for individual feature files?

Andrew Vit andrew at avit.ca
Wed Apr 29 13:11:50 EDT 2009

On Apr 29, 2009, at 8:45 AM, Arco wrote:

> But I am still not convinced that it makes sense for create a new
> context for each row of an example table.  As a newbie, I expected the
> Before: block would be run once before the scenario, not once before
> every row of the example table.  (so did Ben initially...)
> Approach A -----------------------
> Before:
>  Given I have a clean database
> Scenario Outline:  Signup Scenarios
>  Given I start on the login page
>  When I signup as <userid>
>  Then I should see <message>
>  Examples:
>    | userid | message                 |
>    | userA  | successful signup       |
>    | userA  | error: duplicate userid |

To me, "Examples" means separate, independent items.

If these are to be run under the same scenario in sequence, then the  
table should be called something else, maybe "Sequence:" or "Steps:"

There might be other use cases for such a feature... I don't have any  
to suggest at the moment, just brainstorming.

Andrew Vit

More information about the rspec-users mailing list