Should native validations be tested in rails?

前端 未结 5 2712
醉梦人生
醉梦人生 2021-02-20 07:25

Everybody knows that automated testing is a good thing.

Not everybody knows exacly what to test.

My question is if native validations like validate_presence_of,

5条回答
  •  情话喂你
    2021-02-20 08:10

    Yes.

    Testing that a model attribute is present or not is only testing the validates_presence_of code as a by-product of the real test which is that the validates_presence_of exists within your model.

    If someone commented out a bunch of validation code and then forgot to uncomment it then this would go undetected and could cause all sorts of problems.

    I test them, not because I think they don't work but to ensure that they are present in my model when required.

提交回复
热议问题