Sha256: 4a1819e02f5b04ab3f88db9abee106e0017e5d0ce54ea6b907a79b8708214ac8

Contents?: true

Size: 1.01 KB

Versions: 2

Compression:

Stored size: 1.01 KB

Contents

require 'spec_helper'

describe Clearance::User do
  subject do
    class UniquenessValidator < ActiveModel::Validator
      undef validate

      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

2 entries across 2 versions & 1 rubygems

Version Path
clearance-1.7.0 spec/models/password_strategies_spec.rb
clearance-1.6.1 spec/models/password_strategies_spec.rb