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

# 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