Sha256: 67ce3b6580ecf2b3a4c30affc79255f20fef97554cec8598284938ffe12ee881

Contents?: true

Size: 470 Bytes

Versions: 4

Compression:

Stored size: 470 Bytes

Contents

module Ribose
  module ConsoleHelper
    def capture_stdout(&_block)
      original_stdout = $stdout
      $stdout = fake = StringIO.new

      begin
        yield
      ensure
        $stdout = original_stdout
      end

      fake.string
    end

    def capture_stderr(&_block)
      original_stderr = $stderr
      $stderr = fake = StringIO.new

      begin
        yield
      ensure
        $stderr = original_stderr
      end

      fake.string
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ribose-cli-0.5.0 spec/support/console_helper.rb
ribose-cli-0.3.2 spec/support/console_helper.rb
ribose-cli-0.2.1 spec/support/console_helper.rb
ribose-cli-0.2.0 spec/support/console_helper.rb