开发者

How to test the Model has has_secure_password?

开发者 https://www.devze.com 2023-03-27 16:53 出处:网络
Lets say I have User model as below.. class User < ActiveRec开发者_开发百科ord::Base has_secure_password

Lets say I have User model as below..

class User < ActiveRec开发者_开发百科ord::Base
  has_secure_password
end

I would like to test whether User has has_secure_password but not sure how to do it. And I don't want to test what rails has been tested.

Thanks in advance.


What I have been doing is just checking if the object responds to authenticate and has the password_digest field.

test "user model has secure password" do 
  assert_respond_to @user, :password_digest
  assert_respond_to @user, :authenticate, "User requires has_secure_password"
end
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号