2014-12-31 15:59:32 -05:00
|
|
|
require 'spec_helper'
|
2010-04-22 00:57:21 -04:00
|
|
|
|
2016-11-08 00:07:03 -05:00
|
|
|
RSpec.describe 'AwesomePrint logging extensions' do
|
2010-04-22 00:57:21 -04:00
|
|
|
before(:all) do
|
2011-03-15 15:16:39 -04:00
|
|
|
@logger = Logger.new('/dev/null') rescue Logger.new('nul')
|
2010-04-22 00:57:21 -04:00
|
|
|
end
|
|
|
|
|
2016-11-08 00:07:03 -05:00
|
|
|
describe 'ap method' do
|
|
|
|
it 'should awesome_inspect the given object' do
|
2014-05-15 16:47:57 -04:00
|
|
|
object = double
|
|
|
|
expect(object).to receive(:ai)
|
2010-04-22 00:57:21 -04:00
|
|
|
@logger.ap object
|
|
|
|
end
|
2016-11-08 21:39:25 -05:00
|
|
|
|
2016-11-08 00:07:03 -05:00
|
|
|
describe 'the log level' do
|
2011-02-05 14:31:51 -05:00
|
|
|
before do
|
|
|
|
AwesomePrint.defaults = {}
|
2010-04-22 00:57:21 -04:00
|
|
|
end
|
2016-11-08 21:39:25 -05:00
|
|
|
|
2016-11-08 00:07:03 -05:00
|
|
|
it 'should fallback to the default :debug log level' do
|
2014-05-15 16:47:57 -04:00
|
|
|
expect(@logger).to receive(:debug)
|
2010-04-22 00:57:21 -04:00
|
|
|
@logger.ap(nil)
|
|
|
|
end
|
|
|
|
|
2016-11-08 00:07:03 -05:00
|
|
|
it 'should use the global user default if no level passed' do
|
2016-11-08 09:53:17 -05:00
|
|
|
AwesomePrint.defaults = { log_level: :info }
|
2014-05-15 16:47:57 -04:00
|
|
|
expect(@logger).to receive(:info)
|
2010-04-22 00:57:21 -04:00
|
|
|
@logger.ap(nil)
|
|
|
|
end
|
|
|
|
|
2016-11-08 00:07:03 -05:00
|
|
|
it 'should use the passed in level' do
|
2014-05-15 16:47:57 -04:00
|
|
|
expect(@logger).to receive(:warn)
|
2010-04-22 00:57:21 -04:00
|
|
|
@logger.ap(nil, :warn)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|