From dca2925461ce17540d0fdf3171868ce025f286ac Mon Sep 17 00:00:00 2001 From: Michael Miller Date: Fri, 22 Mar 2019 21:43:33 -0600 Subject: [PATCH] Simplify to_json calls --- src/spectator/errored_result.cr | 2 +- src/spectator/expectations/expectation.cr | 6 +++--- src/spectator/finished_result.cr | 2 +- src/spectator/result.cr | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/spectator/errored_result.cr b/src/spectator/errored_result.cr index e930cb3..00c73ff 100644 --- a/src/spectator/errored_result.cr +++ b/src/spectator/errored_result.cr @@ -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 diff --git a/src/spectator/expectations/expectation.cr b/src/spectator/expectations/expectation.cr index 15be4b7..d370063 100644 --- a/src/spectator/expectations/expectation.cr +++ b/src/spectator/expectations/expectation.cr @@ -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| diff --git a/src/spectator/finished_result.cr b/src/spectator/finished_result.cr index 88e3058..068719e 100644 --- a/src/spectator/finished_result.cr +++ b/src/spectator/finished_result.cr @@ -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 diff --git a/src/spectator/result.cr b/src/spectator/result.cr index 9c524a2..c2f0b45 100644 --- a/src/spectator/result.cr +++ b/src/spectator/result.cr @@ -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