Class: Synthesis::Reporter

Inherits:
Object show all
Defined in:
lib/synthesis/reporter.rb

Class Method Summary collapse

Class Method Details

.report(format, formatter_out) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/synthesis/reporter.rb', line 3

def self.report(format, formatter_out)
  begin
    require "synthesis/formatter/#{format}"
  rescue LoadError
    raise "Invalid format: #{format}"
  end
  out = formatter_out ? File.open(formatter_out, 'w') : STDOUT
  result = 0
  begin
    formatter = Formatter.load(out)
    if ExpectationRecord.has_untested_expectations?
      formatter.format_failure
      result = -1
    else
      formatter.format_success
    end
  ensure
    out.close unless out == STDOUT
  end
  return result
end