Sha256: 9b70b46189c42f8b57659a273aa63633cd5e79fb23fe9d0f6706987417e574c6

Contents?: true

Size: 1011 Bytes

Versions: 3

Compression:

Stored size: 1011 Bytes

Contents

require 'spec_helper'

describe Clearance::User do
  subject do
    class UniquenessValidator < ActiveModel::Validator
      def validate(record)
      end
    end

    Class.new do
      include ActiveModel::Validations

      validates_with UniquenessValidator

      def self.before_validation(*args); end
      def self.before_create(*args); end

      include Clearance::User
    end.new
  end

  describe 'when Clearance.configuration.password_strategy is set' do
    let(:mock_password_strategy) { Module.new }

    before { Clearance.configuration.password_strategy = mock_password_strategy }

    it 'includes the value it is set to' do
      expect(subject).to be_kind_of(mock_password_strategy)
    end
  end

  describe 'when Clearance.configuration.password_strategy is not set' do
    before { Clearance.configuration.password_strategy = nil }

    it 'includes Clearance::PasswordStrategies::BCrypt' do
      expect(subject).to be_kind_of(Clearance::PasswordStrategies::BCrypt)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
clearance-1.6.0 spec/models/password_strategies_spec.rb
clearance-1.5.1 spec/models/password_strategies_spec.rb
clearance-1.5.0 spec/models/password_strategies_spec.rb