diff options
Diffstat (limited to 'test/lib/puppettest/fileparsing.rb')
-rw-r--r-- | test/lib/puppettest/fileparsing.rb | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/test/lib/puppettest/fileparsing.rb b/test/lib/puppettest/fileparsing.rb new file mode 100644 index 000000000..004a0c3b5 --- /dev/null +++ b/test/lib/puppettest/fileparsing.rb @@ -0,0 +1,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$ |