Skip to content

Commit dc754e4

Browse files
committed
add feature specs for method coverage
1 parent 9a8b324 commit dc754e4

File tree

4 files changed

+63
-1
lines changed

4 files changed

+63
-1
lines changed

Gemfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ when "local"
99
when "github"
1010
# Use development version of html formatter from github
1111
gem "simplecov-html", github: "simplecov-ruby/simplecov-html"
12+
when "methods"
13+
gem "simplecov-html", github: "umbrellio/simplecov-html", branch: "add-method-coverage-support"
1214
end
1315

1416
group :development do

Gemfile.lock

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
GIT
2+
remote: https://github.com/umbrellio/simplecov-html.git
3+
revision: fc9c7a1beaa75bad3a925d1296b94fcd0c96b126
4+
branch: add-method-coverage-support
5+
specs:
6+
simplecov-html (0.12.3)
7+
18
PATH
29
remote: .
310
specs:
@@ -101,6 +108,10 @@ GEM
101108
pry (0.13.1)
102109
coderay (~> 1.1)
103110
method_source (~> 1.0)
111+
pry (0.13.1-java)
112+
coderay (~> 1.1)
113+
method_source (~> 1.0)
114+
spoon (~> 0.0)
104115
public_suffix (4.0.6)
105116
racc (1.5.2)
106117
racc (1.5.2-java)
@@ -136,8 +147,9 @@ GEM
136147
rubocop-ast (1.4.1)
137148
parser (>= 2.7.1.5)
138149
ruby-progressbar (1.11.0)
139-
simplecov-html (0.12.3)
140150
simplecov_json_formatter (0.1.2)
151+
spoon (0.0.6)
152+
ffi
141153
sys-uname (1.2.2)
142154
ffi (~> 1.1)
143155
test-unit (3.3.6)
@@ -175,6 +187,7 @@ DEPENDENCIES
175187
rspec (~> 3.2)
176188
rubocop
177189
simplecov!
190+
simplecov-html!
178191
test-unit
179192
webrick
180193

features/method_coverage.feature

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
@rspec @method_coverage
2+
Feature:
3+
4+
Simply executing method coverage gives ok results.
5+
6+
Background:
7+
Given I'm working on the project "faked_project"
8+
9+
Scenario:
10+
Given SimpleCov for RSpec is configured with:
11+
"""
12+
require 'simplecov'
13+
SimpleCov.start do
14+
enable_coverage :method
15+
end
16+
"""
17+
When I open the coverage report generated with `bundle exec rspec spec`
18+
Then I should see the groups:
19+
| name | coverage | files |
20+
| All Files | 91.8% | 7 |
21+
And I should see a line coverage summary of 56/61
22+
And I should see a method coverage summary of 10/13
23+
And I should see the source files:
24+
| name | coverage | method coverage |
25+
| lib/faked_project.rb | 100.00 % | 100.00 % |
26+
| lib/faked_project/some_class.rb | 80.00 % | 75.00 % |
27+
| lib/faked_project/framework_specific.rb | 75.00 % | 33.33 % |
28+
| lib/faked_project/meta_magic.rb | 100.00 % | 100.00 % |
29+
| spec/forking_spec.rb | 100.00 % | 100.00 % |
30+
| spec/meta_magic_spec.rb | 100.00 % | 100.00 % |
31+
| spec/some_class_spec.rb | 100.00 % | 100.00 % |
32+
33+
When I open the detailed view for "lib/faked_project/framework_specific.rb"
34+
Then I should see a line coverage summary of 6/8 for the file
35+
And I should see a method coverage summary of 1/3 for the file
36+
And I should see missed methods list:
37+
| name |
38+
| #<Class:FrameworkSpecific>#test_unit |
39+
| #<Class:FrameworkSpecific>#cucumber |

features/step_definitions/html_steps.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
available_source_files = all(".t-file", visible: true, count: expected_files.count)
2626

2727
include_branch_coverage = table.column_names.include?("branch coverage")
28+
include_method_coverage = table.column_names.include?("method coverage")
2829

2930
# Find all filenames and their coverage present in coverage report
3031
files = available_source_files.map do |file_row|
@@ -35,6 +36,7 @@
3536
}
3637

3738
coverage_data["branch coverage"] = file_row.find(".t-file__branch-coverage").text if include_branch_coverage
39+
coverage_data["method coverage"] = file_row.find(".t-file__method-coverage").text if include_method_coverage
3840

3941
coverage_data
4042
end
@@ -68,3 +70,9 @@
6870
Then /^I should see coverage branch data like "(.+)"$/ do |text|
6971
expect(find(".hits", visible: true, text: text)).to be_truthy
7072
end
73+
74+
Then /^I should see missed methods list:$/ do |table|
75+
expected_list = table.hashes.map { |x| x.fetch("name") }
76+
list = all(".t-missed-method-summary li", visible: true).map(&:text)
77+
expect(list).to eq(expected_list)
78+
end

0 commit comments

Comments
 (0)