Sha256: fe0fa17d04ecbdd43340281da3f2c23c31e235e0c09b147839c9fdc3b7057450
Contents?: true
Size: 1.42 KB
Versions: 33
Compression:
Stored size: 1.42 KB
Contents
# frozen_string_literal: true require 'rails_helper' describe LHC::Logging do let(:logger) { spy('logger') } before(:each) do LHC.config.interceptors = [LHC::Logging] LHC::Logging.logger = logger stub_request(:get, 'http://local.ch').to_return(status: 200) end it 'does log information before and after every request made with LHC' do LHC.get('http://local.ch') expect(logger).to have_received(:info).once.with( %r{Before LHC request <\d+> GET http://local.ch at \d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\+\d{2}:\d{2} Params={} Headers={.*?}} ) expect(logger).to have_received(:info).once.with( %r{After LHC response for request <\d+> GET http://local.ch at \d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\+\d{2}:\d{2} Time=0ms URL=http://local.ch:80/} ) end context 'source' do let(:source) { '/Users/Sebastian/LHC/test.rb' } it 'does log the source if provided as option' do LHC.get('http://local.ch', source: source) expect(logger).to have_received(:info).once.with( %r{Before LHC request <\d+> GET http://local.ch at \d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\+\d{2}:\d{2} Params={} Headers={.*?} \nCalled from #{source}} ) expect(logger).to have_received(:info).once.with( %r{After LHC response for request <\d+> GET http://local.ch at \d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\+\d{2}:\d{2} Time=0ms URL=http://local.ch:80/ \nCalled from #{source}} ) end end end
Version data entries
33 entries across 33 versions & 1 rubygems