Sha256: 0f796d353f10c93bd0ddb1f9d57425183dcce3aca1e47e8f61109f0ccf0ad02c

Contents?: true

Size: 1.66 KB

Versions: 2

Compression:

Stored size: 1.66 KB

Contents

# coding: utf-8
require File.expand_path('../support/test_helper', __FILE__)

class UriParsingTest < Minitest::Test
  def test_asian_characters
    schema = {
      "$schema"=> "http://json-schema.org/draft-04/schema#",
      "id"=> "http://俺:鍵@例え.テスト/p?条件#ここ#",
      "type" => "object",
      "required" => ["a"],
      "properties" => {
        "a" => {
          "id" => "a",
          "type" => "integer"
        }
      }
    }
    data = { "a" => 5 }
    assert_valid schema, data
  end

  def test_schema_ref_with_empty_fragment
    schema = {
      "$schema" => "http://json-schema.org/draft-04/schema#",
      "type" => "object",
      "required" => ["names"],
      "properties"=> {
        "names"=> {
          "type"=> "array",
          "items"=> {
            "anyOf"=> [
              { "$ref" => "test/schemas/ref john with spaces schema.json#" },
            ]
          }
        }
      }
    }
    data = {"names" => [{"first" => "john"}]}
    assert_valid schema, data
  end

  def test_schema_ref_from_file_with_spaces
    schema = {
      "$schema" => "http://json-schema.org/draft-04/schema#",
      "type" => "object",
      "required" => ["names"],
      "properties"=> {
        "names"=> {
          "type"=> "array",
          "items"=> {
            "anyOf"=> [
              { "$ref" => "test/schemas/ref john with spaces schema.json" }
            ]
          }
        }
      }
    }
    data = {"names" => [{"first" => "john"}]}
    assert_valid schema, data
  end

  def test_schema_from_file_with_spaces
    data = {"first" => "john"}
    schema = "test/schemas/ref john with spaces schema.json"
    assert_valid schema, data
  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/uri_parsing_test.rb
mountapi-0.11.1 vendor/json-schema/test/uri_parsing_test.rb