Handle case where there was zero coverage data.

This commit is contained in:
Porter Schutz 2013-04-29 18:36:57 -07:00
parent ba69ca37dd
commit 27e4088732

View File

@ -14,7 +14,7 @@ class SimpleCov::Formatter::JSONFormatter
filename: sourceFile.filename,
covered_percent: sourceFile.covered_percent,
coverage: sourceFile.coverage,
covered_strength: sourceFile.covered_strength,
covered_strength: sourceFile.covered_strength.nan? ? 0.0 : sourceFile.covered_strength,
covered_lines: sourceFile.covered_lines.count,
lines_of_code: sourceFile.lines_of_code,
}
@ -22,7 +22,7 @@ class SimpleCov::Formatter::JSONFormatter
data[:groups] = result.groups
data[:metrics] = {
covered_percent: result.covered_percent,
covered_strength: result.covered_strength,
covered_strength: result.covered_strength.nan? ? 0.0 : result.covered_strength,
covered_lines: result.covered_lines,
total_lines: result.total_lines,
}