blob: fc5c5c1161d08e22db88fc33d8573e3e64c67ab9 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# frozen_string_literal: true
require "abstract_unit"
require "active_support/logger_silence"
require "logger"
class LoggerSilenceTest < ActiveSupport::TestCase
class MyLogger < ::Logger
include LoggerSilence
end
setup do
@io = StringIO.new
@logger = MyLogger.new(@io)
end
test "#silence silences the log" do
@logger.silence(Logger::ERROR) do
@logger.info("Foo")
end
@io.rewind
assert_empty @io.read
end
test "#debug? is true when setting the temporary level to Logger::DEBUG" do
@logger.level = Logger::INFO
@logger.silence(Logger::DEBUG) do
assert_predicate @logger, :debug?
end
assert_predicate @logger, :info?
end
end
|