Sha256: 88761ebd10aa3dbcb23db0a13168f0938b76387bed226ea44cfe0fd2ee30a64a

Contents?: true

Size: 1.02 KB

Versions: 10

Compression:

Stored size: 1.02 KB

Contents

require 'spec_helper'

describe Apipie::Generator::Swagger::TypeExtractor do
  let(:extractor) { described_class.new(validator) }

  shared_examples 'extractable method' do
    let(:warnings) { {} }
    let(:validator) {}

    it { is_expected.to eq(Apipie::Generator::Swagger::TypeExtractor::TYPES[:string]) }

    context "when enum validator is used" do
      let(:enum_values) { ["Name"] }

      context "of type Apipie::Validator::EnumValidator" do
        let(:validator) { Apipie::Validator::EnumValidator.new(nil, enum_values) }

        it { is_expected.to eq("enum") }
      end

      context "that responds to is_enum?" do
        let(:validator) do
          Apipie::ResponseDescriptionAdapter::PropDesc::Validator.new('some-type', enum_values)
        end

        it 'returns an enum type' do
          expect(subject).to eq(Apipie::Generator::Swagger::TypeExtractor::TYPES[:enum])
        end
      end
    end
  end

  describe '#extract' do
    subject { extractor.extract }

    it_behaves_like 'extractable method'
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
apipie-rails-1.4.2 spec/lib/apipie/generator/swagger/type_extractor_spec.rb
apipie-rails-1.4.1 spec/lib/apipie/generator/swagger/type_extractor_spec.rb
apipie-rails-1.4.0 spec/lib/apipie/generator/swagger/type_extractor_spec.rb
apipie-rails-1.3.0 spec/lib/apipie/generator/swagger/type_extractor_spec.rb
apipie-rails-1.2.3 spec/lib/apipie/generator/swagger/type_extractor_spec.rb
apipie-rails-1.2.2 spec/lib/apipie/generator/swagger/type_extractor_spec.rb
apipie-rails-1.2.1 spec/lib/apipie/generator/swagger/type_extractor_spec.rb
apipie-rails-1.2.0 spec/lib/apipie/generator/swagger/type_extractor_spec.rb
apipie-rails-1.1.0 spec/lib/apipie/generator/swagger/type_extractor_spec.rb
apipie-rails-1.0.0 spec/lib/apipie/generator/swagger/type_extractor_spec.rb