Skip to content

Commit eff671d

Browse files
committed
Show covered/total ratios in summary stats
1 parent 6bae159 commit eff671d

File tree

4 files changed

+11
-47
lines changed

4 files changed

+11
-47
lines changed

assets/stylesheets/screen.css

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -420,32 +420,6 @@ a.src_link {
420420
word-break: break-all;
421421
}
422422

423-
/* --- Coverage bar in table --------------------------------- */
424-
425-
.coverage-bar {
426-
display: flex;
427-
align-items: center;
428-
gap: var(--sp-2);
429-
min-width: 120px;
430-
}
431-
432-
.coverage-bar__track {
433-
flex: 1;
434-
height: var(--bar-height);
435-
background: var(--bar-bg);
436-
border-radius: 3px;
437-
overflow: hidden;
438-
}
439-
440-
.coverage-bar__fill {
441-
height: 100%;
442-
border-radius: 3px;
443-
transition: width 0.3s ease-out;
444-
}
445-
446-
.coverage-bar__fill--green { background: var(--green); }
447-
.coverage-bar__fill--yellow { background: var(--yellow); }
448-
.coverage-bar__fill--red { background: var(--red); }
449423

450424
/* --- Color utility classes --------------------------------- */
451425

public/application.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/test_simple_cov-html.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,9 @@ def assert_header_coverage(html_doc)
113113

114114
return if RUBY_ENGINE == "jruby"
115115

116-
branch_covered = html_doc.at_css("div#AllFiles div.t-branch-summary span.green").content.strip
116+
branch_summary = html_doc.at_css("div#AllFiles div.t-branch-summary").content.strip
117117

118-
assert_match(/covered/, branch_covered)
118+
assert_match(/covered/, branch_summary)
119119
end
120120

121121
def assert_line_coverages(html_doc)

views/file_list.erb

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,20 @@
99

1010
<div class="summary-stats">
1111
<div class="t-line-summary">
12-
<b><%= source_files.length %></b> files,
13-
<b><%= source_files.lines_of_code %></b> relevant lines:
14-
<span class="green"><b><%= source_files.covered_lines %></b> covered</span>,
15-
<span class="red"><b><%= source_files.missed_lines %></b> missed</span>
12+
<b><%= source_files.length %></b> files.
13+
Lines: <span class="green"><b><%= source_files.covered_lines %></b></span>/<b><%= source_files.lines_of_code %></b> relevant lines covered<% if source_files.missed_lines > 0 %>,
14+
<span class="red"><b><%= source_files.missed_lines %></b> missed</span><% end %>
1615
</div>
1716
<%- if branch_coverage? -%>
1817
<div class="t-branch-summary">
19-
<b><%= source_files.total_branches %></b> branches:
20-
<span class="green"><b><%= source_files.covered_branches %></b> covered</span>,
21-
<span class="red"><b><%= source_files.missed_branches %></b> missed</span>
18+
Branches: <span class="green"><b><%= source_files.covered_branches %></b></span>/<b><%= source_files.total_branches %></b> covered<% if source_files.missed_branches > 0 %>,
19+
<span class="red"><b><%= source_files.missed_branches %></b> missed</span><% end %>
2220
</div>
2321
<%- end -%>
2422
<%- if method_coverage? -%>
2523
<div class="t-method-summary">
26-
<b><%= source_files.total_methods %></b> methods:
27-
<span class="green"><b><%= source_files.covered_methods %></b> covered</span>,
28-
<span class="red"><b><%= source_files.missed_methods %></b> missed</span>
24+
Methods: <span class="green"><b><%= source_files.covered_methods %></b></span>/<b><%= source_files.total_methods %></b> covered<% if source_files.missed_methods > 0 %>,
25+
<span class="red"><b><%= source_files.missed_methods %></b> missed</span><% end %>
2926
</div>
3027
<%- end -%>
3128
</div>
@@ -59,14 +56,7 @@
5956
<%- source_files.each do |source_file| -%>
6057
<tr class="t-file">
6158
<td class="strong t-file__name"><%= link_to_source_file(source_file) %></td>
62-
<td class="strong cell--number t-file__coverage">
63-
<div class="coverage-bar">
64-
<span class="<%= coverage_css_class(source_file.covered_percent) %>"><%= sprintf("%.2f", source_file.covered_percent.floor(2)) %>%</span>
65-
<span class="coverage-bar__track">
66-
<span class="coverage-bar__fill coverage-bar__fill--<%= coverage_css_class(source_file.covered_percent) %>" style="width: <%= sprintf("%.1f", source_file.covered_percent.floor(1)) %>%"></span>
67-
</span>
68-
</div>
69-
</td>
59+
<td class="strong cell--number t-file__coverage"><%= covered_percent(source_file.covered_percent) %></td>
7060
<td class="cell--number"><%= source_file.lines.count %></td>
7161
<td class="cell--number"><%= source_file.covered_lines.count + source_file.missed_lines.count %></td>
7262
<td class="cell--number"><%= source_file.covered_lines.count %></td>

0 commit comments

Comments
 (0)