Simplify to_json calls

This commit is contained in:
Michael Miller 2019-03-22 21:43:33 -06:00
parent 09b6dee004
commit dca2925461
4 changed files with 7 additions and 7 deletions

View file

@ -43,7 +43,7 @@ module Spectator
json.object do
json.field("type", error.class.to_s)
json.field("message", error.message)
json.field("backtrace") { error.backtrace.to_json(json) }
json.field("backtrace", error.backtrace)
end
end
end

View file

@ -44,9 +44,9 @@ module Spectator::Expectations
# Creates the JSON representation of the expectation.
def to_json(json : ::JSON::Builder)
json.object do
json.field("satisfied") { satisfied?.to_json(json) }
json.field("expected") { expected_message.to_json(json) }
json.field("actual") { actual_message.to_json(json) }
json.field("satisfied", satisfied?)
json.field("expected", expected_message)
json.field("actual", actual_message)
json.field("values") do
json.object do
values.each do |labeled_value|

View file

@ -21,7 +21,7 @@ module Spectator
private def add_json_fields(json : ::JSON::Builder)
super
json.field("time", elapsed.to_s)
json.field("expectations") { expectations.to_json(json) }
json.field("expectations", expectations)
end
end
end

View file

@ -32,8 +32,8 @@ module Spectator
# Adds the common fields for a result to a JSON builder.
private def add_json_fields(json : ::JSON::Builder)
json.field("name") { example.to_json(json) }
json.field("location") { example.source.to_json(json) }
json.field("name", example)
json.field("location", example.source)
json.field("result", to_s)
end
end