Sha256: 58e3533a954c0d57081d508a87b4df41cbec17571ef55a98fe5e91cdf534cb29

Contents?: true

Size: 756 Bytes

Versions: 1

Compression:

Stored size: 756 Bytes

Contents

require 'sitehub/transaction_id'

class SiteHub
  describe TransactionId do
    let(:transaction_id) { Constants::RackHttpHeaderKeys::TRANSACTION_ID }
    subject do
      described_class.new(proc {})
    end
    it 'adds a unique identifier to the request' do
      uuid = UUID.generate(:compact)
      expect(UUID).to receive(:generate).with(:compact).and_return(uuid)
      env = {}
      subject.call(env)

      expect(env[transaction_id]).to eq(uuid)
    end

    context 'transaction id header already exists' do
      it 'leaves it intact' do
        expect(UUID).to_not receive(:generate)
        env = { transaction_id => :exiting_id }
        subject.call(env)

        expect(env[transaction_id]).to eq(:exiting_id)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sitehub-0.4.3 spec/sitehub/transaction_id_spec.rb