Skip to content

Commit

Permalink
Merge afb0671 into 4fffff3
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeer committed May 15, 2019
2 parents 4fffff3 + afb0671 commit d31e474
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
3 changes: 1 addition & 2 deletions lib/core_ext/logger.rb
Expand Up @@ -3,7 +3,7 @@
class Logger

def level_with_yell=( level )
self.level_without_yell= Integer(level)
self.level_without_yell= level.is_a?(Yell::Level) ? Integer(level) : level
end
alias_method :level_without_yell=, :level=
alias_method :level=, :level_with_yell=
Expand All @@ -15,4 +15,3 @@ def add_with_yell( severity, message = nil, progname = nil, &block )
alias_method :add, :add_with_yell

end

28 changes: 23 additions & 5 deletions spec/compatibility/level_spec.rb
Expand Up @@ -2,17 +2,35 @@
require 'logger'

describe "backwards compatible level" do

let(:level) { Yell::Level.new(:error) }
let(:logger) { Logger.new($stdout) }

before do
logger.level = level
end

it "should format out the level correctly" do
expect(logger.level).to eq(level.to_i)
context "with a Yell::Level instance" do
let(:level) { Yell::Level.new(:error) }

it "should format out the level correctly" do
expect(logger.level).to eq(level.to_i)
end
end

end
context "with a symbol", :pending => (RUBY_VERSION < "2.4") do
let(:level) { :error }

it "should format out the level correctly" do
expect(logger.level).to eq(3)
end
end

context "with an integer" do
let(:level) { 2 }

it "should format out the level correctly" do
expect(logger.level).to eq(2)
end
end


end

0 comments on commit d31e474

Please sign in to comment.