Sha256: 36f36595d73ee4265c6aff8ed2b6acb4c0f953afe8dd57036bf74622ec3f8210

Contents?: true

Size: 984 Bytes

Versions: 8

Compression:

Stored size: 984 Bytes

Contents

module Byebug
  #
  # Custom interface for easier assertions
  #
  class TestInterface < Interface
    attr_accessor :test_block

    def initialize
      super()
      @input, @output, @error = [], [], []
    end

    def errmsg(message)
      error.concat(message.to_s.split("\n"))
    end

    def print(message)
      output.concat(message.to_s.split("\n"))
    end

    def puts(message)
      output.concat(message.to_s.split("\n"))
    end

    def read_command(prompt)
      cmd = super(prompt)

      return cmd unless cmd.nil? && test_block

      test_block.call
      self.test_block = nil
    end

    def clear
      @input, @output, @error = [], [], []
      history.clear
    end

    def inspect
      [
        'Input:', input.join("\n"),
        'Output:', output.join("\n"),
        'Error:', error.join("\n")
      ].join("\n")
    end

    def readline(prompt)
      puts(prompt)

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

Version data entries

8 entries across 7 versions & 2 rubygems

Version Path
honeybadger-2.4.0 vendor/gems/ruby/2.1.0/gems/byebug-4.0.5/lib/byebug/interfaces/test_interface.rb
honeybadger-2.4.0 vendor/gems/ruby/2.2.0/gems/byebug-4.0.5/lib/byebug/interfaces/test_interface.rb
byebug-4.0.5 lib/byebug/interfaces/test_interface.rb
byebug-4.0.4 lib/byebug/interfaces/test_interface.rb
byebug-4.0.3 lib/byebug/interfaces/test_interface.rb
byebug-4.0.2 lib/byebug/interfaces/test_interface.rb
byebug-4.0.1 lib/byebug/interfaces/test_interface.rb
byebug-4.0.0 lib/byebug/interfaces/test_interface.rb