Sha256: cf3cfb30f5b5948b476e27bc6da8519004b275e040c9df57ee012b83c7ff250f

Contents?: true

Size: 716 Bytes

Versions: 11

Compression:

Stored size: 716 Bytes

Contents

require 'test/unit'
require File.dirname(__FILE__) + '/../lib/json-schema'

class RubySchemaTest < Test::Unit::TestCase
  def test_string_keys
    schema = {
      "type" => 'object',
      "required" => ["a"],
      "properties" => {
        "a" => {"type" => "integer", "default" => 42},
        "b" => {"type" => "integer"}
      }
    }

    data = {
      "a" => 5
    }

    assert(JSON::Validator.validate(schema, data))
  end

  def test_symbol_keys
    schema = {
      type: 'object',
      required: ["a"],
      properties: {
        a: {type: "integer", default: 42},
        b: {type: "integer"}
      }
    }

    data = {
      a: 5
    }

    assert(JSON::Validator.validate(schema, data))
  end
end

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
json-schema-pvdgm-2.3.1 test/test_ruby_schema.rb
json-schema-2.2.2 test/test_ruby_schema.rb
json-schema-2.2.1 test/test_ruby_schema.rb
json-schema-2.2.0 test/test_ruby_schema.rb
json-schema-2.1.9 test/test_ruby_schema.rb
json-schema-2.1.8 test/test_ruby_schema.rb
json-schema-2.1.7 test/test_ruby_schema.rb
json-schema-2.1.5 test/test_ruby_schema.rb
json-schema-2.1.4 test/test_ruby_schema.rb
json-schema-2.1.3 test/test_ruby_schema.rb
json-schema-2.1.2 test/test_ruby_schema.rb