at_path(path)
click to toggle source
def at_path(path)
@path = path
self
end
description()
click to toggle source
def description
message_with_path("equal JSON")
end
diffable?()
click to toggle source
excluding(*keys)
click to toggle source
def excluding(*keys)
excluded_keys.merge(keys.map(&:to_s))
self
end
failure_message()
click to toggle source
def failure_message
message_with_path("Expected equivalent JSON")
end
failure_message_for_should()
failure_message_for_should_not()
failure_message_when_negated()
click to toggle source
def failure_message_when_negated
message_with_path("Expected inequivalent JSON")
end
including(*keys)
click to toggle source
def including(*keys)
excluded_keys.subtract(keys.map(&:to_s))
self
end
matches?(actual_json)
click to toggle source
def matches?(actual_json)
raise "Expected equivalent JSON not provided" if @expected_json.nil?
@actual, @expected = scrub(actual_json, @path), scrub(@expected_json)
@actual == @expected
end
to_file(path)
click to toggle source
def to_file(path)
@expected_json = load_json(path)
self
end