Can't see why my asseet fails in unit test


I have the following model

class Advertisement < ActiveRecord::Base

presence validation code

validates_presence_of :job_title,

#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 =>
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]
:message => “is an invalid email address”


When I execute the following test case the second assert fails.

def test_invalid_ad_with_no_attrs
ad =
assert !ad.valid?
assert ad.errors.invalid?(:min_salary)

Can anyone shed some light on this?