Sha256: ce2396069884f56294298e927c8081034a0351ec2cb5ffb8535d7a04ec9121e8

Contents?: true

Size: 1.05 KB

Versions: 6

Compression:

Stored size: 1.05 KB

Contents

require 'spec_helper'

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

    subject do
      get '/swagger_doc'
      JSON.parse(last_response.body)['apis'][0]
    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 :aspace, desc: 'Description for aspace' do
          get '/'
        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)['apis'][0]
    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

6 entries across 6 versions & 1 rubygems

Version Path
grape-swagger-0.10.4 spec/namespaced_api_spec.rb
grape-swagger-0.10.2 spec/namespaced_api_spec.rb
grape-swagger-0.10.1 spec/namespaced_api_spec.rb
grape-swagger-0.10.0 spec/namespaced_api_spec.rb
grape-swagger-0.9.0 spec/namespaced_api_spec.rb
grape-swagger-0.8.0 spec/namespaced_api_spec.rb