Class: Byebug::TestInterface
Overview
Custom interface for easier assertions
Instance Attribute Summary collapse
Attributes inherited from Interface
#command_queue, #error, #history, #input, #output
Instance Method Summary
collapse
Methods inherited from Interface
#autorestore, #autosave, #close, #confirm, #last_if_empty, #prepare_input, #read_file, #read_input
#get_line, #get_lines, #n_lines, #normalize, #shortpath, #virtual_file?
Constructor Details
Returns a new instance of TestInterface.
8
9
10
11
12
|
# File 'lib/byebug/interfaces/test_interface.rb', line 8
def initialize
super()
clear
end
|
Instance Attribute Details
#test_block ⇒ Object
Returns the value of attribute test_block.
6
7
8
|
# File 'lib/byebug/interfaces/test_interface.rb', line 6
def test_block
@test_block
end
|
Instance Method Details
#clear ⇒ Object
35
36
37
38
39
40
|
# File 'lib/byebug/interfaces/test_interface.rb', line 35
def clear
@input = []
@output = []
@error = []
history.clear
end
|
#errmsg(message) ⇒ Object
14
15
16
|
# File 'lib/byebug/interfaces/test_interface.rb', line 14
def errmsg(message)
error.concat(prepare(message))
end
|
#inspect ⇒ Object
42
43
44
45
46
47
48
|
# File 'lib/byebug/interfaces/test_interface.rb', line 42
def inspect
[
'Input:', input.join("\n"),
'Output:', output.join("\n"),
'Error:', error.join("\n")
].join("\n")
end
|
#print(message) ⇒ Object
18
19
20
|
# File 'lib/byebug/interfaces/test_interface.rb', line 18
def print(message)
output.concat(prepare(message))
end
|
#puts(message) ⇒ Object
22
23
24
|
# File 'lib/byebug/interfaces/test_interface.rb', line 22
def puts(message)
output.concat(prepare(message))
end
|
#read_command(prompt) ⇒ Object
26
27
28
29
30
31
32
33
|
# File 'lib/byebug/interfaces/test_interface.rb', line 26
def read_command(prompt)
cmd = super(prompt)
return cmd unless cmd.nil? && test_block
test_block.call
self.test_block = nil
end
|
#readline(prompt) ⇒ Object
50
51
52
53
54
55
|
# File 'lib/byebug/interfaces/test_interface.rb', line 50
def readline(prompt)
puts(prompt)
cmd = input.shift
cmd.is_a?(Proc) ? cmd.call : cmd
end
|