Skip to content
This repository has been archived by the owner on Dec 8, 2020. It is now read-only.

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
binarylogic committed Mar 21, 2017
1 parent c92c4d3 commit 0db8c97
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
1 change: 0 additions & 1 deletion lib/timber/integrations/rack/exception_event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ def call(env)
begin
status, headers, body = @app.call(env)
rescue Exception => exception
puts "\n\n\n\nexception!\n\n\n"
Config.instance.logger.fatal do
Events::Exception.new(
name: exception.class.name,
Expand Down
2 changes: 1 addition & 1 deletion lib/timber/logger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def initialize(*args)
end

def formatter=(value)
if @dev.is_a?(Timber::LogDevices::HTTP)
if @logdev && @logdev.dev.is_a?(Timber::LogDevices::HTTP) && !value.is_a?(PassThroughFormatter)
raise ArgumentError.new("The formatter cannot be changed when using the " +
"Timber::LogDevices::HTTP log device. The PassThroughFormatter must be used for proper " +
"delivery.")
Expand Down
18 changes: 9 additions & 9 deletions spec/timber/logger_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,17 +119,17 @@
end

describe "#formatter=" do
let(:io) { StringIO.new }
let(:logger) { Timber::Logger.new(io) }

it "should not allow non Timber::Logger::Formatter formatters" do
logger.formatter = ::Logger::Formatter.new
expect(logger.formatter).to be_kind_of(::Timber::Logger::HybridFormatter)
it "should not allow changing the formatter when the device is HTTP" do
http_device = Timber::LogDevices::HTTP.new("api_key")
logger = Timber::Logger.new(http_device)
expect { logger.formatter = ::Logger::Formatter.new }.to raise_error(ArgumentError)
end

it "should allow Timber::Logger::Formatter formatters" do
logger.formatter = ::Timber::Logger::JSONFormatter.new
expect(logger.formatter).to be_kind_of(::Timber::Logger::JSONFormatter)
it "should set the formatter" do
logger = Timber::Logger.new(STDOUT)
formatter = ::Logger::Formatter.new
logger.formatter = formatter
expect(logger.formatter).to eq(formatter)
end
end

Expand Down

0 comments on commit 0db8c97

Please sign in to comment.