Sha256: 6d6c41ce7000ec7f55701f9430ffc932d0ba316be7e6991cc9c7058c7131838d

Contents?: true

Size: 889 Bytes

Versions: 3

Compression:

Stored size: 889 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
      Napa::LogTransaction.id.should == id
    end

    it "sets and returns a new id if the transaction id hasn't been set" do
      Napa::LogTransaction.id.should_not be_nil
    end

    it "allows the id to be overridden by a setter" do
      Napa::LogTransaction.id.should_not be_nil
      Napa::LogTransaction.id = 'foo'
      Napa::LogTransaction.id.should == 'foo'
    end
  end

  context "#clear" do
    it "sets the id to nil" do
      Napa::LogTransaction.id.should_not be_nil
      Napa::LogTransaction.clear
      Thread.current[:napa_tid].should be_nil
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
napa-0.1.2 spec/logger/log_transaction_spec.rb
napa-0.1.1 spec/logger/log_transaction_spec.rb
napa-0.1.0 spec/logger/log_transaction_spec.rb