diff options
author | sawanoboly <sawanoboriyu@higanworks.com> | 2015-04-23 15:25:14 +0900 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2015-05-06 15:09:44 -0700 |
commit | 9a0f9d284424f9d38edc3df184271492dd8f2472 (patch) | |
tree | ba4ec85f538419e3b3279951e876d3bbfadd969f | |
parent | 76e5b5a91dd1b92486a8b21a8fcc206ba321f6ab (diff) | |
download | chef-9a0f9d284424f9d38edc3df184271492dd8f2472.tar.gz |
add unit specs for Chef::Log::Syslog
-rw-r--r-- | lib/chef/log.rb | 1 | ||||
-rw-r--r-- | spec/unit/log_spec.rb | 14 |
2 files changed, 15 insertions, 0 deletions
diff --git a/lib/chef/log.rb b/lib/chef/log.rb index a5ba5059ac..d11e16b1f3 100644 --- a/lib/chef/log.rb +++ b/lib/chef/log.rb @@ -35,6 +35,7 @@ class Chef def initialize(program_name = 'chef-client', facility = ::Syslog::LOG_DAEMON, logopts=nil) super + return if defined? ::Logger::Syslog::SYSLOG ::Logger::Syslog.const_set :SYSLOG, SYSLOG end diff --git a/spec/unit/log_spec.rb b/spec/unit/log_spec.rb index 7be40f77e6..54e0c940b4 100644 --- a/spec/unit/log_spec.rb +++ b/spec/unit/log_spec.rb @@ -22,3 +22,17 @@ require 'spec_helper' describe Chef::Log do end + +describe Chef::Log::Syslog do + let(:logger) { Chef::Log::Syslog.new } + + it "should send message with severity info to syslog." do + expect_any_instance_of(Logger::Syslog).to receive(:info).with(" *** Chef 12.4.0.dev.0 ***") + logger.write("[2015-04-23T15:16:23+09:00] INFO: *** Chef 12.4.0.dev.0 ***") + end + + it "should send message with severity warning to syslog." do + expect_any_instance_of(Logger::Syslog).to receive(:warn).with(" No config file found or specified on command line, using command line options.") + logger.write("[2015-04-23T15:16:20+09:00] WARN: No config file found or specified on command line, using command line options.") + end +end |