spec/lib/augeas_spec/augparse.rb
# Creates a simple test file, reads in a fixture (that's been modified by
# the provider) and runs augparse against the expected tree.
Creates a simple test file, reads in a fixture (that's been modified by
the provider) and runs augparse against the expected tree.
Creates a simple test file reads in a fixture ( that ' s been modified by the provider ) and runs augparse against the expected tree .
def augparse(file, lens, result = '?')
    Dir.mktmpdir do |dir|
      File.open("#{dir}/input", 'w') do |finput|
        File.open(file, 'r') do |ffile|
          line = ffile.readline
          finput.write line unless line == "\n"
          ffile.each { |l| finput.write l }
        end
      end
      testaug = "#{dir}/test_augeasproviders.aug"
      File.open(testaug, 'w') do |tf|
        tf.write(<<~EOS)
          module Test_Augeasproviders =
            test #{lens} get Sys.read_file "#{dir}/input" =
              #{result}
        EOS
      end
      output = `augparse --notypecheck #{testaug} 2>&1`
      raise AugeasSpec::Error, "augparse failed:\n#{output}" unless $CHILD_STATUS == 0 && output.empty?
    end
  end
def augparse ( file , lens , result = '?' ) Dir . mktmpdir do | dir | File . open ( "#{dir}/input" , 'w' ) do | finput | File . open ( file , 'r' ) do | ffile | line = ffile . readline finput . write line unless line == "\n" ffile . each { | l | finput . write l } end end testaug = "#{dir}/test_augeasproviders.aug" File . open ( testaug , 'w' ) do | tf | tf . write ( <<~EOS ) 
          module Test_Augeasproviders =
            test  #{ lens }  get Sys.read_file " #{ dir } /input" =
               #{ result } EOS end output = ` augparse --notypecheck  #{ testaug }  2>&1 ` raise AugeasSpec :: Error , "augparse failed:\n#{output}" unless $CHILD_STATUS == 0 && output . empty? end end
Creates a simple test file, reads in a fixture (that's been modified by
the provider) and runs augparse against the expected tree.
Creates a simple test file reads in a fixture ( that ' s been modified by the provider ) and runs augparse against the expected tree .
# Augeas always starts with a blank line when creating new files, so # reprocess file and remove it to make writing tests easier # Test module, Augeas reads back in the input file
file
<not_specific>
lens
<not_specific>
result
<not_specific>