Add support for rspec mutant expression metadata
This commit is contained in:
parent
2624e2eb87
commit
41101e4abe
3 changed files with 38 additions and 8 deletions
|
@ -1,3 +1,3 @@
|
||||||
---
|
---
|
||||||
threshold: 18
|
threshold: 18
|
||||||
total_score: 1240
|
total_score: 1241
|
||||||
|
|
|
@ -111,19 +111,33 @@ module Mutant
|
||||||
# @api private
|
# @api private
|
||||||
#
|
#
|
||||||
def parse_example(example, index)
|
def parse_example(example, index)
|
||||||
metadata = example.metadata
|
metadata = example.metadata
|
||||||
location = metadata.fetch(:location)
|
location = metadata.fetch(:location)
|
||||||
full_description = metadata.fetch(:full_description)
|
full_description = metadata.fetch(:full_description)
|
||||||
|
|
||||||
match = EXPRESSION_CANDIDATE.match(full_description)
|
|
||||||
expression = Expression.try_parse(match.captures.first) || ALL
|
|
||||||
|
|
||||||
Test.new(
|
Test.new(
|
||||||
id: "rspec:#{index}:#{location}/#{full_description}",
|
id: "rspec:#{index}:#{location}/#{full_description}",
|
||||||
expression: expression
|
expression: parse_expression(metadata)
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Parse metadata into expression
|
||||||
|
#
|
||||||
|
# @param [RSpec::Core::Example::Medatada] metadata
|
||||||
|
#
|
||||||
|
# @return [Expression]
|
||||||
|
#
|
||||||
|
# @api private
|
||||||
|
#
|
||||||
|
def parse_expression(metadata)
|
||||||
|
if metadata.key?(:mutant_expression)
|
||||||
|
Expression.parse(metadata.fetch(:mutant_expression))
|
||||||
|
else
|
||||||
|
match = EXPRESSION_CANDIDATE.match(metadata.fetch(:full_description))
|
||||||
|
Expression.try_parse(match.captures.first) || ALL
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Return all examples
|
# Return all examples
|
||||||
#
|
#
|
||||||
# @return [Array<String, RSpec::Core::Example]
|
# @return [Array<String, RSpec::Core::Example]
|
||||||
|
|
|
@ -47,12 +47,24 @@ RSpec.describe Mutant::Integration::Rspec do
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
let(:example_e) do
|
||||||
|
double(
|
||||||
|
'Example E',
|
||||||
|
metadata: {
|
||||||
|
location: 'example-e-location',
|
||||||
|
full_description: 'Example::E',
|
||||||
|
mutant_expression: 'Foo'
|
||||||
|
}
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
let(:examples) do
|
let(:examples) do
|
||||||
[
|
[
|
||||||
example_a,
|
example_a,
|
||||||
example_b,
|
example_b,
|
||||||
example_c,
|
example_c,
|
||||||
example_d
|
example_d,
|
||||||
|
example_e
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -94,6 +106,10 @@ RSpec.describe Mutant::Integration::Rspec do
|
||||||
Mutant::Test.new(
|
Mutant::Test.new(
|
||||||
id: "rspec:2:example-d-location/Example::D\nblah",
|
id: "rspec:2:example-d-location/Example::D\nblah",
|
||||||
expression: Mutant::Expression.parse('*')
|
expression: Mutant::Expression.parse('*')
|
||||||
|
),
|
||||||
|
Mutant::Test.new(
|
||||||
|
id: 'rspec:3:example-e-location/Example::E',
|
||||||
|
expression: Mutant::Expression.parse('Foo')
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue