File tree Expand file tree Collapse file tree 1 file changed +54
-0
lines changed Expand file tree Collapse file tree 1 file changed +54
-0
lines changed Original file line number Diff line number Diff line change
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe 'Grape::Endpoint#path_and_definitions' do
6
+ let ( :item ) do
7
+ Class . new ( Grape ::API ) do
8
+ version 'v1' , using : :path
9
+
10
+ resource :item do
11
+ get '/'
12
+ end
13
+ end
14
+ end
15
+
16
+ let ( :api ) do
17
+ item_api = item
18
+
19
+ Class . new ( Grape ::API ) do
20
+ mount item_api
21
+ add_swagger_documentation openapi_version : '3.0' , add_version : true
22
+ end
23
+ end
24
+
25
+ let ( :options ) { { add_version : true } }
26
+ let ( :target_routes ) { api . combined_namespace_routes }
27
+
28
+ subject { api . endpoints [ 0 ] . path_and_definition_objects ( target_routes , api , options ) }
29
+
30
+ it 'is returning a versioned path' do
31
+ expect ( subject [ 0 ] . keys [ 0 ] ) . to eq '/v1/item'
32
+ end
33
+
34
+ it 'tags the endpoint with the resource name' do
35
+ expect ( subject . first [ '/v1/item' ] [ :get ] [ :tags ] ) . to eq [ 'item' ]
36
+ end
37
+
38
+ context 'when custom tags are specified' do
39
+ let ( :item ) do
40
+ Class . new ( Grape ::API ) do
41
+ version 'v1' , using : :path
42
+
43
+ resource :item do
44
+ desc 'Item description' , tags : [ 'special-item' ]
45
+ get '/'
46
+ end
47
+ end
48
+ end
49
+
50
+ it 'tags the endpoint with the custom tags' do
51
+ expect ( subject . first [ '/v1/item' ] [ :get ] [ :tags ] ) . to eq [ 'special-item' ]
52
+ end
53
+ end
54
+ end
You can’t perform that action at this time.
0 commit comments