summaryrefslogtreecommitdiffstats
path: root/test/lib/puppettest/fileparsing.rb
blob: 004a0c3b5a48aedfc14b2908de1349abfa9257db (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
module PuppetTest::FileParsing
    # Run an isomorphism test on our parsing process.
    def fakedataparse(file)
        @provider.path = file
        instances = nil
        assert_nothing_raised {
            instances = @provider.retrieve
        }

        text = @provider.fileobj.read

        yield if block_given?

        dest = tempfile()
        @provider.path = dest

        # Now write it back out
        assert_nothing_raised {
            @provider.store(instances)
        }

        newtext = @provider.fileobj.read

        # Don't worry about difference in whitespace
        assert_equal(text.gsub(/\s+/, ' '), newtext.gsub(/\s+/, ' '))
    end
end

# $Id$