Sha256: 278573635ff4af301e8603c6c2a9eae8cda2a8779393e8e3b979d87ef5c12681

Contents?: true

Size: 789 Bytes

Versions: 5

Compression:

Stored size: 789 Bytes

Contents

# encoding: utf-8

require 'stringio'

class Cri::TestCase < Minitest::Test

  def setup
    @orig_io = capture_io
  end

  def teardown
    uncapture_io(*@orig_io)
  end

  def capture_io_while(&block)
    orig_io = capture_io
    block.call
    [ $stdout.string, $stderr.string ]
  ensure
    uncapture_io(*orig_io)
  end

  def lines(string)
    string.scan(/^.*\n/).map { |s| s.chomp }
  end

private

  def capture_io
    orig_stdout = $stdout
    orig_stderr = $stderr

    $stdout = StringIO.new
    $stderr = StringIO.new

    [ orig_stdout, orig_stderr ]
  end

  def uncapture_io(orig_stdout, orig_stderr)
    $stdout = orig_stdout
    $stderr = orig_stderr
  end

end

# Unexpected system exit is unexpected
::MiniTest::Unit::TestCase::PASSTHROUGH_EXCEPTIONS.delete(SystemExit)

Version data entries

5 entries across 4 versions & 2 rubygems

Version Path
cri-2.5.0 test/helper.rb
cri-2.4.1 test/helper.rb
candlepin-api-0.4.0 bundle/ruby/1.9.1/gems/cri-2.4.0/test/helper.rb
candlepin-api-0.4.0 bundle/ruby/gems/cri-2.4.0/test/helper.rb
cri-2.4.0 test/helper.rb