Skip to content

Commit b36c1c0

Browse files
committed
Use SimpleCov::SourceFile#methods instead of #total_methods
Also fix RuboCop offenses, add method coverage test, and update SimpleCov dependency to latest.
1 parent 7ae6981 commit b36c1c0

4 files changed

Lines changed: 13 additions & 3 deletions

File tree

.rubocop.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Metrics/BlockNesting:
2323
Max: 2
2424

2525
Metrics/ClassLength:
26+
Max: 110
2627
CountAsOne:
2728
- array
2829
- hash

Gemfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
GIT
22
remote: https://github.com/simplecov-ruby/simplecov
3-
revision: 6bc01182d366be51cbe3a590bede1bd41ac71db8
3+
revision: 3d8d723874ff14b06f30dee5d1453f9acc92fdf9
44
specs:
55
simplecov (0.22.0)
66
docile (~> 1.1)
7-
simplecov-html (~> 0.11)
7+
simplecov-html (~> 0.12)
88
simplecov_json_formatter (~> 0.1)
99

1010
PATH

lib/simplecov-html.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ def link_to_source_file(source_file)
160160

161161
def render_stats(result, criterion)
162162
stats = result.coverage_statistics.fetch(criterion)
163-
sprintf("%d / %d (%.2f%%)", stats.covered, stats.total, stats.percent)
163+
Kernel.format("%<covered>d / %<total>d (%<percent>.2f%%)", covered: stats.covered, total: stats.total, percent: stats.percent)
164164
end
165165
end
166166
end

test/test_simple_cov-html.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,15 @@ def test_output
4242
assert_branch_coverages(html_doc) if RUBY_ENGINE != "jruby"
4343
end
4444

45+
def test_output_with_method_coverage
46+
return unless SimpleCov.method_coverage_supported?
47+
48+
SimpleCov.enable_coverage(:method)
49+
html_doc = format_results("sample.rb" => CoverageFixtures::SAMPLE_RB)
50+
51+
assert html_doc.at_css("div#AllFiles div.t-method-summary")
52+
end
53+
4554
def test_output_without_branch_coverage
4655
SimpleCov.clear_coverage_criteria
4756
html_doc = format_results("sample.rb" => CoverageFixtures::SAMPLE_RB)

0 commit comments

Comments
 (0)