From 17c0c715b956092e3459b3b54dfde0a9629e109f Mon Sep 17 00:00:00 2001 From: Markus Schirp Date: Tue, 7 Jul 2015 19:33:32 +0000 Subject: [PATCH 1/3] Remove unused subject_select matcher config --- config/flay.yml | 2 +- lib/mutant/matcher/compiler.rb | 28 +---------- lib/mutant/matcher/config.rb | 3 +- spec/unit/mutant/matcher/compiler_spec.rb | 48 +------------------ .../reporter/cli/printer/config_spec.rb | 4 +- .../reporter/cli/printer/env_progress_spec.rb | 6 +-- .../reporter/cli/printer/env_result_spec.rb | 2 +- .../reporter/cli/printer/status_spec.rb | 10 ++-- spec/unit/mutant/reporter/cli_spec.rb | 8 ++-- 9 files changed, 19 insertions(+), 92 deletions(-) diff --git a/config/flay.yml b/config/flay.yml index c3a14bb7..c6cd5ab4 100644 --- a/config/flay.yml +++ b/config/flay.yml @@ -1,3 +1,3 @@ --- threshold: 18 -total_score: 1185 +total_score: 1167 diff --git a/lib/mutant/matcher/compiler.rb b/lib/mutant/matcher/compiler.rb index b601c2ec..60e62821 100644 --- a/lib/mutant/matcher/compiler.rb +++ b/lib/mutant/matcher/compiler.rb @@ -38,41 +38,15 @@ module Mutant # # @return [#call] # - # rubocop:disable MethodLength - # # @api private def predicate - if subject_selector && subject_rejector - Morpher::Evaluator::Predicate::Boolean::And.new([ - subject_selector, - Morpher::Evaluator::Predicate::Negation.new(subject_rejector) - ]) - elsif subject_selector - subject_selector - elsif subject_rejector + if subject_rejector Morpher::Evaluator::Predicate::Negation.new(subject_rejector) else Morpher::Evaluator::Predicate::Tautology.new end end - # the subject selector predicate - # - # @return [#call] - # if selector is present - # - # @return [nil] - # otherwise - # - # @api private - def subject_selector - selectors = config.subject_selects.map do |attribute, value| - Morpher.compile(s(:eql, s(:attribute, attribute), s(:static, value))) - end - - Morpher::Evaluator::Predicate::Boolean::Or.new(selectors) if selectors.any? - end - # Subject rejector predicate # # @return [#call] diff --git a/lib/mutant/matcher/config.rb b/lib/mutant/matcher/config.rb index ae4a901b..9c64c167 100644 --- a/lib/mutant/matcher/config.rb +++ b/lib/mutant/matcher/config.rb @@ -4,8 +4,7 @@ module Mutant class Config include Adamantium, Anima::Update, Anima.new( :match_expressions, - :subject_ignores, - :subject_selects + :subject_ignores ) DEFAULT = new(Hash[anima.attribute_names.map { |name| [name, []] }]) diff --git a/spec/unit/mutant/matcher/compiler_spec.rb b/spec/unit/mutant/matcher/compiler_spec.rb index 5a4ec2f7..12eef9bf 100644 --- a/spec/unit/mutant/matcher/compiler_spec.rb +++ b/spec/unit/mutant/matcher/compiler_spec.rb @@ -41,7 +41,7 @@ RSpec.describe Mutant::Matcher::Compiler do it { should eql(expected_matcher) } end - context 'and a subject filter' do + context 'and a subject ignore' do let(:attributes) do { match_expressions: [expression_a], @@ -61,52 +61,6 @@ RSpec.describe Mutant::Matcher::Compiler do it { should eql(expected_matcher) } end - - context 'and an attribute filter' do - let(:attributes) do - { - match_expressions: [expression_a], - subject_selects: [[:code, 'foo']] - } - end - - let(:expected_positive_matcher) { Mutant::Matcher::Chain.new([matcher_a]) } - - let(:expected_predicate) do - Morpher::Evaluator::Predicate::Boolean::Or.new([ - Morpher.compile(s(:eql, s(:attribute, :code), s(:static, 'foo'))) - ]) - end - - it { should eql(expected_matcher) } - end - - context 'and subject and attribute filter' do - let(:attributes) do - { - match_expressions: [expression_a], - subject_ignores: [expression_b], - subject_selects: [[:code, 'foo']] - } - end - - let(:expected_positive_matcher) { Mutant::Matcher::Chain.new([matcher_a]) } - - let(:expected_predicate) do - Morpher::Evaluator::Predicate::Boolean::And.new([ - Morpher::Evaluator::Predicate::Boolean::Or.new([ - Morpher.compile(s(:eql, s(:attribute, :code), s(:static, 'foo'))) - ]), - Morpher::Evaluator::Predicate::Negation.new( - Morpher::Evaluator::Predicate::Boolean::Or.new([ - described_class::SubjectPrefix.new(expression_b) - ]) - ) - ]) - end - - it { should eql(expected_matcher) } - end end context 'on config with multiple match expressions' do diff --git a/spec/unit/mutant/reporter/cli/printer/config_spec.rb b/spec/unit/mutant/reporter/cli/printer/config_spec.rb index 69c5f0f9..b643a116 100644 --- a/spec/unit/mutant/reporter/cli/printer/config_spec.rb +++ b/spec/unit/mutant/reporter/cli/printer/config_spec.rb @@ -7,7 +7,7 @@ RSpec.describe Mutant::Reporter::CLI::Printer::Config do context 'on default config' do it_reports(<<-REPORT) Mutant configuration: - Matcher: # + Matcher: # Integration: Mutant::Integration::Null Expect Coverage: 100.00% Jobs: 1 @@ -21,7 +21,7 @@ RSpec.describe Mutant::Reporter::CLI::Printer::Config do it_reports(<<-REPORT) Mutant configuration: - Matcher: # + Matcher: # Integration: Mutant::Integration::Null Expect Coverage: 10.00% Jobs: 1 diff --git a/spec/unit/mutant/reporter/cli/printer/env_progress_spec.rb b/spec/unit/mutant/reporter/cli/printer/env_progress_spec.rb index adb15a95..db9d4b4c 100644 --- a/spec/unit/mutant/reporter/cli/printer/env_progress_spec.rb +++ b/spec/unit/mutant/reporter/cli/printer/env_progress_spec.rb @@ -11,7 +11,7 @@ RSpec.describe Mutant::Reporter::CLI::Printer::EnvProgress do it_reports <<-'STR' Mutant configuration: - Matcher: # + Matcher: # Integration: Mutant::Integration::Null Expect Coverage: 10.00% Jobs: 1 @@ -32,7 +32,7 @@ RSpec.describe Mutant::Reporter::CLI::Printer::EnvProgress do context 'on full coverage' do it_reports <<-'STR' Mutant configuration: - Matcher: # + Matcher: # Integration: Mutant::Integration::Null Expect Coverage: 10.00% Jobs: 1 @@ -55,7 +55,7 @@ RSpec.describe Mutant::Reporter::CLI::Printer::EnvProgress do it_reports <<-'STR' Mutant configuration: - Matcher: # + Matcher: # Integration: Mutant::Integration::Null Expect Coverage: 10.00% Jobs: 1 diff --git a/spec/unit/mutant/reporter/cli/printer/env_result_spec.rb b/spec/unit/mutant/reporter/cli/printer/env_result_spec.rb index 5476ffe9..bc22f47e 100644 --- a/spec/unit/mutant/reporter/cli/printer/env_result_spec.rb +++ b/spec/unit/mutant/reporter/cli/printer/env_result_spec.rb @@ -15,7 +15,7 @@ RSpec.describe Mutant::Reporter::CLI::Printer::EnvResult do +false ----------------------- Mutant configuration: - Matcher: # + Matcher: # Integration: Mutant::Integration::Null Expect Coverage: 100.00% Jobs: 1 diff --git a/spec/unit/mutant/reporter/cli/printer/status_spec.rb b/spec/unit/mutant/reporter/cli/printer/status_spec.rb index 346b5099..018d937a 100644 --- a/spec/unit/mutant/reporter/cli/printer/status_spec.rb +++ b/spec/unit/mutant/reporter/cli/printer/status_spec.rb @@ -9,7 +9,7 @@ RSpec.describe Mutant::Reporter::CLI::Printer::Status do it_reports <<-REPORT Mutant configuration: - Matcher: # + Matcher: # Integration: Mutant::Integration::Null Expect Coverage: 100.00% Jobs: 1 @@ -32,7 +32,7 @@ RSpec.describe Mutant::Reporter::CLI::Printer::Status do it_reports <<-REPORT Mutant configuration: - Matcher: # + Matcher: # Integration: Mutant::Integration::Null Expect Coverage: 10.00% Jobs: 1 @@ -58,7 +58,7 @@ RSpec.describe Mutant::Reporter::CLI::Printer::Status do it_reports(<<-REPORT) Mutant configuration: - Matcher: # + Matcher: # Integration: Mutant::Integration::Null Expect Coverage: 100.00% Jobs: 1 @@ -85,7 +85,7 @@ RSpec.describe Mutant::Reporter::CLI::Printer::Status do it_reports(<<-REPORT) Mutant configuration: - Matcher: # + Matcher: # Integration: Mutant::Integration::Null Expect Coverage: 100.00% Jobs: 1 @@ -114,7 +114,7 @@ RSpec.describe Mutant::Reporter::CLI::Printer::Status do context 'on success' do it_reports(<<-REPORT) Mutant configuration: - Matcher: # + Matcher: # Integration: Mutant::Integration::Null Expect Coverage: 100.00% Jobs: 1 diff --git a/spec/unit/mutant/reporter/cli_spec.rb b/spec/unit/mutant/reporter/cli_spec.rb index a017b2dd..ee81418d 100644 --- a/spec/unit/mutant/reporter/cli_spec.rb +++ b/spec/unit/mutant/reporter/cli_spec.rb @@ -121,7 +121,7 @@ RSpec.describe Mutant::Reporter::CLI do it_reports(<<-REPORT) Mutant configuration: - Matcher: # + Matcher: # Integration: Mutant::Integration::Null Expect Coverage: 100.00% Jobs: 1 @@ -136,7 +136,7 @@ RSpec.describe Mutant::Reporter::CLI do it_reports(<<-REPORT) Mutant configuration: - Matcher: # + Matcher: # Integration: Mutant::Integration::Null Expect Coverage: 10.00% Jobs: 1 @@ -155,7 +155,7 @@ RSpec.describe Mutant::Reporter::CLI do it_reports(<<-REPORT) Mutant configuration: - Matcher: # + Matcher: # Integration: Mutant::Integration::Null Expect Coverage: 100.00% Jobs: 1 @@ -181,7 +181,7 @@ RSpec.describe Mutant::Reporter::CLI do it_reports(<<-REPORT) [tput-restore]Mutant configuration: - Matcher: # + Matcher: # Integration: Mutant::Integration::Null Expect Coverage: 100.00% Jobs: 1 From 13ada5e6b900aea85fd2582cd28da49e2e260d07 Mon Sep 17 00:00:00 2001 From: Markus Schirp Date: Tue, 7 Jul 2015 19:41:12 +0000 Subject: [PATCH 2/3] Rename Matcher::Config#subject_ignores to #ignore_expressions --- config/flay.yml | 2 +- lib/mutant/cli.rb | 2 +- lib/mutant/matcher/compiler.rb | 29 ++++++------------- lib/mutant/matcher/config.rb | 4 +-- spec/unit/mutant/cli_spec.rb | 2 +- spec/unit/mutant/matcher/compiler_spec.rb | 4 +-- .../reporter/cli/printer/config_spec.rb | 4 +-- .../reporter/cli/printer/env_progress_spec.rb | 6 ++-- .../reporter/cli/printer/env_result_spec.rb | 2 +- .../reporter/cli/printer/status_spec.rb | 10 +++---- spec/unit/mutant/reporter/cli_spec.rb | 8 ++--- 11 files changed, 31 insertions(+), 42 deletions(-) diff --git a/config/flay.yml b/config/flay.yml index c6cd5ab4..aaff9513 100644 --- a/config/flay.yml +++ b/config/flay.yml @@ -1,3 +1,3 @@ --- threshold: 18 -total_score: 1167 +total_score: 1168 diff --git a/lib/mutant/cli.rb b/lib/mutant/cli.rb index 96cab728..eef3a968 100644 --- a/lib/mutant/cli.rb +++ b/lib/mutant/cli.rb @@ -153,7 +153,7 @@ module Mutant # @api private def add_filter_options(opts) opts.on('--ignore-subject PATTERN', 'Ignore subjects that match PATTERN') do |pattern| - add_matcher(:subject_ignores, config.expression_parser.(pattern)) + add_matcher(:ignore_expressions, config.expression_parser.(pattern)) end end diff --git a/lib/mutant/matcher/compiler.rb b/lib/mutant/matcher/compiler.rb index 60e62821..fa73b9b1 100644 --- a/lib/mutant/matcher/compiler.rb +++ b/lib/mutant/matcher/compiler.rb @@ -13,7 +13,7 @@ module Mutant def result Filter.new( Chain.build(config.match_expressions.map(&method(:matcher))), - predicate + ignored_subjects ) end @@ -34,34 +34,23 @@ module Mutant private - # Predicate constraining matches + # Predicate returning false on ignored subject # # @return [#call] # # @api private - def predicate - if subject_rejector - Morpher::Evaluator::Predicate::Negation.new(subject_rejector) + def ignored_subjects + rejectors = config.ignore_expressions.map(&SubjectPrefix.method(:new)) + + if rejectors.any? + Morpher::Evaluator::Predicate::Boolean::Negation.new( + Morpher::Evaluator::Predicate::Boolean::Or.new(rejectors) + ) else Morpher::Evaluator::Predicate::Tautology.new end end - # Subject rejector predicate - # - # @return [#call] - # if there is a subject rejector - # - # @return [nil] - # otherwise - # - # @api private - def subject_rejector - rejectors = config.subject_ignores.map(&SubjectPrefix.method(:new)) - - Morpher::Evaluator::Predicate::Boolean::Or.new(rejectors) if rejectors.any? - end - # Matcher for expression on env # # @param [Mutant::Expression] expression diff --git a/lib/mutant/matcher/config.rb b/lib/mutant/matcher/config.rb index 9c64c167..642156ba 100644 --- a/lib/mutant/matcher/config.rb +++ b/lib/mutant/matcher/config.rb @@ -1,10 +1,10 @@ module Mutant class Matcher - # Match configuration + # Subject matcher configuration class Config include Adamantium, Anima::Update, Anima.new( :match_expressions, - :subject_ignores + :ignore_expressions ) DEFAULT = new(Hash[anima.attribute_names.map { |name| [name, []] }]) diff --git a/spec/unit/mutant/cli_spec.rb b/spec/unit/mutant/cli_spec.rb index 928910e9..c22eb8c9 100644 --- a/spec/unit/mutant/cli_spec.rb +++ b/spec/unit/mutant/cli_spec.rb @@ -234,7 +234,7 @@ Options: let(:flags) { %w[--ignore-subject Foo::Bar] } let(:expected_matcher_config) do - default_matcher_config.update(subject_ignores: [parse_expression('Foo::Bar')]) + default_matcher_config.update(ignore_expressions: [parse_expression('Foo::Bar')]) end it_should_behave_like 'a cli parser' diff --git a/spec/unit/mutant/matcher/compiler_spec.rb b/spec/unit/mutant/matcher/compiler_spec.rb index 12eef9bf..24ea46d4 100644 --- a/spec/unit/mutant/matcher/compiler_spec.rb +++ b/spec/unit/mutant/matcher/compiler_spec.rb @@ -44,8 +44,8 @@ RSpec.describe Mutant::Matcher::Compiler do context 'and a subject ignore' do let(:attributes) do { - match_expressions: [expression_a], - subject_ignores: [expression_b] + match_expressions: [expression_a], + ignore_expressions: [expression_b] } end diff --git a/spec/unit/mutant/reporter/cli/printer/config_spec.rb b/spec/unit/mutant/reporter/cli/printer/config_spec.rb index b643a116..2432cd22 100644 --- a/spec/unit/mutant/reporter/cli/printer/config_spec.rb +++ b/spec/unit/mutant/reporter/cli/printer/config_spec.rb @@ -7,7 +7,7 @@ RSpec.describe Mutant::Reporter::CLI::Printer::Config do context 'on default config' do it_reports(<<-REPORT) Mutant configuration: - Matcher: # + Matcher: # Integration: Mutant::Integration::Null Expect Coverage: 100.00% Jobs: 1 @@ -21,7 +21,7 @@ RSpec.describe Mutant::Reporter::CLI::Printer::Config do it_reports(<<-REPORT) Mutant configuration: - Matcher: # + Matcher: # Integration: Mutant::Integration::Null Expect Coverage: 10.00% Jobs: 1 diff --git a/spec/unit/mutant/reporter/cli/printer/env_progress_spec.rb b/spec/unit/mutant/reporter/cli/printer/env_progress_spec.rb index db9d4b4c..e28e8317 100644 --- a/spec/unit/mutant/reporter/cli/printer/env_progress_spec.rb +++ b/spec/unit/mutant/reporter/cli/printer/env_progress_spec.rb @@ -11,7 +11,7 @@ RSpec.describe Mutant::Reporter::CLI::Printer::EnvProgress do it_reports <<-'STR' Mutant configuration: - Matcher: # + Matcher: # Integration: Mutant::Integration::Null Expect Coverage: 10.00% Jobs: 1 @@ -32,7 +32,7 @@ RSpec.describe Mutant::Reporter::CLI::Printer::EnvProgress do context 'on full coverage' do it_reports <<-'STR' Mutant configuration: - Matcher: # + Matcher: # Integration: Mutant::Integration::Null Expect Coverage: 10.00% Jobs: 1 @@ -55,7 +55,7 @@ RSpec.describe Mutant::Reporter::CLI::Printer::EnvProgress do it_reports <<-'STR' Mutant configuration: - Matcher: # + Matcher: # Integration: Mutant::Integration::Null Expect Coverage: 10.00% Jobs: 1 diff --git a/spec/unit/mutant/reporter/cli/printer/env_result_spec.rb b/spec/unit/mutant/reporter/cli/printer/env_result_spec.rb index bc22f47e..49aba836 100644 --- a/spec/unit/mutant/reporter/cli/printer/env_result_spec.rb +++ b/spec/unit/mutant/reporter/cli/printer/env_result_spec.rb @@ -15,7 +15,7 @@ RSpec.describe Mutant::Reporter::CLI::Printer::EnvResult do +false ----------------------- Mutant configuration: - Matcher: # + Matcher: # Integration: Mutant::Integration::Null Expect Coverage: 100.00% Jobs: 1 diff --git a/spec/unit/mutant/reporter/cli/printer/status_spec.rb b/spec/unit/mutant/reporter/cli/printer/status_spec.rb index 018d937a..6b37dc7b 100644 --- a/spec/unit/mutant/reporter/cli/printer/status_spec.rb +++ b/spec/unit/mutant/reporter/cli/printer/status_spec.rb @@ -9,7 +9,7 @@ RSpec.describe Mutant::Reporter::CLI::Printer::Status do it_reports <<-REPORT Mutant configuration: - Matcher: # + Matcher: # Integration: Mutant::Integration::Null Expect Coverage: 100.00% Jobs: 1 @@ -32,7 +32,7 @@ RSpec.describe Mutant::Reporter::CLI::Printer::Status do it_reports <<-REPORT Mutant configuration: - Matcher: # + Matcher: # Integration: Mutant::Integration::Null Expect Coverage: 10.00% Jobs: 1 @@ -58,7 +58,7 @@ RSpec.describe Mutant::Reporter::CLI::Printer::Status do it_reports(<<-REPORT) Mutant configuration: - Matcher: # + Matcher: # Integration: Mutant::Integration::Null Expect Coverage: 100.00% Jobs: 1 @@ -85,7 +85,7 @@ RSpec.describe Mutant::Reporter::CLI::Printer::Status do it_reports(<<-REPORT) Mutant configuration: - Matcher: # + Matcher: # Integration: Mutant::Integration::Null Expect Coverage: 100.00% Jobs: 1 @@ -114,7 +114,7 @@ RSpec.describe Mutant::Reporter::CLI::Printer::Status do context 'on success' do it_reports(<<-REPORT) Mutant configuration: - Matcher: # + Matcher: # Integration: Mutant::Integration::Null Expect Coverage: 100.00% Jobs: 1 diff --git a/spec/unit/mutant/reporter/cli_spec.rb b/spec/unit/mutant/reporter/cli_spec.rb index ee81418d..6d25fe58 100644 --- a/spec/unit/mutant/reporter/cli_spec.rb +++ b/spec/unit/mutant/reporter/cli_spec.rb @@ -121,7 +121,7 @@ RSpec.describe Mutant::Reporter::CLI do it_reports(<<-REPORT) Mutant configuration: - Matcher: # + Matcher: # Integration: Mutant::Integration::Null Expect Coverage: 100.00% Jobs: 1 @@ -136,7 +136,7 @@ RSpec.describe Mutant::Reporter::CLI do it_reports(<<-REPORT) Mutant configuration: - Matcher: # + Matcher: # Integration: Mutant::Integration::Null Expect Coverage: 10.00% Jobs: 1 @@ -155,7 +155,7 @@ RSpec.describe Mutant::Reporter::CLI do it_reports(<<-REPORT) Mutant configuration: - Matcher: # + Matcher: # Integration: Mutant::Integration::Null Expect Coverage: 100.00% Jobs: 1 @@ -181,7 +181,7 @@ RSpec.describe Mutant::Reporter::CLI do it_reports(<<-REPORT) [tput-restore]Mutant configuration: - Matcher: # + Matcher: # Integration: Mutant::Integration::Null Expect Coverage: 100.00% Jobs: 1 From 991e561d4966ce42f9f9ec969db73fe9708302eb Mon Sep 17 00:00:00 2001 From: Markus Schirp Date: Tue, 7 Jul 2015 21:17:45 +0000 Subject: [PATCH 3/3] Refactor matcher config inspection * Only print config attributes that are present * This reduces noise for the user because he is not presented with meaningless information on configuration reports * This reduces the noise for the mutant developers as specs will be much more stable on future matcher config additions. Most of the specs that print a matcher config will not have to be altered when a new attribute is added. --- config/flay.yml | 2 +- lib/mutant/matcher/config.rb | 54 +++++++++++++++++++ lib/mutant/reporter/cli/printer/config.rb | 4 +- spec/unit/mutant/matcher/config_spec.rb | 36 +++++++++++++ .../reporter/cli/printer/config_spec.rb | 4 +- .../reporter/cli/printer/env_progress_spec.rb | 6 +-- .../reporter/cli/printer/env_result_spec.rb | 2 +- .../reporter/cli/printer/status_spec.rb | 10 ++-- spec/unit/mutant/reporter/cli_spec.rb | 8 +-- 9 files changed, 107 insertions(+), 19 deletions(-) create mode 100644 spec/unit/mutant/matcher/config_spec.rb diff --git a/config/flay.yml b/config/flay.yml index aaff9513..947b154f 100644 --- a/config/flay.yml +++ b/config/flay.yml @@ -1,3 +1,3 @@ --- threshold: 18 -total_score: 1168 +total_score: 1178 diff --git a/lib/mutant/matcher/config.rb b/lib/mutant/matcher/config.rb index 642156ba..eb4064e3 100644 --- a/lib/mutant/matcher/config.rb +++ b/lib/mutant/matcher/config.rb @@ -7,8 +7,25 @@ module Mutant :ignore_expressions ) + INSPECT_FORMAT = "#<#{self} %s>".freeze + ATTRIBUTE_DELIMITER = ' '.freeze + ATTRIBUTE_FORMAT = '%s: [%s]'.freeze + ENUM_DELIMITER = ','.freeze + EMPTY_ATTRIBUTES = 'empty'.freeze + private_constant(*constants(false)) + DEFAULT = new(Hash[anima.attribute_names.map { |name| [name, []] }]) + # Inspection string + # + # @return [String] + # + # @api private + def inspect + INSPECT_FORMAT % inspect_attributes + end + memoize :inspect + # Add value to configurable collection # # @param [Symbol] attribute @@ -21,6 +38,43 @@ module Mutant update(attribute => public_send(attribute).dup << value) end + private + + # Present attributes + # + # @return [Array] + # + # @api private + def present_attributes + to_h.reject { |_key, value| value.empty? }.keys + end + + # Formatted attributes + # + # @return [String] + # + # @api private + def inspect_attributes + attributes = present_attributes + .map(&method(:format_attribute)) + .join(ATTRIBUTE_DELIMITER) + + attributes.empty? ? EMPTY_ATTRIBUTES : attributes + end + + # Format attribute + # + # @param [Symbol] attribute_name + # + # @return [String] + def format_attribute(attribute_name) + ATTRIBUTE_FORMAT % + [ + attribute_name, + public_send(attribute_name).map(&:syntax).join(ENUM_DELIMITER) + ] + end + end # Config end # Matcher end # Mutant diff --git a/lib/mutant/reporter/cli/printer/config.rb b/lib/mutant/reporter/cli/printer/config.rb index a8d8884b..4688b624 100644 --- a/lib/mutant/reporter/cli/printer/config.rb +++ b/lib/mutant/reporter/cli/printer/config.rb @@ -11,13 +11,11 @@ module Mutant # # @return [undefined] # - # rubocop:disable AbcSize - # # @api private def run info 'Mutant configuration:' info 'Matcher: %s', object.matcher.inspect - info 'Integration: %s', object.integration.name + info 'Integration: %s', object.integration info 'Expect Coverage: %0.2f%%', (object.expected_coverage * 100) info 'Jobs: %d', object.jobs info 'Includes: %s', object.includes diff --git a/spec/unit/mutant/matcher/config_spec.rb b/spec/unit/mutant/matcher/config_spec.rb new file mode 100644 index 00000000..e675b2ee --- /dev/null +++ b/spec/unit/mutant/matcher/config_spec.rb @@ -0,0 +1,36 @@ +RSpec.describe Mutant::Matcher::Config do + describe '#inspect' do + subject { object.inspect } + + context 'on default config' do + let(:object) { described_class::DEFAULT } + + it { should eql('#') } + end + + context 'with one expression' do + let(:object) { described_class::DEFAULT.add(:match_expressions, parse_expression('Foo')) } + it { should eql('#') } + end + + context 'with many expressions' do + let(:object) do + described_class::DEFAULT + .add(:match_expressions, parse_expression('Foo')) + .add(:match_expressions, parse_expression('Bar')) + end + + it { should eql('#') } + end + + context 'with match and ignore expression' do + let(:object) do + described_class::DEFAULT + .add(:match_expressions, parse_expression('Foo')) + .add(:ignore_expressions, parse_expression('Bar')) + end + + it { should eql('#') } + end + end +end diff --git a/spec/unit/mutant/reporter/cli/printer/config_spec.rb b/spec/unit/mutant/reporter/cli/printer/config_spec.rb index 2432cd22..9d891452 100644 --- a/spec/unit/mutant/reporter/cli/printer/config_spec.rb +++ b/spec/unit/mutant/reporter/cli/printer/config_spec.rb @@ -7,7 +7,7 @@ RSpec.describe Mutant::Reporter::CLI::Printer::Config do context 'on default config' do it_reports(<<-REPORT) Mutant configuration: - Matcher: # + Matcher: # Integration: Mutant::Integration::Null Expect Coverage: 100.00% Jobs: 1 @@ -21,7 +21,7 @@ RSpec.describe Mutant::Reporter::CLI::Printer::Config do it_reports(<<-REPORT) Mutant configuration: - Matcher: # + Matcher: # Integration: Mutant::Integration::Null Expect Coverage: 10.00% Jobs: 1 diff --git a/spec/unit/mutant/reporter/cli/printer/env_progress_spec.rb b/spec/unit/mutant/reporter/cli/printer/env_progress_spec.rb index e28e8317..565f3cb7 100644 --- a/spec/unit/mutant/reporter/cli/printer/env_progress_spec.rb +++ b/spec/unit/mutant/reporter/cli/printer/env_progress_spec.rb @@ -11,7 +11,7 @@ RSpec.describe Mutant::Reporter::CLI::Printer::EnvProgress do it_reports <<-'STR' Mutant configuration: - Matcher: # + Matcher: # Integration: Mutant::Integration::Null Expect Coverage: 10.00% Jobs: 1 @@ -32,7 +32,7 @@ RSpec.describe Mutant::Reporter::CLI::Printer::EnvProgress do context 'on full coverage' do it_reports <<-'STR' Mutant configuration: - Matcher: # + Matcher: # Integration: Mutant::Integration::Null Expect Coverage: 10.00% Jobs: 1 @@ -55,7 +55,7 @@ RSpec.describe Mutant::Reporter::CLI::Printer::EnvProgress do it_reports <<-'STR' Mutant configuration: - Matcher: # + Matcher: # Integration: Mutant::Integration::Null Expect Coverage: 10.00% Jobs: 1 diff --git a/spec/unit/mutant/reporter/cli/printer/env_result_spec.rb b/spec/unit/mutant/reporter/cli/printer/env_result_spec.rb index 49aba836..2e22d173 100644 --- a/spec/unit/mutant/reporter/cli/printer/env_result_spec.rb +++ b/spec/unit/mutant/reporter/cli/printer/env_result_spec.rb @@ -15,7 +15,7 @@ RSpec.describe Mutant::Reporter::CLI::Printer::EnvResult do +false ----------------------- Mutant configuration: - Matcher: # + Matcher: # Integration: Mutant::Integration::Null Expect Coverage: 100.00% Jobs: 1 diff --git a/spec/unit/mutant/reporter/cli/printer/status_spec.rb b/spec/unit/mutant/reporter/cli/printer/status_spec.rb index 6b37dc7b..1521f1a7 100644 --- a/spec/unit/mutant/reporter/cli/printer/status_spec.rb +++ b/spec/unit/mutant/reporter/cli/printer/status_spec.rb @@ -9,7 +9,7 @@ RSpec.describe Mutant::Reporter::CLI::Printer::Status do it_reports <<-REPORT Mutant configuration: - Matcher: # + Matcher: # Integration: Mutant::Integration::Null Expect Coverage: 100.00% Jobs: 1 @@ -32,7 +32,7 @@ RSpec.describe Mutant::Reporter::CLI::Printer::Status do it_reports <<-REPORT Mutant configuration: - Matcher: # + Matcher: # Integration: Mutant::Integration::Null Expect Coverage: 10.00% Jobs: 1 @@ -58,7 +58,7 @@ RSpec.describe Mutant::Reporter::CLI::Printer::Status do it_reports(<<-REPORT) Mutant configuration: - Matcher: # + Matcher: # Integration: Mutant::Integration::Null Expect Coverage: 100.00% Jobs: 1 @@ -85,7 +85,7 @@ RSpec.describe Mutant::Reporter::CLI::Printer::Status do it_reports(<<-REPORT) Mutant configuration: - Matcher: # + Matcher: # Integration: Mutant::Integration::Null Expect Coverage: 100.00% Jobs: 1 @@ -114,7 +114,7 @@ RSpec.describe Mutant::Reporter::CLI::Printer::Status do context 'on success' do it_reports(<<-REPORT) Mutant configuration: - Matcher: # + Matcher: # Integration: Mutant::Integration::Null Expect Coverage: 100.00% Jobs: 1 diff --git a/spec/unit/mutant/reporter/cli_spec.rb b/spec/unit/mutant/reporter/cli_spec.rb index 6d25fe58..ac0812cd 100644 --- a/spec/unit/mutant/reporter/cli_spec.rb +++ b/spec/unit/mutant/reporter/cli_spec.rb @@ -121,7 +121,7 @@ RSpec.describe Mutant::Reporter::CLI do it_reports(<<-REPORT) Mutant configuration: - Matcher: # + Matcher: # Integration: Mutant::Integration::Null Expect Coverage: 100.00% Jobs: 1 @@ -136,7 +136,7 @@ RSpec.describe Mutant::Reporter::CLI do it_reports(<<-REPORT) Mutant configuration: - Matcher: # + Matcher: # Integration: Mutant::Integration::Null Expect Coverage: 10.00% Jobs: 1 @@ -155,7 +155,7 @@ RSpec.describe Mutant::Reporter::CLI do it_reports(<<-REPORT) Mutant configuration: - Matcher: # + Matcher: # Integration: Mutant::Integration::Null Expect Coverage: 100.00% Jobs: 1 @@ -181,7 +181,7 @@ RSpec.describe Mutant::Reporter::CLI do it_reports(<<-REPORT) [tput-restore]Mutant configuration: - Matcher: # + Matcher: # Integration: Mutant::Integration::Null Expect Coverage: 100.00% Jobs: 1