Sha256: 6d0aabd5fa3927c5b9a0cafdd5450ac79b0cee6084d63550e355450f3ffa530e
Contents?: true
Size: 1.03 KB
Versions: 35
Compression:
Stored size: 1.03 KB
Contents
# frozen_string_literal: true require 'rails_helper' describe LHC do context 'interceptor' do before(:each) do class Services def self.timing(_path, _time); end end class StatsTimingInterceptor < LHC::Interceptor def after_response uri = URI.parse(response.request.url) path = [ 'web', Rails.application.class.parent_name, Rails.env, response.request.method, uri.scheme, uri.host, response.code ].join('.') Services.timing(path.downcase, response.time) end end LHC.configure { |c| c.interceptors = [StatsTimingInterceptor] } end let(:url) { "http://local.ch/v2/feedbacks/-Sc4_pYNpqfsudzhtivfkA" } it 'can take action after a response was received' do allow(Services).to receive(:timing).with('web.dummy.test.get.http.local.ch.200', 0) stub_request(:get, url) LHC.get(url) expect(Services).to have_received(:timing) end end end
Version data entries
35 entries across 35 versions & 1 rubygems