Sha256: 2eaa1fb2430dd38a14140497da27c214ef4afc80a4d550ab24e2af458f92df2c

Contents?: true

Size: 898 Bytes

Versions: 70

Compression:

Stored size: 898 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
      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

70 entries across 70 versions & 1 rubygems

Version Path
lhc-10.1.2 spec/interceptors/define_spec.rb
lhc-10.1.1 spec/interceptors/define_spec.rb
lhc-10.1.0 spec/interceptors/define_spec.rb
lhc-10.0.2 spec/interceptors/define_spec.rb
lhc-9.4.4 spec/interceptors/define_spec.rb
lhc-10.0.1 spec/interceptors/define_spec.rb
lhc-10.0.0 spec/interceptors/define_spec.rb
lhc-9.4.3 spec/interceptors/define_spec.rb
lhc-9.4.2 spec/interceptors/define_spec.rb
lhc-9.4.1 spec/interceptors/define_spec.rb
lhc-9.4.0 spec/interceptors/define_spec.rb
lhc-9.3.1 spec/interceptors/define_spec.rb
lhc-9.3.0 spec/interceptors/define_spec.rb
lhc-9.2.0 spec/interceptors/define_spec.rb
lhc-9.1.2 spec/interceptors/define_spec.rb
lhc-9.1.2.pre spec/interceptors/define_spec.rb
lhc-9.1.1 spec/interceptors/define_spec.rb
lhc-8.1.1 spec/interceptors/define_spec.rb
lhc-9.1.0 spec/interceptors/define_spec.rb
lhc-9.0.0 spec/interceptors/define_spec.rb