Sha256: 8001b2175717f4c3919dc7eb6ab054635316e4b0798856202c72c74847732809

Contents?: true

Size: 384 Bytes

Versions: 3

Compression:

Stored size: 384 Bytes

Contents

require "json-schema"

module JSON
  module Matchers
    Matcher = Struct.new(:schema_path) do
      def matches?(response)
        @response = response

        JSON::Validator.validate!(schema_path.to_s, response.body, strict: true)
      rescue JSON::Schema::ValidationError
        false
      rescue JSON::ParserError
        raise InvalidSchemaError
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
json-matchers-0.2.1 lib/json/matchers/matcher.rb
json-matchers-0.2.0 lib/json/matchers/matcher.rb
json-matchers-0.1.0 lib/json/matchers/matcher.rb