Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always return nil. #68

Merged
merged 1 commit into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading