Sha256: 4a2c975067a88e29bc03971cdc60555d86c8ff31b4453151463a7cea63f02ba6
Contents?: true
Size: 1.52 KB
Versions: 6
Compression:
Stored size: 1.52 KB
Contents
require 'rails_helper' describe LHC do context 'configured endpoints' do let(:url) { 'http://analytics.lb-service/track/:entity_id/w/:type' } let(:options) do { params: { env: 'PROD' }, followlocation: false } end before(:each) do LHC.configure do |c| c.endpoint(:kpi_tracker, url, options) end end it 'configures urls to be able to access them by name later' do expect(LHC.config.endpoints[:kpi_tracker].url).to eq url expect(LHC.config.endpoints[:kpi_tracker].options).to eq options end it 'compile url' do stub_request(:get, 'http://analytics.lb-service/track/123/w/request?env=PROD') response = LHC.get(:kpi_tracker, params: { entity_id: 123, type: 'request' }) expect(response.request.options[:followlocation]).to eq false end it 'gets overwritten by explicit request options' do stub_request(:get, 'http://analytics.lb-service/track/123/w/request?env=STG') response = LHC.get(:kpi_tracker, params: { entity_id: 123, type: 'request', env: 'STG' }) end it 'raises in case of claching endpoint names' do expect(->{ LHC.config.endpoint(:kpi_tracker, 'http://kpi-tracker.lb-service') }).to raise_error 'Endpoint already exists for that name' end it 'enforces endpoint name to be a symbol' do LHC.configure { |c| c.endpoint('datastore', 'http://datastore.lb-service') } expect(LHC.config.endpoints[:datastore].url).to eq 'http://datastore.lb-service' end end end
Version data entries
6 entries across 6 versions & 1 rubygems