Sha256: 0610458e45920084cbc38a9f9dc7edc327bcb91fdb3c4971b511347ae3199787

Contents?: true

Size: 1.25 KB

Versions: 8

Compression:

Stored size: 1.25 KB

Contents

require 'spec_helper'

describe SimpleTokenAuthentication::ExceptionFallbackHandler do

  let(:exception_fallback_handler) { SimpleTokenAuthentication::ExceptionFallbackHandler.instance }

  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{ exception_fallback_handler.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{ exception_fallback_handler.fallback!(@controller, @entity) }.not_to throw_symbol(:warden, scope: :entity)
      end
    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/exception_fallback_handler_spec.rb
simple_token_authentication-1.18.0 spec/lib/simple_token_authentication/exception_fallback_handler_spec.rb
simple_token_authentication-1.17.0 spec/lib/simple_token_authentication/exception_fallback_handler_spec.rb
simple_token_authentication-1.16.0 spec/lib/simple_token_authentication/exception_fallback_handler_spec.rb
simple_token_authentication-1.15.1 spec/lib/simple_token_authentication/exception_fallback_handler_spec.rb
simple_token_authentication-1.15.0 spec/lib/simple_token_authentication/exception_fallback_handler_spec.rb
simple_token_authentication-1.14.0 spec/lib/simple_token_authentication/exception_fallback_handler_spec.rb
simple_token_authentication-1.13.0 spec/lib/simple_token_authentication/exception_fallback_handler_spec.rb