Sha256: 44c8d9693b84ed96e3c738ec4dafb3768599a2984bdb92b695c8f3a7883ca83b
Contents?: true
Size: 1.02 KB
Versions: 5
Compression:
Stored size: 1.02 KB
Contents
require 'spec_helper' describe Clearance::PasswordStrategies::SHA1 do subject do fake_model_with_password_strategy(Clearance::PasswordStrategies::SHA1) end describe '#password=' do context 'when the password is set' do let(:salt) { 'salt' } let(:password) { 'password' } before do subject.salt = salt subject.password = password end it 'does not initialize the salt' do expect(subject.salt).to eq salt end it 'encrypts the password using SHA1 and the existing salt' do expected = Digest::SHA1.hexdigest("--#{salt}--#{password}--") expect(subject.encrypted_password).to eq expected end end context "when the password is not set" do before do subject.salt = nil subject.password = "" end it "initializes the salt" do expect(subject.salt).not_to be_nil end it "doesn't encrpt the password" do expect(subject.encrypted_password).to be_nil end end end end
Version data entries
5 entries across 5 versions & 1 rubygems