Forum: RSpec [cucumber] before/after scenarios

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
3464536ce6396bacc132ad18d2c46489?d=identicon&s=25 Tim Walker (timw)
on 2008-12-17 22:17
(Received via mailing list)
Hi Guys,

Sorry for the double-whine but I've seen references to these listeners
but not a lot of luck finding any details.

So...that's it: Setup/Teardown Before/After scenarios...what's the
scoop?

Thanks,

Tim
(Also, the logo's are looking awesome!)
5d38ab152e1e3e219512a9859fcd93af?d=identicon&s=25 David Chelimsky (Guest)
on 2008-12-17 22:25
(Received via mailing list)
On Wed, Dec 17, 2008 at 3:14 PM, Tim Walker <walketim@gmail.com> wrote:
> Hi Guys,
>
> Sorry for the double-whine but I've seen references to these listeners
> but not a lot of luck finding any details.
>
> So...that's it: Setup/Teardown Before/After scenarios...what's the scoop?

That's it.
C694a032be7518a0d704318895f8fe1d?d=identicon&s=25 Ben Mabey (mabes)
on 2008-12-17 22:28
(Received via mailing list)
Tim Walker wrote:
> (Also, the logo's are looking awesome!)
> _______________________________________________
> rspec-users mailing list
> rspec-users@rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>
Hey Tim,
The 'Hooks' and "RSpec Stories Migration' pages on the wiki has some
information on this.  Have you looked at those pages?

If you have and are still confused, could you be more specific on what
you are needing to do?

-Ben
F68f69615423aa3851bd445409754dbf?d=identicon&s=25 Joseph Wilk (joesniff)
on 2008-12-17 23:14
(Received via mailing list)
Tim Walker wrote:
> Hi Guys,
>
> Sorry for the double-whine but I've seen references to these listeners
> but not a lot of luck finding any details.
>
> 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?

HTH
--
Joseph Wilk
http://blog.josephwilk.net
3464536ce6396bacc132ad18d2c46489?d=identicon&s=25 Tim Walker (timw)
on 2008-12-17 23:57
(Received via mailing list)
Joseph,

This is very, very helpful and gets me to a place where I can try it.
If anything, I just didn't think to look in "hooks" for the concept of
setup/teardown. Really looking forward to the book!

Many sincere thanks, I hope i can return the favor some day.

Tim
Ece726dc06b47720b98a7be611f03c0c?d=identicon&s=25 Paul Covell (Guest)
on 2009-01-14 10:29
(Received via mailing list)
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-scen...
Sent from the rspec-users mailing list archive at Nabble.com.
1f6cdb8e62c84a40eb61246ca36b5c82?d=identicon&s=25 Joseph Wilk (Guest)
on 2009-01-14 10:45
(Received via mailing list)
Paul Covell wrote:
>>
>>
>
> 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/tick...

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/tick...

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
>     Given a venue manager role
>
>     | basic      | public       | not_found |
>     | basic      | unverified   | not_found |
>
> I am still new to BDD so please holler if I'm missing something fundamental.
>
Cdf378de2284d8acf137122e541caa28?d=identicon&s=25 Matt Wynne (mattwynne)
on 2009-01-14 11:56
(Received via mailing list)
On 6 Jan 2009, at 05:22, Paul Covell wrote:

>> 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

You might want to check out this ticket, I think you and Eric Kidd
basically want the same thing:
http://rspec.lighthouseapp.com/projects/16211/tick...

Matt Wynne
http://blog.mattwynne.net
http://www.songkick.com
This topic is locked and can not be replied to.