Sha256: 6e2166d2c654249d06c70a9e7ee911e7f39cc599d5b70b2d428b0d7c3e4f9636

Contents?: true

Size: 1.08 KB

Versions: 5

Compression:

Stored size: 1.08 KB

Contents

require 'spec_helper'

describe 'namespace' do
  context 'at root level' do
    def app
      Class.new(Grape::API) do
        namespace :aspace do
          get '/', desc: 'Description for aspace'
        end
        add_swagger_documentation format: :json
      end
    end

    subject do
      get '/swagger_doc'
      JSON.parse(last_response.body)['paths']['/aspace']['get']
    end

    it 'shows the namespace description in the json spec' do
      expect(subject['description']).to eql('Description for aspace')
    end
  end

  context 'mounted' do
    def app
      namespaced_api = Class.new(Grape::API) do
        namespace :bspace do
          get '/', desc: 'Description for aspace'
        end
      end

      Class.new(Grape::API) do
        mount namespaced_api
        add_swagger_documentation format: :json
      end
    end

    subject do
      get '/swagger_doc'
      JSON.parse(last_response.body)['paths']['/bspace']['get']
    end

    it 'shows the namespace description in the json spec' do
      expect(subject['description']).to eql('Description for aspace')
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
grape-swagger-0.21.0 spec/swagger_v2/namespaced_api_spec.rb
grape-swagger-0.20.3 spec/swagger_v2/namespaced_api_spec.rb
grape-swagger-0.20.2 spec/swagger_v2/namespaced_api_spec.rb
grape-swagger-0.20.1 spec/swagger_v2/namespaced_api_spec.rb
grape-swagger-0.20.0 spec/swagger_v2/namespaced_api_spec.rb