diff options
author | Christopher Brown <cb@opscode.com> | 2009-12-14 11:52:54 -0800 |
---|---|---|
committer | Christopher Brown <cb@opscode.com> | 2009-12-14 11:52:54 -0800 |
commit | 23baac7af14a88b8acb43db78b4f74b066d711e2 (patch) | |
tree | c66f79abaccf304d01b48b4b1ba79b1162540f86 /spec | |
parent | 1c18b2b2badc4de2f5c13b55759aae3399551dc5 (diff) | |
parent | 227da700bc76ea01ccd8f68076b1d4befd6ead47 (diff) | |
download | mixlib-log-23baac7af14a88b8acb43db78b4f74b066d711e2.tar.gz |
making log level changes backward compatible
Diffstat (limited to 'spec')
-rw-r--r-- | spec/mixlib/log_spec.rb | 24 | ||||
-rw-r--r-- | spec/spec_helper.rb | 23 |
2 files changed, 43 insertions, 4 deletions
diff --git a/spec/mixlib/log_spec.rb b/spec/mixlib/log_spec.rb index 2c90b08..f07ff66 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,13 +46,32 @@ 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 + it "should pass other method calls directly to logger" do Logit.level = :debug Logit.should be_debug 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 |