Sha256: a7537cc2d1f5e2428333a01f1b706a642398619dd787d5bbf7052b6731d30af9

Contents?: true

Size: 1.16 KB

Versions: 4

Compression:

Stored size: 1.16 KB

Contents

require 'spec_helper'

describe SimpleTokenAuthentication::DeviseFallbackHandler do

  it_behaves_like 'an authentication handler'

  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 = subject.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(subject).to receive(:authenticate_entity!).with(controller, entity)

      subject.send(:fallback!, controller, entity)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
simple_token_authentication-1.12.0 spec/lib/simple_token_authentication/devise_fallback_handler_spec.rb
simple_token_authentication-1.11.0 spec/lib/simple_token_authentication/devise_fallback_handler_spec.rb
simple_token_authentication-1.10.1 spec/lib/simple_token_authentication/devise_fallback_handler_spec.rb
simple_token_authentication-1.10.0 spec/lib/simple_token_authentication/devise_fallback_handler_spec.rb