Sha256: 4d9e5ee1cc4bd61d12a68ad606148d44196d7cfb858063a3d4a4c9246efe11cc

Contents?: true

Size: 1.41 KB

Versions: 11

Compression:

Stored size: 1.41 KB

Contents

require 'spec_helper'

module Startback
  module Audit
    describe TraceLogger do

      let(:fake_logger) do
        Support::FakeLogger.new
      end

      let(:trace_logger) do
        TraceLogger.new(fake_logger)
      end

      let(:tracer) do
        Tracer.new.on_span(trace_logger)
      end

      it 'helps logging successes' do
        attached = tracer.attach_to('trace', 'root-span')
        attached.fork(foo: 'bar') do
          "hello world"
        end
        expect(fake_logger.seen.size).to eql(2)
        expect(fake_logger.seen.first).to match(/DEBUG/)
        expect(fake_logger.seen.last).to match(/INFO/)
      end

      it 'helps logging user errors' do
        attached = tracer.attach_to('trace', 'root-span')
        attached.fork(foo: 'bar') do
          raise Startback::Errors::ForbiddenError, "no such access granted"
        end rescue nil
        expect(fake_logger.seen.size).to eql(2)
        expect(fake_logger.seen.first).to match(/DEBUG/)
        expect(fake_logger.seen.last).to match(/WARN/)
      end

      it 'helps logging fatal errors' do
        attached = tracer.attach_to('trace', 'root-span')
        attached.fork(foo: 'bar') do
          raise ArgumentError, "something bad"
        end rescue nil
        expect(fake_logger.seen.size).to eql(2)
        expect(fake_logger.seen.first).to match(/DEBUG/)
        expect(fake_logger.seen.last).to match(/ERROR/)
      end

    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
startback-1.0.3 spec/unit/audit/test_trace_logger.rb
startback-1.0.2 spec/unit/audit/test_trace_logger.rb
startback-1.0.1 spec/unit/audit/test_trace_logger.rb
startback-1.0.0 spec/unit/audit/test_trace_logger.rb
startback-0.19.4 spec/unit/audit/test_trace_logger.rb
startback-0.19.3 spec/unit/audit/test_trace_logger.rb
startback-0.19.1 spec/unit/audit/test_trace_logger.rb
startback-0.19.0 spec/unit/audit/test_trace_logger.rb
startback-0.18.2 spec/unit/audit/test_trace_logger.rb
startback-0.18.1 spec/unit/audit/test_trace_logger.rb
startback-0.18.0 spec/unit/audit/test_trace_logger.rb