Sha256: 86fdc003a5d47604abe4b1552590f08ea809888e3f7568b65741b1af5fb34227

Contents?: true

Size: 1.54 KB

Versions: 1

Compression:

Stored size: 1.54 KB

Contents

describe DistributedTracing do
  describe '#request_id_tag' do
    it 'should return request id from request object' do
      request = double('request')
      request_id = 'f914eb91-c550-48c4-af35-d14db95bd49f'

      expect(request).to receive(:request_id).and_return(request_id)
      expect(request).to receive(:headers).and_return({})

      expect(DistributedTracing.request_id_tag.call(request)).to eq(request_id)
    end

    it 'should return request id from header' do
      request = double('request')
      request_id = '00bfc934-b429-4606-b0c8-318ffa82e884'

      expect(request).to receive(:headers).and_return({'Request-ID' => request_id})

      expect(DistributedTracing.request_id_tag.call(request)).to eq(request_id)
    end
  end

  describe '#current_request_id' do
    it 'should return current request id' do
      request = double('request')
      request_id = '00bfc934-b429-4606-b0c8-318ffa82e884'

      expect(request).to receive(:headers).and_return({'Request-ID' => request_id})

      DistributedTracing.request_id_tag.call(request)

      expect(DistributedTracing.current_request_id).to eq(request_id)
    end
  end

  describe '#request_id_header' do
    it 'should return request id in a header' do
      request = double('request')
      request_id = '00bfc934-b429-4606-b0c8-318ffa82e884'

      expect(request).to receive(:headers).and_return({'Request-ID' => request_id})

      DistributedTracing.request_id_tag.call(request)

      expect(DistributedTracing.request_id_header).to eq({'Request-ID' => request_id})
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rails_distributed_tracing-0.0.1 spec/lib/distributed_tracing_spec.rb