Permalink
Browse files

Easier to read key names

  • Loading branch information...
1 parent 78d525e commit 438285c0fb22c2ff73a7de81216bc162f375f64a @chrismcg committed Jun 11, 2012
Showing with 7 additions and 7 deletions.
  1. +3 −3 lib/yamldiff/yamldiff_error.rb
  2. +4 −4 spec/lib/yamldiff_error_spec.rb
View
6 lib/yamldiff/yamldiff_error.rb
@@ -8,13 +8,13 @@ def initialize(key, context)
class YamldiffKeyError < YamldiffError
def to_s
- "Missing key: #{@key} in path #{@context.join(".")}"
+ "Missing key: #{@context.join(".")}.#{@key}"
end
end
class YamldiffKeyValueTypeError < YamldiffError
def to_s
- "Key value type mismatch: #{@key} in path #{@context.join(".")}"
+ "Key value type mismatch: #{@context.join(".")}.#{@key}"
end
end
@@ -26,7 +26,7 @@ def initialize(key, context, diff = nil)
def to_s
output = []
- output << "Key value mismatch: #{@key} in path #{@context.join(".")}"
+ output << "Key content differs: #{@context.join(".")}.#{@key}"
if @diff
output << "Diff:"
output << @diff
View
8 spec/lib/yamldiff_error_spec.rb
@@ -2,27 +2,27 @@
describe YamldiffKeyError, "#to_s" do
it "outputs human readable text" do
- YamldiffKeyError.new('key', ['root', 'namespace']).to_s.should == "Missing key: key in path root.namespace"
+ YamldiffKeyError.new('key', ['root', 'namespace']).to_s.should == "Missing key: root.namespace.key"
end
end
describe YamldiffKeyValueTypeError, "#to_s" do
it "outputs human readable text" do
- YamldiffKeyValueTypeError.new('key', ['root', 'namespace']).to_s.should == "Key value type mismatch: key in path root.namespace"
+ YamldiffKeyValueTypeError.new('key', ['root', 'namespace']).to_s.should == "Key value type mismatch: root.namespace.key"
end
end
describe YamldiffKeyValueError, "#to_s" do
it "outputs human readable text" do
- YamldiffKeyValueError.new('key', ['root', 'namespace']).to_s.should == "Key value mismatch: key in path root.namespace"
+ YamldiffKeyValueError.new('key', ['root', 'namespace']).to_s.should == "Key content differs: root.namespace.key"
end
it "outputs diff if given" do
str1 = "foo\n"
str2 = "bar\n"
diff = Diffy::Diff.new(str1, str2)
YamldiffKeyValueError.new('key', ['root', 'namespace'], diff).to_s.should == <<-OUTPUT
-Key value mismatch: key in path root.namespace
+Key content differs: root.namespace.key
Diff:
-foo
+bar

0 comments on commit 438285c

Please sign in to comment.