Sha256: 2df7e7f8b243ac86ffae6070a53bfeeefdca1b4ee6417ca13b58b4c401ec81ae

Contents?: true

Size: 602 Bytes

Versions: 1

Compression:

Stored size: 602 Bytes

Contents

module ShellInteractionHelpers
  def capture_stderr(&block)
    original_stderr = $stderr
    $stderr = fake = StringIO.new
    begin
      yield
    ensure
      $stderr = original_stderr
    end
    fake.string
  end

  def capture_stdout(&block)
    original_stdout = $stdout
    $stdout = fake = StringIO.new
    begin
      yield
    ensure
      $stdout = original_stdout
    end
    fake.string
  end

  # wrapper around raise_error that captures stderr
  def should_abort_with(msg)
    capture_stderr do
      expect do
        yield
      end.to raise_error SystemExit, msg
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
elzar-0.2.0 spec/support/shell_interaction_helpers.rb