Sha256: 41dc071823d35728e49f81cd1c5670fdcf5574775bac91ac0b2ef57e2bbd3578

Contents?: true

Size: 1.18 KB

Versions: 10

Compression:

Stored size: 1.18 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

describe 'Grape::Endpoint#path_and_definitions' do
  let(:item) do
    Class.new(Grape::API) do
      version 'v1', using: :path

      resource :item do
        get '/'
      end
    end
  end

  let(:api) do
    item_api = item

    Class.new(Grape::API) do
      mount item_api
      add_swagger_documentation add_version: true
    end
  end

  let(:options) { { add_version: true } }
  let(:target_routes) { api.combined_namespace_routes }

  subject { api.endpoints[0].path_and_definition_objects(target_routes, options) }

  it 'is returning a versioned path' do
    expect(subject[0].keys[0]).to eq '/v1/item'
  end

  it 'tags the endpoint with the resource name' do
    expect(subject.first['/v1/item'][:get][:tags]).to eq ['item']
  end

  context 'when custom tags are specified' do
    let(:item) do
      Class.new(Grape::API) do
        version 'v1', using: :path

        resource :item do
          desc 'Item description', tags: ['special-item']
          get '/'
        end
      end
    end

    it 'tags the endpoint with the custom tags' do
      expect(subject.first['/v1/item'][:get][:tags]).to eq ['special-item']
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
grape-swagger-0.31.1 spec/swagger_v2/endpoint_versioned_path_spec.rb
grape-swagger-0.31.0 spec/swagger_v2/endpoint_versioned_path_spec.rb
grape-swagger-0.30.1 spec/swagger_v2/endpoint_versioned_path_spec.rb
grape-swagger-0.30.0 spec/swagger_v2/endpoint_versioned_path_spec.rb
grape-swagger-0.29.0 spec/swagger_v2/endpoint_versioned_path_spec.rb
grape-swagger-0.28.0 spec/swagger_v2/endpoint_versioned_path_spec.rb
grape-swagger-0.27.3 spec/swagger_v2/endpoint_versioned_path_spec.rb
grape-swagger-0.27.2 spec/swagger_v2/endpoint_versioned_path_spec.rb
grape-swagger-0.27.1 spec/swagger_v2/endpoint_versioned_path_spec.rb
grape-swagger-0.27.0 spec/swagger_v2/endpoint_versioned_path_spec.rb