round 2
This commit is contained in:
parent
ad6c0d4ded
commit
21b4337b76
@ -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)
|
||||||
|
|||||||
@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user