File tree Expand file tree Collapse file tree 2 files changed +19
-12
lines changed Expand file tree Collapse file tree 2 files changed +19
-12
lines changed Original file line number Diff line number Diff line change 2
2
3
3
require_relative "nop"
4
4
require_relative "../source_finder"
5
+ require_relative "../pager"
5
6
require_relative "../color"
6
7
7
8
module IRB
@@ -40,12 +41,16 @@ def execute(str = nil)
40
41
private
41
42
42
43
def show_source ( source )
43
- puts
44
- puts "#{ bold ( "From" ) } : #{ source . file } :#{ source . first_line } "
45
- puts
46
- code = IRB ::Color . colorize_code ( File . read ( source . file ) )
47
- puts code . lines [ ( source . first_line - 1 ) ...source . last_line ] . join
48
- puts
44
+ file_content = IRB ::Color . colorize_code ( File . read ( source . file ) )
45
+ code = file_content . lines [ ( source . first_line - 1 ) ...source . last_line ] . join
46
+ content = <<~CONTENT
47
+
48
+ #{ bold ( "From" ) } : #{ source . file } :#{ source . first_line }
49
+
50
+ #{ code }
51
+ CONTENT
52
+
53
+ Pager . page_content ( content )
49
54
end
50
55
51
56
def bold ( str )
Original file line number Diff line number Diff line change 6
6
module TestIRB
7
7
class InputTest < IntegrationTestCase
8
8
def test_symbol_aliases_are_handled_correctly
9
+ write_rc <<~RUBY
10
+ # disable pager
11
+ STDIN.singleton_class.define_method(:tty?) { false }
12
+ RUBY
13
+
9
14
write_ruby <<~'RUBY'
10
15
class Foo
11
16
end
@@ -21,12 +26,11 @@ class Foo
21
26
end
22
27
23
28
def test_symbol_aliases_are_handled_correctly_with_singleline_mode
24
- @irbrc = Tempfile . new ( 'irbrc' )
25
- @irbrc . write <<~RUBY
29
+ write_rc <<~RUBY
30
+ # disable pager
31
+ STDIN.singleton_class.define_method(:tty?) { false }
26
32
IRB.conf[:USE_SINGLELINE] = true
27
33
RUBY
28
- @irbrc . close
29
- @envs [ 'IRBRC' ] = @irbrc . path
30
34
31
35
write_ruby <<~'RUBY'
32
36
class Foo
@@ -43,8 +47,6 @@ class Foo
43
47
# Make sure it's tested in singleline mode
44
48
assert_include output , "InputMethod: ReadlineInputMethod"
45
49
assert_include output , "From: #{ @ruby_file . path } :1"
46
- ensure
47
- @irbrc . unlink if @irbrc
48
50
end
49
51
50
52
def test_symbol_aliases_dont_affect_ruby_syntax
You can’t perform that action at this time.
0 commit comments