[Pkg-puppet-devel] [facter] 202/352: (maint) Delegate #warnonce printing to #warn

Stig Sandbeck Mathisen ssm at debian.org
Sun Apr 6 22:21:45 UTC 2014


This is an automated email from the git hooks/post-receive script.

ssm pushed a commit to branch master
in repository facter.

commit b34eb1e2e6abcad892f0bac04fb9bb1506e1c73d
Author: Adrien Thebo <git at somethingsinistral.net>
Date:   Mon Feb 3 11:29:19 2014 -0800

    (maint) Delegate #warnonce printing to #warn
---
 lib/facter/core/logging.rb     |  4 ++--
 spec/unit/core/logging_spec.rb | 17 ++---------------
 2 files changed, 4 insertions(+), 17 deletions(-)

diff --git a/lib/facter/core/logging.rb b/lib/facter/core/logging.rb
index 185440d..c7e8674 100644
--- a/lib/facter/core/logging.rb
+++ b/lib/facter/core/logging.rb
@@ -68,9 +68,9 @@ module Facter::Core::Logging
   #
   # @return [void]
   def warnonce(msg)
-    if msg and not msg.empty? and @@warn_messages[msg].nil?
+    if @@warn_messages[msg].nil?
+      self.warn(msg)
       @@warn_messages[msg] = true
-      Kernel.warn(msg)
     end
   end
 
diff --git a/spec/unit/core/logging_spec.rb b/spec/unit/core/logging_spec.rb
index 44ae3c5..7182e82 100644
--- a/spec/unit/core/logging_spec.rb
+++ b/spec/unit/core/logging_spec.rb
@@ -36,24 +36,11 @@ describe Facter::Core::Logging do
   end
 
   describe "when warning once" do
-    it "should only warn once" do
-      Kernel.stubs(:warnonce)
-      Kernel.expects(:warn).with('foo').once
+    it "only logs a given warning string once" do
+      subject.expects(:warn).with('foo').once
       subject.warnonce('foo')
       subject.warnonce('foo')
     end
-
-    it "should not warnonce if nil is passed" do
-      Kernel.stubs(:warn)
-      Kernel.expects(:warnonce).never
-      subject.warnonce(nil)
-    end
-
-    it "should not warnonce if an empty string is passed" do
-      Kernel.stubs(:warn)
-      Kernel.expects(:warnonce).never
-      subject.warnonce('')
-    end
   end
 
   describe "when setting the debugging mode" do

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-puppet/facter.git



More information about the Pkg-puppet-devel mailing list