]> gitweb.fluxo.info Git - puppet-stdlib.git/commitdiff
(Maint) Make rspec tests work with Puppet 2.6.4
authorJeff McCune <jeff@puppetlabs.com>
Mon, 10 Oct 2011 18:58:48 +0000 (11:58 -0700)
committerJeff McCune <jeff@puppetlabs.com>
Mon, 10 Oct 2011 18:58:48 +0000 (11:58 -0700)
The behavior without this patch applied is that the rspec tests do not
function with Puppet 2.6.4.  This patch back-ports some fixes introduced
in Puppet 2.7.x to the spec_helper to make the tests work as expected on
Puppet 2.6.4.

The specific patches back ported from Puppet are:

 * 2ae88067 (Puppet::Util::ExecutionStub.reset)
 * cf183534 (Switched spec tests to use a class rather than Array as the
             log destination.)

spec/spec_helper.rb

index fc19cefbcfc44603ff068c6be83a16e1aac68166..87aac34075835c33515ee4e215234b8f6dba9fd4 100644 (file)
@@ -27,6 +27,32 @@ require 'puppet_spec/matchers'
 require 'monkey_patches/alias_should_to_must'
 require 'monkey_patches/publicize_methods'
 
+# JJM Hack to make the stdlib tests run in Puppet 2.6 (See puppet commit cf183534)
+if not Puppet.constants.include? "Test" then
+  module Puppet::Test
+    class LogCollector
+      def initialize(logs)
+        @logs = logs
+      end
+
+      def <<(value)
+        @logs << value
+      end
+    end
+  end
+  Puppet::Util::Log.newdesttype :log_collector do
+    match "Puppet::Test::LogCollector"
+
+    def initialize(messages)
+      @messages = messages
+    end
+
+    def handle(msg)
+      @messages << msg
+    end
+  end
+end
+
 Pathname.glob("#{dir}/shared_behaviours/**/*.rb") do |behaviour|
   require behaviour.relative_path_from(Pathname.new(dir))
 end
@@ -66,7 +92,7 @@ RSpec.configure do |config|
     Puppet.settings.clear
     Puppet::Node::Environment.clear
     Puppet::Util::Storage.clear
-    Puppet::Util::ExecutionStub.reset
+    Puppet::Util::ExecutionStub.reset if Puppet::Util.constants.include? "ExecutionStub"
 
     PuppetSpec::Files.cleanup