File: all_parsedfile_providers.rb

package info (click to toggle)
puppet-module-puppetlabs-host-core 1.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 312 kB
  • sloc: ruby: 1,107; sh: 16; makefile: 4
file content (21 lines) | stat: -rw-r--r-- 619 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
shared_examples_for 'all parsedfile providers' do |provider, *files|
  if files.empty?
    files = my_fixtures
  end

  files.flatten.each do |file|
    it "rewrites #{file} reasonably unchanged" do
      allow(provider).to receive(:default_target).and_return(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