Paul Covell wrote:
Joseph Wilk-4 wrote:
Tim Walker wrote:
So...that's it: Setup/Teardown Before/After scenarios...what's the scoop?
http://github.com/aslakhellesoy/cucumber/wikis/hooks

Does the information here answer your questions or do you think its missing some details?


I've been thinking there is a good deal of utility to having a "Before"
block at the top of a Feature -- for two reasons:
1. It's more DRY
2. It captures the relevant information in a place that's obvious and easy
to refer to/update

Looks like the addition of 'Background' to Cucumber will solve your issue.

http://rspec.lighthouseapp.com/projects/16211/tickets/153-add-optional-background-section-to-features#ticket-153-9

WDYT?

I could achieve goal (1) by simply adding a Before block to a steps file,
but this would obscure the setup (against goal 2).  It also prevents use of
feature tables in re-using steps, although I think that a short-term
objection since it will probably be fixed some day.
http://rspec.lighthouseapp.com/projects/16211/tickets/121-handling-step-tables-within-scenarios-with-tables-scenario-outline

Its been fixed on the AST branch of cucumber though this is still a dev branch. At some point it will be merged back into Cucumber.

If there is a pressing need for this is in mainline now shout at me.

--
Joseph Wilk
http://blog.josephwilk.net
For an example, here is an excerpt of what I *would like* to set up in
"Venue" feature file:

<code>
Feature: Create and Update Venues
  In order to manage venues
  An appropriately authorized user
  Should be able to view, create, edit, and update venues

  Before
    Given a venue manager role
    And the following users:
      | username   | roles          |
      | manager    | venue_manager  |
      | owner      |                |
      | basic      |                |
    And the following venues:
      | name           | verified  | creator  |
      | public         | true      |          |
      | public_owned   | true      | owner    |
      | unverified     | false     | owner    |

  Scenario Outline: Only manager can view verified venues
    Given I am logged in as "<user>"
    When I visit the show venue page for "<venue>"
    Then the result should be "<result>"
  Examples:
| user | venue | result | | manager | public | ok |
    | manager    | public_owned | ok        |
    | owner      | public       | not_found |
| owner | public_owned | not_found | | basic | public | not_found |
    | basic      | public_owned | not_found |

  Scenario Outline: Only manager and creator can view unverified venues
    Given I am logged in as "<user>"
    When I visit the show venue page for "<venue>"
    Then the result should be "<result>"
  Examples:
| user | venue | result | | manager | unverified | ok |
    | owner      | unverified   | ok        |
    | basic      | unverified   | not_found |

....
<snip>
</code>

So of course I could make a lump step "set up the venues" but there is
damage done to ease-of-comprehension and maintenance.  I can also see adding
a global Before, but really I don't want to contaminate other features with
this particular venue setup (and it will be out of plain sight, which I
don't want either).

I am still new to BDD so please holler if I'm missing something fundamental.


-Paul


_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to