Sha256: 1f536bee48fa001d749b6b08fb0b241d40c9ca023598ade9ac80fa986555e6cb

Contents?: true

Size: 1.11 KB

Versions: 4

Compression:

Stored size: 1.11 KB

Contents

require 'spec_helper'

describe SimpleTokenAuthentication::ExceptionFallbackHandler do

  it_behaves_like 'a fallback handler'

  describe '#fallback!' do

    context 'when authentication failed' do

      before(:each) do
        @entity = double()
        allow(@entity).to receive_message_chain(:name_underscore).and_return('entity')
        @controller = double()

        allow(@controller).to receive(:current_entity).and_return(nil)
      end

      it 'delegates exception throwing to Warden', private: true do
        expect{ subject.fallback!(@controller, @entity) }.to throw_symbol(:warden, scope: :entity)
      end
    end

    context 'when authentication was successful' do

      before(:each) do
        @entity = double()
        allow(@entity).to receive_message_chain(:name_underscore).and_return('entity')
        @controller = double()

        allow(@controller).to receive(:current_entity).and_return('some entity')
      end

      it 'does not throw any exception', private: true do
        expect{ subject.fallback!(@controller, @entity) }.not_to throw_symbol(:warden, scope: :entity)
      end
    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/exception_fallback_handler_spec.rb
simple_token_authentication-1.11.0 spec/lib/simple_token_authentication/exception_fallback_handler_spec.rb
simple_token_authentication-1.10.1 spec/lib/simple_token_authentication/exception_fallback_handler_spec.rb
simple_token_authentication-1.10.0 spec/lib/simple_token_authentication/exception_fallback_handler_spec.rb