spec/integration_2.rb
# Compares two files to check if they are identical and produces a clear diff
# to highlight the differences.
#
# @param [Pathname] expected @see #yaml_should_match
# @param [Pathname] produced @see #yaml_should_match
#
Compares two files to check if they are identical and produces a clear diff
to highlight the differences.
Compares two files to check if they are identical and produces a clear diff to highlight the differences .
def file_should_match(expected, produced)
  is_equal = FileUtils.compare_file(expected, produced)
  description = []
  description << "File comparison error `#{expected}`"
  description << ""
  description << ("--- DIFF " << "-" * 70)
  Diffy::Diff.new(expected.to_s, produced.to_s, :source => 'files', :context => 3).each do |line|
    case line
    when /^\+/ then description << line.gsub("\n",'').green
    when /^-/ then description << line.gsub("\n",'').red
    else description << line.gsub("\n",'')
    end
  end
  description << ("--- END " << "-" * 70)
  description << ""
  is_equal.should.satisfy(description * "\n") do
    is_equal == true
  end
end
def file_should_match ( expected , produced ) is_equal = FileUtils . compare_file ( expected , produced ) description = [ ] description << "File comparison error `#{expected}`" description << "" description << ( "--- DIFF " << "-" * 70 ) Diffy :: Diff . new ( expected . to_s , produced . to_s , :source => 'files' , :context => 3 ) . each do | line | case line when / ^ \+ / then description << line . gsub ( "\n" , '' ) . green when / ^- / then description << line . gsub ( "\n" , '' ) . red else description << line . gsub ( "\n" , '' ) end end description << ( "--- END " << "-" * 70 ) description << "" is_equal . should . satisfy ( description * "\n" ) do is_equal == true end end
Compares two files to check if they are identical and produces a clear diff
to highlight the differences.
Compares two files to check if they are identical and produces a clear diff to highlight the differences .
expected
produced
produced @see #yaml_should_match
produced @see #yaml_should_match