|
5 | 5 | require_relative "helper"
|
6 | 6 |
|
7 | 7 | module TestIRB
|
8 |
| - class ExtendCommandTest < TestCase |
| 8 | + class CommandTestCase < TestCase |
| 9 | + def execute_lines(*lines, conf: {}, main: self, irb_path: nil) |
| 10 | + IRB.init_config(nil) |
| 11 | + IRB.conf[:VERBOSE] = false |
| 12 | + IRB.conf[:PROMPT_MODE] = :SIMPLE |
| 13 | + IRB.conf.merge!(conf) |
| 14 | + input = TestInputMethod.new(lines) |
| 15 | + irb = IRB::Irb.new(IRB::WorkSpace.new(main), input) |
| 16 | + irb.context.return_format = "=> %s\n" |
| 17 | + irb.context.irb_path = irb_path if irb_path |
| 18 | + IRB.conf[:MAIN_CONTEXT] = irb.context |
| 19 | + capture_output do |
| 20 | + irb.eval_input |
| 21 | + end |
| 22 | + end |
| 23 | + end |
| 24 | + |
| 25 | + class ExtendCommandTest < CommandTestCase |
9 | 26 | def setup
|
10 | 27 | @pwd = Dir.pwd
|
11 | 28 | @tmpdir = File.join(Dir.tmpdir, "test_reline_config_#{$$}")
|
@@ -523,7 +540,7 @@ def test_show_source_end_finder
|
523 | 540 | def show_source_test_method
|
524 | 541 | unless true
|
525 | 542 | end
|
526 |
| - end |
| 543 | + end unless defined?(show_source_test_method) |
527 | 544 | EOS
|
528 | 545 |
|
529 | 546 | out, err = execute_lines(
|
@@ -565,7 +582,7 @@ def test_vars_with_aliases
|
565 | 582 | $bar = nil
|
566 | 583 | end
|
567 | 584 |
|
568 |
| - class EditTest < ExtendCommandTest |
| 585 | + class EditTest < CommandTestCase |
569 | 586 | def setup
|
570 | 587 | @original_editor = ENV["EDITOR"]
|
571 | 588 | # noop the command so nothing gets executed
|
@@ -639,22 +656,5 @@ def test_edit_with_instance_method
|
639 | 656 | assert_match("command: ': code'", out)
|
640 | 657 | end
|
641 | 658 | end
|
642 |
| - |
643 |
| - private |
644 |
| - |
645 |
| - def execute_lines(*lines, conf: {}, main: self, irb_path: nil) |
646 |
| - IRB.init_config(nil) |
647 |
| - IRB.conf[:VERBOSE] = false |
648 |
| - IRB.conf[:PROMPT_MODE] = :SIMPLE |
649 |
| - IRB.conf.merge!(conf) |
650 |
| - input = TestInputMethod.new(lines) |
651 |
| - irb = IRB::Irb.new(IRB::WorkSpace.new(main), input) |
652 |
| - irb.context.return_format = "=> %s\n" |
653 |
| - irb.context.irb_path = irb_path if irb_path |
654 |
| - IRB.conf[:MAIN_CONTEXT] = irb.context |
655 |
| - capture_output do |
656 |
| - irb.eval_input |
657 |
| - end |
658 |
| - end |
659 | 659 | end
|
660 | 660 | end
|
0 commit comments