Sha256: 349369df4c892e0d5c565a2906955cb20a7038fbe1b920e8a62c62d9440c653e

Contents?: true

Size: 801 Bytes

Versions: 3

Compression:

Stored size: 801 Bytes

Contents

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

class BadSchemaRefTest < Test::Unit::TestCase

  def test_bad_uri_ref
    schema = {
        "$schema" => "http://json-schema.org/draft-04/schema#",
        "type" => "array",
        "items" => { "$ref" => "../google.json"}
    }

    data = [1,2,3]
    assert_raise(URI::BadURIError) do
      JSON::Validator.validate(schema,data)
    end
  end

  def test_bad_host_ref
    schema = {
        "$schema" => "http://json-schema.org/draft-04/schema#",
        "type" => "array",
        "items" => { "$ref" => "http://ppcheesecheseunicornnuuuurrrrr.com/json.schema"}
    }

    data = [1,2,3]
    assert_raise(SocketError, OpenURI::HTTPError) do
      JSON::Validator.validate(schema,data)
    end
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
json-schema-2.4.1 test/test_bad_schema_ref.rb
json-schema-2.4.0 test/test_bad_schema_ref.rb
json-schema-2.3.0 test/test_bad_schema_ref.rb