Sha256: a966f07ea4aac5343587c5a7280279330bc35e3b86e219f4be282dd9e5968cc4

Contents?: true

Size: 955 Bytes

Versions: 2

Compression:

Stored size: 955 Bytes

Contents

require File.expand_path('../test_helper', __FILE__)
require 'json-schema'

class FragmentValidationWithRef < Test::Unit::TestCase
  def whole_schema
    {
      "$schema" => "http://json-schema.org/draft-04/schema#",
      "type" => "object",
      "definitions" => {
        "post" => {
          "type" => "object",
          "properties" => {
            "content" => {
              "type" => "string"
            },
            "author" => {
              "type" => "string"
            }
          }
        },
        "posts" => {
          "type" => "array",
          "items" => {
            "$ref" => "#/definitions/post"
          }
        }
      }
    }
  end

  def test_validation_of_fragment
    data = [{"content" => "ohai", "author" => "Bob"}]
    v = nil
    assert_nothing_raised do
      v = JSON::Validator.fully_validate(whole_schema,data,:fragment => "#/definitions/posts")
    end

    assert(v.empty?, v.join("\n"))
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
json-schema-2.4.1 test/test_fragment_validation_with_ref.rb
json-schema-2.4.0 test/test_fragment_validation_with_ref.rb