[rspec-users] validate_presence_of

Fernando Perez lists at ruby-forum.com
Thu Feb 19 05:31:44 EST 2009

> Wrong.  You don't have to test validates_presence_of.  What matters,
> and therefore what you should test, is whether the model will complain
> at you if a particular value is left empty.
> ...
> If your spec breaks because you changed a method call, you're not
> testing behavior any more.  You're testing syntax.

I totally agree with your point of view.

> Also, while I used to be very anal and write "should
> have(1).error_on(:login)" and such, I eventually realized that there's
> no point.  Checking on 'valid?' is entire and sufficient.

I also came to the same conclusion. That's why I am very cautious with 
"rake stats" and rcov, it entices people to write dumb tests / specs 
just to get the figures up.
Posted via http://www.ruby-forum.com/.

More information about the rspec-users mailing list