Skip to content

Commit 99ef976

Browse files
marcotcamatsuda
authored andcommitted
Ensure branches Hash is present when supported
1 parent f167f76 commit 99ef976

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

lib/simplecov/combine/files_combiner.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ module FilesCombiner
1616
#
1717
def combine(coverage_a, coverage_b)
1818
combination = {"lines" => Combine.combine(LinesCombiner, coverage_a["lines"], coverage_b["lines"])}
19-
combination["branches"] = Combine.combine(BranchesCombiner, coverage_a["branches"], coverage_b["branches"]) if SimpleCov.branch_coverage?
19+
combination["branches"] = Combine.combine(BranchesCombiner, coverage_a["branches"], coverage_b["branches"]) || {} if SimpleCov.branch_coverage?
2020
combination
2121
end
2222
end

spec/combine/results_combiner_spec.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@
101101
it "has proper results for three.rb" do
102102
expect(subject[source_fixture("three.rb")]["lines"]).to eq([nil, 3, 7])
103103
end
104+
105+
it "always returns a Hash object for branches" do
106+
expect(subject[source_fixture("three.rb")]["branches"]).to eq({}) if SimpleCov.branch_coverage_supported?
107+
end
104108
end
105109
end
106110

0 commit comments

Comments
 (0)