spec/mixlib/log_spec.rb in mixlib-log-1.0.3 vs spec/mixlib/log_spec.rb in mixlib-log-1.1.0
- old
+ new
@@ -1,7 +1,8 @@
#
# Author:: Adam Jacob (<adam@opscode.com>)
+# Author:: Christopher Brown (<cb@opscode.com>)
# Copyright:: Copyright (c) 2008 Opscode, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -32,29 +33,48 @@
tf.open
lambda { Logit.init(STDOUT) }.should_not raise_error
lambda { Logit.init(tf) }.should_not raise_error
end
- it "should set the log level with :debug, :info, :warn, :error, or :fatal" do
+ it "should set the log level using the binding form, with :debug, :info, :warn, :error, or :fatal" do
levels = {
:debug => Logger::DEBUG,
:info => Logger::INFO,
:warn => Logger::WARN,
:error => Logger::ERROR,
:fatal => Logger::FATAL
}
levels.each do |symbol, constant|
+ Logit.level = symbol
+ Logit.logger.level.should == constant
+ Logit.level.should == symbol
+ end
+ end
+
+ it "should set the log level using the method form, with :debug, :info, :warn, :error, or :fatal" do
+ levels = {
+ :debug => Logger::DEBUG,
+ :info => Logger::INFO,
+ :warn => Logger::WARN,
+ :error => Logger::ERROR,
+ :fatal => Logger::FATAL
+ }
+ levels.each do |symbol, constant|
Logit.level(symbol)
Logit.logger.level.should == constant
end
end
- it "should raise an ArgumentError if you try and set the level to something strange" do
+ it "should raise an ArgumentError if you try and set the level to something strange using the binding form" do
+ lambda { Logit.level = :the_roots }.should raise_error(ArgumentError)
+ end
+
+ it "should raise an ArgumentError if you try and set the level to something strange using the method form" do
lambda { Logit.level(:the_roots) }.should raise_error(ArgumentError)
end
it "should pass other method calls directly to logger" do
- Logit.level(:debug)
+ Logit.level = :debug
Logit.should be_debug
lambda { Logit.debug("Gimme some sugar!") }.should_not raise_error
end
it "should default to STDOUT if init is called with no arguments" do