Sha256: 27f3b16451e8650397ae212f93150667908aa3023ffa544151a88a53a605d665

Contents?: true

Size: 456 Bytes

Versions: 23

Compression:

Stored size: 456 Bytes

Contents

class InputFaker
  def initialize(strings)
    @strings = Array(strings)
  end

  def gets
    next_string = @strings.shift
    # Uncomment the following line if you'd like to see the faked $stdin#gets
    # puts "(DEBUG) Faking #gets with: #{next_string}"
    next_string
  end

  def noecho
    @strings.shift
  end

  def tty?
    true
  end

  def self.with_fake_input(strings)
    $stdin = new(strings)
    yield
  ensure
    $stdin = STDIN
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
shelly-0.5.7 spec/input_faker.rb
shelly-0.5.6 spec/input_faker.rb
shelly-0.5.5 spec/input_faker.rb
shelly-0.5.4 spec/input_faker.rb
shelly-0.5.3 spec/input_faker.rb
shelly-0.5.2 spec/input_faker.rb
shelly-0.5.1 spec/input_faker.rb
shelly-0.5.0 spec/input_faker.rb
shelly-0.4.42 spec/input_faker.rb
shelly-0.4.41 spec/input_faker.rb
shelly-0.4.40 spec/input_faker.rb
shelly-0.4.39 spec/input_faker.rb
shelly-0.4.38 spec/input_faker.rb
shelly-0.4.37 spec/input_faker.rb
shelly-0.4.36 spec/input_faker.rb
shelly-0.4.35 spec/input_faker.rb
shelly-0.4.34 spec/input_faker.rb
shelly-0.4.33 spec/input_faker.rb
shelly-0.4.32 spec/input_faker.rb
shelly-0.4.31 spec/input_faker.rb