summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorChristopher Brown <cb@opscode.com>2009-12-14 11:51:00 -0800
committerChristopher Brown <cb@opscode.com>2009-12-14 11:51:00 -0800
commit227da700bc76ea01ccd8f68076b1d4befd6ead47 (patch)
treeb7d9a70b4714a138d239f4eb431c62b8c9c64f1c /spec
parent336f3ec002177105233c9d79731d52124266adb8 (diff)
downloadmixlib-log-227da700bc76ea01ccd8f68076b1d4befd6ead47.tar.gz
make log level changes backward compatible
Diffstat (limited to 'spec')
-rw-r--r--spec/mixlib/log_spec.rb24
-rw-r--r--spec/spec_helper.rb23
2 files changed, 43 insertions, 4 deletions
diff --git a/spec/mixlib/log_spec.rb b/spec/mixlib/log_spec.rb
index 259ae36..dcfa544 100644
--- a/spec/mixlib/log_spec.rb
+++ b/spec/mixlib/log_spec.rb
@@ -1,5 +1,6 @@
#
# Author:: Adam Jacob (<adam@opscode.com>)
+# Author:: Christopher Brown (<cb@opscode.com>)
# Copyright:: Copyright (c) 2008 Opscode, Inc.
# License:: Apache License, Version 2.0
#
@@ -34,7 +35,7 @@ describe Mixlib::Log do
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,
@@ -45,10 +46,29 @@ describe Mixlib::Log do
levels.each do |symbol, constant|
Logit.level(symbol)
Logit.logger.level.should == constant
+ Logit.level.should == symbol
end
end
- it "should raise an ArgumentError if you try and set the level to something strange" do
+ 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 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
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 518498d..8640957 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -1,3 +1,22 @@
+#
+# 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.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
$TESTING=true
$:.push File.join(File.dirname(__FILE__), '..', 'lib')
@@ -5,5 +24,5 @@ require 'mixlib/log'
require 'mixlib/log/formatter'
class Logit
- extend(Mixlib::Log)
-end \ No newline at end of file
+ extend Mixlib::Log
+end