Sha256: 940e950a96dd91526afe42fd11b9da25a15803edadae06a9be4d0609cb51ed18

Contents?: true

Size: 772 Bytes

Versions: 12

Compression:

Stored size: 772 Bytes

Contents

module VMC::TestSupport::CommandHelper
  def vmc(argv)
    Mothership.new.exit_status 0
    stub(VMC::CLI).exit { |code| code }
    capture_output { VMC::CLI.start(argv + ["--debug"]) }
  end

  def expect_status_and_output(status = 0, out = "", err = "")
    expect([
      status,
      stdout.string.strip_progress_dots,
      stderr.string.strip_progress_dots
    ]).to eq([status, out, err])
  end

  def bool_flag(flag)
    "#{'no-' unless send(flag)}#{flag.to_s.gsub('_', '-')}"
  end

  attr_reader :stdout, :stderr, :status

  def capture_output
    real_stdout = $stdout
    real_stderr = $stderr
    $stdout = @stdout = StringIO.new
    $stderr = @stderr = StringIO.new
    @status = yield
  ensure
    $stdout = real_stdout
    $stderr = real_stderr
  end
end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
af-0.5.0.beta.11 lib/vmc/test_support/command_helper.rb
af-0.5.0.beta.10 lib/vmc/test_support/command_helper.rb
af-0.5.0.beta.9 lib/vmc/test_support/command_helper.rb
af-0.5.0.beta.8 lib/vmc/test_support/command_helper.rb
af-0.5.0.beta.7 lib/vmc/test_support/command_helper.rb
af-0.5.0.beta.6 lib/vmc/test_support/command_helper.rb
af-0.5.0.beta.5 lib/vmc/test_support/command_helper.rb
af-0.5.0.beta.4 lib/vmc/test_support/command_helper.rb
af-0.5.0.beta.3 lib/vmc/test_support/command_helper.rb
af-0.5.0.beta.2 lib/vmc/test_support/command_helper.rb
af-0.5.0.beta.1 lib/vmc/test_support/command_helper.rb
vmc-0.5.0.rc1 lib/vmc/test_support/command_helper.rb