From 049a11b3be7ba2fea35cf2298b458b2f6bbd6a8a Mon Sep 17 00:00:00 2001 From: Markus Schirp Date: Sat, 2 Dec 2023 01:59:27 +0000 Subject: [PATCH] Fix ignore pattern merge --- lib/mutant/mutation/config.rb | 2 +- spec/unit/mutant/mutation/config_spec.rb | 19 +++++++++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/lib/mutant/mutation/config.rb b/lib/mutant/mutation/config.rb index 1cca0c39f..dc7931cce 100644 --- a/lib/mutant/mutation/config.rb +++ b/lib/mutant/mutation/config.rb @@ -49,7 +49,7 @@ class Config def merge(other) with( - ignore_patterns: other.ignore_patterns, + ignore_patterns: other.ignore_patterns.any? ? other.ignore_patterns : ignore_patterns, operators: other.operators || operators, timeout: other.timeout || timeout ) diff --git a/spec/unit/mutant/mutation/config_spec.rb b/spec/unit/mutant/mutation/config_spec.rb index 5b8e555ae..b8480a80c 100644 --- a/spec/unit/mutant/mutation/config_spec.rb +++ b/spec/unit/mutant/mutation/config_spec.rb @@ -28,11 +28,22 @@ def expect_value(value) context 'ignore patterns' do let(:key) { :ignore_patterns } - let(:original_value) { :original } - let(:other_value) { :other } + let(:original_value) { %i[original] } - it 'returns other value' do - expect(apply.ignore_patterns).to be(:other) + context 'when other has ignore patterns' do + let(:other_value) { %i[other] } + + it 'returns other value' do + expect(apply.ignore_patterns).to eql(%i[other]) + end + end + + context 'when other has no ignore patterns' do + let(:other_value) { [] } + + it 'returns other value' do + expect(apply.ignore_patterns).to eql(%i[original]) + end end end