class Byebug::TestInterface - byebug-11.0.1 Documentation

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

      clear
    end

### Public Instance Methods

clear() click to toggle source

    # File lib/byebug/interfaces/test_interface.rb, line 37
    def clear
      @input = []
      @output = []
      @error = []
      history.clear
    end

errmsg(message) click to toggle source

    # File lib/byebug/interfaces/test_interface.rb, line 16
    def errmsg(message)
      error.concat(prepare(message))
    end

inspect() click to toggle source

    # File lib/byebug/interfaces/test_interface.rb, line 44
    def inspect
      [
        "Input:", input.join("\n"),
        "Output:", output.join("\n"),
        "Error:", error.join("\n")
      ].join("\n")
    end

print(message) click to toggle source

    # File lib/byebug/interfaces/test_interface.rb, line 20
    def print(message)
      output.concat(prepare(message))
    end

puts(message) click to toggle source

    # File lib/byebug/interfaces/test_interface.rb, line 24
    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 28
    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 52
    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 61
    def prepare(message)
      return message.map(&:to_s) if message.respond_to?(:map)

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