From: James Edward Gray II Date: 2007-06-11T21:17:38+09:00 Subject: Re: unit testing rails model validation? - why bother? what's rails best practice? On Jun 11, 2007, at 1:16 AM, Greg Hauptmann wrote: > Is there any need to write unit test cases for model validation > when such > validation is implemented by a single rails validate_* line in the > model? > e.g. "validates_presence_of :email". It doesn't have anything to do with how easy it is to implement. It's about validating your business logic. If a client tells me, "An email address is required," writing that test ensures I'm meeting the specification. It's also plenty common to add a custom validation method or two, which generally require more than one line of code. Surely you would want to test those. Finally, I've occasionally had tests show an unexpected interplay of many validation rules. Things like that are what unit tests are so good at uncovering. James Edward Gray II