d647563055
* Avoids boot time mutation of REGISTER constant * Allows to define project specific expression parsing * Avoids custom (slow) serialization of Expression objects speeding up reporter / killer IPC * Improve specification * Improve integration API as it now finally references an object the config * Allow reproduction of syntax from Expression#syntax * Allow instantiation of Expresssion objects without generating the syntax, much nicer for most specs & internal code, avoids generating a string to parse it into an expression * Fix LSP violation in Mutant::Matcher namespace
92 lines
1.9 KiB
Ruby
92 lines
1.9 KiB
Ruby
RSpec.describe Mutant::Subject do
|
|
let(:class_under_test) do
|
|
Class.new(described_class) do
|
|
def expression
|
|
Mutant::Expression::Namespace::Exact.new(scope_name: 'SubjectA')
|
|
end
|
|
|
|
def match_expressions
|
|
[
|
|
expression,
|
|
Mutant::Expression::Namespace::Exact.new(scope_name: 'SubjectB')
|
|
]
|
|
end
|
|
end
|
|
end
|
|
|
|
let(:object) { class_under_test.new(context, node) }
|
|
|
|
let(:node) do
|
|
Parser::CurrentRuby.parse(<<-RUBY)
|
|
def foo
|
|
end
|
|
RUBY
|
|
end
|
|
|
|
let(:location) do
|
|
double('Location', expression: expression)
|
|
end
|
|
|
|
let(:expression) do
|
|
double('Expression', line: 'source_line')
|
|
end
|
|
|
|
let(:context) do
|
|
double(
|
|
'Context',
|
|
source_path: 'source_path',
|
|
source_line: 'source_line'
|
|
)
|
|
end
|
|
|
|
describe '#identification' do
|
|
subject { object.identification }
|
|
|
|
it { should eql('SubjectA:source_path:1') }
|
|
end
|
|
|
|
describe '#source_line' do
|
|
subject { object.source_line }
|
|
|
|
it { should be(1) }
|
|
end
|
|
|
|
describe '#source_lines' do
|
|
subject { object.source_lines }
|
|
|
|
it { should eql(1..2) }
|
|
end
|
|
|
|
describe '#prepare' do
|
|
subject { object.prepare }
|
|
|
|
it_should_behave_like 'a command method'
|
|
end
|
|
|
|
describe '#node' do
|
|
subject { object.node }
|
|
|
|
it { should be(node) }
|
|
|
|
it_should_behave_like 'an idempotent method'
|
|
end
|
|
|
|
describe '#mutations' do
|
|
subject { object.mutations }
|
|
|
|
before do
|
|
expect(Mutant::Mutator).to receive(:each).with(node).and_yield(mutation_a).and_yield(mutation_b)
|
|
end
|
|
|
|
let(:mutation_a) { double('Mutation A') }
|
|
let(:mutation_b) { double('Mutation B') }
|
|
|
|
it 'generates neutral and evil mutations' do
|
|
should eql([
|
|
Mutant::Mutation::Neutral.new(object, node),
|
|
Mutant::Mutation::Evil.new(object, mutation_a),
|
|
Mutant::Mutation::Evil.new(object, mutation_b)
|
|
])
|
|
end
|
|
end
|
|
end
|