summaryrefslogtreecommitdiff
path: root/spec/unit/log_spec.rb
diff options
context:
space:
mode:
authorAdam Jacob <adam@hjksolutions.com>2008-04-08 00:57:17 -0700
committerAdam Jacob <adam@hjksolutions.com>2008-04-08 00:57:17 -0700
commit95eb1375f0647accd1b1a1569a7d0e3acc4a61e4 (patch)
treea58d6fddde4d7818dc33511ff8275c7b9f69f1c6 /spec/unit/log_spec.rb
parent434f25ba07b5c0c50baa1e15b14a945bba3c3c3b (diff)
downloadchef-95eb1375f0647accd1b1a1569a7d0e3acc4a61e4.tar.gz
Adding chef-solo command, config examples, Chef::Log class, Chef::Log::Formatter, Chef::Compile, and all the tests
Diffstat (limited to 'spec/unit/log_spec.rb')
-rw-r--r--spec/unit/log_spec.rb64
1 files changed, 64 insertions, 0 deletions
diff --git a/spec/unit/log_spec.rb b/spec/unit/log_spec.rb
new file mode 100644
index 0000000000..45e0da6dd5
--- /dev/null
+++ b/spec/unit/log_spec.rb
@@ -0,0 +1,64 @@
+#
+# Author:: Adam Jacob (<adam@hjksolutions.com>)
+# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
+# License:: GNU General Public License version 2 or later
+#
+# This program and entire repository is free software; you can
+# redistribute it and/or modify it under the terms of the GNU
+# General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+#
+
+require 'tempfile'
+require 'logger'
+require File.expand_path(File.join(File.dirname(__FILE__), "..", "spec_helper"))
+
+describe Chef::Log do
+ it "should accept regular options to Logger.new via init" do
+ tf = Tempfile.new("chef-test-log")
+ tf.open
+ lambda { Chef::Log.init(STDOUT) }.should_not raise_error
+ lambda { Chef::Log.init(tf) }.should_not raise_error
+ end
+
+ it "should set the log level 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|
+ Chef::Log.level(symbol)
+ Chef::Log.logger.level.should == constant
+ end
+ end
+
+ it "should raise an ArgumentError if you try and set the level to something strange" do
+ lambda { Chef::Log.level(:the_roots) }.should raise_error(ArgumentError)
+ end
+
+ it "should pass other method calls directly to logger" do
+ Chef::Log.level(:debug)
+ Chef::Log.should be_debug
+ lambda { Chef::Log.debug("Gimme some sugar!") }.should_not raise_error
+ end
+
+ it "should default to STDOUT if init is called with no arguments" do
+ logger_mock = mock(Logger, :null_object => true)
+ Logger.stub!(:new).and_return(logger_mock)
+ Logger.should_receive(:new).with(STDOUT).and_return(logger_mock)
+ Chef::Log.init
+ end
+
+end \ No newline at end of file