Skip to content

Commit

Permalink
Merge 27a9909 into 867d5f7
Browse files Browse the repository at this point in the history
  • Loading branch information
mrexox authored May 23, 2023
2 parents 867d5f7 + 27a9909 commit 58101bc
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 3 deletions.
14 changes: 14 additions & 0 deletions spec/coverage_reporter/parsers/simplecov_parser_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,19 @@ Spectator.describe CoverageReporter::SimplecovParser do
})
end
end

context "with only lines" do
let(filename) { "spec/fixtures/simplecov/with-only-lines.resultset.json" }

it "parses correctly" do
reports = subject.parse(filename)
expect(reports.size).to eq 1
expect(reports[0].to_h).to eq({
:name => "home/user/app/models/user.rb",
:branches => [] of Int64,
:coverage => [nil, 1, 1, 0, nil, nil, 1, 0, nil, nil, 1, 0, 0, nil, nil, nil],
})
end
end
end
end
26 changes: 26 additions & 0 deletions spec/fixtures/simplecov/with-only-lines.resultset.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"Rspec": {
"coverage": {
"/home/user/app/models/user.rb": {
"lines": [
null,
1,
1,
0,
null,
null,
1,
0,
null,
null,
1,
0,
0,
null,
null,
null
]
}
}
}
}
7 changes: 4 additions & 3 deletions src/coverage_reporter/parsers/simplecov_parser.cr
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module CoverageReporter
include JSON::Serializable

property lines : Coverage
property branches : Hash(String, Hash(String, Int64?))
property branches : Hash(String, Hash(String, Int64?)) | Nil
end

class Report
Expand Down Expand Up @@ -49,8 +49,9 @@ module CoverageReporter
coverage = info
when ComplexCoverage
coverage = info.lines
unless info.branches.empty?
info.branches.each do |branch, branch_info|
info_branches = info.branches
if info_branches
info_branches.each do |branch, branch_info|
branch_number = 0
line_number = branch.split(", ")[2].to_i64
branch_info.each_value do |hits|
Expand Down

0 comments on commit 58101bc

Please sign in to comment.