Module: Lolcommits::TestHelpers::FakeIO
- Defined in:
- lib/lolcommits/test_helpers/fake_io.rb
Instance Method Summary collapse
-
#fake_io_capture(inputs: []) ⇒ Object
stdout captured and returned stdin mapped to inputs an IO stream seperated with enter key presses.
Instance Method Details
#fake_io_capture(inputs: []) ⇒ Object
stdout captured and returned stdin mapped to inputs an IO stream seperated with enter key presses
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/lolcommits/test_helpers/fake_io.rb', line 8 def fake_io_capture(inputs: []) input_stream = "#{inputs.join("\r\n")}\r\n" $stdin = StringIO.new(input_stream) $stdout = StringIO.new yield $stdout.string ensure $stdin = STDIN $stdout = STDOUT end |