Skip to content

Commit

Permalink
Adding dependency testing
Browse files Browse the repository at this point in the history
  • Loading branch information
hoxworth committed Oct 24, 2011
1 parent 5ea2664 commit 490acf0
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions test/test_jsonschema_draft3.rb
Original file line number Diff line number Diff line change
Expand Up @@ -932,6 +932,41 @@ def test_schema
assert(JSON::Validator.validate(schema,data))
end

def test_dependency
schema = {
"type" => "object",
"properties" => {
"a" => {"type" => "integer"},
"b" => {"type" => "integer"}
},
"dependencies" => {
"a" => "b"
}
}

data = {"a" => 1, "b" => 2}
assert(JSON::Validator.validate(schema,data))
data = {"a" => 1}
assert(!JSON::Validator.validate(schema,data))

schema = {
"type" => "object",
"properties" => {
"a" => {"type" => "integer"},
"b" => {"type" => "integer"},
"c" => {"type" => "integer"}
},
"dependencies" => {
"a" => ["b","c"]
}
}

data = {"a" => 1, "c" => 2}
assert(!JSON::Validator.validate(schema,data))
data = {"a" => 1, "b" => 2, "c" => 3}
assert(JSON::Validator.validate(schema,data))
end


end

0 comments on commit 490acf0

Please sign in to comment.