Sha256: 138f44edaca6eb54d71b527c97dad8954d415ab005fb139719e9380d943917b2

Contents?: true

Size: 700 Bytes

Versions: 2

Compression:

Stored size: 700 Bytes

Contents

# frozen_string_literal: true

require "stringio"

require_relative "../prompt"

module TTY
  # Used for initializing test cases
  class Prompt
    module StringIOExtensions
      def wait_readable(*)
        true
      end

      def ioctl(*)
        80
      end
    end

    class Test < TTY::Prompt
      def initialize(**options)
        @input = StringIO.new
        @input.extend(StringIOExtensions)
        @output = StringIO.new

        options.merge!({
          input: @input,
          output: @output,
          env: { "TTY_TEST" => true },
          enable_color: options.fetch(:enable_color, true)
        })
        super(**options)
      end
    end # Test
  end # Prompt
end # TTY

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
tty-prompt-0.23.1 lib/tty/prompt/test.rb
tty-prompt-0.23.0 lib/tty/prompt/test.rb