Sha256: 65ffc2c09ef4d759e1917f523e3eec65cf48e6e3d732be66e76d6d7cfb19bb14

Contents?: true

Size: 876 Bytes

Versions: 4

Compression:

Stored size: 876 Bytes

Contents

require File.expand_path('../test_helper', __FILE__)
require 'socket'


class BadSchemaRefTest < Minitest::Test
  def setup
    WebMock.allow_net_connect!
  end

  def teardown
    WebMock.disable_net_connect!
  end

  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_raises(Errno::ENOENT) 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.example.invalid/json.schema"}
    }

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

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
json-schema-openc-fork-0.0.2 test/test_bad_schema_ref.rb
json-schema-2.5.1 test/test_bad_schema_ref.rb
json-schema-openc-fork-0.0.1 test/test_bad_schema_ref.rb
json-schema-2.5.0 test/test_bad_schema_ref.rb