]> gitweb.fluxo.info Git - puppet-stdlib.git/commitdiff
(#13439) Fix test failures with Puppet 2.6.x
authorJeff McCune <jeff@puppetlabs.com>
Thu, 29 Mar 2012 23:52:15 +0000 (16:52 -0700)
committerJeff McCune <jeff@puppetlabs.com>
Thu, 29 Mar 2012 23:52:15 +0000 (16:52 -0700)
Without this patch the spec_helper sends a message named
initialize_everything_for_tests to Puppet.settings.  This is a problem
because Puppet 2.6.x does not have this method, only Puppet 2.7.x and
Puppet master have this method at this time and we're getting false
positive test failures.

This patch fixes the problem by looking before we leap.  We test if the
private method exists before calling it.  This works with Ruby 1.8.5 and
onwards and Puppet 2.6, 2.7 and master.

This should fix all of the failures I've caused in Jenkins today.

spec/spec_helper.rb

index d6837a98264e0f567060e21f1aafd8385004443a..d0b493eaa285c6c64434ed2f07e21d263c8679df 100644 (file)
@@ -71,7 +71,12 @@ RSpec.configure do |config|
     # I suck for letting this float. --daniel 2011-04-21
     Signal.stubs(:trap)
 
-    Puppet.settings.send(:initialize_everything_for_tests)
+    # We're using send because this is a private method to communicate it
+    # should only be used for tests.  We're testing if it's defined to work
+    # with Puppet 2.6.x which does not have the method.
+    if Puppet.settings.private_methods.include? "initialize_everything_for_tests"
+      Puppet.settings.send(:initialize_everything_for_tests)
+    end
 
 
     @logs = []
@@ -81,7 +86,12 @@ RSpec.configure do |config|
   end
 
   config.after :each do
-    Puppet.settings.send(:clear_everything_for_tests)
+    # We're using send because this is a private method to communicate it
+    # should only be used for tests.  We're testing if it's defined to work
+    # with Puppet 2.6.x which does not have the method at all.
+    if Puppet.settings.private_methods.include? "clear_everything_for_tests"
+      Puppet.settings.send(:clear_everything_for_tests)
+    end
     Puppet::Node::Environment.clear
     Puppet::Util::Storage.clear
     Puppet::Util::ExecutionStub.reset if Puppet::Util.constants.include? "ExecutionStub"