Sha256: 85009bee05077a19f24fd22d70bb27c844853562642e27c775d399b809928d2e
Contents?: true
Size: 1.31 KB
Versions: 3
Compression:
Stored size: 1.31 KB
Contents
require 'spec_helper' describe Clearance::PasswordStrategies::BCrypt do subject do fake_model_with_password_strategy(Clearance::PasswordStrategies::BCrypt) end describe '#password=' do let(:password) { 'password' } let(:encrypted_password) { stub('encrypted password') } before do BCrypt::Password.stubs create: encrypted_password end it 'encrypts the password into encrypted_password' do subject.password = password subject.encrypted_password.should == encrypted_password end it 'encrypts with BCrypt using default cost in non test environments' do Rails.stubs env: ActiveSupport::StringInquirer.new("production") subject.password = password BCrypt::Password.should have_received(:create).with( password, cost: ::BCrypt::Engine::DEFAULT_COST ) end it 'encrypts with BCrypt using minimum cost in test environment' do subject.password = password BCrypt::Password.should have_received(:create).with( password, cost: ::BCrypt::Engine::MIN_COST ) end end describe '#authenticated?' do let(:password) { 'password' } before do subject.password = password end it 'is authenticated with BCrypt' do subject.should be_authenticated(password) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
clearance-1.4.0 | spec/models/bcrypt_spec.rb |
clearance-1.3.0 | spec/models/bcrypt_spec.rb |
clearance-1.2.1 | spec/models/bcrypt_spec.rb |