Sha256: ef91ca0f30123ebe2cf8bc526df90c588f82a44156e489b07a03ef32943fc82c

Contents?: true

Size: 506 Bytes

Versions: 17

Compression:

Stored size: 506 Bytes

Contents

# frozen_string_literal: true

module Lolcommits
  module TestHelpers
    module FakeIO
      # stdout captured and returned
      # stdin mapped to inputs an IO stream seperated with enter key presses
      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
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
lolcommits-0.17.2 lib/lolcommits/test_helpers/fake_io.rb
lolcommits-0.17.1 lib/lolcommits/test_helpers/fake_io.rb
lolcommits-0.17.0 lib/lolcommits/test_helpers/fake_io.rb
lolcommits-0.16.5 lib/lolcommits/test_helpers/fake_io.rb
lolcommits-0.16.4 lib/lolcommits/test_helpers/fake_io.rb
lolcommits-0.16.3 lib/lolcommits/test_helpers/fake_io.rb
lolcommits-0.16.2 lib/lolcommits/test_helpers/fake_io.rb
lolcommits-0.16.1 lib/lolcommits/test_helpers/fake_io.rb
lolcommits-0.16.0 lib/lolcommits/test_helpers/fake_io.rb
lolcommits-0.16.0.pre1 lib/lolcommits/test_helpers/fake_io.rb
lolcommits-0.15.1 lib/lolcommits/test_helpers/fake_io.rb
lolcommits-0.15.0 lib/lolcommits/test_helpers/fake_io.rb
lolcommits-0.14.2 lib/lolcommits/test_helpers/fake_io.rb
lolcommits-0.14.1 lib/lolcommits/test_helpers/fake_io.rb
lolcommits-0.14.0 lib/lolcommits/test_helpers/fake_io.rb
lolcommits-0.13.1 lib/lolcommits/test_helpers/fake_io.rb
lolcommits-0.13.0 lib/lolcommits/test_helpers/fake_io.rb