[rspec-users] Best practices: How small to make > examples?

James B. Byrne byrnejb at harte-lyne.ca
Mon Apr 6 11:02:12 EDT 2009


On: Sun, 5 Apr 2009 10:03:40 -0700, Mark Wilden <mark at mwilden.com>
wrote:
>
> On Sun, Apr 5, 2009 at 5:20 AM, David Chelimsky
> <dchelimsky at gmail.com> wrote:
>
>> Given I register for a conference
>> Then my name should be on the list of conference attendees
>> And the conference should be my list of conferences
>
> If I were describing 'register for a conference' in this scenario,
> then I would think it important to specify the steps that are used:
>
>  Given I am logged in
>  And I go to the registration page
>  And I fill in the email field
>  And I click "Register"
>  Then my name should be on the list of conference attendees
>  And the conference should be my list of conferences
>
> That's the level of detail the story would have, so that's what I
> want to show works.
>

At the moment, I tend to take a "middle of the road" approach.
(Typically Canadian, eh?)

  Given user "myuser" is authenticated
  When they visit the registration page
   And they provide all required registration data
   And they choose "register"
  Then they should see a registration success message
   And ...

In the step definitions, one then chooses exactly what constitutes
/all required registration data/, or how /choose "register"/ is
implemented (button, link), or what a /registration success message/
looks like. If it is deemed absolutely essential to prove that a
specific input field is available in the view then this can be
slipped in under the /required ... data/ clause.

   And they provide all required registration data
   And they enter the email address "myuser at example.com"

In my, admittedly limited, experience this approach gives you all
the essential elements that the client needs to approve. Yet, it
still provides flexibility on how meeting the requirements are
implemented and tested, without breaking the scenario clauses.

-- 
***          E-Mail is NOT a SECURE channel          ***
James B. Byrne                mailto:ByrneJB at Harte-Lyne.ca
Harte & Lyne Limited          http://www.harte-lyne.ca
9 Brockley Drive              vox: +1 905 561 1241
Hamilton, Ontario             fax: +1 905 561 0757
Canada  L8E 3C3



More information about the rspec-users mailing list