Class: TestOutputParser::Summary

Inherits:
Object
  • Object
show all
Defined in:
lib/test_output_parser.rb

Constant Summary collapse

ATTRIBUTES =
%w(total failed errors pending)

Instance Method Summary collapse

Instance Method Details

#add_failure_lines(lines) ⇒ Object



26
27
28
29
30
31
32
33
34
# File 'lib/test_output_parser.rb', line 26

def add_failure_lines(lines)
  return unless lines
  return if lines.respond_to?(:empty?) && lines.empty?
  if lines.respond_to?(:to_str)
    self.failures << lines
  else
    self.failures << lines.join
  end
end

#failuresObject



36
37
38
# File 'lib/test_output_parser.rb', line 36

def failures
  @failures ||= StringIO.new
end

#to_hashObject



40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/test_output_parser.rb', line 40

def to_hash
  result = {}
  ATTRIBUTES.each do |attr|
    next if self.send(attr) == 0
    result[attr.to_sym] = self.send(attr)
  end

  if failures.size != 0
    result[:failures] = failures.string
  end

  result
end