-
Notifications
You must be signed in to change notification settings - Fork 476
/
Copy path730_swagger_is_not_detecting_mounted_rack_app.rb
76 lines (63 loc) · 1.6 KB
/
730_swagger_is_not_detecting_mounted_rack_app.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# frozen_string_literal: true
require 'spec_helper'
require 'grape-swagger/entity'
module API
module V1
class Welcome < Grape::API
desc 'Greets user' do
detail 'This is the root api and it will greet user on accessing'
end
get '/' do
{
data: [
{ message: 'Welcome to notes app' }
]
}
end
end
end
end
module API
module V1
class Base < Grape::API
version :v1, using: :path
mount Welcome
end
end
end
module API
class Base < Grape::API
format :json
prefix :api
mount V1::Base
add_swagger_documentation hide_documentation_path: true,
version: 'V1',
info: {
title: 'User notes app',
description: 'Demo app for user notes'
}
end
end
describe 'swagger is not detecting mounted rack app' do
let(:app) { API::Base }
context 'when a rack app is mounted under API::Base' do
context 'when api/v1/ is called' do
subject do
get '/api/v1'
JSON.parse(last_response.body)
end
it 'checks if the response is correct' do
expect(subject).to eq('data' => [{ 'message' => 'Welcome to notes app' }])
end
end
context 'when api/swagger_doc is called' do
subject do
get '/api/swagger_doc'
JSON.parse(last_response.body)
end
it 'checks if the swagger documentation is properly generated' do
expect(subject['paths']).to_not be_nil
end
end
end
end