grape 1.6.0 → 1.6.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +26 -0
  3. data/CONTRIBUTING.md +2 -1
  4. data/README.md +9 -1
  5. data/UPGRADING.md +4 -4
  6. data/lib/grape/api.rb +12 -0
  7. data/lib/grape/dsl/headers.rb +5 -2
  8. data/lib/grape/dsl/helpers.rb +1 -1
  9. data/lib/grape/middleware/auth/dsl.rb +7 -1
  10. data/lib/grape/middleware/base.rb +1 -1
  11. data/lib/grape/util/strict_hash_configuration.rb +1 -1
  12. data/lib/grape/validations/validators/all_or_none.rb +7 -5
  13. data/lib/grape/validations/validators/allow_blank.rb +9 -7
  14. data/lib/grape/validations/validators/as.rb +7 -5
  15. data/lib/grape/validations/validators/at_least_one_of.rb +6 -4
  16. data/lib/grape/validations/validators/base.rb +73 -71
  17. data/lib/grape/validations/validators/coerce.rb +63 -75
  18. data/lib/grape/validations/validators/default.rb +36 -34
  19. data/lib/grape/validations/validators/exactly_one_of.rb +8 -6
  20. data/lib/grape/validations/validators/except_values.rb +13 -11
  21. data/lib/grape/validations/validators/multiple_params_base.rb +24 -22
  22. data/lib/grape/validations/validators/mutual_exclusion.rb +7 -5
  23. data/lib/grape/validations/validators/presence.rb +6 -4
  24. data/lib/grape/validations/validators/regexp.rb +7 -5
  25. data/lib/grape/validations/validators/same_as.rb +17 -15
  26. data/lib/grape/validations/validators/values.rb +59 -57
  27. data/lib/grape/validations.rb +6 -0
  28. data/lib/grape/version.rb +1 -1
  29. data/lib/grape.rb +2 -0
  30. data/spec/grape/api/custom_validations_spec.rb +77 -46
  31. data/spec/grape/api/deeply_included_options_spec.rb +3 -3
  32. data/spec/grape/api/defines_boolean_in_params_spec.rb +2 -1
  33. data/spec/grape/api/invalid_format_spec.rb +2 -0
  34. data/spec/grape/api/recognize_path_spec.rb +1 -1
  35. data/spec/grape/api/shared_helpers_exactly_one_of_spec.rb +9 -15
  36. data/spec/grape/api_remount_spec.rb +16 -15
  37. data/spec/grape/api_spec.rb +317 -193
  38. data/spec/grape/dsl/callbacks_spec.rb +1 -0
  39. data/spec/grape/dsl/headers_spec.rb +39 -9
  40. data/spec/grape/dsl/helpers_spec.rb +3 -2
  41. data/spec/grape/dsl/inside_route_spec.rb +6 -4
  42. data/spec/grape/dsl/logger_spec.rb +16 -18
  43. data/spec/grape/dsl/middleware_spec.rb +1 -0
  44. data/spec/grape/dsl/parameters_spec.rb +1 -0
  45. data/spec/grape/dsl/request_response_spec.rb +1 -0
  46. data/spec/grape/dsl/routing_spec.rb +9 -6
  47. data/spec/grape/endpoint/declared_spec.rb +12 -12
  48. data/spec/grape/endpoint_spec.rb +59 -50
  49. data/spec/grape/entity_spec.rb +13 -13
  50. data/spec/grape/exceptions/body_parse_errors_spec.rb +3 -0
  51. data/spec/grape/exceptions/invalid_accept_header_spec.rb +61 -22
  52. data/spec/grape/exceptions/validation_errors_spec.rb +13 -10
  53. data/spec/grape/exceptions/validation_spec.rb +5 -3
  54. data/spec/grape/extensions/param_builders/hash_spec.rb +7 -7
  55. data/spec/grape/extensions/param_builders/hash_with_indifferent_access_spec.rb +8 -8
  56. data/spec/grape/extensions/param_builders/hashie/mash_spec.rb +8 -8
  57. data/spec/grape/integration/rack_sendfile_spec.rb +1 -1
  58. data/spec/grape/loading_spec.rb +8 -8
  59. data/spec/grape/middleware/auth/dsl_spec.rb +14 -5
  60. data/spec/grape/middleware/auth/strategies_spec.rb +60 -20
  61. data/spec/grape/middleware/base_spec.rb +24 -15
  62. data/spec/grape/middleware/error_spec.rb +1 -0
  63. data/spec/grape/middleware/exception_spec.rb +111 -161
  64. data/spec/grape/middleware/formatter_spec.rb +25 -4
  65. data/spec/grape/middleware/globals_spec.rb +7 -4
  66. data/spec/grape/middleware/stack_spec.rb +11 -11
  67. data/spec/grape/middleware/versioner/accept_version_header_spec.rb +2 -1
  68. data/spec/grape/middleware/versioner/header_spec.rb +14 -13
  69. data/spec/grape/middleware/versioner/param_spec.rb +7 -1
  70. data/spec/grape/middleware/versioner/path_spec.rb +5 -1
  71. data/spec/grape/middleware/versioner_spec.rb +1 -1
  72. data/spec/grape/parser_spec.rb +4 -0
  73. data/spec/grape/path_spec.rb +52 -52
  74. data/spec/grape/presenters/presenter_spec.rb +7 -6
  75. data/spec/grape/request_spec.rb +6 -4
  76. data/spec/grape/util/inheritable_setting_spec.rb +7 -7
  77. data/spec/grape/util/inheritable_values_spec.rb +3 -2
  78. data/spec/grape/util/reverse_stackable_values_spec.rb +3 -1
  79. data/spec/grape/util/stackable_values_spec.rb +7 -5
  80. data/spec/grape/validations/instance_behaivour_spec.rb +9 -10
  81. data/spec/grape/validations/multiple_attributes_iterator_spec.rb +1 -0
  82. data/spec/grape/validations/params_scope_spec.rb +9 -7
  83. data/spec/grape/validations/single_attribute_iterator_spec.rb +1 -0
  84. data/spec/grape/validations/types/primitive_coercer_spec.rb +2 -2
  85. data/spec/grape/validations/types_spec.rb +8 -8
  86. data/spec/grape/validations/validators/all_or_none_spec.rb +50 -56
  87. data/spec/grape/validations/validators/allow_blank_spec.rb +136 -140
  88. data/spec/grape/validations/validators/at_least_one_of_spec.rb +50 -56
  89. data/spec/grape/validations/validators/coerce_spec.rb +10 -12
  90. data/spec/grape/validations/validators/default_spec.rb +72 -78
  91. data/spec/grape/validations/validators/exactly_one_of_spec.rb +71 -77
  92. data/spec/grape/validations/validators/except_values_spec.rb +1 -1
  93. data/spec/grape/validations/validators/mutual_exclusion_spec.rb +71 -77
  94. data/spec/grape/validations/validators/presence_spec.rb +16 -1
  95. data/spec/grape/validations/validators/regexp_spec.rb +25 -31
  96. data/spec/grape/validations/validators/same_as_spec.rb +14 -20
  97. data/spec/grape/validations/validators/values_spec.rb +172 -171
  98. data/spec/grape/validations_spec.rb +45 -16
  99. data/spec/integration/eager_load/eager_load_spec.rb +2 -2
  100. data/spec/integration/multi_json/json_spec.rb +1 -1
  101. data/spec/integration/multi_xml/xml_spec.rb +1 -1
  102. data/spec/shared/versioning_examples.rb +10 -7
  103. data/spec/spec_helper.rb +11 -1
  104. metadata +102 -102
@@ -2,53 +2,47 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- describe Grape::Validations::RegexpValidator do
6
- module ValidationsSpec
7
- module RegexpValidatorSpec
8
- class API < Grape::API
9
- default_format :json
10
-
11
- resources :custom_message do
12
- params do
13
- requires :name, regexp: { value: /^[a-z]+$/, message: 'format is invalid' }
14
- end
15
- get do
16
- end
17
-
18
- params do
19
- requires :names, type: { value: Array[String], message: 'can\'t be nil' }, regexp: { value: /^[a-z]+$/, message: 'format is invalid' }
20
- end
21
- get 'regexp_with_array' do
22
- end
23
- end
5
+ describe Grape::Validations::Validators::RegexpValidator do
6
+ let_it_be(:app) do
7
+ Class.new(Grape::API) do
8
+ default_format :json
24
9
 
10
+ resources :custom_message do
25
11
  params do
26
- requires :name, regexp: /^[a-z]+$/
12
+ requires :name, regexp: { value: /^[a-z]+$/, message: 'format is invalid' }
27
13
  end
28
14
  get do
29
15
  end
30
16
 
31
17
  params do
32
- requires :names, type: Array[String], regexp: /^[a-z]+$/
18
+ requires :names, type: { value: Array[String], message: 'can\'t be nil' }, regexp: { value: /^[a-z]+$/, message: 'format is invalid' }
33
19
  end
34
20
  get 'regexp_with_array' do
35
21
  end
22
+ end
36
23
 
37
- params do
38
- requires :people, type: Hash do
39
- requires :names, type: Array[String], regexp: /^[a-z]+$/
40
- end
41
- end
42
- get 'nested_regexp_with_array' do
24
+ params do
25
+ requires :name, regexp: /^[a-z]+$/
26
+ end
27
+ get do
28
+ end
29
+
30
+ params do
31
+ requires :names, type: Array[String], regexp: /^[a-z]+$/
32
+ end
33
+ get 'regexp_with_array' do
34
+ end
35
+
36
+ params do
37
+ requires :people, type: Hash do
38
+ requires :names, type: Array[String], regexp: /^[a-z]+$/
43
39
  end
44
40
  end
41
+ get 'nested_regexp_with_array' do
42
+ end
45
43
  end
46
44
  end
47
45
 
48
- def app
49
- ValidationsSpec::RegexpValidatorSpec::API
50
- end
51
-
52
46
  context 'custom validation message' do
53
47
  context 'with invalid input' do
54
48
  it 'refuses inapppopriate' do
@@ -2,31 +2,25 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- describe Grape::Validations::SameAsValidator do
6
- module ValidationsSpec
7
- module SameAsValidatorSpec
8
- class API < Grape::API
9
- params do
10
- requires :password
11
- requires :password_confirmation, same_as: :password
12
- end
13
- post do
14
- end
5
+ describe Grape::Validations::Validators::SameAsValidator do
6
+ let_it_be(:app) do
7
+ Class.new(Grape::API) do
8
+ params do
9
+ requires :password
10
+ requires :password_confirmation, same_as: :password
11
+ end
12
+ post do
13
+ end
15
14
 
16
- params do
17
- requires :password
18
- requires :password_confirmation, same_as: { value: :password, message: 'not match' }
19
- end
20
- post '/custom-message' do
21
- end
15
+ params do
16
+ requires :password
17
+ requires :password_confirmation, same_as: { value: :password, message: 'not match' }
18
+ end
19
+ post '/custom-message' do
22
20
  end
23
21
  end
24
22
  end
25
23
 
26
- def app
27
- ValidationsSpec::SameAsValidatorSpec::API
28
- end
29
-
30
24
  describe '/' do
31
25
  context 'is the same' do
32
26
  it do
@@ -2,11 +2,12 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- describe Grape::Validations::ValuesValidator do
6
- module ValidationsSpec
7
- class ValuesModel
5
+ describe Grape::Validations::Validators::ValuesValidator do
6
+ let_it_be(:values_model) do
7
+ Class.new do
8
8
  DEFAULT_VALUES = %w[valid-type1 valid-type2 valid-type3].freeze
9
9
  DEFAULT_EXCEPTS = %w[invalid-type1 invalid-type2 invalid-type3].freeze
10
+
10
11
  class << self
11
12
  def values
12
13
  @values ||= []
@@ -33,212 +34,213 @@ describe Grape::Validations::ValuesValidator do
33
34
  end
34
35
  end
35
36
  end
37
+ end
36
38
 
37
- module ValuesValidatorSpec
38
- class API < Grape::API
39
- default_format :json
40
-
41
- resources :custom_message do
42
- params do
43
- requires :type, values: { value: ValuesModel.values, message: 'value does not include in values' }
44
- end
45
- get '/' do
46
- { type: params[:type] }
47
- end
48
-
49
- params do
50
- optional :type, values: { value: -> { ValuesModel.values }, message: 'value does not include in values' }, default: 'valid-type2'
51
- end
52
- get '/lambda' do
53
- { type: params[:type] }
54
- end
55
-
56
- params do
57
- requires :type, values: { except: ValuesModel.excepts, except_message: 'value is on exclusions list', message: 'default exclude message' }
58
- end
59
- get '/exclude/exclude_message'
60
-
61
- params do
62
- requires :type, values: { except: -> { ValuesModel.excepts }, except_message: 'value is on exclusions list' }
63
- end
64
- get '/exclude/lambda/exclude_message'
65
-
66
- params do
67
- requires :type, values: { except: ValuesModel.excepts, message: 'default exclude message' }
68
- end
69
- get '/exclude/fallback_message'
70
- end
39
+ before do
40
+ stub_const('ValuesModel', values_model)
41
+ end
42
+
43
+ let_it_be(:app) do
44
+ ValuesModel = values_model
45
+ Class.new(Grape::API) do
46
+ default_format :json
71
47
 
48
+ resources :custom_message do
72
49
  params do
73
- requires :type, values: ValuesModel.values
50
+ requires :type, values: { value: ValuesModel.values, message: 'value does not include in values' }
74
51
  end
75
52
  get '/' do
76
53
  { type: params[:type] }
77
54
  end
78
55
 
79
56
  params do
80
- requires :type, values: []
57
+ optional :type, values: { value: -> { ValuesModel.values }, message: 'value does not include in values' }, default: 'valid-type2'
81
58
  end
82
- get '/empty'
83
-
84
- params do
85
- optional :type, values: { value: ValuesModel.values }, default: 'valid-type2'
86
- end
87
- get '/default/hash/valid' do
59
+ get '/lambda' do
88
60
  { type: params[:type] }
89
61
  end
90
62
 
91
63
  params do
92
- optional :type, values: ValuesModel.values, default: 'valid-type2'
93
- end
94
- get '/default/valid' do
95
- { type: params[:type] }
64
+ requires :type, values: { except: ValuesModel.excepts, except_message: 'value is on exclusions list', message: 'default exclude message' }
96
65
  end
66
+ get '/exclude/exclude_message'
97
67
 
98
68
  params do
99
- optional :type, values: { except: ValuesModel.excepts }, default: 'valid-type2'
100
- end
101
- get '/default/except' do
102
- { type: params[:type] }
69
+ requires :type, values: { except: -> { ValuesModel.excepts }, except_message: 'value is on exclusions list' }
103
70
  end
71
+ get '/exclude/lambda/exclude_message'
104
72
 
105
73
  params do
106
- optional :type, values: -> { ValuesModel.values }, default: 'valid-type2'
107
- end
108
- get '/lambda' do
109
- { type: params[:type] }
74
+ requires :type, values: { except: ValuesModel.excepts, message: 'default exclude message' }
110
75
  end
76
+ get '/exclude/fallback_message'
77
+ end
111
78
 
112
- params do
113
- requires :type, values: ->(v) { ValuesModel.include? v }
114
- end
115
- get '/lambda_val' do
116
- { type: params[:type] }
117
- end
79
+ params do
80
+ requires :type, values: ValuesModel.values
81
+ end
82
+ get '/' do
83
+ { type: params[:type] }
84
+ end
118
85
 
119
- params do
120
- requires :number, type: Integer, values: ->(v) { v > 0 }
121
- end
122
- get '/lambda_int_val' do
123
- { number: params[:number] }
124
- end
86
+ params do
87
+ requires :type, values: []
88
+ end
89
+ get '/empty'
125
90
 
126
- params do
127
- requires :type, values: -> { [] }
128
- end
129
- get '/empty_lambda'
91
+ params do
92
+ optional :type, values: { value: ValuesModel.values }, default: 'valid-type2'
93
+ end
94
+ get '/default/hash/valid' do
95
+ { type: params[:type] }
96
+ end
130
97
 
131
- params do
132
- optional :type, values: ValuesModel.values, default: -> { ValuesModel.values.sample }
133
- end
134
- get '/default_lambda' do
135
- { type: params[:type] }
136
- end
98
+ params do
99
+ optional :type, values: ValuesModel.values, default: 'valid-type2'
100
+ end
101
+ get '/default/valid' do
102
+ { type: params[:type] }
103
+ end
137
104
 
138
- params do
139
- optional :type, values: -> { ValuesModel.values }, default: -> { ValuesModel.values.sample }
140
- end
141
- get '/default_and_values_lambda' do
142
- { type: params[:type] }
143
- end
105
+ params do
106
+ optional :type, values: { except: ValuesModel.excepts }, default: 'valid-type2'
107
+ end
108
+ get '/default/except' do
109
+ { type: params[:type] }
110
+ end
144
111
 
145
- params do
146
- optional :type, type: Boolean, desc: 'A boolean', values: [true]
147
- end
148
- get '/values/optional_boolean' do
149
- { type: params[:type] }
150
- end
112
+ params do
113
+ optional :type, values: -> { ValuesModel.values }, default: 'valid-type2'
114
+ end
115
+ get '/lambda' do
116
+ { type: params[:type] }
117
+ end
151
118
 
152
- params do
153
- requires :type, type: Integer, desc: 'An integer', values: [10, 11], default: 10
154
- end
155
- get '/values/coercion' do
156
- { type: params[:type] }
157
- end
119
+ params do
120
+ requires :type, values: ->(v) { ValuesModel.include? v }
121
+ end
122
+ get '/lambda_val' do
123
+ { type: params[:type] }
124
+ end
158
125
 
159
- params do
160
- requires :type, type: Array[Integer], desc: 'An integer', values: [10, 11], default: 10
161
- end
162
- get '/values/array_coercion' do
163
- { type: params[:type] }
164
- end
126
+ params do
127
+ requires :number, type: Integer, values: ->(v) { v > 0 }
128
+ end
129
+ get '/lambda_int_val' do
130
+ { number: params[:number] }
131
+ end
165
132
 
166
- params do
167
- optional :optional, type: Array do
168
- requires :type, values: %w[a b]
169
- end
170
- end
171
- get '/optional_with_required_values'
133
+ params do
134
+ requires :type, values: -> { [] }
135
+ end
136
+ get '/empty_lambda'
172
137
 
173
- params do
174
- requires :type, values: { except: ValuesModel.excepts }
175
- end
176
- get '/except/exclusive' do
177
- { type: params[:type] }
178
- end
138
+ params do
139
+ optional :type, values: ValuesModel.values, default: -> { ValuesModel.values.sample }
140
+ end
141
+ get '/default_lambda' do
142
+ { type: params[:type] }
143
+ end
179
144
 
180
- params do
181
- requires :type, type: String, values: { except: ValuesModel.excepts }
182
- end
183
- get '/except/exclusive/type' do
184
- { type: params[:type] }
185
- end
145
+ params do
146
+ optional :type, values: -> { ValuesModel.values }, default: -> { ValuesModel.values.sample }
147
+ end
148
+ get '/default_and_values_lambda' do
149
+ { type: params[:type] }
150
+ end
186
151
 
187
- params do
188
- requires :type, values: { except: -> { ValuesModel.excepts } }
189
- end
190
- get '/except/exclusive/lambda' do
191
- { type: params[:type] }
192
- end
152
+ params do
153
+ optional :type, type: Grape::API::Boolean, desc: 'A boolean', values: [true]
154
+ end
155
+ get '/values/optional_boolean' do
156
+ { type: params[:type] }
157
+ end
193
158
 
194
- params do
195
- requires :type, type: String, values: { except: -> { ValuesModel.excepts } }
196
- end
197
- get '/except/exclusive/lambda/type' do
198
- { type: params[:type] }
199
- end
159
+ params do
160
+ requires :type, type: Integer, desc: 'An integer', values: [10, 11], default: 10
161
+ end
162
+ get '/values/coercion' do
163
+ { type: params[:type] }
164
+ end
200
165
 
201
- params do
202
- requires :type, type: Integer, values: { except: -> { [3, 4, 5] } }
203
- end
204
- get '/except/exclusive/lambda/coercion' do
205
- { type: params[:type] }
206
- end
166
+ params do
167
+ requires :type, type: Array[Integer], desc: 'An integer', values: [10, 11], default: 10
168
+ end
169
+ get '/values/array_coercion' do
170
+ { type: params[:type] }
171
+ end
207
172
 
208
- params do
209
- requires :type, type: Integer, values: { value: 1..5, except: [3] }
210
- end
211
- get '/mixed/value/except' do
212
- { type: params[:type] }
173
+ params do
174
+ optional :optional, type: Array do
175
+ requires :type, values: %w[a b]
213
176
  end
177
+ end
178
+ get '/optional_with_required_values'
214
179
 
215
- params do
216
- optional :optional, type: Array[String], values: %w[a b c]
217
- end
218
- put '/optional_with_array_of_string_values'
180
+ params do
181
+ requires :type, values: { except: ValuesModel.excepts }
182
+ end
183
+ get '/except/exclusive' do
184
+ { type: params[:type] }
185
+ end
219
186
 
220
- params do
221
- requires :type, values: { proc: ->(v) { ValuesModel.include? v } }
222
- end
223
- get '/proc' do
224
- { type: params[:type] }
225
- end
187
+ params do
188
+ requires :type, type: String, values: { except: ValuesModel.excepts }
189
+ end
190
+ get '/except/exclusive/type' do
191
+ { type: params[:type] }
192
+ end
226
193
 
227
- params do
228
- requires :type, values: { proc: ->(v) { ValuesModel.include? v }, message: 'failed check' }
229
- end
230
- get '/proc/message'
194
+ params do
195
+ requires :type, values: { except: -> { ValuesModel.excepts } }
196
+ end
197
+ get '/except/exclusive/lambda' do
198
+ { type: params[:type] }
199
+ end
231
200
 
232
- params do
233
- optional :name, type: String, values: %w[a b], allow_blank: true
234
- end
235
- get '/allow_blank'
201
+ params do
202
+ requires :type, type: String, values: { except: -> { ValuesModel.excepts } }
203
+ end
204
+ get '/except/exclusive/lambda/type' do
205
+ { type: params[:type] }
236
206
  end
237
- end
238
- end
239
207
 
240
- def app
241
- ValidationsSpec::ValuesValidatorSpec::API
208
+ params do
209
+ requires :type, type: Integer, values: { except: -> { [3, 4, 5] } }
210
+ end
211
+ get '/except/exclusive/lambda/coercion' do
212
+ { type: params[:type] }
213
+ end
214
+
215
+ params do
216
+ requires :type, type: Integer, values: { value: 1..5, except: [3] }
217
+ end
218
+ get '/mixed/value/except' do
219
+ { type: params[:type] }
220
+ end
221
+
222
+ params do
223
+ optional :optional, type: Array[String], values: %w[a b c]
224
+ end
225
+ put '/optional_with_array_of_string_values'
226
+
227
+ params do
228
+ requires :type, values: { proc: ->(v) { ValuesModel.include? v } }
229
+ end
230
+ get '/proc' do
231
+ { type: params[:type] }
232
+ end
233
+
234
+ params do
235
+ requires :type, values: { proc: ->(v) { ValuesModel.include? v }, message: 'failed check' }
236
+ end
237
+ get '/proc/message'
238
+
239
+ params do
240
+ optional :name, type: String, values: %w[a b], allow_blank: true
241
+ end
242
+ get '/allow_blank'
243
+ end
242
244
  end
243
245
 
244
246
  context 'with a custom validation message' do
@@ -255,7 +257,7 @@ describe Grape::Validations::ValuesValidator do
255
257
  end
256
258
 
257
259
  it 'validates against values in a proc' do
258
- ValidationsSpec::ValuesModel.add_value('valid-type4')
260
+ ValuesModel.add_value('valid-type4')
259
261
 
260
262
  get('/custom_message/lambda', type: 'valid-type4')
261
263
  expect(last_response.status).to eq 200
@@ -354,15 +356,14 @@ describe Grape::Validations::ValuesValidator do
354
356
  end
355
357
 
356
358
  it 'does not validate updated values without proc' do
357
- ValidationsSpec::ValuesModel.add_value('valid-type4')
358
-
359
+ ValuesModel.add_value('valid-type4')
359
360
  get('/', type: 'valid-type4')
360
361
  expect(last_response.status).to eq 400
361
362
  expect(last_response.body).to eq({ error: 'type does not have a valid value' }.to_json)
362
363
  end
363
364
 
364
365
  it 'validates against values in a proc' do
365
- ValidationsSpec::ValuesModel.add_value('valid-type4')
366
+ ValuesModel.add_value('valid-type4')
366
367
 
367
368
  get('/lambda', type: 'valid-type4')
368
369
  expect(last_response.status).to eq 200
@@ -424,7 +425,7 @@ describe Grape::Validations::ValuesValidator do
424
425
  it 'raises IncompatibleOptionValues on an invalid default value from proc' do
425
426
  subject = Class.new(Grape::API)
426
427
  expect do
427
- subject.params { optional :type, values: %w[valid-type1 valid-type2 valid-type3], default: "#{ValidationsSpec::ValuesModel.values.sample}_invalid" }
428
+ subject.params { optional :type, values: %w[valid-type1 valid-type2 valid-type3], default: "#{ValuesModel.values.sample}_invalid" }
428
429
  end.to raise_error Grape::Exceptions::IncompatibleOptionValues
429
430
  end
430
431