Sha256: 7997efbe948d862322ff948c0f4bd4cbacb6323e4ccd03900d11e03a330fbd9c

Contents?: true

Size: 1.38 KB

Versions: 13

Compression:

Stored size: 1.38 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

describe 'a parent less namespace' do
  include_context 'namespace example'

  before :all do
    class ParentLessApi < Grape::API
      prefix :api
      mount TheApi::ParentLessNamespaceApi
      add_swagger_documentation version: 'v1'
    end
  end

  def app
    ParentLessApi
  end

  describe 'retrieves swagger-documentation on /swagger_doc' do
    let(:route_name) { ':animal/:breed/queues/:queue_id/reservations' }
    subject do
      get '/api/swagger_doc.json'
      JSON.parse(last_response.body)
    end

    context 'not raises error' do
      specify do
        expect(subject['tags']).to eql([{ 'name' => 'queues', 'description' => 'Operations about queues' }])
        expect(subject['paths']['/api/{animal}/{breed}/queues/{queue_id}/reservations']['get']['operationId'])
          .to eql('getApiAnimalBreedQueuesQueueIdReservations')
      end
    end

    context 'raises error' do
      specify do
        allow_any_instance_of(ParentLessApi)
          .to receive(:extract_parent_route).with(route_name).and_return(':animal') # BUT IT'S NOT STUBBING, CAUSE IT'S A PRIVATE METHODS
        expect { subject }.to raise_error NoMethodError
      end
    end

    context 'ParentLessApi.extract_parent_route' do
      specify do
        expect(ParentLessApi.send(:extract_parent_route, route_name)).to eq('queues')
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

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