Sha256: 8ed0093fe3300e96d9c4d939fc6f70a7c5ecd9c4be7d0b2d409eb6dd9515d96b

Contents?: true

Size: 1.39 KB

Versions: 2

Compression:

Stored size: 1.39 KB

Contents

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

class ExtendsNestedTest < Minitest::Test
  ADDITIONAL_PROPERTIES = ['extends_and_additionalProperties_false_schema.json']
  PATTERN_PROPERTIES = ['extends_and_patternProperties_schema.json']

  ALL_SCHEMAS = ADDITIONAL_PROPERTIES + PATTERN_PROPERTIES

  def test_valid_outer
    ALL_SCHEMAS.each do |file|
      path = schema_fixture_path(file)
      assert_valid path, { "outerC" => true }, {}, "Outer defn is broken, maybe the outer extends overrode it"
    end
  end

  def test_valid_outer_extended
    ALL_SCHEMAS.each do |file|
      path = schema_fixture_path(file)
      assert_valid path, { "innerA" => true }, {}, "Extends at the root level isn't working"
    end
  end

  def test_valid_inner
    ALL_SCHEMAS.each do |file|
      path = schema_fixture_path(file)
      assert_valid path, { "outerB" => [{ "innerA" => true }] }, {}, "Extends isn't working in the array element defn"
    end
  end

  def test_invalid_inner
    ALL_SCHEMAS.each do |file|
      path = schema_fixture_path(file)
      refute_valid path, { "outerB" => [{ "whaaaaat" => true }] }, {}, "Array element defn allowing anything when it should only allow what's in inner.schema"
    end
  end

  def test_invalid_outer
    path = schema_fixture_path(ADDITIONAL_PROPERTIES)
    refute_valid path, { "whaaaaat" => true }, {}, "Outer defn allowing anything when it shouldn't"
  end
end

Version data entries

2 entries across 1 versions & 1 rubygems

Version Path
mountapi-0.11.1 vendor/bundle/ruby/2.7.0/bundler/gems/json-schema-2253a5ee6679/test/extends_nested_test.rb
mountapi-0.11.1 vendor/json-schema/test/extends_nested_test.rb