diff --git a/lib/mutant/integration/minitest.rb b/lib/mutant/integration/minitest.rb index bdd0076db..e957d41c0 100644 --- a/lib/mutant/integration/minitest.rb +++ b/lib/mutant/integration/minitest.rb @@ -124,8 +124,8 @@ def all_tests_index def construct_test(test_case) Test.new( - id: test_case.identification, - expression: config.expression_parser.apply(test_case.expression_syntax).from_right + id: test_case.identification, + expressions: [config.expression_parser.apply(test_case.expression_syntax).from_right] ) end diff --git a/lib/mutant/integration/rspec.rb b/lib/mutant/integration/rspec.rb index d7377daf9..098c6c017 100644 --- a/lib/mutant/integration/rspec.rb +++ b/lib/mutant/integration/rspec.rb @@ -97,8 +97,8 @@ def parse_example(example, index) } Test.new( - expression: parse_metadata(metadata), - id: id + expressions: [parse_metadata(metadata)], + id: id ) end diff --git a/lib/mutant/selector/expression.rb b/lib/mutant/selector/expression.rb index 8392e3a30..f30295613 100644 --- a/lib/mutant/selector/expression.rb +++ b/lib/mutant/selector/expression.rb @@ -14,7 +14,9 @@ class Expression < self def call(subject) subject.match_expressions.each do |match_expression| subject_tests = integration.all_tests.select do |test| - match_expression.prefix?(test.expression) + test.expressions.any? do |test_expression| + match_expression.prefix?(test_expression) + end end return subject_tests if subject_tests.any? end diff --git a/lib/mutant/test.rb b/lib/mutant/test.rb index 39626392a..d045d22db 100644 --- a/lib/mutant/test.rb +++ b/lib/mutant/test.rb @@ -4,7 +4,7 @@ module Mutant # Abstract base class for test that might kill a mutation class Test include Adamantium::Flat, Anima.new( - :expression, + :expressions, :id ) diff --git a/spec/unit/mutant/integration/rspec_spec.rb b/spec/unit/mutant/integration/rspec_spec.rb index 70e4ad2c3..1e6e59943 100644 --- a/spec/unit/mutant/integration/rspec_spec.rb +++ b/spec/unit/mutant/integration/rspec_spec.rb @@ -98,20 +98,20 @@ let(:all_tests) do [ Mutant::Test.new( - id: 'rspec:0:example-a-location/example-a-full-description', - expression: parse_expression('*') + id: 'rspec:0:example-a-location/example-a-full-description', + expressions: [parse_expression('*')] ), Mutant::Test.new( - id: 'rspec:1:example-c-location/Example::C blah', - expression: parse_expression('Example::C') + id: 'rspec:1:example-c-location/Example::C blah', + expressions: [parse_expression('Example::C')] ), Mutant::Test.new( - id: "rspec:2:example-d-location/Example::D\nblah", - expression: parse_expression('*') + id: "rspec:2:example-d-location/Example::D\nblah", + expressions: [parse_expression('*')] ), Mutant::Test.new( - id: 'rspec:3:example-e-location/Example::E', - expression: parse_expression('Foo') + id: 'rspec:3:example-e-location/Example::E', + expressions: [parse_expression('Foo')] ) ] end diff --git a/spec/unit/mutant/selector/expression_spec.rb b/spec/unit/mutant/selector/expression_spec.rb index ce4fb4992..8d2f74e7f 100644 --- a/spec/unit/mutant/selector/expression_spec.rb +++ b/spec/unit/mutant/selector/expression_spec.rb @@ -4,14 +4,34 @@ describe '#call' do let(:object) { described_class.new(integration) } - let(:mutation_subject) { subject_class.new(context: context, node: node, warnings: warnings) } - let(:context) { instance_double(Mutant::Context) } - let(:node) { instance_double(Parser::AST::Node) } - let(:integration) { instance_double(Mutant::Integration, all_tests: all_tests) } - let(:test_a) { instance_double(Mutant::Test, expression: parse_expression('SubjectA')) } - let(:test_b) { instance_double(Mutant::Test, expression: parse_expression('SubjectB')) } - let(:test_c) { instance_double(Mutant::Test, expression: parse_expression('SubjectC')) } - let(:warnings) { instance_double(Mutant::Warnings) } + let(:context) { instance_double(Mutant::Context) } + let(:node) { instance_double(Parser::AST::Node) } + let(:test_a) { mk_test('SubjectA') } + let(:test_b) { mk_test('SubjectB') } + let(:test_c) { mk_test('SubjectC') } + let(:warnings) { instance_double(Mutant::Warnings) } + + let(:integration) do + instance_double( + Mutant::Integration, + all_tests: all_tests + ) + end + + let(:mutation_subject) do + subject_class.new( + context: context, + node: node, + warnings: warnings + ) + end + + def mk_test(expression) + instance_double( + Mutant::Test, + expressions: [parse_expression(expression)] + ) + end let(:subject_class) do parse = method(:parse_expression)