Sha256: f6e54d0732b8628550629a255851b248e5d6c80883c7ac074f7fb10caa5fbae9

Contents?: true

Size: 750 Bytes

Versions: 5

Compression:

Stored size: 750 Bytes

Contents

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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
puppet-2.6.4 test/lib/puppettest/fileparsing.rb
puppet-2.6.3 test/lib/puppettest/fileparsing.rb
puppet-2.6.2 test/lib/puppettest/fileparsing.rb
puppet-2.6.1 test/lib/puppettest/fileparsing.rb
puppet-2.6.0 test/lib/puppettest/fileparsing.rb