Sha256: 9195017497999ae99bc8e7564ad5881209a9bca3503471863c73504cbce0937b

Contents?: true

Size: 1.43 KB

Versions: 2

Compression:

Stored size: 1.43 KB

Contents

require File.expand_path(File.join(File.dirname(__FILE__), 'helpers'))

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

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

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

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
prmd-0.3.1 test/schema_test.rb
prmd-0.3.0 test/schema_test.rb