Sha256: 0a574a706b8ffbabaac312b52fe8a22792f0e798a80ae113b98885902c7c15e3

Contents?: true

Size: 915 Bytes

Versions: 6

Compression:

Stored size: 915 Bytes

Contents

require 'coveralls'
Coveralls.wear!

require 'minitest'
require 'minitest/autorun'

require 'cri'

require 'stringio'

module Cri
  class TestCase < Minitest::Test
    def setup
      @orig_io = capture_io
    end

    def teardown
      uncapture_io(*@orig_io)
    end

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

    def lines(string)
      string.scan(/^.*\n/).map(&: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
end

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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
cri-2.10.1 test/helper.rb
cri-2.10.0 test/helper.rb
cri-2.9.1 test/helper.rb
cri-2.9.0 test/helper.rb
cri-2.8.0 test/helper.rb
cri-2.7.1 test/helper.rb