summaryrefslogtreecommitdiffstats
path: root/spec/lib/puppet_spec/files.rb
blob: cab4a1e47da4bf86b38ff0803185a0ab55b672e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
require 'fileutils'

# A support module for testing files.
module PuppetSpec::Files
  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