]> gitweb.fluxo.info Git - puppet-stdlib.git/commitdiff
(#13439) Fix MRI 1.9 issue with spec_helper
authorJeff McCune <jeff@puppetlabs.com>
Fri, 30 Mar 2012 06:04:12 +0000 (23:04 -0700)
committerJeff McCune <jeff@puppetlabs.com>
Fri, 30 Mar 2012 06:18:15 +0000 (23:18 -0700)
When using MRI 1.9.x the stdlib spec helper does not invoke because
Puppet.settings.private_methods returns symbols instead of strings.

This is a problem because we need to set default configuration settings
like Puppet[:vardir] when using the compiler.

This patch fixes the issue by simply checking the Puppet version.  This
seems a better choice than rescuing NoMethodError since the method might
be renamed or removed in the future.

spec/spec_helper.rb

index d0b493eaa285c6c64434ed2f07e21d263c8679df..92fe1ad565057db2ecc75339b1e32846099c208c 100644 (file)
@@ -72,11 +72,8 @@ RSpec.configure do |config|
     Signal.stubs(:trap)
 
     # 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
+    # should only be used for tests.  Puppet 2.6.x does not have the method.
+    Puppet.settings.send(:initialize_everything_for_tests) unless Puppet.version =~ /^2\.6/
 
 
     @logs = []
@@ -87,11 +84,8 @@ RSpec.configure do |config|
 
   config.after :each do
     # 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
+    # should only be used for tests.  Puppet 2.6.x does not have the method.
+    Puppet.settings.send(:clear_everything_for_tests) unless Puppet.version =~ /^2\.6/
     Puppet::Node::Environment.clear
     Puppet::Util::Storage.clear
     Puppet::Util::ExecutionStub.reset if Puppet::Util.constants.include? "ExecutionStub"