Sha256: a932f38168f40e5c79a70919e243ee13080a63b2c6fe853f3f8eeb80cc22400c

Contents?: true

Size: 928 Bytes

Versions: 4

Compression:

Stored size: 928 Bytes

Contents

require 'spec_helper'

describe Clearance::PasswordStrategies::BCrypt do
  subject do
    Class.new do
      attr_accessor :encrypted_password
      include Clearance::PasswordStrategies::BCrypt
    end.new
  end

  describe '#password=' do
    let(:password) { 'password' }
    let(:encrypted_password) { stub('encrypted password') }

    before do
      BCrypt::Password.stubs :create => encrypted_password
      subject.password = password
    end

    it 'encrypts the password into encrypted_password' do
      subject.encrypted_password.should == encrypted_password
    end

    it 'encrypts with BCrypt' do
      BCrypt::Password.should have_received(:create).with(password)
    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

4 entries across 4 versions & 1 rubygems

Version Path
clearance-1.0.0.rc4 spec/models/bcrypt_spec.rb
clearance-1.0.0.rc3 spec/models/bcrypt_spec.rb
clearance-1.0.0.rc2 spec/models/bcrypt_spec.rb
clearance-1.0.0.rc1 spec/models/bcrypt_spec.rb