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 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. 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 -- View this message in context: http://www.nabble.com/-cucumber--before-after-scenarios-tp21061651p21304997.html Sent from the rspec-users mailing list archive at Nabble.com. _______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users