]> review.fuel-infra Code Review - puppet-modules/puppetlabs-firewall.git/commitdiff
(#10263) Fix tests on Puppet 2.6.x
authorKen Barber <ken@bob.sh>
Tue, 25 Oct 2011 09:10:42 +0000 (10:10 +0100)
committerKen Barber <ken@bob.sh>
Tue, 25 Oct 2011 09:31:26 +0000 (10:31 +0100)
Due to the lack of Puppet::Test::LogCollector class, tests fail on puppet
2.6.x. Instead of just using the class, I'm testing its existance first
and only using it if it exists. Otherwise, I'm going to fall back to 2.6.x
methodology.

This seems to make tests work on 2.6.7 (and up) and 2.7.1 (and up) which is
sufficient for now.

spec/spec_helper.rb

index 79fda18eef5fa7efdef2126a53176d45870e849c..8e9fbdba42be9f91db35de91c08141195460600f 100644 (file)
@@ -54,7 +54,13 @@ RSpec.configure do |config|
     Puppet.settings[:bindaddress] = "127.0.0.1"
 
     @logs = []
-    Puppet::Util::Log.newdestination(Puppet::Test::LogCollector.new(@logs))
+    # This tests allows the spec_helper to be >2.6.7 and >2.7.1 compatible
+    # as the Puppet::Test::LogCollector facility wasn't available until 2.7.x
+    if Puppet.const_defined?("Test") and Puppet::Test.const_defined?("LogCollector")
+      Puppet::Util::Log.newdestination(Puppet::Test::LogCollector.new(@logs))
+    else
+      Puppet::Util::Log.newdestination(@logs)
+    end
 
     @log_level = Puppet::Util::Log.level
   end