aboutsummaryrefslogtreecommitdiff
path: root/spec/shared_behaviours
diff options
context:
space:
mode:
authorJosh Cooper <josh@puppet.com>2018-04-26 11:41:34 -0700
committerGitHub <noreply@github.com>2018-04-26 11:41:34 -0700
commit81d2cf81cd02c09f53774c1b95ae2de474b28b80 (patch)
tree4997f732281a7e0cb5ff33a745663cc5cffed741 /spec/shared_behaviours
parent7c51be1c0d8ace7cb679f16ee4d8e3697ea95ae8 (diff)
parentbeb0aa2b549ed4b6f90d82a864a443e35c102b38 (diff)
downloadpuppet-mailalias_core-81d2cf81cd02c09f53774c1b95ae2de474b28b80.tar.gz
puppet-mailalias_core-81d2cf81cd02c09f53774c1b95ae2de474b28b80.tar.bz2
Merge pull request #1 from melissa/maint/master/initial-commits
Maint/master/initial commits
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..d697a14
--- /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?
+ 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!(%r{^# HEADER.+\n}, '')
+
+ oldlines = File.readlines(file)
+ newlines = text.chomp.split "\n"
+ oldlines.zip(newlines).each do |old, new|
+ expect(new.gsub(%r{\s+}, '')).to eq(old.chomp.gsub(%r{\s+}, ''))
+ end
+ end
+ end
+end