Sha256: 810e543053808b4eae6acc5bf6d48f9f8c33a0f56593c8ea0cac9dce3dfba51b

Contents?: true

Size: 1.09 KB

Versions: 6788

Compression:

Stored size: 1.09 KB

Contents

# frozen_string_literal: true

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

    def initialize
      super()

      clear
    end

    def errmsg(message)
      error.concat(prepare(message))
    end

    def print(message)
      output.concat(prepare(message))
    end

    def puts(message)
      output.concat(prepare(message))
    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

    private

    def prepare(message)
      return message.map(&:to_s) if message.respond_to?(:map)

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

Version data entries

6,788 entries across 6,784 versions & 35 rubygems

Version Path
cybrid_api_organization_ruby-0.123.118 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/lib/byebug/interfaces/test_interface.rb
cybrid_api_bank_ruby-0.123.117 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/lib/byebug/interfaces/test_interface.rb
cybrid_api_id_ruby-0.123.117 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/lib/byebug/interfaces/test_interface.rb
cybrid_api_organization_ruby-0.123.117 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/lib/byebug/interfaces/test_interface.rb
cybrid_api_bank_ruby-0.123.116 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/lib/byebug/interfaces/test_interface.rb
cybrid_api_organization_ruby-0.123.116 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/lib/byebug/interfaces/test_interface.rb
cybrid_api_id_ruby-0.123.116 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/lib/byebug/interfaces/test_interface.rb
minato_ruby_api_client-0.2.2 vendor/bundle/ruby/3.2.0/gems/byebug-11.1.3/lib/byebug/interfaces/test_interface.rb
cybrid_api_bank_ruby-0.123.115 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/lib/byebug/interfaces/test_interface.rb
cybrid_api_id_ruby-0.123.115 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/lib/byebug/interfaces/test_interface.rb
cybrid_api_organization_ruby-0.123.115 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/lib/byebug/interfaces/test_interface.rb
ory-client-1.15.17 vendor/bundle/ruby/3.1.0/gems/byebug-11.1.3/lib/byebug/interfaces/test_interface.rb
cybrid_api_bank_ruby-0.123.114 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/lib/byebug/interfaces/test_interface.rb
cybrid_api_organization_ruby-0.123.114 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/lib/byebug/interfaces/test_interface.rb
cybrid_api_id_ruby-0.123.114 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/lib/byebug/interfaces/test_interface.rb
cybrid_api_organization_ruby-0.123.113 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/lib/byebug/interfaces/test_interface.rb
cybrid_api_bank_ruby-0.123.113 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/lib/byebug/interfaces/test_interface.rb
cybrid_api_id_ruby-0.123.113 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/lib/byebug/interfaces/test_interface.rb
cybrid_api_organization_ruby-0.123.112 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/lib/byebug/interfaces/test_interface.rb
cybrid_api_bank_ruby-0.123.112 vendor/bundle/ruby/3.3.0/gems/byebug-11.1.3/lib/byebug/interfaces/test_interface.rb