test/lib/puppettest.rb in puppet-2.6.0 vs test/lib/puppettest.rb in puppet-2.6.1

- old
+ new

@@ -4,21 +4,10 @@ # Add .../lib mainlib = File.expand_path(File.join(File.dirname(__FILE__), '../../lib')) $LOAD_PATH.unshift(mainlib) unless $LOAD_PATH.include?(mainlib) require 'puppet' - -# include any gems in vendor/gems -Dir["#{mainlib}/../vendor/gems/**"].each do |path| - libpath = File.join(path, "lib") - if File.directory?(libpath) - $LOAD_PATH.unshift(libpath) - else - $LOAD_PATH.unshift(path) - end -end - require 'mocha' # Only load the test/unit class if we're not in the spec directory. # Else we get the bogus 'no tests, no failures' message. unless Dir.getwd =~ /spec/ @@ -29,21 +18,12 @@ if ARGV.include?("-d") ARGV.delete("-d") $console = true end -# Some monkey-patching to allow us to test private methods. -class Class - def publicize_methods(*methods) - saved_private_instance_methods = methods.empty? ? self.private_instance_methods : methods +require File.expand_path(File.join(File.dirname(__FILE__), '../../spec/monkey_patches/publicize_methods')) - self.class_eval { public(*saved_private_instance_methods) } - yield - self.class_eval { private(*saved_private_instance_methods) } - end -end - module PuppetTest # These need to be here for when rspec tests use these # support methods. @@tmpfiles = [] @@ -225,17 +205,17 @@ #Facter.stubs(:value).returns "stubbed_value" #Facter.stubs(:to_hash).returns({}) end - def tempfile + def tempfile(suffix = '') if defined?(@@tmpfilenum) @@tmpfilenum += 1 else @@tmpfilenum = 1 end - f = File.join(self.tmpdir, "tempfile_" + @@tmpfilenum.to_s) + f = File.join(self.tmpdir, "tempfile_" + @@tmpfilenum.to_s + suffix) @@tmpfiles ||= [] @@tmpfiles << f f end