Sha256: a082701c294e55a7e5eb21abf118217125939c17041cf7fecb49dbaa3ad17157

Contents?: true

Size: 946 Bytes

Versions: 5

Compression:

Stored size: 946 Bytes

Contents

require 'rails_helper'

describe LHC do
  context 'interceptor' do
    before(:each) do
      class SomeInterceptor < LHC::Interceptor
      end
      class AnotherInterceptor < LHC::Interceptor
      end
    end

    it 'performs interceptor when they are set globally' do
      described_class.configure { |c| c.interceptors = [SomeInterceptor] }
      expect_any_instance_of(SomeInterceptor).to receive(:before_request)
      stub_request(:get, 'http://local.ch')
      described_class.get('http://local.ch')
    end

    it 'overrides interceptors on request level' do
      described_class.configure { |c| c.interceptors = [SomeInterceptor] }
      expect_any_instance_of(AnotherInterceptor).to receive(:before_request)
      expect_any_instance_of(SomeInterceptor).not_to receive(:before_request)
      stub_request(:get, 'http://local.ch')
      described_class.get('http://local.ch', interceptors: [AnotherInterceptor])
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
lhc-3.5.4 spec/interceptors/define_spec.rb
lhc-3.5.3 spec/interceptors/define_spec.rb
lhc-3.5.2 spec/interceptors/define_spec.rb
lhc-3.5.1 spec/interceptors/define_spec.rb
lhc-3.5.0 spec/interceptors/define_spec.rb