diff options
author | Luke Kanies <luke@madstop.com> | 2009-11-04 16:52:47 -0600 |
---|---|---|
committer | test branch <puppet-dev@googlegroups.com> | 2010-02-17 06:50:53 -0800 |
commit | c6dd180450404c74bac8aadbf68b297c5f74764c (patch) | |
tree | e4b1e43a4a02adf10c79c949b25abebeba05b627 | |
parent | 242209d251c7807378d3af6d9bffbc9ed59be723 (diff) | |
download | puppet-c6dd180450404c74bac8aadbf68b297c5f74764c.tar.gz puppet-c6dd180450404c74bac8aadbf68b297c5f74764c.tar.xz puppet-c6dd180450404c74bac8aadbf68b297c5f74764c.zip |
Adding tests for "Logging" module
Signed-off-by: Luke Kanies <luke@madstop.com>
-rwxr-xr-x | spec/unit/util/logging.rb | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/spec/unit/util/logging.rb b/spec/unit/util/logging.rb new file mode 100755 index 000000000..39edbb47e --- /dev/null +++ b/spec/unit/util/logging.rb @@ -0,0 +1,47 @@ +#!/usr/bin/env ruby + +Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") } + +require 'puppet/util/logging' + +class LoggingTester + include Puppet::Util::Logging +end + +describe Puppet::Util::Logging do + before do + @logger = LoggingTester.new + end + + Puppet::Util::Log.eachlevel do |level| + it "should have a method for sending '#{level}' logs" do + @logger.should respond_to(level) + end + end + + describe "when sending a log" do + it "should use the Log's 'create' entrance method" do + Puppet::Util::Log.expects(:create) + + @logger.notice "foo" + end + + it "should send itself as the log source" do + Puppet::Util::Log.expects(:create).with { |args| args[:source].equal?(@logger) } + + @logger.notice "foo" + end + + it "should send the provided argument as the log message" do + Puppet::Util::Log.expects(:create).with { |args| args[:message] == "foo" } + + @logger.notice "foo" + end + + it "should join any provided arguments into a single string for the message" do + Puppet::Util::Log.expects(:create).with { |args| args[:message] == "foo bar baz" } + + @logger.notice ["foo", "bar", "baz"] + end + end +end |