This commit is contained in:
Miguel Savignano 2019-11-03 01:58:41 +01:00
parent ad6c0d4ded
commit 21b4337b76
2 changed files with 3 additions and 3 deletions

View File

@ -29,9 +29,9 @@ class CoverageReport
def lcov_covered_percent(lcov_result) def lcov_covered_percent(lcov_result)
lines = lcov_result.map { |r| r['lines']['details'] }.flatten lines = lcov_result.map { |r| r['lines']['details'] }.flatten
total_lines = lines.count&.to_f total_lines = lines.count&.to_f.round(2)
covered_lines = lines.select { |r| r['hit'] >= 1 }.count&.to_f covered_lines = lines.select { |r| r['hit'] >= 1 }.count&.to_f
(covered_lines / total_lines) * 100 ((covered_lines / total_lines) * 100).round(2)
end end
def execute_lcov_parse(report_path) def execute_lcov_parse(report_path)

View File

@ -10,6 +10,6 @@ describe CoverageReport do
it '.lcov' do it '.lcov' do
result = CoverageReport.lcov('./spec/fixtures/example.lcov', min: 80) result = CoverageReport.lcov('./spec/fixtures/example.lcov', min: 80)
expect(result['lines']['covered_percent']).to eq(85.60606060606061) expect(result['lines']['covered_percent']).to eq(85.61)
end end
end end