diff options
author | Josh Cooper <josh@puppet.com> | 2018-07-09 17:15:39 -0700 |
---|---|---|
committer | Josh Cooper <josh@puppet.com> | 2018-07-09 19:44:47 -0700 |
commit | 2ac89832b7e065df4490d81b3080b2b570a172ad (patch) | |
tree | f9f4f28f30a77c958e8e850acf954336b2301dc9 /spec/shared_behaviours | |
parent | 1c6ae8bfde5175c5d3512f5acb5352fda94a4801 (diff) | |
download | puppet-hosts_core-2ac89832b7e065df4490d81b3080b2b570a172ad.tar.gz puppet-hosts_core-2ac89832b7e065df4490d81b3080b2b570a172ad.tar.bz2 |
Initial host import from puppet#ee7cf4d28077be7d1bdbbe934ea012d41d33deff
Diffstat (limited to 'spec/shared_behaviours')
-rw-r--r-- | spec/shared_behaviours/all_parsedfile_providers.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/spec/shared_behaviours/all_parsedfile_providers.rb b/spec/shared_behaviours/all_parsedfile_providers.rb new file mode 100644 index 0000000..9fdf54b --- /dev/null +++ b/spec/shared_behaviours/all_parsedfile_providers.rb @@ -0,0 +1,21 @@ +shared_examples_for "all parsedfile providers" do |provider, *files| + if files.empty? then + files = my_fixtures + end + + files.flatten.each do |file| + it "should rewrite #{file} reasonably unchanged" do + provider.stubs(:default_target).returns(file) + provider.prefetch + + text = provider.to_file(provider.target_records(file)) + text.gsub!(/^# HEADER.+\n/, '') + + oldlines = File.readlines(file) + newlines = text.chomp.split "\n" + oldlines.zip(newlines).each do |old, new| + expect(new.gsub(/\s+/, '')).to eq(old.chomp.gsub(/\s+/, '')) + end + end + end +end |