Sha256: 635bc67b7f4d328d0580d5aa5ce73ea62a62cd531f9370c4f6f5f03f0be25f78

Contents?: true

Size: 924 Bytes

Versions: 8

Compression:

Stored size: 924 Bytes

Contents

require_relative '../test_helper'
require 'logster/logger'
require 'logger'

class TestStore
  attr_accessor :calls

  def report(*args)
    (@calls ||= []) << args
  end
end

class TestLogger < Minitest::Test

  def setup
    @store = TestStore.new
    @logger = Logster::Logger.new(@store)
  end

  def test_backtrace
    @logger.add(0, "test", "prog", backtrace: "backtrace", env: {a: "x"})
    assert_equal "backtrace", @store.calls[0][3][:backtrace]
  end

  def test_chain
    io = StringIO.new
    @logger.chain Logger.new(io)
    @logger.warn "boom"

    assert_match(/W,.*boom/, io.string)
  end

  class PlayLogger
    attr_accessor :skip_store
    def initialize(tester)
      @tester = tester
    end

    def add(s,m,p,&block)
      @tester.assert(skip_store)
    end
  end

  def test_chain_with_ignore
    @logger.chain PlayLogger.new(self)
    @logger.skip_store = true
    @logger.warn("testing")
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
logster-1.2.4 test/logster/test_logger.rb
logster-1.2.3 test/logster/test_logger.rb
logster-1.2.2 test/logster/test_logger.rb
logster-1.2.1 test/logster/test_logger.rb
logster-1.2.0 test/logster/test_logger.rb
logster-1.1.1 test/logster/test_logger.rb
logster-1.0.1 test/logster/test_logger.rb
logster-1.0.0.3.pre test/logster/test_logger.rb