[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, experimental, updated. debian/2.6.8-1-844-g7ec39d5

Daniel Pittman daniel at puppetlabs.com
Tue May 10 08:11:09 UTC 2011


The following commit has been merged in the experimental branch:
commit 07a79cf4f2b62250049fb9b52d7d310d3e0ab5d2
Author: Daniel Pittman <daniel at puppetlabs.com>
Date:   Wed Apr 6 16:23:28 2011 -0700

    maint: add `write_scratch_string` helper for testing...
    
    We had a pattern where we wanted to routinely write scratch strings to disk,
    on the load path, so we could reference them later.  This extracts that into a
    helper, and starts to use it in tests that should follow that pattern.
    
    Reviewed-By: Dan Bode <dan at puppetlabs.com>

diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 3b04636..bb71fca 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -26,7 +26,9 @@ RSpec.configure do |config|
     @logs = []
     Puppet::Util::Log.newdestination(@logs)
 
-    
+    @load_path_scratch_dir = Dir.mktmpdir
+    $LOAD_PATH.push @load_path_scratch_dir
+    FileUtils.mkdir_p(File.join @load_path_scratch_dir, 'puppet', 'string')
   end
 
   config.after :each do
@@ -34,6 +36,18 @@ RSpec.configure do |config|
 
     @logs.clear
     Puppet::Util::Log.close_all
+
+    $LOAD_PATH.delete @load_path_scratch_dir
+    FileUtils.remove_entry_secure @load_path_scratch_dir
+  end
+
+  def write_scratch_string(name)
+    fail "you need to supply a block: do |fh| fh.puts 'content' end" unless block_given?
+    fail "name should be a symbol" unless name.is_a? Symbol
+    filename = File.join(@load_path_scratch_dir, 'puppet', 'string', "#{name}.rb")
+    File.open(filename, 'w') do |fh|
+      yield fh
+    end
   end
 end
 

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list