Tanto per chiarirci:
Se scrivo due test come questi:
codice:
def test_post_must_have_a_title
p = Post.new
assert !p.save, "post must have a title"
end
def test_post_must_have_a_body
p = Post.new
p.title = 'title'
assert !p.save, "post must have a body"
end
Entrambi dovrebbero fallire al primo "run"
Se poi metto nel Model "Post"
codice:
validates_presence_of :title
e rieseguo il test dovrei passare il primo test e non il secondo giusto?
A questo punto aggiungo anche:
codice:
validates_presence_of :title, :body
E di conseguenza ora il test case viene passato senza errori.
E' quindi questo il modo corretto di procedere? Il codice, e la sua sequenza logica, che ho postato è formalmente corretto?
Tnx.