Sha256: 1e59be865b7c5592f9c9301840ee723e79047acb44ae5951d7c3dd196d0597b1

Contents?: true

Size: 917 Bytes

Versions: 4

Compression:

Stored size: 917 Bytes

Contents

require 'spec_helper'
require 'napa/logger/log_transaction'

describe Napa::LogTransaction do
  before(:each) do
    Napa::LogTransaction.clear
  end

  context '#id' do
    it 'returns the current transaction id if it has been set' do
      id = SecureRandom.hex(10)
      Thread.current[:napa_tid] = id
      expect(Napa::LogTransaction.id).to eq(id)
    end

    it 'sets and returns a new id if the transaction id hasn\'t been set' do
      expect(Napa::LogTransaction.id).to_not be_nil
    end

    it 'allows the id to be overridden by a setter' do
      expect(Napa::LogTransaction.id).to_not be_nil
      Napa::LogTransaction.id = 'foo'
      expect(Napa::LogTransaction.id).to eq('foo')
    end
  end

  context '#clear' do
    it 'sets the id to nil' do
      expect(Napa::LogTransaction.id).to_not be_nil
      Napa::LogTransaction.clear
      expect(Thread.current[:napa_tid]).to be_nil
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
napa-0.5.0 spec/logger/log_transaction_spec.rb
napa-0.4.3 spec/logger/log_transaction_spec.rb
napa-0.4.1 spec/logger/log_transaction_spec.rb
napa-0.4.0 spec/logger/log_transaction_spec.rb