[rspec-users] features and form filling - going declarative?

Pat Maddox pergesu at gmail.com
Fri Nov 7 11:04:07 EST 2008


"Andrew Premdas" <apremdas at gmail.com> writes:

> I'm working on writing features for a wizard. The wizard collects information from a number of different forms, and you can navigate through
> it in a number of ways. Anyhow one of these forms is a customer form collecting name, and email.
>
> In the context of the wizard I feel that the following scenarios
>
>   Scenario: 
>     Given I step to customer
>        And I fill in my customer details correctly
>
>   Scenario: 
>     Given I step to customer
>        And I fill in my customer details incorrectly
>      Then I should see an error
>
> are preferable to
>
>   Scenario: 
>     Given I step to customer
>        And I fill in email with fred at example.com
>        And I fill in name "Fred Bloggs"
>
>     Given I step to customer
>        And I fill in email with ''
>        And I fill in name "Fred Bloggs"
>      Then I should see an error
>
>     # add table for different combinations of form fields that cause errors
>     # consider checking that errors are appropriate
>
> note:  Given I step to customer is nested step doing all sorts to get to the form
>
> What do you think?
>
> I'm looking for some input on this, and in particular am wondering where should I put the more specific tests for form validation, error
> messages etc. in my test hierarchy, or even if I should test them at all (could you argue they're in built rails functionality).

I typically go with the first style, because I'm lazy and don't want to
write out a bunch of steps and their associated definitions.  Also, I
think that "fill in my customer details incorrectly" expresses the
intent better.  But really that's what the scenario title is for I
guess.  So mostly it's just that I'm lazy, cause declarative steps are
less work up front and are more resilient to change.

Pat


More information about the rspec-users mailing list