[rspec-users] [rails] shoud I test validate_presentence_of series?

Zhenning Guan lists at ruby-forum.com
Wed Jul 21 02:41:56 EDT 2010

Suppose I have a model Forum, have some attributes, title, content,
tag.so I do it in Forum model.
validates_presence_of :title
validates_presence_of :tag
validates_presence_of :content.

when I added validateds_presence_of, rails will restrict the attribute
not be empty, when save record. so after that, Do I still need to test
those attributs not_valid?

like this

it 'should not be valid when title empty' do
  Forum.new(empty_title_attrbiute_hash).should_not be_valid

it 'should not be valid when tag empty' do
  Forum.new(empty_tag_attrbiute_hash).should_not be_valid

it 'should not be valid when content empty' do
  Forum.new(empty_content_attrbiute_hash).should_not be_valid
Posted via http://www.ruby-forum.com/.

More information about the rspec-users mailing list