[rspec-users] How much test data to use in specs

Nick Hoffman nick at deadorange.com
Wed Aug 27 14:03:37 EDT 2008


On 2008-08-27, at 12:57, Rahoul Baruah wrote:
> For this, trivial, example, I find that far too verbose.
>
> The "specification" says "if it is less than 2 characters then  
> invalid" and "if it is more than 128 characters then invalid" .
>
> But you are actually running three checks - "if less than 2", "if  
> greater than 2 but less than 128" and "if greater than 2 and greater  
> than 128".
>
> B
>
>
> Rahoul Baruah

This is what I ended up with:

Property addresses that are valid
- can't be 129 characters
- can't have a 1-letter street name
- can't have an &
- can't have an !
- can't have a "
- can't have 2 letters after the street number
- can't be missing a street number
- can't have only 3 characters
- can't be empty
- can have 128 characters
- can have 127 characters
- can have only 5 characters
- can have only 4 characters
- can have a ,
- can have a -
- can have a '
- can have 1 letter after the street number
- can have multiple spaces

Each of the "can ..." examples are proper addresses in the sense that  
they're variations of:
- "123 A Street With A Long Name"
- "123B Maple Ave"
- "123 O'Connor Street"
- etc

One thing that I didn't do is write examples for each invalid  
character. That'd be too hairy and verbose. Instead, I picked a few,  
and wrote examples for them, as you can see above (Eg: "can't have an  
&").

Cheers,
Nick


More information about the rspec-users mailing list