2011-05-13 19:37:24 -04:00
|
|
|
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2010-04-22 00:57:21 -04:00
|
|
|
|
|
|
|
|
|
|
|
require 'logger'
|
2011-05-13 19:37:24 -04:00
|
|
|
require 'awesome_print/core_ext/logger'
|
2010-04-22 00:57:21 -04:00
|
|
|
|
|
|
|
describe "AwesomePrint logging extensions" do
|
|
|
|
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
|
|
|
|
|
|
|
|
describe "ap method" do
|
|
|
|
it "should awesome_inspect the given object" do
|
|
|
|
object = mock
|
|
|
|
object.should_receive(:ai)
|
|
|
|
@logger.ap object
|
|
|
|
end
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
it "should fallback to the default :debug log level" do
|
|
|
|
@logger.should_receive(:debug)
|
|
|
|
@logger.ap(nil)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "should use the global user default if no level passed" do
|
|
|
|
AwesomePrint.defaults = { :log_level => :info }
|
|
|
|
@logger.should_receive(:info)
|
|
|
|
@logger.ap(nil)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "should use the passed in level" do
|
|
|
|
@logger.should_receive(:warn)
|
|
|
|
@logger.ap(nil, :warn)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|