@@ -376,38 +376,6 @@ def test_irb_source_without_argument
376
376
assert_match ( /Please specify the file name./ , out )
377
377
end
378
378
379
- def test_help_and_show_doc
380
- [ "help" , "show_doc" ] . each do |cmd |
381
- out , _ = execute_lines (
382
- "#{ cmd } String#gsub\n " ,
383
- "\n " ,
384
- )
385
-
386
- # the former is what we'd get without document content installed, like on CI
387
- # the latter is what we may get locally
388
- possible_rdoc_output = [ /Nothing known about String#gsub/ , /str.gsub\( pattern\) / ]
389
- assert ( possible_rdoc_output . any? { |output | output . match? ( out ) } , "Expect the `#{ cmd } ` command to match one of the possible outputs" )
390
- end
391
- ensure
392
- # this is the only way to reset the redefined method without coupling the test with its implementation
393
- EnvUtil . suppress_warning { load "irb/cmd/help.rb" }
394
- end
395
-
396
- def test_help_without_rdoc
397
- out , _ = without_rdoc do
398
- execute_lines (
399
- "help 'String#gsub'\n " ,
400
- "\n " ,
401
- )
402
- end
403
-
404
- # if it fails to require rdoc, it only returns the command object
405
- assert_match ( /=> IRB::ExtendCommand::Help\n / , out )
406
- ensure
407
- # this is the only way to reset the redefined method without coupling the test with its implementation
408
- EnvUtil . suppress_warning { load "irb/cmd/help.rb" }
409
- end
410
-
411
379
def test_irb_load
412
380
File . write ( "#{ @tmpdir } /a.rb" , "a = 'hi'\n " )
413
381
out , err = execute_lines (
@@ -612,6 +580,40 @@ def test_show_cmds
612
580
assert_match ( /Start the debugger of debug\. gem/ , out )
613
581
end
614
582
583
+ class ShowDocTest < CommandTestCase
584
+ def test_help_and_show_doc
585
+ [ "help" , "show_doc" ] . each do |cmd |
586
+ out , _ = execute_lines (
587
+ "#{ cmd } String#gsub\n " ,
588
+ "\n " ,
589
+ )
590
+
591
+ # the former is what we'd get without document content installed, like on CI
592
+ # the latter is what we may get locally
593
+ possible_rdoc_output = [ /Nothing known about String#gsub/ , /gsub\( pattern\) / ]
594
+ assert ( possible_rdoc_output . any? { |output | output . match? ( out ) } , "Expect the `#{ cmd } ` command to match one of the possible outputs. Got:\n #{ out } " )
595
+ end
596
+ ensure
597
+ # this is the only way to reset the redefined method without coupling the test with its implementation
598
+ EnvUtil . suppress_warning { load "irb/cmd/help.rb" }
599
+ end
600
+
601
+ def test_show_doc_without_rdoc
602
+ out , _ = without_rdoc do
603
+ execute_lines (
604
+ "show_doc String#gsub\n " ,
605
+ "\n " ,
606
+ )
607
+ end
608
+
609
+ # if it fails to require rdoc, it only returns the command object
610
+ assert_match ( /=> IRB::ExtendCommand::Help\n / , out )
611
+ ensure
612
+ # this is the only way to reset the redefined method without coupling the test with its implementation
613
+ EnvUtil . suppress_warning { load "irb/cmd/help.rb" }
614
+ end
615
+ end
616
+
615
617
class EditTest < CommandTestCase
616
618
def setup
617
619
@original_editor = ENV [ "EDITOR" ]
0 commit comments