Sha256: 987db0efeabfb7a04d20e666cdf4505a47ba957049383585691abbf183ce60e3

Contents?: true

Size: 1.15 KB

Versions: 8

Compression:

Stored size: 1.15 KB

Contents

module Finitio
  module JsonSchema
    describe "MultiTupleType" do

      context 'with a true allow extra and some optional attribute' do
        let(:heading){
          Heading.new([
            Attribute.new(:a, anyType),
            Attribute.new(:b, anyType, false),
          ], allow_extra: true)
        }

        let(:multi_tuple_type) {
          MultiTupleType.new(heading)
        }

        it 'works as expected' do
          expect(multi_tuple_type.to_json_schema).to eql({
            type: "object",
            properties: {
              a: {},
              b: {}
            },
            required: [:a],
            additionalProperties: {}
          })
        end
      end

      context 'with a allow extra requiring Strings' do
        let(:heading){
          Heading.new([
          ], allow_extra: BuiltinType.new(String))
        }

        let(:multi_tuple_type) {
          MultiTupleType.new(heading)
        }

        it 'works as expected' do
          expect(multi_tuple_type.to_json_schema).to eql({
            type: "object",
            additionalProperties: { type: "string" }
          })
        end
      end

    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
finitio-0.12.0 spec/json_schema/test_multi_tuple_type.rb
finitio-0.11.4 spec/json_schema/test_multi_tuple_type.rb
finitio-0.11.3 spec/json_schema/test_multi_tuple_type.rb
finitio-0.11.2 spec/json_schema/test_multi_tuple_type.rb
finitio-0.11.1 spec/json_schema/test_multi_tuple_type.rb
finitio-0.10.0 spec/json_schema/test_multi_tuple_type.rb
finitio-0.9.1 spec/json_schema/test_multi_tuple_type.rb
finitio-0.9.0 spec/json_schema/test_multi_tuple_type.rb