lib/json_matchers/rspec.rb in json_matchers-0.6.0 vs lib/json_matchers/rspec.rb in json_matchers-0.6.1

- old
+ new

@@ -9,40 +9,44 @@ super(JsonMatchers::Matcher.new(schema_path, options)) end def failure_message(response) - <<-FAIL.strip_heredoc - expected + <<-FAIL +#{validation_failure_message} - #{response.body} +--- - to match schema "#{schema_name}": +expected - #{schema_body} +#{pretty_json(response.body)} - --- +to match schema "#{schema_name}": - #{validation_failure_message} +#{pretty_json(schema_body)} FAIL end def failure_message_when_negated(response) - <<-FAIL.strip_heredoc - expected + <<-FAIL +#{validation_failure_message} - #{response.body} +--- - not to match schema "#{schema_name}": +expected - #{schema_body} +#{pretty_json(response.body)} - --- +not to match schema "#{schema_name}": - #{validation_failure_message} +#{pretty_json(schema_body)} FAIL + end + + def pretty_json(json_string) + JSON.pretty_generate(JSON.parse(json_string.to_s)) end def schema_path JsonMatchers.path_to_schema(schema_name) end