Sha256: a1e5d8df7092d78ee812b4ec546579ee2390e7f490aeb9469e4b65cb41ad1ea0

Contents?: true

Size: 754 Bytes

Versions: 2

Compression:

Stored size: 754 Bytes

Contents

require 'sitehub/transaction_id'

class SiteHub
  describe TransactionId do
    let(:transaction_id){Constants::RackHttpHeaderKeys::TRANSACTION_ID}
    subject do
      described_class.new(Proc.new{})
    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

2 entries across 2 versions & 1 rubygems

Version Path
sitehub-0.4.2 spec/sitehub/transaction_id_spec.rb
sitehub-0.4.1 spec/sitehub/transaction_id_spec.rb