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 9
def initialize
  super()

  clear
end

Public Instance Methods

clear() click to toggle source
# File lib/byebug/interfaces/test_interface.rb, line 36
def clear
  @input = []
  @output = []
  @error = []
  history.clear
end
errmsg(message) click to toggle source
# File lib/byebug/interfaces/test_interface.rb, line 15
def errmsg(message)
  error.concat(prepare(message))
end
inspect() click to toggle source
# File lib/byebug/interfaces/test_interface.rb, line 43
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 23
def puts(message)
  output.concat(prepare(message))
end
read_command(prompt) click to toggle source
Calls superclass method Byebug::Interface#read_command
# File lib/byebug/interfaces/test_interface.rb, line 27
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 51
def readline(prompt)
  puts(prompt)

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

Private Instance Methods

prepare(message) click to toggle source
# File lib/byebug/interfaces/test_interface.rb, line 60
def prepare(message)
  return message.map(&:to_s) if message.respond_to?(:map)

  message.to_s.split("\n")
end