File: list_option_test.rb

package info (click to toggle)
ruby-json-schema 2.8.1-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 836 kB
  • sloc: ruby: 5,805; makefile: 10
file content (21 lines) | stat: -rw-r--r-- 615 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
require File.expand_path('../support/test_helper', __FILE__)

class ListOptionTest < Minitest::Test
  def test_list_option_reusing_schemas
    schema_hash = {
      "$schema" => "http://json-schema.org/draft-04/schema#",
      "type" => "object",
      "properties" => { "a" => { "type" => "integer" } }
    }

    uri = Addressable::URI.parse('http://example.com/item')
    schema = JSON::Schema.new(schema_hash, uri)
    JSON::Validator.add_schema(schema)

    data = {"a" => 1}
    assert_valid uri.to_s, data, clear_cache: false

    data = [{"a" => 1}]
    assert_valid uri.to_s, data, :list => true
  end
end