@@ -390,6 +390,16 @@ def test_display_method_inherited
390
390
assert_match %r%^=== Implementation from Foo% , out
391
391
end
392
392
393
+ def test_display_method_overriden
394
+ util_multi_store
395
+
396
+ out , = capture_io do
397
+ @driver . display_method 'Bar#override'
398
+ end
399
+
400
+ refute_match %r%must not be displayed% , out
401
+ end
402
+
393
403
def test_display_name_not_found_class
394
404
util_store
395
405
@@ -495,6 +505,32 @@ def test_find_methods_method
495
505
assert_equal expected , items
496
506
end
497
507
508
+ def test_filter_methods
509
+ util_multi_store
510
+
511
+ name = 'Bar#override'
512
+
513
+ found = @driver . load_methods_matching name
514
+
515
+ sorted = @driver . filter_methods found , name
516
+
517
+ expected = [ [ @store2 , [ @override ] ] ]
518
+
519
+ assert_equal expected , sorted
520
+ end
521
+
522
+ def test_filter_methods_not_found
523
+ util_multi_store
524
+
525
+ name = 'Bar#inherit'
526
+
527
+ found = @driver . load_methods_matching name
528
+
529
+ sorted = @driver . filter_methods found , name
530
+
531
+ assert_equal found , sorted
532
+ end
533
+
498
534
def test_formatter
499
535
tty = Object . new
500
536
def tty . tty? ( ) true ; end
@@ -533,6 +569,16 @@ def test_method_type
533
569
assert_equal :class , @driver . method_type ( '::' )
534
570
end
535
571
572
+ def test_name_regexp
573
+ assert_equal /^RDoc::AnyMethod#new$/ ,
574
+ @driver . name_regexp ( 'RDoc::AnyMethod#new' )
575
+ assert_equal /^RDoc::AnyMethod::new$/ ,
576
+ @driver . name_regexp ( 'RDoc::AnyMethod::new' )
577
+
578
+ assert_equal /^RDoc::AnyMethod(#|::)new$/ ,
579
+ @driver . name_regexp ( 'RDoc::AnyMethod.new' )
580
+ end
581
+
536
582
def test_list_known_classes
537
583
util_store
538
584
@@ -766,6 +812,7 @@ def util_multi_store
766
812
@mAmbiguous = RDoc ::NormalModule . new 'Ambiguous'
767
813
768
814
@cFoo = RDoc ::NormalClass . new 'Foo'
815
+
769
816
@cBar = RDoc ::NormalClass . new 'Bar'
770
817
@cBar . superclass = 'Foo'
771
818
@cFoo_Baz = RDoc ::NormalClass . new 'Baz'
@@ -774,10 +821,15 @@ def util_multi_store
774
821
@baz = RDoc ::AnyMethod . new nil , 'baz'
775
822
@cBar . add_method @baz
776
823
824
+ @override = RDoc ::AnyMethod . new nil , 'override'
825
+ @override . comment = 'must be displayed'
826
+ @cBar . add_method @override
827
+
777
828
@store2 . save_class @mAmbiguous
778
829
@store2 . save_class @cBar
779
830
@store2 . save_class @cFoo_Baz
780
831
832
+ @store2 . save_method @cBar , @override
781
833
@store2 . save_method @cBar , @baz
782
834
783
835
@store2 . save_cache
@@ -824,6 +876,11 @@ def util_store
824
876
@inherit = RDoc ::AnyMethod . new nil , 'inherit'
825
877
@cFoo . add_method @inherit
826
878
879
+ # overriden by Bar in multi_store
880
+ @overriden = RDoc ::AnyMethod . new nil , 'override'
881
+ @overriden . comment = 'must not be displayed'
882
+ @cFoo . add_method @overriden
883
+
827
884
@store . save_class @cFoo
828
885
@store . save_class @cFoo_Bar
829
886
@store . save_class @cFoo_Baz
@@ -836,6 +893,7 @@ def util_store
836
893
@store . save_method @cFoo_Bar , @attr
837
894
838
895
@store . save_method @cFoo , @inherit
896
+ @store . save_method @cFoo , @overriden
839
897
840
898
@store . save_cache
841
899
0 commit comments