I trying to spec validations of my model this is my model
class Account < CouchRest::Model::Base
property :user, String
property :password, String
property :name, String
property :email, String
property :activate, TrueClass, :default => true
validates_presence_of :user, :password, :name, :email
validates_length_of :password, :in => 6..15, :if => lambda{|account| !account.password.blank? }
validates_uniqueness_of :user, :if => (lambda{|account| !account.user.blank?})
end
and into my model_spec i’m trying to do this
account = Account.new
account.should have(1).error_on_presence_of(:email)
But instead 1 error, I’m getting 6
I think that might be caused by validates of couchrest but not sure.
Can someone clarify this for me please?
P.S.: If I validate the same model into console I get 4 errors corresponding the four empty properties
It seems you’re expecting 1 error, but there are actually 6. To figure out what is in the error hash, you can set a temporary expectation:
Then the example will fail and RSpec will print the value of the error hash, and you can see which errors are actually being generated.