After some consideration, I agree with Aslak's and Ben's advice
against keeping context across an entire feature.
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 |
Approach B ------------------------
Before:
Given I have a clean database
Scenario: Successful Signup
Given I start on the login page
When I signup as "userA"
Then I should see "successful signup"
Scenario: Failure - Duplicate Userid
Given I start on the login page
When I signup as "userA"
And I signup again as "userA"
Then I should see "error: duplicate userid"
OK I will use Approach B, but ideally would prefer to use Approach A,
and personally find it easier to read and understand.
Thanks again for your feedback! :)
On Apr 28, 11:13 pm, aslak hellesoy <[email protected]> wrote:
> > Hey Ben,
>
> > It'd be kinda cool if there was a sort of before and after for a feature
> > rather than each scenario. Is there?
>
> I think that would be particularly *un*cool actually, because people would
> start using it without understanding the implications.
> Implications: Coupled, brittle scenarios.
>
> Why do you think it would be useful?
>
> Aslak
>
> _______________________________________________
> 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