grape 1.6.1 → 1.7.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +36 -0
- data/CONTRIBUTING.md +1 -1
- data/README.md +120 -19
- data/UPGRADING.md +19 -4
- data/lib/grape/api/instance.rb +1 -1
- data/lib/grape/dsl/api.rb +0 -2
- data/lib/grape/dsl/callbacks.rb +0 -2
- data/lib/grape/dsl/configuration.rb +0 -2
- data/lib/grape/dsl/desc.rb +0 -15
- data/lib/grape/dsl/helpers.rb +0 -2
- data/lib/grape/dsl/inside_route.rb +33 -29
- data/lib/grape/dsl/middleware.rb +0 -2
- data/lib/grape/dsl/parameters.rb +5 -7
- data/lib/grape/dsl/request_response.rb +0 -2
- data/lib/grape/dsl/routing.rb +4 -2
- data/lib/grape/dsl/settings.rb +0 -2
- data/lib/grape/dsl/validations.rb +0 -15
- data/lib/grape/error_formatter/json.rb +7 -1
- data/lib/grape/exceptions/base.rb +2 -2
- data/lib/grape/exceptions/missing_group_type.rb +8 -1
- data/lib/grape/exceptions/too_many_multipart_files.rb +11 -0
- data/lib/grape/exceptions/unsupported_group_type.rb +8 -1
- data/lib/grape/exceptions/validation.rb +0 -4
- data/lib/grape/locale/en.yml +9 -8
- data/lib/grape/middleware/auth/dsl.rb +0 -1
- data/lib/grape/middleware/error.rb +2 -2
- data/lib/grape/request.rb +2 -0
- data/lib/grape/validations/attributes_doc.rb +58 -0
- data/lib/grape/validations/params_scope.rb +66 -40
- data/lib/grape/validations/types/array_coercer.rb +2 -2
- data/lib/grape/validations/types/build_coercer.rb +94 -0
- data/lib/grape/validations/types/dry_type_coercer.rb +13 -8
- data/lib/grape/validations/types/json.rb +2 -0
- data/lib/grape/validations/types/primitive_coercer.rb +20 -10
- data/lib/grape/validations/types/set_coercer.rb +3 -2
- data/lib/grape/validations/types.rb +20 -26
- data/lib/grape/validations/validators/base.rb +7 -0
- data/lib/grape/validations.rb +16 -6
- data/lib/grape/version.rb +1 -1
- data/lib/grape.rb +20 -15
- data/spec/grape/api/custom_validations_spec.rb +41 -2
- data/spec/grape/api/deeply_included_options_spec.rb +0 -2
- data/spec/grape/api/defines_boolean_in_params_spec.rb +0 -2
- data/spec/grape/api/documentation_spec.rb +59 -0
- data/spec/grape/api/inherited_helpers_spec.rb +0 -2
- data/spec/grape/api/instance_spec.rb +0 -1
- data/spec/grape/api/invalid_format_spec.rb +0 -2
- data/spec/grape/api/namespace_parameters_in_route_spec.rb +0 -2
- data/spec/grape/api/nested_helpers_spec.rb +0 -2
- data/spec/grape/api/optional_parameters_in_route_spec.rb +0 -2
- data/spec/grape/api/parameters_modification_spec.rb +0 -2
- data/spec/grape/api/patch_method_helpers_spec.rb +0 -2
- data/spec/grape/api/recognize_path_spec.rb +0 -2
- data/spec/grape/api/required_parameters_in_route_spec.rb +0 -2
- data/spec/grape/api/required_parameters_with_invalid_method_spec.rb +0 -2
- data/spec/grape/api/routes_with_requirements_spec.rb +0 -2
- data/spec/grape/api/shared_helpers_exactly_one_of_spec.rb +0 -2
- data/spec/grape/api/shared_helpers_spec.rb +0 -2
- data/spec/grape/api_remount_spec.rb +0 -1
- data/spec/grape/api_spec.rb +18 -5
- data/spec/grape/config_spec.rb +0 -2
- data/spec/grape/dsl/callbacks_spec.rb +0 -2
- data/spec/grape/dsl/configuration_spec.rb +0 -2
- data/spec/grape/dsl/desc_spec.rb +0 -2
- data/spec/grape/dsl/headers_spec.rb +2 -4
- data/spec/grape/dsl/helpers_spec.rb +0 -2
- data/spec/grape/dsl/inside_route_spec.rb +10 -12
- data/spec/grape/dsl/logger_spec.rb +0 -2
- data/spec/grape/dsl/middleware_spec.rb +0 -2
- data/spec/grape/dsl/parameters_spec.rb +0 -2
- data/spec/grape/dsl/request_response_spec.rb +6 -8
- data/spec/grape/dsl/routing_spec.rb +1 -3
- data/spec/grape/dsl/settings_spec.rb +0 -2
- data/spec/grape/dsl/validations_spec.rb +0 -17
- data/spec/grape/endpoint/declared_spec.rb +2 -4
- data/spec/grape/endpoint_spec.rb +22 -3
- data/spec/grape/entity_spec.rb +0 -1
- data/spec/grape/exceptions/base_spec.rb +16 -2
- data/spec/grape/exceptions/body_parse_errors_spec.rb +0 -2
- data/spec/grape/exceptions/invalid_accept_header_spec.rb +0 -2
- data/spec/grape/exceptions/invalid_formatter_spec.rb +0 -2
- data/spec/grape/exceptions/invalid_response_spec.rb +0 -2
- data/spec/grape/exceptions/invalid_versioner_option_spec.rb +1 -3
- data/spec/grape/exceptions/missing_group_type_spec.rb +21 -0
- data/spec/grape/exceptions/missing_mime_type_spec.rb +0 -2
- data/spec/grape/exceptions/missing_option_spec.rb +1 -3
- data/spec/grape/exceptions/unknown_options_spec.rb +0 -2
- data/spec/grape/exceptions/unknown_validator_spec.rb +0 -2
- data/spec/grape/exceptions/unsupported_group_type_spec.rb +23 -0
- data/spec/grape/exceptions/validation_errors_spec.rb +0 -1
- data/spec/grape/exceptions/validation_spec.rb +1 -3
- data/spec/grape/extensions/param_builders/hash_spec.rb +0 -2
- data/spec/grape/extensions/param_builders/hash_with_indifferent_access_spec.rb +0 -2
- data/spec/grape/extensions/param_builders/hashie/mash_spec.rb +0 -2
- data/spec/grape/integration/global_namespace_function_spec.rb +0 -2
- data/spec/grape/integration/rack_sendfile_spec.rb +0 -2
- data/spec/grape/integration/rack_spec.rb +0 -2
- data/spec/grape/loading_spec.rb +0 -2
- data/spec/grape/middleware/auth/base_spec.rb +0 -1
- data/spec/grape/middleware/auth/dsl_spec.rb +0 -2
- data/spec/grape/middleware/auth/strategies_spec.rb +0 -2
- data/spec/grape/middleware/base_spec.rb +0 -2
- data/spec/grape/middleware/error_spec.rb +6 -1
- data/spec/grape/middleware/exception_spec.rb +0 -2
- data/spec/grape/middleware/formatter_spec.rb +0 -2
- data/spec/grape/middleware/globals_spec.rb +0 -2
- data/spec/grape/middleware/stack_spec.rb +0 -2
- data/spec/grape/middleware/versioner/accept_version_header_spec.rb +0 -2
- data/spec/grape/middleware/versioner/header_spec.rb +18 -4
- data/spec/grape/middleware/versioner/param_spec.rb +0 -2
- data/spec/grape/middleware/versioner/path_spec.rb +0 -2
- data/spec/grape/middleware/versioner_spec.rb +0 -2
- data/spec/grape/named_api_spec.rb +0 -2
- data/spec/grape/parser_spec.rb +0 -2
- data/spec/grape/path_spec.rb +0 -2
- data/spec/grape/presenters/presenter_spec.rb +0 -2
- data/spec/grape/request_spec.rb +0 -2
- data/spec/grape/util/inheritable_setting_spec.rb +0 -1
- data/spec/grape/util/inheritable_values_spec.rb +0 -1
- data/spec/grape/util/reverse_stackable_values_spec.rb +0 -1
- data/spec/grape/util/stackable_values_spec.rb +0 -1
- data/spec/grape/util/strict_hash_configuration_spec.rb +0 -1
- data/spec/grape/validations/attributes_doc_spec.rb +153 -0
- data/spec/grape/validations/attributes_iterator_spec.rb +0 -2
- data/spec/grape/validations/instance_behaivour_spec.rb +0 -2
- data/spec/grape/validations/multiple_attributes_iterator_spec.rb +0 -2
- data/spec/grape/validations/params_scope_spec.rb +315 -86
- data/spec/grape/validations/single_attribute_iterator_spec.rb +0 -2
- data/spec/grape/validations/types/array_coercer_spec.rb +0 -2
- data/spec/grape/validations/types/primitive_coercer_spec.rb +20 -5
- data/spec/grape/validations/types/set_coercer_spec.rb +0 -2
- data/spec/grape/validations/types_spec.rb +28 -2
- data/spec/grape/validations/validators/all_or_none_spec.rb +0 -2
- data/spec/grape/validations/validators/allow_blank_spec.rb +0 -2
- data/spec/grape/validations/validators/at_least_one_of_spec.rb +0 -2
- data/spec/grape/validations/validators/coerce_spec.rb +0 -2
- data/spec/grape/validations/validators/default_spec.rb +0 -2
- data/spec/grape/validations/validators/exactly_one_of_spec.rb +0 -2
- data/spec/grape/validations/validators/except_values_spec.rb +0 -2
- data/spec/grape/validations/validators/mutual_exclusion_spec.rb +0 -2
- data/spec/grape/validations/validators/presence_spec.rb +0 -2
- data/spec/grape/validations/validators/regexp_spec.rb +0 -2
- data/spec/grape/validations/validators/same_as_spec.rb +0 -2
- data/spec/grape/validations/validators/values_spec.rb +0 -2
- data/spec/grape/validations_spec.rb +50 -22
- data/spec/integration/multi_json/json_spec.rb +0 -2
- data/spec/integration/multi_xml/xml_spec.rb +0 -2
- data/spec/spec_helper.rb +9 -4
- metadata +17 -8
- data/spec/support/eager_load.rb +0 -19
@@ -1,7 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
3
|
describe Grape::Validations do
|
6
4
|
subject { Class.new(Grape::API) }
|
7
5
|
|
@@ -45,7 +43,7 @@ describe Grape::Validations do
|
|
45
43
|
subject.params do
|
46
44
|
optional :some_param
|
47
45
|
end
|
48
|
-
expect(declared_params).to eq([:some_param])
|
46
|
+
expect(Grape::Validations::ParamsScope::Attr.attrs_keys(declared_params)).to eq([:some_param])
|
49
47
|
end
|
50
48
|
end
|
51
49
|
|
@@ -65,7 +63,7 @@ describe Grape::Validations do
|
|
65
63
|
|
66
64
|
it 'adds entity documentation to declared params' do
|
67
65
|
define_optional_using
|
68
|
-
expect(declared_params).to eq(%i[field_a field_b])
|
66
|
+
expect(Grape::Validations::ParamsScope::Attr.attrs_keys(declared_params)).to eq(%i[field_a field_b])
|
69
67
|
end
|
70
68
|
|
71
69
|
it 'works when field_a and field_b are not present' do
|
@@ -112,7 +110,7 @@ describe Grape::Validations do
|
|
112
110
|
subject.params do
|
113
111
|
requires :some_param
|
114
112
|
end
|
115
|
-
expect(declared_params).to eq([:some_param])
|
113
|
+
expect(Grape::Validations::ParamsScope::Attr.attrs_keys(declared_params)).to eq([:some_param])
|
116
114
|
end
|
117
115
|
|
118
116
|
it 'works when required field is present but nil' do
|
@@ -197,7 +195,7 @@ describe Grape::Validations do
|
|
197
195
|
|
198
196
|
it 'adds entity documentation to declared params' do
|
199
197
|
define_requires_all
|
200
|
-
expect(declared_params).to eq(%i[required_field optional_field])
|
198
|
+
expect(Grape::Validations::ParamsScope::Attr.attrs_keys(declared_params)).to eq(%i[required_field optional_field])
|
201
199
|
end
|
202
200
|
|
203
201
|
it 'errors when required_field is not present' do
|
@@ -232,7 +230,7 @@ describe Grape::Validations do
|
|
232
230
|
|
233
231
|
it 'adds entity documentation to declared params' do
|
234
232
|
define_requires_none
|
235
|
-
expect(declared_params).to eq(%i[required_field optional_field])
|
233
|
+
expect(Grape::Validations::ParamsScope::Attr.attrs_keys(declared_params)).to eq(%i[required_field optional_field])
|
236
234
|
end
|
237
235
|
|
238
236
|
it 'errors when required_field is not present' do
|
@@ -262,7 +260,7 @@ describe Grape::Validations do
|
|
262
260
|
|
263
261
|
it 'adds only the entity documentation to declared params, nothing more' do
|
264
262
|
define_requires_all
|
265
|
-
expect(declared_params).to eq(%i[required_field optional_field])
|
263
|
+
expect(Grape::Validations::ParamsScope::Attr.attrs_keys(declared_params)).to eq(%i[required_field optional_field])
|
266
264
|
end
|
267
265
|
end
|
268
266
|
|
@@ -328,7 +326,7 @@ describe Grape::Validations do
|
|
328
326
|
requires :key
|
329
327
|
end
|
330
328
|
end
|
331
|
-
expect(declared_params).to eq([items: [:key]])
|
329
|
+
expect(Grape::Validations::ParamsScope::Attr.attrs_keys(declared_params)).to eq([items: [:key]])
|
332
330
|
end
|
333
331
|
end
|
334
332
|
|
@@ -400,7 +398,7 @@ describe Grape::Validations do
|
|
400
398
|
requires :key
|
401
399
|
end
|
402
400
|
end
|
403
|
-
expect(declared_params).to eq([items: [:key]])
|
401
|
+
expect(Grape::Validations::ParamsScope::Attr.attrs_keys(declared_params)).to eq([items: [:key]])
|
404
402
|
end
|
405
403
|
end
|
406
404
|
|
@@ -463,7 +461,7 @@ describe Grape::Validations do
|
|
463
461
|
requires :key
|
464
462
|
end
|
465
463
|
end
|
466
|
-
expect(declared_params).to eq([items: [:key]])
|
464
|
+
expect(Grape::Validations::ParamsScope::Attr.attrs_keys(declared_params)).to eq([items: [:key]])
|
467
465
|
end
|
468
466
|
end
|
469
467
|
|
@@ -824,7 +822,7 @@ describe Grape::Validations do
|
|
824
822
|
requires :key
|
825
823
|
end
|
826
824
|
end
|
827
|
-
expect(declared_params).to eq([items: [:key]])
|
825
|
+
expect(Grape::Validations::ParamsScope::Attr.attrs_keys(declared_params)).to eq([items: [:key]])
|
828
826
|
end
|
829
827
|
end
|
830
828
|
|
@@ -888,7 +886,7 @@ describe Grape::Validations do
|
|
888
886
|
requires(:required_subitems, type: Array) { requires :value }
|
889
887
|
end
|
890
888
|
end
|
891
|
-
expect(declared_params).to eq([items: [:key, { optional_subitems: [:value] }, { required_subitems: [:value] }]])
|
889
|
+
expect(Grape::Validations::ParamsScope::Attr.attrs_keys(declared_params)).to eq([items: [:key, { optional_subitems: [:value] }, { required_subitems: [:value] }]])
|
892
890
|
end
|
893
891
|
|
894
892
|
context <<~DESC do
|
@@ -1428,14 +1426,14 @@ describe Grape::Validations do
|
|
1428
1426
|
subject.params do
|
1429
1427
|
use :pagination
|
1430
1428
|
end
|
1431
|
-
expect(declared_params).to eq %i[page per_page]
|
1429
|
+
expect(Grape::Validations::ParamsScope::Attr.attrs_keys(declared_params)).to eq %i[page per_page]
|
1432
1430
|
end
|
1433
1431
|
|
1434
1432
|
it 'by #use with multiple params' do
|
1435
1433
|
subject.params do
|
1436
1434
|
use :pagination, :period
|
1437
1435
|
end
|
1438
|
-
expect(declared_params).to eq %i[page per_page start_date end_date]
|
1436
|
+
expect(Grape::Validations::ParamsScope::Attr.attrs_keys(declared_params)).to eq %i[page per_page start_date end_date]
|
1439
1437
|
end
|
1440
1438
|
end
|
1441
1439
|
|
@@ -1485,17 +1483,29 @@ describe Grape::Validations do
|
|
1485
1483
|
end
|
1486
1484
|
end
|
1487
1485
|
|
1488
|
-
context '
|
1489
|
-
|
1490
|
-
|
1491
|
-
|
1486
|
+
context 'with block and keyword argument' do
|
1487
|
+
before do
|
1488
|
+
subject.helpers do
|
1489
|
+
params :shared_params do |type:|
|
1490
|
+
optional :param, default: type
|
1491
|
+
end
|
1492
|
+
end
|
1493
|
+
subject.format :json
|
1492
1494
|
subject.params do
|
1493
|
-
|
1495
|
+
use :shared_params, type: 'value'
|
1494
1496
|
end
|
1495
|
-
subject.get '/' do
|
1497
|
+
subject.get '/shared_params' do
|
1498
|
+
{
|
1499
|
+
param: params[:param]
|
1500
|
+
}
|
1496
1501
|
end
|
1502
|
+
end
|
1497
1503
|
|
1498
|
-
|
1504
|
+
it 'works' do
|
1505
|
+
get '/shared_params'
|
1506
|
+
|
1507
|
+
expect(last_response.status).to eq(200)
|
1508
|
+
expect(last_response.body).to eq({ param: 'value' }.to_json)
|
1499
1509
|
end
|
1500
1510
|
end
|
1501
1511
|
|
@@ -1975,4 +1985,22 @@ describe Grape::Validations do
|
|
1975
1985
|
end
|
1976
1986
|
end
|
1977
1987
|
end
|
1988
|
+
|
1989
|
+
describe 'require_validator' do
|
1990
|
+
subject { described_class.require_validator(short_name) }
|
1991
|
+
|
1992
|
+
context 'when found' do
|
1993
|
+
let(:short_name) { :presence }
|
1994
|
+
|
1995
|
+
it { is_expected.to be(Grape::Validations::Validators::PresenceValidator) }
|
1996
|
+
end
|
1997
|
+
|
1998
|
+
context 'when not found' do
|
1999
|
+
let(:short_name) { :test }
|
2000
|
+
|
2001
|
+
it 'raises an error' do
|
2002
|
+
expect { subject }.to raise_error(Grape::Exceptions::UnknownValidator)
|
2003
|
+
end
|
2004
|
+
end
|
2005
|
+
end
|
1978
2006
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -23,8 +23,6 @@ Dir["#{File.dirname(__FILE__)}/support/*.rb"].sort.each do |file|
|
|
23
23
|
require file
|
24
24
|
end
|
25
25
|
|
26
|
-
eager_load!
|
27
|
-
|
28
26
|
# The default value for this setting is true in a standard Rails app,
|
29
27
|
# so it should be set to true here as well to reflect that.
|
30
28
|
I18n.enforce_available_locales = true
|
@@ -43,5 +41,12 @@ RSpec.configure do |config|
|
|
43
41
|
config.example_status_persistence_file_path = '.rspec_status'
|
44
42
|
end
|
45
43
|
|
46
|
-
require '
|
47
|
-
|
44
|
+
require 'simplecov'
|
45
|
+
require 'simplecov-lcov'
|
46
|
+
SimpleCov::Formatter::LcovFormatter.config do |c|
|
47
|
+
c.report_with_single_file = true
|
48
|
+
c.single_report_path = 'coverage/lcov.info'
|
49
|
+
end
|
50
|
+
|
51
|
+
SimpleCov.formatter = SimpleCov::Formatter::LcovFormatter
|
52
|
+
SimpleCov.start
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: grape
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Bleigh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-12-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -152,6 +152,7 @@ files:
|
|
152
152
|
- lib/grape/exceptions/missing_mime_type.rb
|
153
153
|
- lib/grape/exceptions/missing_option.rb
|
154
154
|
- lib/grape/exceptions/missing_vendor_option.rb
|
155
|
+
- lib/grape/exceptions/too_many_multipart_files.rb
|
155
156
|
- lib/grape/exceptions/unknown_options.rb
|
156
157
|
- lib/grape/exceptions/unknown_parameter.rb
|
157
158
|
- lib/grape/exceptions/unknown_validator.rb
|
@@ -218,12 +219,14 @@ files:
|
|
218
219
|
- lib/grape/util/strict_hash_configuration.rb
|
219
220
|
- lib/grape/util/xml.rb
|
220
221
|
- lib/grape/validations.rb
|
222
|
+
- lib/grape/validations/attributes_doc.rb
|
221
223
|
- lib/grape/validations/attributes_iterator.rb
|
222
224
|
- lib/grape/validations/multiple_attributes_iterator.rb
|
223
225
|
- lib/grape/validations/params_scope.rb
|
224
226
|
- lib/grape/validations/single_attribute_iterator.rb
|
225
227
|
- lib/grape/validations/types.rb
|
226
228
|
- lib/grape/validations/types/array_coercer.rb
|
229
|
+
- lib/grape/validations/types/build_coercer.rb
|
227
230
|
- lib/grape/validations/types/custom_type_coercer.rb
|
228
231
|
- lib/grape/validations/types/custom_type_collection_coercer.rb
|
229
232
|
- lib/grape/validations/types/dry_type_coercer.rb
|
@@ -254,6 +257,7 @@ files:
|
|
254
257
|
- spec/grape/api/custom_validations_spec.rb
|
255
258
|
- spec/grape/api/deeply_included_options_spec.rb
|
256
259
|
- spec/grape/api/defines_boolean_in_params_spec.rb
|
260
|
+
- spec/grape/api/documentation_spec.rb
|
257
261
|
- spec/grape/api/inherited_helpers_spec.rb
|
258
262
|
- spec/grape/api/instance_spec.rb
|
259
263
|
- spec/grape/api/invalid_format_spec.rb
|
@@ -293,10 +297,12 @@ files:
|
|
293
297
|
- spec/grape/exceptions/invalid_formatter_spec.rb
|
294
298
|
- spec/grape/exceptions/invalid_response_spec.rb
|
295
299
|
- spec/grape/exceptions/invalid_versioner_option_spec.rb
|
300
|
+
- spec/grape/exceptions/missing_group_type_spec.rb
|
296
301
|
- spec/grape/exceptions/missing_mime_type_spec.rb
|
297
302
|
- spec/grape/exceptions/missing_option_spec.rb
|
298
303
|
- spec/grape/exceptions/unknown_options_spec.rb
|
299
304
|
- spec/grape/exceptions/unknown_validator_spec.rb
|
305
|
+
- spec/grape/exceptions/unsupported_group_type_spec.rb
|
300
306
|
- spec/grape/exceptions/validation_errors_spec.rb
|
301
307
|
- spec/grape/exceptions/validation_spec.rb
|
302
308
|
- spec/grape/extensions/param_builders/hash_spec.rb
|
@@ -330,6 +336,7 @@ files:
|
|
330
336
|
- spec/grape/util/reverse_stackable_values_spec.rb
|
331
337
|
- spec/grape/util/stackable_values_spec.rb
|
332
338
|
- spec/grape/util/strict_hash_configuration_spec.rb
|
339
|
+
- spec/grape/validations/attributes_doc_spec.rb
|
333
340
|
- spec/grape/validations/attributes_iterator_spec.rb
|
334
341
|
- spec/grape/validations/instance_behaivour_spec.rb
|
335
342
|
- spec/grape/validations/multiple_attributes_iterator_spec.rb
|
@@ -361,7 +368,6 @@ files:
|
|
361
368
|
- spec/support/basic_auth_encode_helpers.rb
|
362
369
|
- spec/support/chunks.rb
|
363
370
|
- spec/support/content_type_helpers.rb
|
364
|
-
- spec/support/eager_load.rb
|
365
371
|
- spec/support/endpoint_faker.rb
|
366
372
|
- spec/support/file_streamer.rb
|
367
373
|
- spec/support/integer_helpers.rb
|
@@ -371,9 +377,9 @@ licenses:
|
|
371
377
|
- MIT
|
372
378
|
metadata:
|
373
379
|
bug_tracker_uri: https://github.com/ruby-grape/grape/issues
|
374
|
-
changelog_uri: https://github.com/ruby-grape/grape/blob/v1.
|
375
|
-
documentation_uri: https://www.rubydoc.info/gems/grape/1.
|
376
|
-
source_code_uri: https://github.com/ruby-grape/grape/tree/v1.
|
380
|
+
changelog_uri: https://github.com/ruby-grape/grape/blob/v1.7.0/CHANGELOG.md
|
381
|
+
documentation_uri: https://www.rubydoc.info/gems/grape/1.7.0
|
382
|
+
source_code_uri: https://github.com/ruby-grape/grape/tree/v1.7.0
|
377
383
|
post_install_message:
|
378
384
|
rdoc_options: []
|
379
385
|
require_paths:
|
@@ -389,7 +395,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
389
395
|
- !ruby/object:Gem::Version
|
390
396
|
version: '0'
|
391
397
|
requirements: []
|
392
|
-
rubygems_version: 3.3.
|
398
|
+
rubygems_version: 3.3.7
|
393
399
|
signing_key:
|
394
400
|
specification_version: 4
|
395
401
|
summary: A simple Ruby framework for building REST-like APIs.
|
@@ -397,6 +403,7 @@ test_files:
|
|
397
403
|
- spec/grape/api/custom_validations_spec.rb
|
398
404
|
- spec/grape/api/deeply_included_options_spec.rb
|
399
405
|
- spec/grape/api/defines_boolean_in_params_spec.rb
|
406
|
+
- spec/grape/api/documentation_spec.rb
|
400
407
|
- spec/grape/api/inherited_helpers_spec.rb
|
401
408
|
- spec/grape/api/instance_spec.rb
|
402
409
|
- spec/grape/api/invalid_format_spec.rb
|
@@ -436,10 +443,12 @@ test_files:
|
|
436
443
|
- spec/grape/exceptions/invalid_formatter_spec.rb
|
437
444
|
- spec/grape/exceptions/invalid_response_spec.rb
|
438
445
|
- spec/grape/exceptions/invalid_versioner_option_spec.rb
|
446
|
+
- spec/grape/exceptions/missing_group_type_spec.rb
|
439
447
|
- spec/grape/exceptions/missing_mime_type_spec.rb
|
440
448
|
- spec/grape/exceptions/missing_option_spec.rb
|
441
449
|
- spec/grape/exceptions/unknown_options_spec.rb
|
442
450
|
- spec/grape/exceptions/unknown_validator_spec.rb
|
451
|
+
- spec/grape/exceptions/unsupported_group_type_spec.rb
|
443
452
|
- spec/grape/exceptions/validation_errors_spec.rb
|
444
453
|
- spec/grape/exceptions/validation_spec.rb
|
445
454
|
- spec/grape/extensions/param_builders/hash_spec.rb
|
@@ -473,6 +482,7 @@ test_files:
|
|
473
482
|
- spec/grape/util/reverse_stackable_values_spec.rb
|
474
483
|
- spec/grape/util/stackable_values_spec.rb
|
475
484
|
- spec/grape/util/strict_hash_configuration_spec.rb
|
485
|
+
- spec/grape/validations/attributes_doc_spec.rb
|
476
486
|
- spec/grape/validations/attributes_iterator_spec.rb
|
477
487
|
- spec/grape/validations/instance_behaivour_spec.rb
|
478
488
|
- spec/grape/validations/multiple_attributes_iterator_spec.rb
|
@@ -504,7 +514,6 @@ test_files:
|
|
504
514
|
- spec/support/basic_auth_encode_helpers.rb
|
505
515
|
- spec/support/chunks.rb
|
506
516
|
- spec/support/content_type_helpers.rb
|
507
|
-
- spec/support/eager_load.rb
|
508
517
|
- spec/support/endpoint_faker.rb
|
509
518
|
- spec/support/file_streamer.rb
|
510
519
|
- spec/support/integer_helpers.rb
|
data/spec/support/eager_load.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Grape uses autoload https://api.rubyonrails.org/classes/ActiveSupport/Autoload.html.
|
4
|
-
# When a class/module get added to the list, ActiveSupport doesn't check whether it really exists.
|
5
|
-
# This method loads all classes/modules defined via autoload to be sure only existing
|
6
|
-
# classes/modules were listed.
|
7
|
-
def eager_load!(scope = Grape)
|
8
|
-
# get modules
|
9
|
-
scope.constants.each do |const_name|
|
10
|
-
const = scope.const_get(const_name)
|
11
|
-
|
12
|
-
next unless const.respond_to?(:eager_load!)
|
13
|
-
|
14
|
-
const.eager_load!
|
15
|
-
|
16
|
-
# check its modules, they might need to be loaded as well.
|
17
|
-
eager_load!(const)
|
18
|
-
end
|
19
|
-
end
|