What's the point of some of shoulda's macros?
Posted
by ryeguy
on Stack Overflow
See other posts from Stack Overflow
or by ryeguy
Published on 2010-03-29T15:49:24Z
Indexed on
2010/03/29
16:13 UTC
Read the original article
Hit count: 423
I think shoulda is really neat, but what I don't understand is why some of the macros exist, such as:
should_validate_uniqueness_of :title
should_validate_presence_of :body, :message => /wtf/
should_validate_presence_of :title
should_validate_numericality_of :user_id
I'm relatively new to testing, but what purpose do these serve? They're almost an exact mirror of the same validations that happen in the model. For example, what exactly do you accomplish by going into your model and writing validates_uniqueness_of :title
and then writing a test that says should_validate_uniqueness_of :title
?
© Stack Overflow or respective owner