Sha256: 89366eb7dce98a57ff0cc67cc050579e2494a2b8f9ae0a459f816ee9e073698e

Contents?: true

Size: 1.18 KB

Versions: 59

Compression:

Stored size: 1.18 KB

Contents

require "test_helper"

require "json_reference"

describe JsonReference::Reference do
  it "expands a reference without a URI" do
    ref = reference("#/definitions")
    assert_equal nil, ref.uri
    assert_equal "#/definitions", ref.pointer
  end

  it "expands a reference with a URI" do
    ref = reference("http://example.com#/definitions")
    assert_equal URI.parse("http://example.com"), ref.uri
    assert_equal "#/definitions", ref.pointer
  end

  it "expands just a root sign" do
    ref = reference("#")
    assert_equal nil, ref.uri
    assert_equal "#", ref.pointer
  end

  it "expands a URI with just a root sign" do
    ref = reference("http://example.com#")
    assert_equal URI.parse("http://example.com"), ref.uri
    assert_equal "#", ref.pointer
  end

  it "normalizes pointers by adding a root sign prefix" do
    ref = reference("/definitions")
    assert_equal nil, ref.uri
    assert_equal "#/definitions", ref.pointer
  end

  it "normalizes pointers by stripping a trailing slash" do
    ref = reference("#/definitions/")
    assert_equal nil, ref.uri
    assert_equal "#/definitions", ref.pointer
  end

  def reference(str)
    JsonReference::Reference.new(str)
  end
end

Version data entries

59 entries across 59 versions & 1 rubygems

Version Path
json_schema-0.17.2 test/json_reference/reference_test.rb
json_schema-0.17.1 test/json_reference/reference_test.rb
json_schema-0.17.0 test/json_reference/reference_test.rb
json_schema-0.16.2 test/json_reference/reference_test.rb
json_schema-0.16.1 test/json_reference/reference_test.rb
json_schema-0.16.0 test/json_reference/reference_test.rb
json_schema-0.15.0 test/json_reference/reference_test.rb
json_schema-0.14.4 test/json_reference/reference_test.rb
json_schema-0.14.3 test/json_reference/reference_test.rb
json_schema-0.14.1 test/json_reference/reference_test.rb
json_schema-0.14.0 test/json_reference/reference_test.rb
json_schema-0.13.6 test/json_reference/reference_test.rb
json_schema-0.13.5 test/json_reference/reference_test.rb
json_schema-0.13.4 test/json_reference/reference_test.rb
json_schema-0.13.3 test/json_reference/reference_test.rb
json_schema-0.13.2 test/json_reference/reference_test.rb
json_schema-0.13.0 test/json_reference/reference_test.rb
json_schema-0.12.5 test/json_reference/reference_test.rb
json_schema-0.12.4 test/json_reference/reference_test.rb
json_schema-0.12.3 test/json_reference/reference_test.rb