Sha256: 3196ae3a74b1201e64449c784d6214d248053879536aa97f9202e2946583e380

Contents?: true

Size: 1.04 KB

Versions: 15

Compression:

Stored size: 1.04 KB

Contents

# encoding: utf-8

require 'spec_helper'

describe Axiom::Types, '.infer' do
  subject { object.infer(type) }

  let(:object) { described_class }

  before do
    object.finalize
  end

  Axiom::Types::Type.descendants.each do |descendant|
    context "when the type is #{descendant}" do
      let(:type) { descendant }

      it { should be(descendant) }
    end

    if descendant.equal?(Axiom::Types::Boolean)
      context 'when the type is TrueClass' do
        let(:type) { ::TrueClass }

        it { should be(descendant) }
      end

      context 'when the type is FalseClass' do
        let(:type) { ::FalseClass }

        it { should be(descendant) }
      end
    else
      primitive = descendant.primitive

      context "when the type is #{primitive}" do
        let(:type) { primitive }

        it { should be(descendant) }
      end
    end
  end

  context 'with a custom type' do
    let(:type) do
      Axiom::Types::String.new do
        minimum_length 1
        maximum_length 100
      end
    end

    it { should be(type) }
  end
end

Version data entries

15 entries across 13 versions & 4 rubygems

Version Path
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/axiom-types-0.1.1/spec/unit/axiom/types/class_methods/infer_spec.rb
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/axiom-types-0.1.1/spec/unit/axiom/types/class_methods/infer_spec.rb
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/axiom-types-0.1.1/spec/unit/axiom/types/class_methods/infer_spec.rb
grape-extra_validators-2.0.0 vendor/bundle/ruby/2.6.0/gems/axiom-types-0.1.1/spec/unit/axiom/types/class_methods/infer_spec.rb
grape-extra_validators-1.0.0 vendor/bundle/ruby/2.4.0/gems/axiom-types-0.1.1/spec/unit/axiom/types/class_methods/infer_spec.rb
config_gems_initialization_aim-0.1.4 vendor/bundle/ruby/2.5.0/gems/config_gems_initialization_aim-0.1.1/vendor/bundle/ruby/2.5.0/gems/axiom-types-0.1.1/spec/unit/axiom/types/class_methods/infer_spec.rb
config_gems_initialization_aim-0.1.4 vendor/bundle/ruby/2.5.0/gems/axiom-types-0.1.1/spec/unit/axiom/types/class_methods/infer_spec.rb
config_gems_initialization_aim-0.1.3 vendor/bundle/ruby/2.5.0/gems/config_gems_initialization_aim-0.1.1/vendor/bundle/ruby/2.5.0/gems/axiom-types-0.1.1/spec/unit/axiom/types/class_methods/infer_spec.rb
config_gems_initialization_aim-0.1.3 vendor/bundle/ruby/2.5.0/gems/axiom-types-0.1.1/spec/unit/axiom/types/class_methods/infer_spec.rb
axiom-types-0.1.1 spec/unit/axiom/types/class_methods/infer_spec.rb
axiom-types-0.1.0 spec/unit/axiom/types/class_methods/infer_spec.rb
axiom-types-0.0.5 spec/unit/axiom/types/class_methods/infer_spec.rb
axiom-types-0.0.4 spec/unit/axiom/types/class_methods/infer_spec.rb
axiom-types-0.0.3 spec/unit/axiom/types/class_methods/infer_spec.rb
axiom-types-0.0.2 spec/unit/axiom/types/class_methods/infer_spec.rb