Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- describe User, "password generation" do
- context "when created" do
- it "generates a random password" do
- user = User.create(email: "john@doe.com")
- expect(user.password).not_to be_empty
- end
- end
- context "when updated" do
- it "does NOT change the password" do
- user = User.create(email: "john@doe.com")
- password = user.password
- user.update(email: "jane@doe.com")
- expect(user.authenticate(password)).not_to be false
- end
- end
- context "when password is already set" do
- it "does NOT change the password" do
- user = User.create(email: "john@doe.com", password: "secret")
- expect(user.authenticate("secret")).not_to be false
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement