ruby-on-railssorcery

how to test with sorcery


i have a little problem with sorcery
this is my test :

def setup
@user = users(:anouar)
end

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

and this is my fixture :

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

and my model :

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

until here when i run bundle exec rake test the test is green

but when i add the validation of the password

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

the test "should be valid" is fail

please help?


Solution

  • Did you try to provide directly a password in your fixture ?