From 11232cf5fbd296dcb915ed3e262ed147bcaf12df Mon Sep 17 00:00:00 2001 From: Marco Costa Date: Tue, 2 Feb 2021 16:22:00 -0500 Subject: [PATCH 1/2] Ensure branches Hash is present when supported --- lib/simplecov/combine/files_combiner.rb | 2 +- spec/combine/results_combiner_spec.rb | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/simplecov/combine/files_combiner.rb b/lib/simplecov/combine/files_combiner.rb index 32df1184..d41583bf 100644 --- a/lib/simplecov/combine/files_combiner.rb +++ b/lib/simplecov/combine/files_combiner.rb @@ -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 diff --git a/spec/combine/results_combiner_spec.rb b/spec/combine/results_combiner_spec.rb index 05e1b55e..6f502e03 100644 --- a/spec/combine/results_combiner_spec.rb +++ b/spec/combine/results_combiner_spec.rb @@ -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 From 3bb6b7ee58bf4b1954ca205f50dd44d6f41c57db Mon Sep 17 00:00:00 2001 From: Marco Costa Date: Fri, 5 Feb 2021 16:34:28 -0500 Subject: [PATCH 2/2] Filter out example using conditional filters --- spec/combine/results_combiner_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/combine/results_combiner_spec.rb b/spec/combine/results_combiner_spec.rb index 6f502e03..67e1a96a 100644 --- a/spec/combine/results_combiner_spec.rb +++ b/spec/combine/results_combiner_spec.rb @@ -102,8 +102,8 @@ 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? + it "always returns a Hash object for branches", if: SimpleCov.branch_coverage_supported? do + expect(subject[source_fixture("three.rb")]["branches"]).to eq({}) end end end