class Gem::MockGemUi

This Gem::StreamUI subclass records input and output to StringIO for retrieval during tests.

Public Class Methods

new(input = "") click to toggle source
Calls superclass method Gem::StreamUI.new
# File lib/rubygems/mock_gem_ui.rb, line 44
def initialize(input = "")
  ins = StringIO.new input
  outs = StringIO.new
  errs = StringIO.new

  ins.extend TTY
  outs.extend TTY
  errs.extend TTY

  super ins, outs, errs, true

  @terminated = false
end

Public Instance Methods

ask(question) click to toggle source
Calls superclass method Gem::StreamUI#ask
# File lib/rubygems/mock_gem_ui.rb, line 58
def ask question
  raise InputEOFError, question if @ins.eof?

  super
end
error() click to toggle source
# File lib/rubygems/mock_gem_ui.rb, line 72
def error
  @errs.string
end
input() click to toggle source
# File lib/rubygems/mock_gem_ui.rb, line 64
def input
  @ins.string
end
output() click to toggle source
# File lib/rubygems/mock_gem_ui.rb, line 68
def output
  @outs.string
end
terminate_interaction(status=0) click to toggle source
# File lib/rubygems/mock_gem_ui.rb, line 80
def terminate_interaction(status=0)
  @terminated = true

  raise TermError, status if status != 0
  raise SystemExitException
end
terminated?() click to toggle source
# File lib/rubygems/mock_gem_ui.rb, line 76
def terminated?
  @terminated
end