Sunday, June 18, 2017

Test Behavior vs Implementation

You might have heard that in Rails model:

      validates_presence_of :name
can be tested using helpers like:

should_validates_presence_of :name

The problem with this kind of testing is that it is tied to this specific implementation of validation. If you change the validation to use it's own custom object, this test will break. This is not a good idea.