我正在尝试为使用authlogic定义的“帐户”模型构建工厂:
class Account < UuidEnabled
acts_as_authentic do |c|
c.validate_password_field = true
c.require_password_confirmation = true
c.ignore_blank_passwords = false
c.crypto_provider = Authlogic::CryptoProviders::Sha512
end
end
这是我的工厂:
FactoryGirl.define do
factory :account do
sequence(:email) { |n| "account_#{n}@example.com"}
password = "1234"
password_confirmation { |a| a.password} # to make things work even if the password is changed
end
end
我的测试失败了
ActiveRecord::RecordInvalid: Validation failed: Password is too short (minimum is 4 characters), Password confirmation is too short (minimum is 4 characters)
答案 0 :(得分:1)
认为这只是一个错字,请尝试:
FactoryGirl.define do
factory :account do
sequence(:email) { |n| "account_#{n}@example.com"}
password "1234"
password_confirmation { |a| a.password} # to make things work even if the password is changed
end
end
请注意,删除password
后的等号
答案 1 :(得分:0)
您是否尝试在帐户模型中设置attr_accessible :password
?