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

Nick Hoffman nick at deadorange.com
Mon Aug 25 12:53:12 EDT 2008


I'm not sure how much test data I should be using in my specs. I'm  
writing specs for the Property model in my Rails app. Its "address"  
attribute is going to be validated with this regex:
/\A\d+[a-z]? [-', a-z]{2,128}\Z/i

At the moment, my plan is to spec out the following possibilities. A  
property is invalid if its address:
1) doesn't begin with a digit;
2) is shorter than 2 characters;
3) is longer than 128 characters;

I should also test that certain characters, such as ! @ # $ etc,  
invalidate a property.

However, all of that seems like blacklisting, and achieves poor  
coverage of the regular expression.

Should I create a list of valid and invalid addresses to test against  
the regex? That seems like a decent idea, but seems synonymous with  
fixtures. What would you guys recommend?

Cheers,
Nick


More information about the rspec-users mailing list