Method: OSpec::PhantomFormatter#finish

Defined in:
lib/ospec/phantom_formatter.rb

#finishObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/ospec/phantom_formatter.rb', line 23

def finish
  if @failed_examples.empty?
    log "\nFinished"
    log_green "#{example_count} examples, 0 failures"
    `phantom.exit(0)`
  else
    log "\nFailures:"
    @failed_examples.each_with_index do |example, idx|
      log "\n  #{idx+1}. #{example.example_group.description} #{example.description}"

      exception = example.exception
      case exception
      when OSpec::ExpectationNotMetError
        output  = exception.message
      else
        output  = "#{exception.class}: #{exception.message}\n"
        output += "      #{exception.backtrace.join "\n      "}\n"
      end
      log_red "    #{output}"
    end

    log "\nFinished"
    log_red "#{example_count} examples, #{@failed_examples.size} failures"
    `phantom.exit(1)`
  end
end