aboutsummaryrefslogtreecommitdiffstats
path: root/spec/mspec/lib/mspec/runner/formatters/yaml.rb
blob: 090a9b1b9df02f9c16e2ad837ab918b855732337 (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
37
38
39
40
41
42
require 'mspec/expectations/expectations'
require 'mspec/runner/formatters/dotted'

class YamlFormatter < DottedFormatter
  def initialize(out=nil)
    super(nil)

    if out.nil?
      @finish = $stdout
    else
      @finish = File.open out, "w"
    end
  end

  def switch
    @out = @finish
  end

  def after(state)
  end

  def finish
    switch

    print "---\n"
    print "exceptions:\n"
    @exceptions.each do |exc|
      outcome = exc.failure? ? "FAILED" : "ERROR"
      str =  "#{exc.description} #{outcome}\n"
      str << exc.message << "\n" << exc.backtrace
      print "- ", str.inspect, "\n"
    end

    print "time: ",         @timer.elapsed,              "\n"
    print "files: ",        @tally.counter.files,        "\n"
    print "examples: ",     @tally.counter.examples,     "\n"
    print "expectations: ", @tally.counter.expectations, "\n"
    print "failures: ",     @tally.counter.failures,     "\n"
    print "errors: ",       @tally.counter.errors,       "\n"
    print "tagged: ",       @tally.counter.tagged,       "\n"
  end
end