[rspec-users] Cucumber - Adding a step definition

Mark Wilden mark at mwilden.com
Sat Mar 14 11:50:16 EDT 2009


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
    And I have been invited to that challenge
    When I visit the challenge's page
    And I press "Accept"
    Then I should go to my attempt detail page for the challenge
    And I should see that I accepted the challenge
    And I should not see "Attempt Challenge"

Clearly, there is dependency between steps - each has to know what
challenge they're working on, for one thing. But I've found that it
reads better than the alternative

   Given there is a challenge call 'Reach from the Stars' for 'Halo 3'
    And I am logged in as Mark
    And Mark was invited to 'Reach from the Stars' for 'Halo 3' on
'Sept 1, 2009' by 'Bill'
   When I visit the challenge page for 'Reach from the Stars for 'Halo 3'
    And I press "Accept"
    Then I should go to Mark's attempt detail page for the challenge
'Reach from the Stars' for 'Halo 3'
    And I should see that 'You accepted this challenge on Sept 1,
2009'   And I should not see "Attempt Challenge"

The first one reads more like a business-level story to me and the
second one reads more like a test.

Thoughts?

///ark


More information about the rspec-users mailing list