如何用魔法测试

how to test with sorcery

我的魔法有点问题
这是我的测试:

def setup
@user = users(:anouar)
end

test "should be valid" do
    assert @user.valid?
end

这是我的固定装置:

anouar:
email: anouar@gmail.com
salt: <%= salt = "asdasdastr4325234324sdfds" %>
crypted_password: <%= Sorcery::CryptoProviders::BCrypt.encrypt("secret", salt) %>

和我的模特:

class User < ActiveRecord::Base
authenticates_with_sorcery!

validates :email,                   presence: true, length: { maximum: 255 },
                                  email_format: { message: 'has invalid format' },
                                  uniqueness: { case_sensitive: false }

end

直到这里当我 运行 bundle exec rake test 测试是绿色的

但是当我添加密码验证时

validates :password,                presence: true, confirmation: true, length: { minimum: 3}

测试"should be valid"失败

请帮忙?

您是否尝试在您的设备中直接提供密码?