Sha256: 013010b0ba180e7d8f6af781bb4eae625556fa95c46a281de5a5ef35036890d2
Contents?: true
Size: 1.68 KB
Versions: 2
Compression:
Stored size: 1.68 KB
Contents
require 'test/unit' require File.expand_path('../../lib/json-schema', __FILE__) class CommonTestSuiteTest < Test::Unit::TestCase TEST_DIR = File.expand_path('../test-suite/tests', __FILE__) # These are test files which we know fail spectacularly, either because # we don't support that functionality or because they require external # dependencies IGNORED_TESTS = [ "draft3/disallow.json", "draft3/optional/format.json", "draft3/optional/jsregex.json", "draft3/refRemote.json", "draft4/optional/format.json", "draft4/refRemote.json", ] Dir["#{TEST_DIR}/*"].each do |suite| version = File.basename(suite).to_sym Dir["#{suite}/**/*.json"].each do |tfile| test_list = JSON::Validator.parse(File.read(tfile)) rel_file = tfile[TEST_DIR.length+1..-1] test_list.each do |test| schema = test["schema"] base_description = test["description"] v = nil test["tests"].each do |t| err_id = "#{rel_file}: #{base_description}/#{t['description']}" unless IGNORED_TESTS.include?(rel_file) define_method("test_#{err_id}") do assert_nothing_raised("Exception raised running #{err_id}") do v = JSON::Validator.fully_validate(schema, t["data"], :validate_schema => true, :version => version ) end assert_equal t["valid"], v.empty?, "Common test suite case failed: #{err_id}\n#{v}" end end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
json-schema-2.4.1 | test/test_common_test_suite.rb |
json-schema-2.4.0 | test/test_common_test_suite.rb |