# Can't see why my asseet fails in unit test

**URL:** <https://www.ruby-forum.com/t/cant-see-why-my-asseet-fails-in-unit-test/87971>\
**Category:** Rails\
**Created:** [March 7, 2007, 8:34am UTC](https://www.ruby-forum.com/t/cant-see-why-my-asseet-fails-in-unit-test/87971 "2007-03-07T08:34:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jima](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/47e85d/32.png) [@jima](https://www.ruby-forum.com/u/jima)\
**Post date:** [March 7, 2007, 8:34am UTC](https://www.ruby-forum.com/t/cant-see-why-my-asseet-fails-in-unit-test/87971/1 "2007-03-07T08:34:27Z")

</div>

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
