Skip to content
Browse files

Actually diff different values and add to output

  • Loading branch information...
1 parent 8c64a33 commit 78d525e2807a44565cb0fac04aff849c3befb404 @chrismcg committed Jun 11, 2012
Showing with 17 additions and 1 deletion.
  1. +1 −1 lib/yamldiff/yamldiff.rb
  2. +16 −0 spec/lib/yamldiff_spec.rb
View
2 lib/yamldiff/yamldiff.rb
@@ -36,7 +36,7 @@ def compare_hashes(first, second, context = [])
end
if (value != value2)
- errors << YamldiffKeyValueError.new(key, context) # "Key value mismatch : #{key} in path #{context.join(".")}"
+ errors << YamldiffKeyValueError.new(key, context, Diffy::Diff.new(value.to_s + "\n", value2.to_s + "\n")) # "Key value mismatch : #{key} in path #{context.join(".")}"
end
end
View
16 spec/lib/yamldiff_spec.rb
@@ -117,5 +117,21 @@
result[second].first.key.should eql("bar")
result[second].first.context.should eql(["en", "baz"])
end
+
+ it "diffs the output when the values are different and passes diff to error" do
+ first = "./en.yml"
+ second = "./es.yml"
+ File.open(first, "w") do |f|
+ f.puts("en: ")
+ f.puts(" app_name: 'Verbosefish'")
+ end
+ File.open(second, "w") do |f|
+ f.puts("en: ")
+ f.puts(" app_name: 'Verboszefish'")
+ end
+ Diffy::Diff.expects(:new).with("Verbosefish\n", "Verboszefish\n").returns("DIFF")
+ YamldiffKeyValueError.expects(:new).with('app_name', ['en'], 'DIFF')
+ result = subject.diff_yaml(first, second)
+ end
end
end

0 comments on commit 78d525e

Please sign in to comment.
Something went wrong with that request. Please try again.