0
我试图符合规范我的模型的验证,这是我的模型规格验证错误使用RSpec + CouchRest_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
,然后进入我model_spec我试图做到这一点
account = Account.new
account.should have(1).error_on_presence_of(:email)
但代替1错误,我得到6
我认为这可能是由couchrest验证造成的,但不确定。
有人能为我澄清这个吗?
PS:如果我验证了同样的模式进入控制台我得到相应的4种空性质
感谢您的回答,我意识到该方法.valid?不知何故,它没有被调用,'account.errors.should == {}'的结果是模型加couchrest类型的所有属性。所以我只是一直工作,逐场验证。 – 2011-02-20 22:28:53