Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #127 from mpalmer/fragment-validation-with-ref
Make intra-doc refs work when validating with :fragment
- Loading branch information
Showing
3 changed files
with
46 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
require 'test/unit' | ||
$:.unshift(File.expand_path('../../lib', __FILE__)) |