Sha256: e4c97eec26434074b060f1e7492849b57a981526a81b00fd8a26c701cbb541ff
Contents?: true
Size: 1.04 KB
Versions: 22
Compression:
Stored size: 1.04 KB
Contents
require 'rails_helper' describe LHC do context 'interceptor' do before(:each) do class CacheInterceptor < LHC::Interceptor def before_request LHC::Response.new(Typhoeus::Response.new(response_body: 'Im served from cache'), nil) end end LHC.configure { |c| c.interceptors = [CacheInterceptor] } end it 'can return a response rather then doing a real request' do response = LHC.get('http://local.ch') expect(response.body).to eq 'Im served from cache' end context 'misusage' do before(:each) do class AnotherInterceptor < LHC::Interceptor def before_request LHC::Response.new(Typhoeus::Response.new({}), nil) end end end it 'raises an exception when two interceptors try to return a response' do expect(lambda { LHC.get('http://local.ch', interceptors: [CacheInterceptor, AnotherInterceptor]) }).to raise_error 'Response already set from another interceptor' end end end end
Version data entries
22 entries across 22 versions & 1 rubygems