spec/integration_2.rb
# Compares two lockfiles because CocoaPods 0.16 doesn't oder them in 1.8.7.
#
# @param [Pathname] expected
#        The reference in the `after` folder.
#
# @param [Pathname] produced
#        The file in the temporary directory after running the pod command.
#
Compares two lockfiles because CocoaPods 0.16 doesn't oder them in 1.8.7.
Compares two lockfiles because CocoaPods 0 . 16 doesn ' t oder them in 1 . 8 . 7 .
def yaml_should_match(expected, produced)
  expected_yaml = YAML::load(File.open(expected))
  produced_yaml = YAML::load(File.open(produced))
  expected_yaml.delete('COCOAPODS')
  produced_yaml.delete('COCOAPODS')
  desc = []
  desc << "YAML comparison error `#{expected}`"
  diff_options = {:key_1 => "$produced", :key_2 => "$expected"}
  diff = Xcodeproj::Differ.diff(produced_yaml, expected_yaml, diff_options).to_yaml
  diff.gsub!("$produced", "produced".green)
  diff.gsub!("$expected", "expected".red)
  desc << ("--- DIFF " << "-" * 70)
  Diffy::Diff.new(expected.to_s, produced.to_s, :source => 'files', :context => 3).each do |line|
    case line
    when /^\+/ then desc << line.gsub("\n",'').green
    when /^-/ then desc << line.gsub("\n",'').red
    else desc << line.gsub("\n",'')
    end
  end
  desc << ("--- DIFF " << "-" * 70)
  desc << diff
  desc << ("--- END " << "-" * 70)
  expected_yaml.should.satisfy(desc * "\n\n") do
    if RUBY_VERSION < "1.9"
      true 
    else
      expected_yaml == produced_yaml
    end
  end
end
def yaml_should_match ( expected , produced ) expected_yaml = YAML :: load ( File . open ( expected ) ) produced_yaml = YAML :: load ( File . open ( produced ) ) expected_yaml . delete ( 'COCOAPODS' ) produced_yaml . delete ( 'COCOAPODS' ) desc = [ ] desc << "YAML comparison error `#{expected}`" diff_options = { :key_1 => "$produced" , :key_2 => "$expected" } diff = Xcodeproj :: Differ . diff ( produced_yaml , expected_yaml , diff_options ) . to_yaml diff . gsub! ( "$produced" , "produced" . green ) diff . gsub! ( "$expected" , "expected" . red ) desc << ( "--- DIFF " << "-" * 70 ) Diffy :: Diff . new ( expected . to_s , produced . to_s , :source => 'files' , :context => 3 ) . each do | line | case line when / ^ \+ / then desc << line . gsub ( "\n" , '' ) . green when / ^- / then desc << line . gsub ( "\n" , '' ) . red else desc << line . gsub ( "\n" , '' ) end end desc << ( "--- DIFF " << "-" * 70 ) desc << diff desc << ( "--- END " << "-" * 70 ) expected_yaml . should . satisfy ( desc * "\n\n" ) do if RUBY_VERSION < "1.9" true else expected_yaml == produced_yaml end end end
Compares two lockfiles because CocoaPods 0.16 doesn't oder them in 1.8.7.
Compares two lockfiles because CocoaPods 0 . 16 doesn ' t oder them in 1 . 8 . 7 .
# Remove CocoaPods version # CP is not sorting array derived from hashes whose order is # undefined in 1.8.7
expected
produced
produced The file in the temporary directory after running the pod command.
produced The file in the temporary directory after running the pod command .