ThomYorkkke
ThomYorkkke

Reputation: 2141

How to test Devise user was created with proper password with RSpec

Is there a way to test that a Devise user was created with the correct password in RSpec?

I have a feature spec for creating a user, and have tried testing that created_user.encrypted_password eq User.new(password: same_as_created_user).encrypted_password but the passwords generated do not match.

Upvotes: 3

Views: 762

Answers (1)

AbM
AbM

Reputation: 7779

You can use the devise valid_password? method (more info here)

In your spec:

expect(user.valid_password?('password')).to be_truthy

Upvotes: 6

Related Questions