Sha256: 636a9e2fb65b07214542f65665746c73213f3b3613c4500169ad3b57c1f068d4

Contents?: true

Size: 990 Bytes

Versions: 4

Compression:

Stored size: 990 Bytes

Contents

module Finitio
  module JsonSchema
    describe "BuiltinType" do

      let(:builtin_type) {
        BuiltinType.new(ruby_type)
      }

      subject {
        builtin_type.to_json_schema
      }

      context 'with NilClass' do
        let(:ruby_type){ NilClass }

        it 'works' do
          expect(subject).to eql({ type: "null" })
        end
      end

      context 'with String' do
        let(:ruby_type){ String }

        it 'works' do
          expect(subject).to eql({ type: "string" })
        end
      end

      [Fixnum, Bignum, Integer].each do |rt|
        context "with #{rt}" do
          let(:ruby_type){ rt }

          it 'works' do
            expect(subject).to eql({ type: "integer" })
          end
        end
      end

      [Float, Numeric].each do |rt|
        context "with #{rt}" do
          let(:ruby_type){ rt }

          it 'works' do
            expect(subject).to eql({ type: "number" })
          end
        end
      end

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
finitio-0.11.1 spec/json_schema/test_builtin_type.rb
finitio-0.10.0 spec/json_schema/test_builtin_type.rb
finitio-0.9.1 spec/json_schema/test_builtin_type.rb
finitio-0.9.0 spec/json_schema/test_builtin_type.rb