class Byebug::TestInterface

Custom interface for easier assertions

Attributes

test_block[RW]

Public Class Methods

new() click to toggle source
Calls superclass method Byebug::Interface.new
# File lib/byebug/interfaces/test_interface.rb, line 8
def initialize
  super()
  @input, @output, @error = [], [], []
end

Public Instance Methods

clear() click to toggle source
# File lib/byebug/interfaces/test_interface.rb, line 34
def clear
  @input, @output, @error = [], [], []
  history.clear
end
errmsg(message) click to toggle source
# File lib/byebug/interfaces/test_interface.rb, line 13
def errmsg(message)
  error.concat(message.to_s.split("\n"))
end
inspect() click to toggle source
# File lib/byebug/interfaces/test_interface.rb, line 39
def inspect
  [
    'Input:', input.join("\n"),
    'Output:', output.join("\n"),
    'Error:', error.join("\n")
  ].join("\n")
end
print(message) click to toggle source
puts(message) click to toggle source
# File lib/byebug/interfaces/test_interface.rb, line 21
def puts(message)
  output.concat(message.to_s.split("\n"))
end
read_command(prompt) click to toggle source
Calls superclass method Byebug::Interface#read_command
# File lib/byebug/interfaces/test_interface.rb, line 25
def read_command(prompt)
  cmd = super(prompt)

  return cmd unless cmd.nil? && test_block

  test_block.call
  self.test_block = nil
end
readline(prompt) click to toggle source
# File lib/byebug/interfaces/test_interface.rb, line 47
def readline(prompt)
  puts(prompt)

  cmd = input.shift
  cmd.is_a?(Proc) ? cmd.call : cmd
end