Skip to content

Commit

Permalink
Always return nil.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Dec 9, 2024
1 parent a0e25a1 commit c6315d9
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
4 changes: 4 additions & 0 deletions lib/console/filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ def self.[] **levels
if self.enabled?(subject, level)
@output.call(subject, *arguments, severity: name, **@options, **options, &block)
end

return nil
end

define_immutable_method("#{name}!") do
Expand Down Expand Up @@ -150,6 +152,8 @@ def call(subject, *arguments, **options, &block)
if self.enabled?(subject, level)
@output.call(subject, *arguments, **options, &block)
end

return nil
end
end
end
29 changes: 26 additions & 3 deletions test/console/filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,29 +66,52 @@ def before
end
end

with "#info" do
it "ignores messages below the level" do
logger.level = Console::Logger::INFO

result = logger.debug(MySubject, "Hello World")

expect(output).to be(:empty?)
expect(result).to be_nil
end

it "logs messages at the level" do
logger.level = Console::Logger::INFO

result = logger.info(MySubject, "Hello World", severity: :info)

expect(output).to be(:include?, "Hello World")
expect(result).to be_nil
end
end

with "#call" do
it "ignores messages below the level" do
logger.level = Console::Logger::INFO

logger.call(MySubject, "Hello World", severity: :debug)
result = logger.call(MySubject, "Hello World", severity: :debug)

expect(output).to be(:empty?)
expect(result).to be_nil
end

it "logs messages at the level" do
logger.level = Console::Logger::INFO

logger.call(MySubject, "Hello World", severity: :info)
result = logger.call(MySubject, "Hello World", severity: :info)

expect(output).to be(:include?, "Hello World")
expect(result).to be_nil
end

it "logs messages above the level" do
logger.level = Console::Logger::INFO

logger.call(MySubject, "Hello World", severity: :warn)
result = logger.call(MySubject, "Hello World", severity: :warn)

expect(output).to be(:include?, "Hello World")
expect(result).to be_nil
end
end
end

0 comments on commit c6315d9

Please sign in to comment.