blob: 11de002207f5d3cca9cbfb66b8a9914d4954922f (
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
|
module PuppetTest::FileParsing
# Run an isomorphism test on our parsing process.
def fakedataparse(*files)
files.each do |file|
@provider.stubs(:default_target).returns(file)
@provider.prefetch
text = @provider.to_file(@provider.target_records(file))
text.gsub!(/^# HEADER.+\n/, '')
yield if block_given?
oldlines = File.readlines(file)
newlines = text.chomp.split "\n"
oldlines.zip(newlines).each do |old, new|
if self.is_a?(Test::Unit::TestCase)
assert_equal(old.chomp.gsub(/\s+/, ''), new.gsub(/\s+/, ''), "File was not written back out correctly")
else
new.gsub(/\s+/, '').should == old.chomp.gsub(/\s+/, '')
end
end
end
end
end
|