I have the following model
class Advertisement < ActiveRecord::Base # presence validation code validates_presence_of :job_title, :short_description, :detail_description, :contact_email, :location, :area, :classification, :work_type, :work_place, :salary_type, :min_salary;
#length validation code validates_length_of :job_title, :maximum => 80 validates_length_of :short_description, :maximum => 150 validates_length_of :internal_ref, :allow_nil => true, :maximum => 40 validates_length_of :contact_email, :maximum => 80 validates_length_of :contact_details, :allow_nil => true, :maximum => 200
# numerical validation code validates_numericality_of :min_salary, :only_integer => false validates_numericality_of :max_salary, :allow_nil => true, :only_integer => false
# validate the format of data validates_format_of :contact_email, :with => /\A[\w\._%-]+@[\w\.-]+\.[a-zA-Z] {2,4}\z/, :message => "is an invalid email address"
end
When I execute the following test case the second assert fails.
def test_invalid_ad_with_no_attrs ad = Advertisement.new assert !ad.valid? assert ad.errors.invalid?(:min_salary) end
Can anyone shed some light on this?
cheers </jima>