Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/yamldiff/yamldiff.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def compare_hashes(first, second, context = [])

value2 = second[key]
if (value.class != value2.class)
errors << YamldiffKeyValueTypeError.new(key, context)
errors << YamldiffKeyValueError.new(key, context, Diffy::Diff.new(value.to_s + "\n", value2.to_s + "\n"))
next
end

Expand Down
6 changes: 0 additions & 6 deletions lib/yamldiff/yamldiff_error.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,6 @@ def to_s
end
end

class YamldiffKeyValueTypeError < YamldiffError
def to_s
"Key value type mismatch: #{path}"
end
end

class YamldiffKeyValueError < YamldiffError
attr_reader :diff

Expand Down
8 changes: 0 additions & 8 deletions spec/lib/yamldiff_error_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,6 @@
end
end

describe YamldiffKeyValueTypeError, "#to_s" do
subject(:key_value_type_error) { YamldiffKeyValueTypeError.new('key', ['root', 'namespace']) }

it "outputs human readable text" do
expect(key_value_type_error.to_s).to eql "Key value type mismatch: root.namespace.key"
end
end

describe YamldiffKeyValueError, "#to_s" do
context "without a diff" do
subject(:key_value_error) { YamldiffKeyValueError.new('key', ['root', 'namespace']) }
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/yamldiff_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
second = { a: "1" }
result = subject.compare_hashes(first, second).first

expect(result).to be_an_instance_of(YamldiffKeyValueTypeError)
expect(result).to be_an_instance_of(YamldiffKeyValueError)
expect(result.key).to eql :a
expect(result.context).to be_empty
end
Expand Down