Sha256: f5388e287d35d765d062609e26754dbf9c96c50f2863ec1e70619e79fe332cf3

Contents?: true

Size: 859 Bytes

Versions: 16

Compression:

Stored size: 859 Bytes

Contents

require 'test/unit'
require File.dirname(__FILE__) + '/../lib/json-schema'

class FragmentResolution < Test::Unit::TestCase
  def test_fragment_resolution
    schema = {
      "$schema" => "http://json-schema.org/draft-04/schema#",
      "required" => ["a"],
      "properties" => {
        "a" => {
          "type" => "object",
          "properties" => {
            "b" => {"type" => "integer" }
          }
        }
      }
    }

    data = {"b" => 5}
    assert(!JSON::Validator.validate(schema,data))
    assert(JSON::Validator.validate(schema,data,:fragment => "#/properties/a"))

    assert_raise JSON::Schema::SchemaError do
      JSON::Validator.validate!(schema,data,:fragment => "/properties/a")
    end

    assert_raise JSON::Schema::SchemaError do
      JSON::Validator.validate!(schema,data,:fragment => "#/properties/b")
    end
  end
end

Version data entries

16 entries across 16 versions & 2 rubygems

Version Path
json-schema-2.4.1 test/test_fragment_resolution.rb
json-schema-2.4.0 test/test_fragment_resolution.rb
json-schema-2.3.0 test/test_fragment_resolution.rb
json-schema-2.2.5 test/test_fragment_resolution.rb
json-schema-pvdgm-2.3.1 test/test_fragment_resolution.rb
json-schema-2.2.4 test/test_fragment_resolution.rb
json-schema-2.2.3 test/test_fragment_resolution.rb
json-schema-2.2.2 test/test_fragment_resolution.rb
json-schema-2.2.1 test/test_fragment_resolution.rb
json-schema-2.2.0 test/test_fragment_resolution.rb
json-schema-2.1.9 test/test_fragment_resolution.rb
json-schema-2.1.8 test/test_fragment_resolution.rb
json-schema-2.1.7 test/test_fragment_resolution.rb
json-schema-2.1.6 test/test_fragment_resolution.rb
json-schema-2.1.5 test/test_fragment_resolution.rb
json-schema-2.1.4 test/test_fragment_resolution.rb