Testing custom validations.

I have a large number of models with attributes like backup_started_at, backup_ended_at; essentially paired dates. To ensure that start dates are always on or prior to end dates, I have written a custom validation (config/initializers/validators.rb), and I am wondering how to test it. Ideas? Is there a best practice for this sort of thing?

Cheers--

Charles

Doesn't your unit testing exercise the validator? I'm not an expert on rails testing, but that's where I'd expect it to checked.

Yes, indeed my unit tests all pass when exercising the validator, and perhaps that is all there is to it. Still, this seems like an odd way to test the validation code, and perhaps with such a simple validation unit testing the models that have the validator is enough.

Cheers--

Charles

cnjohnson wrote:

Doesn't your unit testing exercise the validator? I'm not an expert on
rails testing, but that's where I'd expect it to checked.

Yes, indeed my unit tests all pass when exercising the validator, and
perhaps that is all there is to it. Still, this seems like an odd way
to test the validation code, and perhaps with such a simple validation
unit testing the models that have the validator is enough.
Cheers--
Charles

Run tests that do not validate and ones that validate to confirm both sides.