Skip to content

Commit

Permalink
Ensure branches Hash is present when supported
Browse files Browse the repository at this point in the history
  • Loading branch information
marcotc authored and amatsuda committed Jan 13, 2025
1 parent f167f76 commit 99ef976
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/simplecov/combine/files_combiner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module FilesCombiner
#
def combine(coverage_a, coverage_b)
combination = {"lines" => Combine.combine(LinesCombiner, coverage_a["lines"], coverage_b["lines"])}
combination["branches"] = Combine.combine(BranchesCombiner, coverage_a["branches"], coverage_b["branches"]) if SimpleCov.branch_coverage?
combination["branches"] = Combine.combine(BranchesCombiner, coverage_a["branches"], coverage_b["branches"]) || {} if SimpleCov.branch_coverage?
combination
end
end
Expand Down
4 changes: 4 additions & 0 deletions spec/combine/results_combiner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@
it "has proper results for three.rb" do
expect(subject[source_fixture("three.rb")]["lines"]).to eq([nil, 3, 7])
end

it "always returns a Hash object for branches" do
expect(subject[source_fixture("three.rb")]["branches"]).to eq({}) if SimpleCov.branch_coverage_supported?
end
end
end

Expand Down

0 comments on commit 99ef976

Please sign in to comment.