[rspec-users] [Cucumber] When do you log in? (was- Adding a step definition)

David Chelimsky dchelimsky at gmail.com
Sat Mar 14 12:48:50 EDT 2009

On Sat, Mar 14, 2009 at 10:50 AM, Mark Wilden <mark at mwilden.com> wrote:
> On Sat, Mar 14, 2009 at 5:59 AM, Matt Wynne <matt at mattwynne.net> wrote:
>> I'm not sure if I like this - dependency between steps seems like a dodgy
>> road to go down.
> I'm wondering how you'd feel about a style I've adopted:
>  Scenario: Accepting a direct challenge, without leaving a comment
>    Given there is a challenge
>    And I am logged in

One thing I do fairly consistently is put "logged in" steps first.

Given I am logged in as "admin"
And there is a challenge

the /as "admin"/ bit creates a user with login names, passwords and
roles derived from the value.

I also only include these when they are meaningful to the scenario. If
I'm working on a bit of functionality that only "admin" (for example)
can access, I'll have a separate feature talking about access, and
leave that business out of scenarios for this functionality. So
something like:

Scenario: valid vacation request
  Given I have accrued 10 days vacation
  When I submit a vacation request with:
    | start       | days |
    | next monday |    5 |

... would take care of logging in for me implicitly, as being logged
in is a fair assumption for this scenario and is spec'd elsewhere.

Any red flags for ppl? Are you doing it this way? If not, how else?


More information about the rspec-users mailing list