Sha256: 1680862a6829af54db46badbd4449058ba960dee0f484c2fd7f0cb494fb24d75

Contents?: true

Size: 930 Bytes

Versions: 12

Compression:

Stored size: 930 Bytes

Contents

# frozen_string_literal: true

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
      LHC.configure { |c| c.interceptors = [SomeInterceptor] }
      expect_any_instance_of(SomeInterceptor).to receive(:before_request)
      stub_request(:get, 'http://local.ch')
      LHC.get('http://local.ch')
    end

    it 'overrides interceptors on request level' do
      LHC.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')
      LHC.get('http://local.ch', interceptors: [AnotherInterceptor])
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
lhc-15.2.1 spec/interceptors/define_spec.rb
lhc-15.2.0 spec/interceptors/define_spec.rb
lhc-15.1.3 spec/interceptors/define_spec.rb
lhc-15.1.2 spec/interceptors/define_spec.rb
lhc-15.1.1 spec/interceptors/define_spec.rb
lhc-15.1.0 spec/interceptors/define_spec.rb
lhc-16.0.0.pre.pro2162.2 spec/interceptors/define_spec.rb
lhc-16.0.0.pre.pro2162 spec/interceptors/define_spec.rb
lhc-15.0.1 spec/interceptors/define_spec.rb
lhc-15.0.0 spec/interceptors/define_spec.rb
lhc-14.0.0 spec/interceptors/define_spec.rb
lhc-13.4.0.pre.pro1766.1 spec/interceptors/define_spec.rb