lib/json_matchers/matcher.rb in json_matchers-0.6.2 vs lib/json_matchers/matcher.rb in json_matchers-0.6.3

- old
+ new

@@ -1,6 +1,7 @@ require "json-schema" +require "json_matchers/payload" module JsonMatchers class Matcher def initialize(schema_path, options = {}) @schema_path = schema_path @@ -8,11 +9,11 @@ end def matches?(response) JSON::Validator.validate!( schema_path.to_s, - json_from(response).to_s, + Payload.new(response).to_s, options, ) rescue JSON::Schema::ValidationError => ex @validation_failure_message = ex.message false @@ -25,17 +26,9 @@ end private attr_reader :schema_path, :options - - def json_from(response) - if response.respond_to?(:body) - response.body - else - response - end - end def default_options JsonMatchers.configuration.options || {} end end