test/logster/test_pattern.rb in logster-2.12.2 vs test/logster/test_pattern.rb in logster-2.13.0
- old
+ new
@@ -1,10 +1,10 @@
# frozen_string_literal: true
-require_relative '../test_helper'
-require 'logster/redis_store'
-require 'logster/pattern'
+require_relative "../test_helper"
+require "logster/redis_store"
+require "logster/pattern"
class TestPattern < Minitest::Test
class FakePattern < Logster::Pattern
def self.set_name
"__LOGSTER__fake_patterns_set".freeze
@@ -88,26 +88,20 @@
end
def test_save_works_correctly
bad_patterns = ["/bruken", nil, "[a-z", "/(osa|sss{1/"]
bad_patterns.each do |p|
- assert_raises(Logster::Pattern::PatternError) do
- FakePattern.new(p).save
- end
+ assert_raises(Logster::Pattern::PatternError) { FakePattern.new(p).save }
end
assert_equal(0, FakePattern.find_all.size)
good_patterns = ["/logster/i", /logster/, "sssd", "(ccx|tqe){1,5}", "logster"]
- good_patterns.each do |p|
- FakePattern.new(p).save
- end
+ good_patterns.each { |p| FakePattern.new(p).save }
results = FakePattern.find_all
assert_equal(4, results.size) # 4 because /logster/ and logster are the same
good_patterns_regex = [/logster/i, /logster/, /sssd/, /(ccx|tqe){1,5}/]
- results.each do |p|
- assert_includes(good_patterns_regex, p)
- end
+ results.each { |p| assert_includes(good_patterns_regex, p) }
end
def test_modify_works_correctly
record = FakePattern.new(/logster/)
record.save
@@ -121,12 +115,10 @@
def test_modify_doesnt_remove_old_pattern_when_new_is_bad
record = FakePattern.new(/LoGsTEr/)
record.save
- assert_raises(Logster::Pattern::PatternError) do
- record.modify("/badReg")
- end
+ assert_raises(Logster::Pattern::PatternError) { record.modify("/badReg") }
all_patterns = FakePattern.find_all
assert_equal(1, all_patterns.size)
assert_equal(/LoGsTEr/, all_patterns.first)
assert_equal(/LoGsTEr/, record.pattern)
end