summaryrefslogtreecommitdiff
path: root/spec/mspec/lib/mspec/runner/formatters/multi.rb
blob: 085f961be861a5a397cfc690910d0b019b5d319c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
require 'mspec/runner/formatters/spinner'

class MultiFormatter < SpinnerFormatter
  def initialize(out=nil)
    super(out)
    @counter = @tally = Tally.new
    @timer = TimerAction.new
    @timer.start
  end

  def aggregate_results(files)
    require 'yaml'

    @timer.finish
    @exceptions = []

    files.each do |file|
      contents = File.read(file)
      d = YAML.load(contents)
      File.delete file

      if d # The file might be empty if the child process died
        @exceptions += Array(d['exceptions'])
        @tally.files!        d['files']
        @tally.examples!     d['examples']
        @tally.expectations! d['expectations']
        @tally.errors!       d['errors']
        @tally.failures!     d['failures']
      end
    end
  end

  def print_exception(exc, count)
    print "\n#{count})\n#{exc}\n"
  end
end