[rspec-users] Cucumber: Group Given, Whens and Thens

Andrew Premdas apremdas at gmail.com
Thu Nov 20 11:40:45 EST 2008


Also occasionally you may want to use a when as a given. Cucumber
doesn't actually use the given|when|then|and to differentiate steps,
just the regex that comes after them. Sometimes I feel that it makes
sense as in the following examples

    When I log in as Fred
    ....

    Given I log in as Fred

When I'm writing the login feature I'd use the first statement, but
when I'm testing foo as a logged in user I'd use the second. Both
would use the same step.

Now I realise that this counters the excellent advice given on the
step-organisation page of the wiki. However I think in this case even
though the step is definitely a when it should be allowed to be used
as a Given in some stories as its definitely a setup step rather than
an interaction step in certain|most contexts

Finally Cucumber tells you which step is matching your feature so
there is much less need to organise steps by given|when... then there
was with the previous story runner

All best

Andrew

2008/11/20 aidy lewis <aidy.lewis at googlemail.com>:
> Hi,
>
> Do you think this is a satisfactory way to group step files related to
> one feature
>
> e.g.
>
> publish_content_givens
> publish_content_whens
> publish_content_thens
>
> ?
>
> Thanks
>
> Aidy
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>


More information about the rspec-users mailing list