Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it necessary to unit test ActiveRecord validations?

Is it necessary to unit test ActiveRecord validations or they are well-tested already and hence reliable enough?

like image 534
Chirantan Avatar asked Feb 12 '09 11:02

Chirantan


1 Answers

Validations per se should be trustable, but you may want to check if the validation is present.

Put in other words, a good way to test something is as if it were a black box, abstracting the tests from the implementation, so for instance you may have a test that checks that a person model can't be saved without a name, but don't care about how the Person class performs that validation.

like image 193
krusty.ar Avatar answered Sep 23 '22 23:09

krusty.ar