Sha256: 2e11209c4fa42577a6b311e64d4a0991bc25ec213df504556ba65e8609d3c0dd

Contents?: true

Size: 1.11 KB

Versions: 27

Compression:

Stored size: 1.11 KB

Contents

# frozen_string_literal: true

require_relative '../test_helper'
require 'logster/ignore_pattern'

class TestIgnorePattern < Minitest::Test

  def test_string_message_pattern
    msg = Logster::Message.new(Logger::WARN, "test", "my error (oh no!)")
    msg_frog = Logster::Message.new(Logger::WARN, "test", "a frog")
    msg_nil = Logster::Message.new(Logger::WARN, "test", nil)

    pattern = Logster::IgnorePattern.new("my error (")

    assert pattern.matches? msg
    assert !pattern.matches?(msg_frog)
    assert !pattern.matches?(msg_nil)
  end

  def test_env_pattern
    msg = Logster::Message.new(Logger::WARN, "test", "my error")
    msg.env = { "frogs" => "are big" }

    pattern = Logster::IgnorePattern.new(nil, frogs: "big")

    assert pattern.matches? msg

    msg.env = { legs: nil }
    assert !(pattern.matches? msg)

    msg.env = { legs: 3 }
    assert !(pattern.matches? msg)

    msg.env = { frogs: "small" }
    assert !pattern.matches?(msg)

    pattern = Logster::IgnorePattern.new(nil, "small")
    assert pattern.matches? msg

    msg.env = { frogs: "big" }
    assert !(pattern.matches? msg)
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
logster-2.12.2 test/logster/test_ignore_pattern.rb
logster-2.12.1 test/logster/test_ignore_pattern.rb
logster-2.11.4 test/logster/test_ignore_pattern.rb
logster-2.11.3 test/logster/test_ignore_pattern.rb
logster-2.11.2 test/logster/test_ignore_pattern.rb
logster-2.11.1 test/logster/test_ignore_pattern.rb
logster-2.11.0 test/logster/test_ignore_pattern.rb
logster-2.10.1 test/logster/test_ignore_pattern.rb
logster-2.10.0 test/logster/test_ignore_pattern.rb
logster-2.9.8 test/logster/test_ignore_pattern.rb
logster-2.9.7 test/logster/test_ignore_pattern.rb
logster-2.9.6 test/logster/test_ignore_pattern.rb
logster-2.9.5 test/logster/test_ignore_pattern.rb
logster-2.9.4 test/logster/test_ignore_pattern.rb
logster-2.9.3 test/logster/test_ignore_pattern.rb
logster-2.9.2 test/logster/test_ignore_pattern.rb
logster-2.9.1 test/logster/test_ignore_pattern.rb
logster-2.9.0 test/logster/test_ignore_pattern.rb
logster-2.8.0 test/logster/test_ignore_pattern.rb
logster-2.7.1 test/logster/test_ignore_pattern.rb