2014-12-22 15:42:21 +00:00
|
|
|
RSpec.describe Mutant::Selector::Expression do
|
|
|
|
describe '#call' do
|
2014-12-22 17:54:18 +00:00
|
|
|
let(:object) { described_class.new(integration) }
|
2014-12-22 15:42:21 +00:00
|
|
|
|
|
|
|
let(:subject_class) do
|
2015-06-21 14:44:33 +00:00
|
|
|
parse = method(:parse_expression)
|
|
|
|
|
2014-12-22 15:42:21 +00:00
|
|
|
Class.new(Mutant::Subject) do
|
2015-06-21 14:44:33 +00:00
|
|
|
define_method(:expression) do
|
|
|
|
parse.('SubjectA')
|
2014-12-22 15:42:21 +00:00
|
|
|
end
|
|
|
|
|
2015-06-21 14:44:33 +00:00
|
|
|
define_method(:match_expressions) do
|
|
|
|
[expression] << parse.('SubjectB')
|
2014-12-22 15:42:21 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-11-15 20:16:42 +00:00
|
|
|
let(:mutation_subject) { subject_class.new(context, node) }
|
|
|
|
let(:context) { instance_double(Mutant::Context) }
|
|
|
|
let(:node) { instance_double(Parser::AST::Node) }
|
|
|
|
let(:config) { Mutant::Config::DEFAULT.with(integration: integration) }
|
|
|
|
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')) }
|
2014-12-22 15:42:21 +00:00
|
|
|
|
|
|
|
subject { object.call(mutation_subject) }
|
|
|
|
|
|
|
|
context 'without available tests' do
|
|
|
|
let(:all_tests) { [] }
|
|
|
|
|
|
|
|
it { should eql([]) }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'without qualifying tests' do
|
|
|
|
let(:all_tests) { [test_c] }
|
|
|
|
|
|
|
|
it { should eql([]) }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with qualifying tests for first match expression' do
|
|
|
|
let(:all_tests) { [test_a] }
|
|
|
|
|
|
|
|
it { should eql([test_a]) }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with qualifying tests for second match expression' do
|
|
|
|
let(:all_tests) { [test_b] }
|
|
|
|
|
|
|
|
it { should eql([test_b]) }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with qualifying tests for the first and second match expression' do
|
|
|
|
let(:all_tests) { [test_a, test_b] }
|
|
|
|
|
|
|
|
it { should eql([test_a]) }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|