Sha256: b57eb9382f894175f378d3bd7e7d9a52e8913e2d9dc28bf982d8667f3f2b8e69

Contents?: true

Size: 1.69 KB

Versions: 13

Compression:

Stored size: 1.69 KB

Contents

require 'spec_helper'

describe Apipie::Generator::Swagger::ParamDescription::Name do
  let(:validator_options) { {} }
  let(:param_description_options) { {}.merge(validator_options) }
  let(:with_null) { false }
  let(:http_method) { :GET }
  let(:path) { '/api' }
  let(:validator) { String }
  let(:prefixed_by) {}

  let(:base_dsl_data) do
    {
      :api => false,
      :api_args => [],
      :api_from_routes => nil,
      :errors => [],
      :tag_list => [],
      :returns => {},
      :params => [],
      :headers => [],
      :resource_id => nil,
      :short_description => nil,
      :description => nil,
      :examples => [],
      :see => [],
      :formats => nil,
      :api_versions => [],
      :meta => nil,
      :show => true,
      :deprecated => false
    }
  end

  let(:dsl_data) do
    base_dsl_data.merge({
      api_args: [
        [
          http_method,
          path,
          'description',
          { deprecated: true }
        ]
      ]
    })
  end

  let(:resource_desc) do
    Apipie::ResourceDescription.new(UsersController, 'dummy')
  end

  let(:method_desc) do
    Apipie::MethodDescription.new(:show, resource_desc, dsl_data)
  end

  let(:param_description) do
    Apipie::ParamDescription.new(
      method_desc,
      :param,
      validator,
      param_description_options
    )
  end

  let(:name_definition) do
    described_class.new(
      param_description,
      prefixed_by: prefixed_by
    ).to_hash
  end

  subject { name_definition[:name] }

  it { is_expected.to eq(param_description.name) }

  context 'when prefixed by is given' do
    let(:prefixed_by) { 'some-prefix' }

    it { is_expected.to eq("#{prefixed_by}[#{param_description.name}]") }
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
apipie-rails-1.4.2 spec/lib/apipie/generator/swagger/param_description/name_spec.rb
apipie-rails-1.4.1 spec/lib/apipie/generator/swagger/param_description/name_spec.rb
apipie-rails-1.4.0 spec/lib/apipie/generator/swagger/param_description/name_spec.rb
apipie-rails-1.3.0 spec/lib/apipie/generator/swagger/param_description/name_spec.rb
apipie-rails-1.2.3 spec/lib/apipie/generator/swagger/param_description/name_spec.rb
apipie-rails-1.2.2 spec/lib/apipie/generator/swagger/param_description/name_spec.rb
apipie-rails-1.2.1 spec/lib/apipie/generator/swagger/param_description/name_spec.rb
apipie-rails-1.2.0 spec/lib/apipie/generator/swagger/param_description/name_spec.rb
apipie-rails-1.1.0 spec/lib/apipie/generator/swagger/param_description/name_spec.rb
apipie-rails-1.0.0 spec/lib/apipie/generator/swagger/param_description/name_spec.rb
apipie-rails-0.9.4 spec/lib/apipie/generator/swagger/param_description/name_spec.rb
apipie-rails-0.9.3 spec/lib/apipie/generator/swagger/param_description/name_spec.rb
apipie-rails-0.9.2 spec/lib/generator/swagger/param_description/name_spec.rb