aboutsummaryrefslogtreecommitdiff
path: root/spec/shared_behaviours
diff options
context:
space:
mode:
authorMelissa Stone <melissa@puppet.com>2018-04-13 14:04:01 -0700
committerMelissa Stone <melissa@puppet.com>2018-04-16 16:19:34 -0700
commit88cd8802c5841b619baa3df2313f7b1fdf68308f (patch)
treec5bc9fde350a689824304f7331921ceb648004cb /spec/shared_behaviours
parent759ad74f328af3e0ff16cfb9f341ea7fdca31313 (diff)
downloadpuppet-mailalias_core-88cd8802c5841b619baa3df2313f7b1fdf68308f.tar.gz
puppet-mailalias_core-88cd8802c5841b619baa3df2313f7b1fdf68308f.tar.bz2
Get unit tests passing
Diffstat (limited to 'spec/shared_behaviours')
-rw-r--r--spec/shared_behaviours/all_parsedfile_providers.rb21
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