Rspec and validates_existence_of

Hi List

I am using validates_existence_of in some of my Model classes. For
instance I have the following class:

class User < ActiveRecord::Base
belongs_to :department

 validates_existence_of :department

end

If I create an instance of User in the console and set the department to
be one that does not exist in the db, then a call to valid? returns
false.

However, if I create a rspec test block, that does something similar,
then valid? returns true. It is almost as if rspec is ignoring the
validates_existence_of. Does naybody have any ideas how to fix this?

Thanks in advance

Rory

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs