spec/lib/puppet_spec/files.rb in puppet-0.25.5 vs spec/lib/puppet_spec/files.rb in puppet-2.6.0
- old
+ new
@@ -1,9 +1,19 @@
+require 'fileutils'
+
# A support module for testing files.
module PuppetSpec::Files
- def tmpfile(name)
- source = Tempfile.new(name)
- path = source.path
- source.close!
- path
- end
+ def tmpfile(name)
+ source = Tempfile.new(name)
+ path = source.path
+ source.close!
+ $tmpfiles ||= []
+ $tmpfiles << path
+ path
+ end
+
+ def tmpdir(name)
+ file = tmpfile(name)
+ FileUtils.mkdir_p(file)
+ file
+ end
end