Forum: Ruby on Rails Can't see why my asseet fails in unit test

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Eaef4535f7a0e36ae4c8db2b940431b8?d=identicon&s=25 Jim Alateras (Guest)
on 2007-03-07 08:34
(Received via mailing list)
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>
This topic is locked and can not be replied to.