Sha256: 086c4af1fcf2e6d20148f620f16da7f70693fbbf7dca2a235dfd4df14550c6e3

Contents?: true

Size: 390 Bytes

Versions: 28

Compression:

Stored size: 390 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 self.with_fake_input(strings)
    $stdin = new(strings)
    yield
  ensure
    $stdin = STDIN
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
shelly-0.4.26 spec/input_faker.rb
shelly-0.4.26.pre spec/input_faker.rb
shelly-0.4.25 spec/input_faker.rb
shelly-0.4.24 spec/input_faker.rb
shelly-0.4.23 spec/input_faker.rb
shelly-0.4.23.pre spec/input_faker.rb
shelly-0.4.22 spec/input_faker.rb
shelly-0.4.21 spec/input_faker.rb
shelly-0.4.19 spec/input_faker.rb
shelly-0.4.18 spec/input_faker.rb
shelly-0.4.17 spec/input_faker.rb
shelly-0.4.16 spec/input_faker.rb
shelly-0.4.15 spec/input_faker.rb
shelly-0.4.14 spec/input_faker.rb
shelly-0.4.13 spec/input_faker.rb
shelly-0.4.12 spec/input_faker.rb
shelly-0.4.11 spec/input_faker.rb
shelly-0.4.10 spec/input_faker.rb
shelly-0.4.9 spec/input_faker.rb
shelly-0.4.8 spec/input_faker.rb