Sha256: 92fbfd25ce3c2b832dbdddb6c6fea3ab6cb82d4753799bbe0f5d49046c6b177f
Contents?: true
Size: 1.14 KB
Versions: 2
Compression:
Stored size: 1.14 KB
Contents
require File.expand_path('../support/test_helper', __FILE__) class CachingTestTest < Minitest::Test def setup @schema = Tempfile.new(['schema', '.json']) end def teardown @schema.close @schema.unlink JSON::Validator.clear_cache end def test_caching set_schema('type' => 'string') assert_valid(schema_path, 'foo', :clear_cache => false) set_schema('type' => 'number') refute_valid(schema_path, 123) end def test_clear_cache set_schema('type' => 'string') assert_valid(schema_path, 'foo', :clear_cache => true) set_schema('type' => 'number') assert_valid(schema_path, 123) end def test_cache_schemas suppress_warnings do JSON::Validator.cache_schemas = false end set_schema('type' => 'string') assert_valid(schema_path, 'foo', :clear_cache => false) set_schema('type' => 'number') assert_valid(schema_path, 123) ensure suppress_warnings do JSON::Validator.cache_schemas = true end end private def schema_path @schema.path end def set_schema(schema_definition) @schema.write(schema_definition.to_json) @schema.rewind end end
Version data entries
2 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mountapi-0.11.1 | vendor/bundle/ruby/2.7.0/bundler/gems/json-schema-2253a5ee6679/test/caching_test.rb |
mountapi-0.11.1 | vendor/json-schema/test/caching_test.rb |