Sha256: 07f2946dc6f0cf1c399284a5885d5a9e96b7c3c27cbc740672dd1b3f607ae0ed

Contents?: true

Size: 1.23 KB

Versions: 6

Compression:

Stored size: 1.23 KB

Contents

# encoding: utf-8

require 'rubygems'
require 'stringio' # stdlib
require 'spec' # not 'minitest'

class MiniTest::Spec
  @@output = StringIO.new

  def self.output
    @@output
  end

  def p msg
    @@output.puts msg
  end
end

class SpecTest < MiniTest::Spec
  describe 'a' do
    before_first { p '-- before_first' }
    after_last { p '-- after_last' }
    t('') { p 1 }
    t('') { p 2 }
    t('') { p 3 }
    t('') { p 4 }
    t('') { p 5 }
    t('') { p 6 }
    t('') { p 7 }
  end

  describe 'b' do
    t('') { p 8 }
    t('') { p 9 }
  end

  describe 'c' do
    before { p '-- before' }
    after { p '-- after' }
    t('') { p 10 }
    t('') { p 11 }
    t('') { p 12 }
  end

  describe 'd' do
    t('') { p 13 }
    t('') { p 14 }
  end
end

options = {}
out = MiniTest::Spec.output
reporter = Minitest::CompositeReporter.new
reporter << Minitest::SummaryReporter.new(out, options)
reporter << Minitest::ProgressReporter.new(out, options)
#reporter.start

Minitest.__run reporter, options

#reporter.report
out.flush
out.rewind

actual = out.readlines.join ''
exp = <<'EXP'.strip
-- before_first
1
.2
.3
.4
.5
.6
.7
.-- after_last
8
.9
.-- before
10
-- after
.-- before
11
-- after
.-- before
12
-- after
.13
.14
.
EXP

puts actual.must_equal exp

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
spec-5.0.19 test/manual/run3.rb
spec-5.0.18 test/manual/run3.rb
spec-5.0.17 test/manual/run3.rb
spec-5.0.16 test/manual/run3.rb
spec-5.0.15 test/manual/run3.rb
spec-5.0.14 test/manual/run3.rb