grape-swagger 1.6.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +18 -1
- data/README.md +6 -5
- data/grape-swagger.gemspec +5 -5
- data/lib/grape-swagger/doc_methods/extensions.rb +2 -1
- data/lib/grape-swagger/doc_methods/format_data.rb +2 -2
- data/lib/grape-swagger/doc_methods/move_params.rb +1 -0
- data/lib/grape-swagger/doc_methods/parse_params.rb +1 -1
- data/lib/grape-swagger/endpoint.rb +1 -1
- data/lib/grape-swagger/version.rb +1 -1
- metadata +26 -129
- data/.coveralls.yml +0 -1
- data/.github/dependabot.yml +0 -20
- data/.github/workflows/ci.yml +0 -45
- data/.gitignore +0 -45
- data/.rspec +0 -3
- data/.rubocop.yml +0 -136
- data/.rubocop_todo.yml +0 -60
- data/Dangerfile +0 -3
- data/Gemfile +0 -43
- data/Rakefile +0 -20
- data/example/api/endpoints.rb +0 -131
- data/example/api/entities.rb +0 -18
- data/example/config.ru +0 -42
- data/example/example_requests.postman_collection +0 -146
- data/example/splines.png +0 -0
- data/example/swagger-example.png +0 -0
- data/spec/issues/267_nested_namespaces.rb +0 -55
- data/spec/issues/403_versions_spec.rb +0 -124
- data/spec/issues/427_entity_as_string_spec.rb +0 -39
- data/spec/issues/430_entity_definitions_spec.rb +0 -94
- data/spec/issues/532_allow_custom_format_spec.rb +0 -38
- data/spec/issues/533_specify_status_code_spec.rb +0 -78
- data/spec/issues/537_enum_values_spec.rb +0 -50
- data/spec/issues/539_array_post_body_spec.rb +0 -65
- data/spec/issues/542_array_of_type_in_post_body_spec.rb +0 -46
- data/spec/issues/553_align_array_put_post_params_spec.rb +0 -144
- data/spec/issues/572_array_post_body_spec.rb +0 -51
- data/spec/issues/579_align_put_post_parameters_spec.rb +0 -179
- data/spec/issues/582_file_response_spec.rb +0 -55
- data/spec/issues/587_range_parameter_delimited_by_dash_spec.rb +0 -26
- data/spec/issues/605_root_route_documentation_spec.rb +0 -23
- data/spec/issues/650_params_array_spec.rb +0 -59
- data/spec/issues/677_consumes_produces_add_swagger_documentation_options_spec.rb +0 -100
- data/spec/issues/680_keep_204_error_schemas_spec.rb +0 -55
- data/spec/issues/751_deeply_nested_objects_spec.rb +0 -190
- data/spec/issues/776_multiple_presents_spec.rb +0 -59
- data/spec/issues/784_extensions_on_params_spec.rb +0 -38
- data/spec/issues/809_utf8_routes_spec.rb +0 -55
- data/spec/issues/832_array_hash_float_decimal_spec.rb +0 -111
- data/spec/issues/847_route_param_options_spec.rb +0 -37
- data/spec/lib/data_type_spec.rb +0 -111
- data/spec/lib/endpoint/params_parser_spec.rb +0 -124
- data/spec/lib/endpoint_spec.rb +0 -153
- data/spec/lib/extensions_spec.rb +0 -185
- data/spec/lib/format_data_spec.rb +0 -115
- data/spec/lib/model_parsers_spec.rb +0 -104
- data/spec/lib/move_params_spec.rb +0 -444
- data/spec/lib/oapi_tasks_spec.rb +0 -163
- data/spec/lib/operation_id_spec.rb +0 -55
- data/spec/lib/optional_object_spec.rb +0 -47
- data/spec/lib/parse_params_spec.rb +0 -68
- data/spec/lib/path_string_spec.rb +0 -101
- data/spec/lib/produces_consumes_spec.rb +0 -116
- data/spec/lib/tag_name_description_spec.rb +0 -80
- data/spec/lib/version_spec.rb +0 -28
- data/spec/spec_helper.rb +0 -39
- data/spec/support/empty_model_parser.rb +0 -23
- data/spec/support/grape_version.rb +0 -13
- data/spec/support/mock_parser.rb +0 -23
- data/spec/support/model_parsers/entity_parser.rb +0 -334
- data/spec/support/model_parsers/mock_parser.rb +0 -346
- data/spec/support/model_parsers/representable_parser.rb +0 -406
- data/spec/support/namespace_tags.rb +0 -93
- data/spec/support/the_paths_definitions.rb +0 -109
- data/spec/swagger_v2/api_documentation_spec.rb +0 -28
- data/spec/swagger_v2/api_swagger_v2_additional_properties_spec.rb +0 -83
- data/spec/swagger_v2/api_swagger_v2_body_definitions_spec.rb +0 -48
- data/spec/swagger_v2/api_swagger_v2_definitions-models_spec.rb +0 -36
- data/spec/swagger_v2/api_swagger_v2_detail_spec.rb +0 -79
- data/spec/swagger_v2/api_swagger_v2_extensions_spec.rb +0 -145
- data/spec/swagger_v2/api_swagger_v2_format-content_type_spec.rb +0 -137
- data/spec/swagger_v2/api_swagger_v2_global_configuration_spec.rb +0 -56
- data/spec/swagger_v2/api_swagger_v2_hash_and_array_spec.rb +0 -64
- data/spec/swagger_v2/api_swagger_v2_headers_spec.rb +0 -58
- data/spec/swagger_v2/api_swagger_v2_hide_documentation_path_spec.rb +0 -57
- data/spec/swagger_v2/api_swagger_v2_hide_param_spec.rb +0 -103
- data/spec/swagger_v2/api_swagger_v2_ignore_defaults_spec.rb +0 -48
- data/spec/swagger_v2/api_swagger_v2_mounted_spec.rb +0 -145
- data/spec/swagger_v2/api_swagger_v2_param_type_body_nested_spec.rb +0 -355
- data/spec/swagger_v2/api_swagger_v2_param_type_body_spec.rb +0 -217
- data/spec/swagger_v2/api_swagger_v2_param_type_spec.rb +0 -239
- data/spec/swagger_v2/api_swagger_v2_request_params_fix_spec.rb +0 -72
- data/spec/swagger_v2/api_swagger_v2_response_spec.rb +0 -143
- data/spec/swagger_v2/api_swagger_v2_response_with_examples_spec.rb +0 -135
- data/spec/swagger_v2/api_swagger_v2_response_with_headers_spec.rb +0 -216
- data/spec/swagger_v2/api_swagger_v2_response_with_models_spec.rb +0 -55
- data/spec/swagger_v2/api_swagger_v2_response_with_root_spec.rb +0 -153
- data/spec/swagger_v2/api_swagger_v2_spec.rb +0 -237
- data/spec/swagger_v2/api_swagger_v2_status_codes_spec.rb +0 -93
- data/spec/swagger_v2/api_swagger_v2_type-format_spec.rb +0 -89
- data/spec/swagger_v2/boolean_params_spec.rb +0 -35
- data/spec/swagger_v2/default_api_spec.rb +0 -175
- data/spec/swagger_v2/deprecated_field_spec.rb +0 -25
- data/spec/swagger_v2/description_not_initialized_spec.rb +0 -39
- data/spec/swagger_v2/endpoint_versioned_path_spec.rb +0 -130
- data/spec/swagger_v2/errors_spec.rb +0 -77
- data/spec/swagger_v2/float_api_spec.rb +0 -33
- data/spec/swagger_v2/form_params_spec.rb +0 -67
- data/spec/swagger_v2/grape-swagger_spec.rb +0 -17
- data/spec/swagger_v2/guarded_endpoint_spec.rb +0 -162
- data/spec/swagger_v2/hide_api_spec.rb +0 -147
- data/spec/swagger_v2/host_spec.rb +0 -43
- data/spec/swagger_v2/inheritance_and_discriminator_spec.rb +0 -57
- data/spec/swagger_v2/mount_override_api_spec.rb +0 -58
- data/spec/swagger_v2/mounted_target_class_spec.rb +0 -76
- data/spec/swagger_v2/namespace_tags_prefix_spec.rb +0 -122
- data/spec/swagger_v2/namespace_tags_spec.rb +0 -78
- data/spec/swagger_v2/namespaced_api_spec.rb +0 -121
- data/spec/swagger_v2/nicknamed_api_spec.rb +0 -25
- data/spec/swagger_v2/operation_id_api_spec.rb +0 -27
- data/spec/swagger_v2/param_multi_type_spec.rb +0 -77
- data/spec/swagger_v2/param_type_spec.rb +0 -87
- data/spec/swagger_v2/param_values_spec.rb +0 -162
- data/spec/swagger_v2/params_array_collection_format_spec.rb +0 -105
- data/spec/swagger_v2/params_array_spec.rb +0 -203
- data/spec/swagger_v2/params_example_spec.rb +0 -40
- data/spec/swagger_v2/params_hash_spec.rb +0 -71
- data/spec/swagger_v2/params_nested_spec.rb +0 -86
- data/spec/swagger_v2/parent_less_namespace_spec.rb +0 -32
- data/spec/swagger_v2/reference_entity_spec.rb +0 -129
- data/spec/swagger_v2/security_requirement_spec.rb +0 -46
- data/spec/swagger_v2/simple_mounted_api_spec.rb +0 -326
- data/spec/version_spec.rb +0 -10
data/spec/lib/extensions_spec.rb
DELETED
@@ -1,185 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe GrapeSwagger::DocMethods::Extensions do
|
6
|
-
context 'it should not break method introspection' do
|
7
|
-
describe '.method' do
|
8
|
-
describe 'method introspection' do
|
9
|
-
specify do
|
10
|
-
expect(described_class.method(described_class.methods.first)).to be_a(Method)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
describe '#find_definition' do
|
17
|
-
subject { described_class }
|
18
|
-
|
19
|
-
let(:method) { :get }
|
20
|
-
let(:status) { 200 }
|
21
|
-
|
22
|
-
before { allow(subject).to receive(:method).and_return(method) }
|
23
|
-
|
24
|
-
describe 'no response for status' do
|
25
|
-
let(:path) { { get: { responses: {} } } }
|
26
|
-
|
27
|
-
specify do
|
28
|
-
definition = subject.find_definition(status, path)
|
29
|
-
expect(definition).to be_nil
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
describe 'response found' do
|
34
|
-
let(:model) { 'Item' }
|
35
|
-
|
36
|
-
describe 'ref given' do
|
37
|
-
let(:path) do
|
38
|
-
{ get: { responses: { 200 => { schema: { '$ref' => "#/definitions/#{model}" } } } } }
|
39
|
-
end
|
40
|
-
specify do
|
41
|
-
definition = subject.find_definition(status, path)
|
42
|
-
expect(definition).to eql model
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
describe 'items given' do
|
47
|
-
let(:path) do
|
48
|
-
{ get: { responses: { 200 => { schema: { 'items' => { '$ref' => "#/definitions/#{model}" } } } } } }
|
49
|
-
end
|
50
|
-
specify do
|
51
|
-
definition = subject.find_definition(status, path)
|
52
|
-
expect(definition).to eql model
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
describe '#extended? and extension' do
|
59
|
-
subject { described_class }
|
60
|
-
describe 'return false (default)' do
|
61
|
-
let(:part) { { foo: 'bar', bar: 'foo' } }
|
62
|
-
|
63
|
-
specify do
|
64
|
-
expect(subject.extended?(part)).to be false
|
65
|
-
expect(subject.extension(part)).to be_empty
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
describe 'return true' do
|
70
|
-
specify do
|
71
|
-
part = { foo: 'bar', bar: 'foo', x: 'something' }
|
72
|
-
expect(subject.extended?(part)).to be true
|
73
|
-
expect(subject.extension(part)).to eql(x: 'something')
|
74
|
-
expect(subject.extended?(part, :x)).to be true
|
75
|
-
expect(subject.extension(part, :x)).to eql(x: 'something')
|
76
|
-
end
|
77
|
-
|
78
|
-
specify do
|
79
|
-
part = { foo: 'bar', bar: 'foo', x_path: 'something' }
|
80
|
-
expect(subject.extended?(part, :x_path)).to be true
|
81
|
-
expect(subject.extension(part, :x_path)).to eql(x_path: 'something')
|
82
|
-
end
|
83
|
-
|
84
|
-
specify do
|
85
|
-
part = { foo: 'bar', bar: 'foo', x_def: 'something' }
|
86
|
-
expect(subject.extended?(part, :x_def)).to be true
|
87
|
-
expect(subject.extension(part, :x_def)).to eql(x_def: 'something')
|
88
|
-
end
|
89
|
-
|
90
|
-
specify do
|
91
|
-
part = { foo: 'bar', bar: 'foo', x_path: 'something', x_def: 'something' }
|
92
|
-
expect(subject.extended?(part, :x_path)).to be true
|
93
|
-
expect(subject.extension(part, :x_path)).to eql(x_path: 'something')
|
94
|
-
expect(subject.extended?(part, :x_def)).to be true
|
95
|
-
expect(subject.extension(part, :x_def)).to eql(x_def: 'something')
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
describe 'concatenate' do
|
101
|
-
describe 'not nested' do
|
102
|
-
describe 'simple' do
|
103
|
-
let(:extensions) { { x: { key_1: 'foo' } } }
|
104
|
-
let(:result) { { 'x-key_1' => 'foo' } }
|
105
|
-
subject { described_class.concatenate(extensions) }
|
106
|
-
|
107
|
-
specify do
|
108
|
-
expect(subject).to eql result
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
describe 'multiple' do
|
113
|
-
let(:extensions) { { x: { key_1: 'foo', key_2: 'bar' } } }
|
114
|
-
let(:result) { { 'x-key_1' => 'foo', 'x-key_2' => 'bar' } }
|
115
|
-
subject { described_class.concatenate(extensions) }
|
116
|
-
|
117
|
-
specify do
|
118
|
-
expect(subject).to eql result
|
119
|
-
end
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
|
-
describe 'nested' do
|
124
|
-
describe 'simple' do
|
125
|
-
let(:extensions) { { x: { key_1: { key_2: 'foo' } } } }
|
126
|
-
let(:result) { { 'x-key_1' => { key_2: 'foo' } } }
|
127
|
-
subject { described_class.concatenate(extensions) }
|
128
|
-
|
129
|
-
specify do
|
130
|
-
expect(subject).to eql result
|
131
|
-
end
|
132
|
-
end
|
133
|
-
|
134
|
-
describe 'simple multiple' do
|
135
|
-
let(:extensions) { { x: { key_1: { key_2: 'foo', key_3: 'bar' } } } }
|
136
|
-
let(:result) { { 'x-key_1' => { key_2: 'foo', key_3: 'bar' } } }
|
137
|
-
subject { described_class.concatenate(extensions) }
|
138
|
-
|
139
|
-
specify do
|
140
|
-
expect(subject).to eql result
|
141
|
-
end
|
142
|
-
end
|
143
|
-
|
144
|
-
describe 'simple deeper' do
|
145
|
-
let(:extensions) { { x: { key_1: { key_2: { key_3: 'foo' } } } } }
|
146
|
-
let(:result) { { 'x-key_1' => { key_2: { key_3: 'foo' } } } }
|
147
|
-
subject { described_class.concatenate(extensions) }
|
148
|
-
|
149
|
-
specify do
|
150
|
-
expect(subject).to eql result
|
151
|
-
end
|
152
|
-
end
|
153
|
-
|
154
|
-
describe 'multiple' do
|
155
|
-
let(:extensions) { { x: { key_1: { key_3: 'foo' }, key_2: { key_3: 'bar' } } } }
|
156
|
-
let(:result) { { 'x-key_1' => { key_3: 'foo' }, 'x-key_2' => { key_3: 'bar' } } }
|
157
|
-
subject { described_class.concatenate(extensions) }
|
158
|
-
|
159
|
-
specify do
|
160
|
-
expect(subject).to eql result
|
161
|
-
end
|
162
|
-
end
|
163
|
-
end
|
164
|
-
|
165
|
-
describe 'real example' do
|
166
|
-
let(:extensions) do
|
167
|
-
{ x: {
|
168
|
-
'amazon-apigateway-auth' => { type: 'none' },
|
169
|
-
'amazon-apigateway-integration' => { type: 'aws', uri: 'foo_bar_uri', httpMethod: 'get' }
|
170
|
-
} }
|
171
|
-
end
|
172
|
-
let(:result) do
|
173
|
-
{
|
174
|
-
'x-amazon-apigateway-auth' => { type: 'none' },
|
175
|
-
'x-amazon-apigateway-integration' => { type: 'aws', uri: 'foo_bar_uri', httpMethod: 'get' }
|
176
|
-
}
|
177
|
-
end
|
178
|
-
subject { described_class.concatenate(extensions) }
|
179
|
-
|
180
|
-
specify do
|
181
|
-
expect(subject).to eql result
|
182
|
-
end
|
183
|
-
end
|
184
|
-
end
|
185
|
-
end
|
@@ -1,115 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe GrapeSwagger::DocMethods::FormatData do
|
6
|
-
let(:subject) { GrapeSwagger::DocMethods::FormatData }
|
7
|
-
|
8
|
-
[true, false].each do |array_use_braces|
|
9
|
-
context 'when param is nested in a param of array type' do
|
10
|
-
let(:braces) { array_use_braces ? '[]' : '' }
|
11
|
-
let(:params) do
|
12
|
-
[
|
13
|
-
{ in: 'formData', name: "param1#{braces}", type: 'array', items: { type: 'string' } },
|
14
|
-
{ in: 'formData', name: 'param1[param2]', type: 'string' }
|
15
|
-
]
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'skips root parameter' do
|
19
|
-
expect(subject.to_format(params).first).not_to have_key "param1#{braces}"
|
20
|
-
end
|
21
|
-
|
22
|
-
it 'Move array type to param2' do
|
23
|
-
expect(subject.to_format(params).first).to include(name: "param1#{braces}[param2]", type: 'array')
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
context 'when param is nested in a param of hash type' do
|
29
|
-
let(:params) { [{ in: 'formData', type: 'object', name: 'param1' }, { in: 'formData', name: 'param1[param2]', type: 'string' }] }
|
30
|
-
|
31
|
-
it 'skips root parameter' do
|
32
|
-
expect(subject.to_format(params).first).not_to have_key 'param1'
|
33
|
-
end
|
34
|
-
|
35
|
-
it 'Move array type to param2' do
|
36
|
-
expect(subject.to_format(params).first).to include(name: 'param1[param2]', type: 'string')
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
context 'when params contain a complex array' do
|
41
|
-
let(:params) do
|
42
|
-
[
|
43
|
-
{ name: 'id', required: true, type: 'string' },
|
44
|
-
{ name: 'description', required: false, type: 'string' },
|
45
|
-
{ name: 'stuffs', required: true, type: 'array' },
|
46
|
-
{ name: 'stuffs[id]', required: true, type: 'string' }
|
47
|
-
]
|
48
|
-
end
|
49
|
-
|
50
|
-
let(:expected_params) do
|
51
|
-
[
|
52
|
-
{ name: 'id', required: true, type: 'string' },
|
53
|
-
{ name: 'description', required: false, type: 'string' },
|
54
|
-
{ name: 'stuffs[id]', required: true, type: 'array', items: { type: 'string' } }
|
55
|
-
]
|
56
|
-
end
|
57
|
-
|
58
|
-
it 'parses params correctly and adds array type all concerned elements' do
|
59
|
-
expect(subject.to_format(params)).to eq expected_params
|
60
|
-
end
|
61
|
-
|
62
|
-
context 'when array params are not contiguous with parent array' do
|
63
|
-
let(:params) do
|
64
|
-
[
|
65
|
-
{ name: 'id', required: true, type: 'string' },
|
66
|
-
{ name: 'description', required: false, type: 'string' },
|
67
|
-
{ name: 'stuffs', required: true, type: 'array' },
|
68
|
-
{ name: 'stuffs[owners]', required: true, type: 'array' },
|
69
|
-
{ name: 'stuffs[creators]', required: true, type: 'array' },
|
70
|
-
{ name: 'stuffs[owners][id]', required: true, type: 'string' },
|
71
|
-
{ name: 'stuffs[creators][id]', required: true, type: 'string' },
|
72
|
-
{ name: 'stuffs_and_things', required: true, type: 'string' }
|
73
|
-
]
|
74
|
-
end
|
75
|
-
|
76
|
-
let(:expected_params) do
|
77
|
-
[
|
78
|
-
{ name: 'id', required: true, type: 'string' },
|
79
|
-
{ name: 'description', required: false, type: 'string' },
|
80
|
-
{ name: 'stuffs[owners][id]', required: true, type: 'array', items: { type: 'string' } },
|
81
|
-
{ name: 'stuffs[creators][id]', required: true, type: 'array', items: { type: 'string' } },
|
82
|
-
{ name: 'stuffs_and_things', required: true, type: 'string' }
|
83
|
-
]
|
84
|
-
end
|
85
|
-
|
86
|
-
it 'parses params correctly and adds array type all concerned elements' do
|
87
|
-
expect(subject.to_format(params)).to eq expected_params
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
context 'when array params are not related' do
|
92
|
-
let(:params) do
|
93
|
-
[
|
94
|
-
{ name: 'id', required: true, type: 'string' },
|
95
|
-
{ name: 'description', required: false, type: 'string' },
|
96
|
-
{ name: 'ids[]', required: true, type: 'array', items: { type: 'string' } },
|
97
|
-
{ name: 'user_ids[]', required: true, type: 'array', items: { type: 'string' } }
|
98
|
-
]
|
99
|
-
end
|
100
|
-
|
101
|
-
let(:expected_params) do
|
102
|
-
[
|
103
|
-
{ name: 'id', required: true, type: 'string' },
|
104
|
-
{ name: 'description', required: false, type: 'string' },
|
105
|
-
{ name: 'ids[]', required: true, type: 'array', items: { type: 'string' } },
|
106
|
-
{ name: 'user_ids[]', required: true, type: 'array', items: { type: 'string' } }
|
107
|
-
]
|
108
|
-
end
|
109
|
-
|
110
|
-
it 'parses params correctly and adds array type all concerned elements' do
|
111
|
-
expect(subject.to_format(params)).to eq expected_params
|
112
|
-
end
|
113
|
-
end
|
114
|
-
end
|
115
|
-
end
|
@@ -1,104 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe GrapeSwagger::ModelParsers do
|
6
|
-
let(:model_parsers) { described_class.new }
|
7
|
-
let(:parser) { Class.new }
|
8
|
-
let(:parser2) { Class.new }
|
9
|
-
let(:parser3) { Class.new }
|
10
|
-
|
11
|
-
describe '#register' do
|
12
|
-
describe 'successfully register new parser' do
|
13
|
-
before do
|
14
|
-
model_parsers.register(parser, Class)
|
15
|
-
end
|
16
|
-
|
17
|
-
specify do
|
18
|
-
expect(model_parsers.to_a).to eq([[parser, 'Class']])
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
describe 'should be empty if no registered parsers' do
|
23
|
-
specify do
|
24
|
-
expect(model_parsers.to_a).to be_empty
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
describe '#insert_before' do
|
30
|
-
describe 'SomeModelParser2 should be first parser' do
|
31
|
-
before do
|
32
|
-
model_parsers.register(parser, Class)
|
33
|
-
model_parsers.register(parser3, Class)
|
34
|
-
model_parsers.insert_before(parser, parser2, Class)
|
35
|
-
end
|
36
|
-
|
37
|
-
specify do
|
38
|
-
expect(model_parsers.count).to eq(3)
|
39
|
-
expect(model_parsers.to_a.first).to eq([parser2, Class])
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
describe 'SomeModelParser2 should be inserted anyway if SomeModelParser not registered' do
|
44
|
-
before do
|
45
|
-
model_parsers.register(parser3, Class)
|
46
|
-
model_parsers.insert_before(parser, parser2, Class)
|
47
|
-
end
|
48
|
-
|
49
|
-
specify do
|
50
|
-
expect(model_parsers.count).to eq(2)
|
51
|
-
expect(model_parsers.to_a).to include([parser2, Class])
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
describe 'SomeModelParser2 should be inserted anyway if model parsers is empty' do
|
56
|
-
before do
|
57
|
-
model_parsers.insert_before(parser, parser2, Class)
|
58
|
-
end
|
59
|
-
|
60
|
-
specify do
|
61
|
-
expect(model_parsers.count).to eq(1)
|
62
|
-
expect(model_parsers.to_a).to include([parser2, Class])
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
describe '#insert_after' do
|
68
|
-
describe 'SomeModelParser2 should be second parser' do
|
69
|
-
before do
|
70
|
-
model_parsers.register(parser, Class)
|
71
|
-
model_parsers.register(parser3, Class)
|
72
|
-
model_parsers.insert_after(parser, parser2, Class)
|
73
|
-
end
|
74
|
-
|
75
|
-
specify do
|
76
|
-
expect(model_parsers.count).to eq(3)
|
77
|
-
expect(model_parsers.to_a[1]).to eq([parser2, Class])
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
describe 'SomeModelParser2 should be inserted anyway if SomeModelParser not registered' do
|
82
|
-
before do
|
83
|
-
model_parsers.register(parser3, Class)
|
84
|
-
model_parsers.insert_after(parser, parser2, Class)
|
85
|
-
end
|
86
|
-
|
87
|
-
specify do
|
88
|
-
expect(model_parsers.count).to eq(2)
|
89
|
-
expect(model_parsers.to_a).to include([parser2, Class])
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
describe 'SomeModelParser2 should be inserted anyway if model parsers is empty' do
|
94
|
-
before do
|
95
|
-
model_parsers.insert_after(parser, parser2, Class)
|
96
|
-
end
|
97
|
-
|
98
|
-
specify do
|
99
|
-
expect(model_parsers.count).to eq(1)
|
100
|
-
expect(model_parsers.to_a).to include([parser2, Class])
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|