summaryrefslogtreecommitdiff
path: root/lib/highline/io_console_compatible.rb
blob: 7fa388c8546149a820aa601fb764ab63a627bd81 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# coding: utf-8

require "stringio"
require "tempfile"

#
# On tests, we try to simulate input output with
# StringIO, Tempfile and File objects.
#
# For this to be accomplished, we have to do some
# tweaking so that they respond adequately to the
# called methods during tests.
#

module IOConsoleCompatible
  def getch(min:nil, time:nil, intr: nil)
    getc
  end

  attr_accessor :echo

  def winsize
    [24, 80]
  end
end

class Tempfile
  include IOConsoleCompatible
end

class File
  include IOConsoleCompatible
end

class StringIO
  include IOConsoleCompatible
end