[rspec-users] Learning Cucumber

Andrew Premdas apremdas at gmail.com
Fri Nov 14 01:53:14 EST 2008


What you're doing here is writing imperative features. Writing
declarative features might be a better alternative. Instead of

 Given I am on the new entity page
   When I fill in a textbox labelled "Common Name" with "My New Entity"
   And I fill in a textbox labelled "Full Legal Name:" with "My New
Enitity is a CORP"
   And I select from a listbox labelled "Legal Form:" the value "CORP"
   And I press "Create"
   Then I should see "Entity was successfully created."

You could consider

Given I am on the new entity page
 When I correctly fill in the new entity form
 Then I should see a confirmation

Then the feature has much less technical stuff in it that

1) Hide the intent
2) Make the story brittle to cosmetic changes, in particular to small
rewordings of error messages and confirmations

A side effect of this is you need much less regex magic to match your
expressions.

HTH

Andrew


2008/11/13 James B. Byrne <byrnejb at harte-lyne.ca>:
>
> On Thu, November 13, 2008 11:51, James B. Byrne wrote:
>
>> So, evidently I need some other specification to check the validity of the
>> action with respect to the web page displayed.  Can some one give me a
>> hint as to what "I should see "X" should actually say?  Should this be a
>> regex?  In other worlds should the outcome be specified as:
>>
>>    Then I should see "*Entity was successfully created*"
>>
>>
>
> Actually, I have discovered that what I need to do is to create some steps
> to move the data passed by the When clauses into the form variables and
> thus get the expected result instead of an error.
>
>
> --
> ***          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
>
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>


More information about the rspec-users mailing list