Skip to content

Commit

Permalink
add test for validate_json
Browse files Browse the repository at this point in the history
  • Loading branch information
Ethan committed Apr 8, 2012
1 parent 91900d8 commit 38767ab
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions test/test_files.rb
Expand Up @@ -20,6 +20,14 @@ def test_data_from_file
assert(!JSON::Validator.validate_uri(schema,File.join(File.dirname(__FILE__),"data/bad_data_1.json")))
end

def test_data_from_json
if JSON::Validator.json_backend != nil
schema = {"type" => "object", "properties" => {"a" => {"type" => "integer"}}}
assert(JSON::Validator.validate_json(schema, %Q({"a" : 5})))
assert(!JSON::Validator.validate_json(schema, %Q({"a" : "poop"})))
end
end

def test_both_from_file
assert(JSON::Validator.validate_uri(File.join(File.dirname(__FILE__),"schemas/good_schema_1.json"),File.join(File.dirname(__FILE__),"data/good_data_1.json")))
assert(!JSON::Validator.validate_uri(File.join(File.dirname(__FILE__),"schemas/good_schema_1.json"),File.join(File.dirname(__FILE__),"data/bad_data_1.json")))
Expand Down

0 comments on commit 38767ab

Please sign in to comment.