Sha256: 341669fbc93e50554b8888c3f46361675504ef968f75b34703794a0c15ed975b

Contents?: true

Size: 1.05 KB

Versions: 37

Compression:

Stored size: 1.05 KB

Contents

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")
    msg_frog = Logster::Message.new(Logger::WARN, "test", "a frog")
    msg_nil = Logster::Message.new(Logger::WARN, "test", nil)

    pattern = Logster::IgnorePattern.new("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

37 entries across 37 versions & 1 rubygems

Version Path
logster-1.3.1 test/logster/test_ignore_pattern.rb
logster-1.2.11 test/logster/test_ignore_pattern.rb
logster-1.2.9 test/logster/test_ignore_pattern.rb
logster-1.2.8 test/logster/test_ignore_pattern.rb
logster-1.2.7 test/logster/test_ignore_pattern.rb
logster-1.2.6 test/logster/test_ignore_pattern.rb
logster-1.2.5 test/logster/test_ignore_pattern.rb
logster-1.2.4 test/logster/test_ignore_pattern.rb
logster-1.2.3 test/logster/test_ignore_pattern.rb
logster-1.2.2 test/logster/test_ignore_pattern.rb
logster-1.2.1 test/logster/test_ignore_pattern.rb
logster-1.2.0 test/logster/test_ignore_pattern.rb
logster-1.1.1 test/logster/test_ignore_pattern.rb
logster-1.0.1 test/logster/test_ignore_pattern.rb
logster-1.0.0.3.pre test/logster/test_ignore_pattern.rb
logster-1.0.0.2.pre test/logster/test_ignore_pattern.rb
logster-1.0.0.1.pre test/logster/test_ignore_pattern.rb
logster-1.0.0.0.pre test/logster/test_ignore_pattern.rb
logster-0.9.9 test/logster/test_ignore_pattern.rb
logster-0.8.4.8.pre test/logster/test_ignore_pattern.rb