Sha256: 33c81a64e1dc0df8571d6f98cd538c7d58d3a7e39d7947487e5d1002502de5d5

Contents?: true

Size: 549 Bytes

Versions: 1

Compression:

Stored size: 549 Bytes

Contents

module CliHelper
  # Capture stdout and stderr
  def capture(&blk)
    previous_stderr, $stderr = $stderr, StringIO.new
    previous_stdout, $stdout = $stdout, StringIO.new

    yield

    return [$stdout.string, $stderr.string]
  ensure
    $stderr = previous_stderr
    $stdout = previous_stdout
  end

  # Runs a CLI runner and captures output
  def cli(&blk)
    @stdout, @stderr = capture { yield }
  end

  def stdout
    @stdout
  end

  def stderr
    @stderr
  end

  # def aura(cmd)
  #   cli { Aura::CLI.run *cmd.split(' ') }
  # end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
aura-0.0.1.pre10 test/test_cli_helper.rb