summaryrefslogtreecommitdiffstats
path: root/spec/lib/puppet_spec/files.rb
blob: aad37405730f55b4b19b475df1868eaa866810cb (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