Sha256: 27676dd855840a45559804768789a6ae759e7bf227f6b8e3bb2a7212f8f82a10

Contents?: true

Size: 1.37 KB

Versions: 4

Compression:

Stored size: 1.37 KB

Contents

require_relative 'helpers'

class SchemaTest < Minitest::Test
  def test_dereference_with_ref
    key, value = user_input_schema.dereference(
      '$ref' => '#/definitions/user/definitions/id'
    )
    assert_equal(key,   '#/definitions/user/definitions/id')
    user_id = user_input_schema['definitions']['user']['definitions']['id']
    assert_equal(value, user_id)
  end

  def test_dereference_without_ref
    key, value = user_input_schema.dereference(
      '#/definitions/user/definitions/id'
    )
    assert_equal(key,   '#/definitions/user/definitions/id')
    user_id = user_input_schema['definitions']['user']['definitions']['id']
    assert_equal(value, user_id)
  end

  def test_dereference_with_nested_ref
    key, value = user_input_schema.dereference(
      '$ref' => '#/definitions/user/definitions/identity'
    )
    assert_equal(key,   '#/definitions/user/definitions/id')
    user_id = user_input_schema['definitions']['user']['definitions']['id']
    assert_equal(value, user_id)
  end

  def test_dereference_with_local_context
    key, value = user_input_schema.dereference(
      '$ref'     => '#/definitions/user/properties/id',
      'override' => true
    )
    assert_equal(key,   '#/definitions/user/definitions/id')
    user_id = user_input_schema['definitions']['user']['definitions']['id']
    assert_equal(value, { 'override' => true }.merge(user_id))
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
prmd-0.14.0 test/schema_test.rb
prmd-0.13.0 test/schema_test.rb
prmd-0.12.0 test/schema_test.rb
prmd-0.11.11 test/schema_test.rb