Sha256: c30b5a5e8c89204bca3e1f8e09e72a899c4412fd019161a0bc6d47b9fe56f6d4

Contents?: true

Size: 780 Bytes

Versions: 8

Compression:

Stored size: 780 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) do
      JSON::Validator.validate(schema,data)
    end
  end

end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
json-schema-2.2.5 test/test_bad_schema_ref.rb
json-schema-pvdgm-2.3.1 test/test_bad_schema_ref.rb
json-schema-2.2.4 test/test_bad_schema_ref.rb
json-schema-2.2.3 test/test_bad_schema_ref.rb
json-schema-2.2.2 test/test_bad_schema_ref.rb
json-schema-2.2.1 test/test_bad_schema_ref.rb
json-schema-2.2.0 test/test_bad_schema_ref.rb
json-schema-2.1.9 test/test_bad_schema_ref.rb