如何用巫术测试

时间:2015-05-14 16:49:39

标签: ruby-on-rails sorcery

我对巫术有点问题 这是我的考验:

var search = NHibernateSession.CreateCriteria(typeof(Order))
            .CreateAlias("Contract", "C", JoinType.InnerJoin)
            .CreateAlias("C.Supplier", "S", JoinType.InnerJoin)
            .Add(Restrictions.Eq("Buyer.Id", companyId))
            .Add(Restrictions.Eq("IsDeleted", false))
            .Add(Restrictions.Eq("IsActiveVersion", true))
            .SetFirstResult(paging.PageIndexSQL)
            .SetMaxResults(paging.PageSize)
            .AddOrder(SortOrder.Desc("Id"));

这是我的装备:

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) %>

直到这里,当我运行bundle exec rake test时,测试为绿色

但是当我添加密码验证时

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

测试“应该有效”失败

请帮帮忙?

1 个答案:

答案 0 :(得分:1)

您是否尝试直接在灯具中提供密码?