Sha256: f0fd0c99c3d09064135c374e96017e9572da77a435b5e6f6dd892e1e0ef3291f

Contents?: true

Size: 674 Bytes

Versions: 8

Compression:

Stored size: 674 Bytes

Contents

require 'spec_helper'

describe SimpleTokenAuthentication::TokenComparator do

  let(:token_comparator) { described_class.instance }

  it_behaves_like 'a token comparator'

  it 'delegates token comparison to Devise.secure_compare', private: true do
    devise = double()
    allow(devise).to receive(:secure_compare).and_return('Devise.secure_compare response.')
    stub_const('Devise', devise)

    # delegating consists in sending the message
    expect(Devise).to receive(:secure_compare)
    response = token_comparator.compare('A_raNd0MtoKeN', 'ano4heR-Tok3n')

    # and returning the response
    expect(response).to eq 'Devise.secure_compare response.'
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
simple_token_authentication-1.18.1 spec/lib/simple_token_authentication/token_comparator_spec.rb
simple_token_authentication-1.18.0 spec/lib/simple_token_authentication/token_comparator_spec.rb
simple_token_authentication-1.17.0 spec/lib/simple_token_authentication/token_comparator_spec.rb
simple_token_authentication-1.16.0 spec/lib/simple_token_authentication/token_comparator_spec.rb
simple_token_authentication-1.15.1 spec/lib/simple_token_authentication/token_comparator_spec.rb
simple_token_authentication-1.15.0 spec/lib/simple_token_authentication/token_comparator_spec.rb
simple_token_authentication-1.14.0 spec/lib/simple_token_authentication/token_comparator_spec.rb
simple_token_authentication-1.13.0 spec/lib/simple_token_authentication/token_comparator_spec.rb