grape-swagger 1.6.1 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +11 -1
  3. data/README.md +1 -0
  4. data/grape-swagger.gemspec +5 -5
  5. data/lib/grape-swagger/doc_methods/extensions.rb +2 -1
  6. data/lib/grape-swagger/doc_methods/move_params.rb +1 -0
  7. data/lib/grape-swagger/endpoint.rb +1 -1
  8. data/lib/grape-swagger/version.rb +1 -1
  9. metadata +26 -129
  10. data/.coveralls.yml +0 -1
  11. data/.github/dependabot.yml +0 -20
  12. data/.github/workflows/ci.yml +0 -120
  13. data/.gitignore +0 -45
  14. data/.rspec +0 -3
  15. data/.rubocop.yml +0 -136
  16. data/.rubocop_todo.yml +0 -45
  17. data/Dangerfile +0 -3
  18. data/Gemfile +0 -43
  19. data/Rakefile +0 -20
  20. data/example/api/endpoints.rb +0 -131
  21. data/example/api/entities.rb +0 -18
  22. data/example/config.ru +0 -42
  23. data/example/example_requests.postman_collection +0 -146
  24. data/example/splines.png +0 -0
  25. data/example/swagger-example.png +0 -0
  26. data/spec/issues/267_nested_namespaces.rb +0 -55
  27. data/spec/issues/403_versions_spec.rb +0 -124
  28. data/spec/issues/427_entity_as_string_spec.rb +0 -39
  29. data/spec/issues/430_entity_definitions_spec.rb +0 -94
  30. data/spec/issues/532_allow_custom_format_spec.rb +0 -38
  31. data/spec/issues/533_specify_status_code_spec.rb +0 -78
  32. data/spec/issues/537_enum_values_spec.rb +0 -50
  33. data/spec/issues/539_array_post_body_spec.rb +0 -65
  34. data/spec/issues/542_array_of_type_in_post_body_spec.rb +0 -46
  35. data/spec/issues/553_align_array_put_post_params_spec.rb +0 -144
  36. data/spec/issues/572_array_post_body_spec.rb +0 -51
  37. data/spec/issues/579_align_put_post_parameters_spec.rb +0 -179
  38. data/spec/issues/582_file_response_spec.rb +0 -55
  39. data/spec/issues/587_range_parameter_delimited_by_dash_spec.rb +0 -26
  40. data/spec/issues/605_root_route_documentation_spec.rb +0 -23
  41. data/spec/issues/650_params_array_spec.rb +0 -59
  42. data/spec/issues/677_consumes_produces_add_swagger_documentation_options_spec.rb +0 -100
  43. data/spec/issues/680_keep_204_error_schemas_spec.rb +0 -55
  44. data/spec/issues/751_deeply_nested_objects_spec.rb +0 -190
  45. data/spec/issues/776_multiple_presents_spec.rb +0 -59
  46. data/spec/issues/784_extensions_on_params_spec.rb +0 -38
  47. data/spec/issues/809_utf8_routes_spec.rb +0 -55
  48. data/spec/issues/832_array_hash_float_decimal_spec.rb +0 -111
  49. data/spec/issues/847_route_param_options_spec.rb +0 -37
  50. data/spec/lib/data_type_spec.rb +0 -111
  51. data/spec/lib/endpoint/params_parser_spec.rb +0 -124
  52. data/spec/lib/endpoint_spec.rb +0 -153
  53. data/spec/lib/extensions_spec.rb +0 -185
  54. data/spec/lib/format_data_spec.rb +0 -115
  55. data/spec/lib/model_parsers_spec.rb +0 -104
  56. data/spec/lib/move_params_spec.rb +0 -444
  57. data/spec/lib/oapi_tasks_spec.rb +0 -163
  58. data/spec/lib/operation_id_spec.rb +0 -55
  59. data/spec/lib/optional_object_spec.rb +0 -47
  60. data/spec/lib/parse_params_spec.rb +0 -82
  61. data/spec/lib/path_string_spec.rb +0 -101
  62. data/spec/lib/produces_consumes_spec.rb +0 -116
  63. data/spec/lib/tag_name_description_spec.rb +0 -80
  64. data/spec/lib/version_spec.rb +0 -28
  65. data/spec/spec_helper.rb +0 -39
  66. data/spec/support/empty_model_parser.rb +0 -23
  67. data/spec/support/grape_version.rb +0 -13
  68. data/spec/support/mock_parser.rb +0 -23
  69. data/spec/support/model_parsers/entity_parser.rb +0 -334
  70. data/spec/support/model_parsers/mock_parser.rb +0 -346
  71. data/spec/support/model_parsers/representable_parser.rb +0 -406
  72. data/spec/support/namespace_tags.rb +0 -93
  73. data/spec/support/the_paths_definitions.rb +0 -109
  74. data/spec/swagger_v2/api_documentation_spec.rb +0 -26
  75. data/spec/swagger_v2/api_swagger_v2_additional_properties_spec.rb +0 -83
  76. data/spec/swagger_v2/api_swagger_v2_body_definitions_spec.rb +0 -48
  77. data/spec/swagger_v2/api_swagger_v2_definitions-models_spec.rb +0 -36
  78. data/spec/swagger_v2/api_swagger_v2_detail_spec.rb +0 -79
  79. data/spec/swagger_v2/api_swagger_v2_extensions_spec.rb +0 -145
  80. data/spec/swagger_v2/api_swagger_v2_format-content_type_spec.rb +0 -137
  81. data/spec/swagger_v2/api_swagger_v2_global_configuration_spec.rb +0 -56
  82. data/spec/swagger_v2/api_swagger_v2_hash_and_array_spec.rb +0 -64
  83. data/spec/swagger_v2/api_swagger_v2_headers_spec.rb +0 -58
  84. data/spec/swagger_v2/api_swagger_v2_hide_documentation_path_spec.rb +0 -57
  85. data/spec/swagger_v2/api_swagger_v2_hide_param_spec.rb +0 -103
  86. data/spec/swagger_v2/api_swagger_v2_ignore_defaults_spec.rb +0 -48
  87. data/spec/swagger_v2/api_swagger_v2_mounted_spec.rb +0 -145
  88. data/spec/swagger_v2/api_swagger_v2_param_type_body_nested_spec.rb +0 -355
  89. data/spec/swagger_v2/api_swagger_v2_param_type_body_spec.rb +0 -217
  90. data/spec/swagger_v2/api_swagger_v2_param_type_spec.rb +0 -239
  91. data/spec/swagger_v2/api_swagger_v2_request_params_fix_spec.rb +0 -72
  92. data/spec/swagger_v2/api_swagger_v2_response_spec.rb +0 -143
  93. data/spec/swagger_v2/api_swagger_v2_response_with_examples_spec.rb +0 -135
  94. data/spec/swagger_v2/api_swagger_v2_response_with_headers_spec.rb +0 -216
  95. data/spec/swagger_v2/api_swagger_v2_response_with_models_spec.rb +0 -55
  96. data/spec/swagger_v2/api_swagger_v2_response_with_root_spec.rb +0 -153
  97. data/spec/swagger_v2/api_swagger_v2_spec.rb +0 -237
  98. data/spec/swagger_v2/api_swagger_v2_status_codes_spec.rb +0 -93
  99. data/spec/swagger_v2/api_swagger_v2_type-format_spec.rb +0 -89
  100. data/spec/swagger_v2/boolean_params_spec.rb +0 -35
  101. data/spec/swagger_v2/default_api_spec.rb +0 -175
  102. data/spec/swagger_v2/deprecated_field_spec.rb +0 -25
  103. data/spec/swagger_v2/description_not_initialized_spec.rb +0 -39
  104. data/spec/swagger_v2/endpoint_versioned_path_spec.rb +0 -130
  105. data/spec/swagger_v2/errors_spec.rb +0 -77
  106. data/spec/swagger_v2/float_api_spec.rb +0 -33
  107. data/spec/swagger_v2/form_params_spec.rb +0 -67
  108. data/spec/swagger_v2/grape-swagger_spec.rb +0 -17
  109. data/spec/swagger_v2/guarded_endpoint_spec.rb +0 -162
  110. data/spec/swagger_v2/hide_api_spec.rb +0 -147
  111. data/spec/swagger_v2/host_spec.rb +0 -43
  112. data/spec/swagger_v2/inheritance_and_discriminator_spec.rb +0 -57
  113. data/spec/swagger_v2/mount_override_api_spec.rb +0 -58
  114. data/spec/swagger_v2/mounted_target_class_spec.rb +0 -76
  115. data/spec/swagger_v2/namespace_tags_prefix_spec.rb +0 -122
  116. data/spec/swagger_v2/namespace_tags_spec.rb +0 -78
  117. data/spec/swagger_v2/namespaced_api_spec.rb +0 -121
  118. data/spec/swagger_v2/nicknamed_api_spec.rb +0 -25
  119. data/spec/swagger_v2/operation_id_api_spec.rb +0 -27
  120. data/spec/swagger_v2/param_multi_type_spec.rb +0 -77
  121. data/spec/swagger_v2/param_type_spec.rb +0 -87
  122. data/spec/swagger_v2/param_values_spec.rb +0 -162
  123. data/spec/swagger_v2/params_array_collection_format_spec.rb +0 -105
  124. data/spec/swagger_v2/params_array_spec.rb +0 -203
  125. data/spec/swagger_v2/params_example_spec.rb +0 -40
  126. data/spec/swagger_v2/params_hash_spec.rb +0 -71
  127. data/spec/swagger_v2/params_nested_spec.rb +0 -86
  128. data/spec/swagger_v2/parent_less_namespace_spec.rb +0 -32
  129. data/spec/swagger_v2/reference_entity_spec.rb +0 -129
  130. data/spec/swagger_v2/security_requirement_spec.rb +0 -46
  131. data/spec/swagger_v2/simple_mounted_api_spec.rb +0 -326
  132. data/spec/version_spec.rb +0 -10
@@ -1,47 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- describe GrapeSwagger::DocMethods::OptionalObject do
6
- subject { described_class }
7
-
8
- specify { expect(subject).to eql GrapeSwagger::DocMethods::OptionalObject }
9
- specify { expect(subject).to respond_to :build }
10
-
11
- describe 'build' do
12
- let(:key) { :host }
13
- let!(:request) { Rack::Request.new(Rack::MockRequest.env_for('http://example.com:8080/')) }
14
-
15
- describe 'no option given for host, take from request' do
16
- let(:options) { { foo: 'foo' } }
17
- specify do
18
- expect(subject.build(key, options, request)).to eql request.host_with_port
19
- end
20
- end
21
-
22
- let(:value) { 'grape-swagger.example.com' }
23
-
24
- describe 'option is a string' do
25
- let(:options) { { host: value } }
26
- specify do
27
- expect(subject.build(key, options, request)).to eql value
28
- end
29
- end
30
-
31
- describe 'option is a lambda' do
32
- let(:options) { { host: -> { value } } }
33
- specify do
34
- expect(subject.build(key, options, request)).to eql value
35
- end
36
- end
37
-
38
- describe 'option is a proc' do
39
- let(:options) do
40
- { host: proc { |request| request.host =~ /^example/ ? '/api-example' : '/api' } }
41
- end
42
- specify do
43
- expect(subject.build(key, options, request)).to eql '/api-example'
44
- end
45
- end
46
- end
47
- end
@@ -1,82 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- describe GrapeSwagger::DocMethods::ParseParams do
6
- subject { described_class }
7
- let(:start_value) { -5 }
8
- let(:end_value) { 5 }
9
-
10
- describe '#parse_range_values' do
11
- specify do
12
- parsed_range = subject.send(:parse_range_values, start_value..end_value)
13
- expect(parsed_range).to eql(minimum: start_value, maximum: end_value)
14
- end
15
-
16
- describe 'endless range' do
17
- specify do
18
- parsed_range = subject.send(:parse_range_values, start_value..)
19
- expect(parsed_range).to eql(minimum: start_value)
20
- end
21
- end
22
-
23
- describe 'beginless range' do
24
- specify do
25
- parsed_range = subject.send(:parse_range_values, ..end_value)
26
- expect(parsed_range).to eql(maximum: end_value)
27
- end
28
- end
29
- end
30
-
31
- describe '#parse_enum_or_range_values' do
32
- describe 'value as Range' do
33
- describe 'first Integer' do
34
- specify do
35
- parsed_range = subject.send(:parse_enum_or_range_values, start_value..end_value)
36
- expect(parsed_range).to eql(minimum: start_value, maximum: end_value)
37
- end
38
- end
39
-
40
- describe 'first String' do
41
- specify do
42
- parsed_range = subject.send(:parse_enum_or_range_values, 'a'..'z')
43
- expect(parsed_range).to be_nil
44
- end
45
- end
46
- end
47
-
48
- describe 'value as Proc' do
49
- describe 'as Range' do
50
- let(:values) { proc { start_value..end_value } }
51
- specify do
52
- parsed_range = subject.send(:parse_enum_or_range_values, values)
53
- expect(parsed_range).to eql(minimum: start_value, maximum: end_value)
54
- end
55
- end
56
-
57
- describe 'as Array' do
58
- let(:values) { proc { %w[a b c] } }
59
- specify do
60
- parsed_range = subject.send(:parse_enum_or_range_values, values)
61
- expect(parsed_range).to eql(enum: %w[a b c])
62
- end
63
- end
64
-
65
- describe 'with arity one' do
66
- let(:values) { proc { |v| v < 25 } }
67
- specify do
68
- parsed_range = subject.send(:parse_enum_or_range_values, values)
69
- expect(parsed_range).to be_nil
70
- end
71
- end
72
- end
73
-
74
- describe 'values as Array -> enums' do
75
- let(:values) { %w[a b c] }
76
- specify do
77
- parsed_range = subject.send(:parse_enum_or_range_values, values)
78
- expect(parsed_range).to eql(enum: %w[a b c])
79
- end
80
- end
81
- end
82
- end
@@ -1,101 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- describe GrapeSwagger::DocMethods::PathString do
6
- subject { described_class }
7
-
8
- specify { expect(subject).to eql GrapeSwagger::DocMethods::PathString }
9
- specify { expect(subject).to respond_to :build }
10
-
11
- describe 'path_string_object' do
12
- specify 'The original route path is not mutated' do
13
- route = Struct.new(:version, :path).new
14
- route.path = '/foo/:dynamic/bar'
15
- subject.build(route, add_version: true)
16
- expect(route.path).to eq '/foo/:dynamic/bar'
17
- end
18
-
19
- describe 'version' do
20
- describe 'defaults: given, true' do
21
- let(:options) { { add_version: true } }
22
- let(:route) { Struct.new(:version, :path).new('v1') }
23
-
24
- specify 'The returned path includes version' do
25
- route.path = '/{version}/thing(.json)'
26
- expect(subject.build(route, options)).to eql ['Thing', '/v1/thing']
27
- route.path = '/{version}/thing/foo(.json)'
28
- expect(subject.build(route, options)).to eql ['Foo', '/v1/thing/foo']
29
- route.path = '/{version}/thing(.:format)'
30
- expect(subject.build(route, options)).to eql ['Thing', '/v1/thing']
31
- route.path = '/{version}/thing/foo(.:format)'
32
- expect(subject.build(route, options)).to eql ['Foo', '/v1/thing/foo']
33
- route.path = '/{version}/thing/:id'
34
- expect(subject.build(route, options)).to eql ['Thing', '/v1/thing/{id}']
35
- route.path = '/{version}/thing/foo/:id'
36
- expect(subject.build(route, options)).to eql ['Foo', '/v1/thing/foo/{id}']
37
- end
38
- end
39
-
40
- describe 'defaults: not given, both false' do
41
- let(:options) { { add_version: false } }
42
- let(:route) { Struct.new(:version, :path).new }
43
-
44
- specify 'The returned path does not include version' do
45
- route.path = '/{version}/thing(.json)'
46
- expect(subject.build(route, options)).to eql ['Thing', '/thing']
47
- route.path = '/{version}/thing/foo(.json)'
48
- expect(subject.build(route, options)).to eql ['Foo', '/thing/foo']
49
- route.path = '/{version}/thing(.:format)'
50
- expect(subject.build(route, options)).to eql ['Thing', '/thing']
51
- route.path = '/{version}/thing/foo(.:format)'
52
- expect(subject.build(route, options)).to eql ['Foo', '/thing/foo']
53
- route.path = '/{version}/thing/:id'
54
- expect(subject.build(route, options)).to eql ['Thing', '/thing/{id}']
55
- route.path = '/{version}/thing/foo/:id'
56
- expect(subject.build(route, options)).to eql ['Foo', '/thing/foo/{id}']
57
- end
58
- end
59
-
60
- describe 'defaults: add_version false' do
61
- let(:options) { { add_version: false } }
62
- let(:route) { Struct.new(:version, :path).new('v1') }
63
-
64
- specify 'The returned path does not include version' do
65
- route.path = '/{version}/thing(.json)'
66
- expect(subject.build(route, options)).to eql ['Thing', '/thing']
67
- route.path = '/{version}/thing/foo(.json)'
68
- expect(subject.build(route, options)).to eql ['Foo', '/thing/foo']
69
- route.path = '/{version}/thing(.:format)'
70
- expect(subject.build(route, options)).to eql ['Thing', '/thing']
71
- route.path = '/{version}/thing/foo(.:format)'
72
- expect(subject.build(route, options)).to eql ['Foo', '/thing/foo']
73
- route.path = '/{version}/thing/:id'
74
- expect(subject.build(route, options)).to eql ['Thing', '/thing/{id}']
75
- route.path = '/{version}/thing/foo/:id'
76
- expect(subject.build(route, options)).to eql ['Foo', '/thing/foo/{id}']
77
- end
78
- end
79
-
80
- describe 'defaults: root_version nil' do
81
- let(:options) { { add_version: true } }
82
- let(:route) { Struct.new(:version, :path).new }
83
-
84
- specify 'The returned path does not include version' do
85
- route.path = '/{version}/thing(.json)'
86
- expect(subject.build(route, options)).to eql ['Thing', '/thing']
87
- route.path = '/{version}/thing/foo(.json)'
88
- expect(subject.build(route, options)).to eql ['Foo', '/thing/foo']
89
- route.path = '/{version}/thing(.:format)'
90
- expect(subject.build(route, options)).to eql ['Thing', '/thing']
91
- route.path = '/{version}/thing/foo(.:format)'
92
- expect(subject.build(route, options)).to eql ['Foo', '/thing/foo']
93
- route.path = '/{version}/thing/:id'
94
- expect(subject.build(route, options)).to eql ['Thing', '/thing/{id}']
95
- route.path = '/{version}/thing/foo/:id'
96
- expect(subject.build(route, options)).to eql ['Foo', '/thing/foo/{id}']
97
- end
98
- end
99
- end
100
- end
101
- end
@@ -1,116 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- describe GrapeSwagger::DocMethods::ProducesConsumes do
6
- describe ':json (default)' do
7
- subject { described_class.call }
8
-
9
- specify do
10
- expect(subject).to eql(['application/json'])
11
- end
12
- end
13
-
14
- describe 'accept symbols of' do
15
- describe 'single' do
16
- subject { described_class.call(:xml) }
17
-
18
- specify do
19
- expect(subject).to eql(['application/xml'])
20
- end
21
- end
22
-
23
- describe 'multiple' do
24
- subject { described_class.call(:xml, :serializable_hash, :json, :binary, :txt) }
25
-
26
- specify do
27
- expect(subject).to eql(
28
- [
29
- 'application/xml',
30
- 'application/json',
31
- 'application/octet-stream',
32
- 'text/plain'
33
- ]
34
- )
35
- end
36
- end
37
- end
38
-
39
- describe 'accept mime_types of' do
40
- describe 'single' do
41
- subject { described_class.call('application/xml') }
42
-
43
- specify do
44
- expect(subject).to eql(['application/xml'])
45
- end
46
- end
47
-
48
- describe 'multiple' do
49
- subject do
50
- described_class.call(
51
- 'application/xml',
52
- 'application/json',
53
- 'application/octet-stream',
54
- 'text/plain'
55
- )
56
- end
57
-
58
- specify do
59
- expect(subject).to eql(
60
- [
61
- 'application/xml',
62
- 'application/json',
63
- 'application/octet-stream',
64
- 'text/plain'
65
- ]
66
- )
67
- end
68
- end
69
- end
70
-
71
- describe 'mix it up' do
72
- subject do
73
- described_class.call(
74
- :xml,
75
- :serializable_hash,
76
- 'application/json',
77
- 'application/octet-stream',
78
- :txt
79
- )
80
- end
81
-
82
- specify do
83
- expect(subject).to eql(
84
- [
85
- 'application/xml',
86
- 'application/json',
87
- 'application/octet-stream',
88
- 'text/plain'
89
- ]
90
- )
91
- end
92
-
93
- subject do
94
- described_class.call(
95
- [
96
- :xml,
97
- :serializable_hash,
98
- 'application/json',
99
- 'application/octet-stream',
100
- :txt
101
- ]
102
- )
103
- end
104
-
105
- specify do
106
- expect(subject).to eql(
107
- [
108
- 'application/xml',
109
- 'application/json',
110
- 'application/octet-stream',
111
- 'text/plain'
112
- ]
113
- )
114
- end
115
- end
116
- end
@@ -1,80 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- describe GrapeSwagger::DocMethods::TagNameDescription do
6
- describe '#build_memo' do
7
- let(:tag) { 'some_string' }
8
- subject { described_class.send(:build_memo, tag) }
9
-
10
- specify do
11
- expect(subject.keys).to eql %i[name description]
12
- expect(subject).to eql(
13
- name: tag,
14
- description: "Operations about #{tag.pluralize}"
15
- )
16
- end
17
- end
18
-
19
- describe '#build' do
20
- let(:object) { described_class.build(paths) }
21
-
22
- describe 'empty paths' do
23
- let(:paths) { {} }
24
- specify do
25
- expect(object).to eql([])
26
- end
27
- end
28
-
29
- describe 'paths given' do
30
- describe 'uniq as String' do
31
- let(:paths) do
32
- { key_1: { post: { tags: 'tags_given' } } }
33
- end
34
-
35
- specify do
36
- expect(object).to eql [{ name: 'tags_given', description: 'Operations about tags_givens' }]
37
- end
38
- end
39
-
40
- describe 'uniq as Array' do
41
- let(:paths) do
42
- { key_1: { post: { tags: ['tags_given'] } } }
43
- end
44
-
45
- specify do
46
- expect(object).to eql [{ name: 'tags_given', description: 'Operations about tags_givens' }]
47
- end
48
- end
49
-
50
- describe 'multiple' do
51
- describe 'uniq key' do
52
- let(:paths) do
53
- {
54
- key_1: { post: { tags: %w[tags_given another_tag_given] } }
55
- }
56
- end
57
-
58
- specify do
59
- expect(object).to eql [
60
- { name: 'tags_given', description: 'Operations about tags_givens' },
61
- { name: 'another_tag_given', description: 'Operations about another_tag_givens' }
62
- ]
63
- end
64
- end
65
- describe 'under different keys' do
66
- let(:paths) do
67
- {
68
- key_1: { post: { tags: ['tags_given'] } },
69
- key_2: { post: { tags: ['tags_given'] } }
70
- }
71
- end
72
-
73
- specify do
74
- expect(object).to eql [{ name: 'tags_given', description: 'Operations about tags_givens' }]
75
- end
76
- end
77
- end
78
- end
79
- end
80
- end
@@ -1,28 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- describe GrapeSwagger::DocMethods::Version do
6
- let(:route) { OpenStruct.new(version: version) }
7
- subject { described_class.get(route) }
8
-
9
- describe 'grape 0.16.2 version' do
10
- let(:version) { '[:v1, :v2]' }
11
- it { is_expected.to be_a Array }
12
- it { is_expected.to eql %i[v1 v2] }
13
- end
14
-
15
- describe 'newer grape versions' do
16
- describe 'as String' do
17
- let(:version) { 'v1' }
18
- it { is_expected.to be_a String }
19
- it { is_expected.to eql 'v1' }
20
- end
21
-
22
- describe 'as Array' do
23
- let(:version) { %i[v1 v2] }
24
- it { is_expected.to be_a Array }
25
- it { is_expected.to eql %i[v1 v2] }
26
- end
27
- end
28
- end
data/spec/spec_helper.rb DELETED
@@ -1,39 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- if RUBY_ENGINE == 'ruby'
4
- require 'simplecov'
5
- require 'coveralls'
6
-
7
- SimpleCov.formatter = Coveralls::SimpleCov::Formatter
8
- Coveralls.wear!
9
- end
10
-
11
- $LOAD_PATH.unshift File.expand_path('../lib', __dir__)
12
-
13
- MODEL_PARSER = ENV.key?('MODEL_PARSER') ? ENV['MODEL_PARSER'].to_s.downcase.sub('grape-swagger-', '') : 'mock'
14
-
15
- require 'grape'
16
- require 'grape-swagger'
17
-
18
- Dir[File.join(Dir.getwd, 'spec/support/*.rb')].each { |f| require f }
19
- require "grape-swagger/#{MODEL_PARSER}" if MODEL_PARSER != 'mock'
20
- require File.join(Dir.getwd, "spec/support/model_parsers/#{MODEL_PARSER}_parser.rb")
21
-
22
- require 'grape-entity'
23
- require 'grape-swagger-entity'
24
-
25
- Bundler.setup :default, :test
26
-
27
- require 'rack'
28
- require 'rack/test'
29
-
30
- RSpec.configure do |config|
31
- require 'rspec/expectations'
32
- config.include RSpec::Matchers
33
- config.mock_with :rspec
34
- config.include Rack::Test::Methods
35
- config.raise_errors_for_deprecations!
36
-
37
- config.order = 'random'
38
- config.seed = 40_834
39
- end
@@ -1,23 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # rubocop:disable Lint/EmptyClass
4
- class EmptyClass
5
- end
6
- # rubocop:enable Lint/EmptyClass
7
-
8
- module GrapeSwagger
9
- class EmptyModelParser
10
- attr_reader :model, :endpoint
11
-
12
- def initialize(model, endpoint)
13
- @model = model
14
- @endpoint = endpoint
15
- end
16
-
17
- def call
18
- {}
19
- end
20
- end
21
- end
22
-
23
- GrapeSwagger.model_parsers.register(GrapeSwagger::EmptyModelParser, EmptyClass)
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class GrapeVersion
4
- class << self
5
- def current_version
6
- Grape::VERSION
7
- end
8
-
9
- def satisfy?(requirement)
10
- Gem::Dependency.new('grape-test', requirement).match?('grape-test', current_version)
11
- end
12
- end
13
- end
@@ -1,23 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module GrapeSwagger
4
- class MockParser
5
- attr_reader :model, :endpoint
6
-
7
- def initialize(model, endpoint)
8
- @model = model
9
- @endpoint = endpoint
10
- end
11
-
12
- def call
13
- {
14
- mock_data: {
15
- type: :string,
16
- description: "it's a mock"
17
- }
18
- }
19
- end
20
- end
21
- end
22
-
23
- GrapeSwagger.model_parsers.register(GrapeSwagger::MockParser, OpenStruct)