Sha256: 6f23f330dd80a5f7f9c5d79e62686ed41f170db32b7d90424c253489084ff243

Contents?: true

Size: 1.1 KB

Versions: 12

Compression:

Stored size: 1.1 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

12 entries across 12 versions & 1 rubygems

Version Path
logster-2.20.0 test/logster/test_ignore_pattern.rb
logster-2.19.1 test/logster/test_ignore_pattern.rb
logster-2.19.0 test/logster/test_ignore_pattern.rb
logster-2.18.1 test/logster/test_ignore_pattern.rb
logster-2.18.0 test/logster/test_ignore_pattern.rb
logster-2.17.1 test/logster/test_ignore_pattern.rb
logster-2.17.0 test/logster/test_ignore_pattern.rb
logster-2.16.0 test/logster/test_ignore_pattern.rb
logster-2.15.0 test/logster/test_ignore_pattern.rb
logster-2.14.0 test/logster/test_ignore_pattern.rb
logster-2.13.1 test/logster/test_ignore_pattern.rb
logster-2.13.0 test/logster/test_ignore_pattern.rb