Sha256: 0f3f26139a3f9e666b931205ce247f3ddb7d2b3a47f1e0a842cb20e64d4816ac

Contents?: true

Size: 1.35 KB

Versions: 8

Compression:

Stored size: 1.35 KB

Contents

require 'spec_helper'

describe SimpleTokenAuthentication::DeviseFallbackHandler do

  let(:devise_fallback_handler) { SimpleTokenAuthentication::DeviseFallbackHandler.instance }

  it_behaves_like 'an authentication handler', SimpleTokenAuthentication::DeviseFallbackHandler.instance

  it_behaves_like 'a fallback handler'

  describe '#authenticate_entity!' do

    it 'delegates authentication to Devise::Controllers::Helpers through a controller', private: true do
      controller = double()
      allow(controller).to receive(:authenticate_user!).and_return('Devise response.')

      entity = double()
      allow(entity).to receive_message_chain(:name_underscore).and_return('user')

      # delegating consists in sending the message
      expect(controller).to receive(:authenticate_user!)
      response = devise_fallback_handler.authenticate_entity!(controller, entity)

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

  describe '#fallback!' do

    it 'does #authenticate_entity!', private: true do
      entity = double()
      allow(@entity).to receive_message_chain(:name_underscore).and_return('entity')
      controller = double()

      expect(devise_fallback_handler).to receive(:authenticate_entity!).with(controller, entity)

      devise_fallback_handler.send(:fallback!, controller, entity)
    end
  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/devise_fallback_handler_spec.rb
simple_token_authentication-1.18.0 spec/lib/simple_token_authentication/devise_fallback_handler_spec.rb
simple_token_authentication-1.17.0 spec/lib/simple_token_authentication/devise_fallback_handler_spec.rb
simple_token_authentication-1.16.0 spec/lib/simple_token_authentication/devise_fallback_handler_spec.rb
simple_token_authentication-1.15.1 spec/lib/simple_token_authentication/devise_fallback_handler_spec.rb
simple_token_authentication-1.15.0 spec/lib/simple_token_authentication/devise_fallback_handler_spec.rb
simple_token_authentication-1.14.0 spec/lib/simple_token_authentication/devise_fallback_handler_spec.rb
simple_token_authentication-1.13.0 spec/lib/simple_token_authentication/devise_fallback_handler_spec.rb