E
E
eldar_web2017-11-17 17:20:16
Software testing
eldar_web, 2017-11-17 17:20:16

Does it make sense to test model validations in Ruby on Rails?

In one video I saw where it says that there is no point in testing model validations explaining that
they will not fail, and in another place I saw how validation tests are written.
Who is right? Who does not violate the concept of testing?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Z
Zaporozhchenko Oleg, 2017-11-17
@eldar_web

You don't need to test the framework. That is, for example, in the presence validation test, you don’t need to check that both an empty string will work and nil will work, and something else. But, there should still be some kind of test, because if another programmer removes this validation, the test should fail somewhere 100%. If it had to be deleted, the developer will delete the test, if he accidentally deleted it, the test fell, he fixed it. Tests are needed for this - for teamwork and the ability to change the code.
Rspec is very easy to test rail standard validations, gem shoulda

O
OnYourLips, 2017-11-17
@OnYourLips

Of course, you don't need unittests.
But for functional testing, it's a must.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question