Sha256: c377b7541d949159009df3d8fcc6d7ae2c27fa14710a8bbc169d6c188109faee

Contents?: true

Size: 625 Bytes

Versions: 1

Compression:

Stored size: 625 Bytes

Contents

require 'gooddata/cli/cli'

module CliHelper
  # Execute block and capture its stdou
  # @param block Block to be executed with stdout redirected
  # @returns Captured output as string
  def capture_stdout(&block)
    original_stdout = $stdout
    $stdout = fake = StringIO.new
    begin
      yield
    ensure
      $stdout = original_stdout
    end
    fake.string
  end

  # Run CLI with arguments and return captured stdout
  # @param args Arguments
  # @return Captured stdout
  def run_cli(args = [])
    old = $0
    $0 = 'gooddata'
    res = capture_stdout { GoodData::CLI.main(args) }
    $0 = old
    res
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gooddata-0.6.0 spec/helpers/cli_helper.rb