File tree Expand file tree Collapse file tree 3 files changed +43
-5
lines changed Expand file tree Collapse file tree 3 files changed +43
-5
lines changed Original file line number Diff line number Diff line change @@ -224,6 +224,25 @@ def params_also_in_overloads(user_options = {})
224
224
# @option user_options [Number] :xid an alias to transaction_id.
225
225
def params_only_in_overloads ( user_options = { } )
226
226
end
227
+
228
+ # Tests that the default signature can be present as an overload tag.
229
+ #
230
+ # @overload params_only_in_overloads()
231
+ # @example
232
+ # Hello.new
233
+ #
234
+ # @overload params_only_in_overloads(transaction_id)
235
+ # @example
236
+ # Hello.new(123)
237
+ #
238
+ # @example
239
+ # Hello.new(transaction_id: 123)
240
+ # Hello.new(xid: 123)
241
+ # @param [Hash] user_options the options to create a message with.
242
+ # @option user_options [Number] :transaction_id
243
+ # @option user_options [Number] :xid an alias to transaction_id.
244
+ def one_param_missing_in_overload ( user_options = { } )
245
+ end
227
246
end
228
247
229
248
module YardError
Original file line number Diff line number Diff line change 7
7
Bundler . require
8
8
require 'inch'
9
9
10
+ def assert_roles ( object , expected , unexpected )
11
+ roles = object . roles . map ( &:class )
12
+ unexpected . each do |role |
13
+ refute roles . include? ( role ) , "Should not assign #{ role } "
14
+ end
15
+ expected . each do |role |
16
+ assert roles . include? ( role ) , "Should assign #{ role } "
17
+ end
18
+ end
19
+
10
20
def fixture_path ( name )
11
21
File . join ( File . dirname ( __FILE__ ) , "fixtures" , name . to_s )
12
22
end
Original file line number Diff line number Diff line change @@ -295,14 +295,23 @@ def test_overloading_with_bad_doc
295
295
296
296
def test_overloading_with_bad_doc
297
297
m = @objects . find ( "Overloading#params_only_in_overloads" )
298
- roles = m . roles . map ( &:class )
299
- bad_roles = [
298
+ unexpected_roles = [
300
299
Inch ::Evaluation ::Role ::Object ::WithoutCodeExample ,
301
300
Inch ::Evaluation ::Role ::MethodParameter ::WithoutMention ,
302
301
Inch ::Evaluation ::Role ::MethodParameter ::WithoutType ,
303
302
]
304
- bad_roles . each do |role |
305
- refute roles . include? ( role ) , "Should not assign #{ role } "
306
- end
303
+ assert_roles m , [ ] , unexpected_roles
304
+ end
305
+
306
+ def test_overloading_with_half_bad_doc
307
+ m = @objects . find ( "Overloading#one_param_missing_in_overload" )
308
+ unexpected_roles = [
309
+ Inch ::Evaluation ::Role ::Object ::WithoutCodeExample ,
310
+ ]
311
+ expected_roles = [
312
+ Inch ::Evaluation ::Role ::MethodParameter ::WithoutMention ,
313
+ Inch ::Evaluation ::Role ::MethodParameter ::WithoutType ,
314
+ ]
315
+ assert_roles m , expected_roles , unexpected_roles
307
316
end
308
317
end
You can’t perform that action at this time.
0 commit comments