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
60 lines
1.7 KiB
Ruby
60 lines
1.7 KiB
Ruby
RSpec.describe Mutant::Expression::Methods do
|
|
let(:env) { Fixtures::TEST_ENV }
|
|
let(:object) { described_class.new(attributes) }
|
|
|
|
describe '#match_length' do
|
|
let(:attributes) { { scope_name: 'TestApp::Literal', scope_symbol: '#' } }
|
|
|
|
subject { object.match_length(other) }
|
|
|
|
context 'when other is an equivalent expression' do
|
|
let(:other) { parse_expression(object.syntax) }
|
|
|
|
it { should be(object.syntax.length) }
|
|
end
|
|
|
|
context 'when other is matched' do
|
|
let(:other) { parse_expression('TestApp::Literal#foo') }
|
|
|
|
it { should be(object.syntax.length) }
|
|
end
|
|
|
|
context 'when other is an not matched expression' do
|
|
let(:other) { parse_expression('Foo*') }
|
|
|
|
it { should be(0) }
|
|
end
|
|
end
|
|
|
|
describe '#syntax' do
|
|
subject { object.syntax }
|
|
|
|
context 'with an instance method' do
|
|
let(:attributes) { { scope_name: 'TestApp::Literal', scope_symbol: '#' } }
|
|
|
|
it { should eql('TestApp::Literal#') }
|
|
end
|
|
|
|
context 'with a singleton method' do
|
|
let(:attributes) { { scope_name: 'TestApp::Literal', scope_symbol: '.' } }
|
|
|
|
it { should eql('TestApp::Literal.') }
|
|
end
|
|
end
|
|
|
|
describe '#matcher' do
|
|
subject { object.matcher(env) }
|
|
|
|
context 'with an instance method' do
|
|
let(:attributes) { { scope_name: 'TestApp::Literal', scope_symbol: '#' } }
|
|
|
|
it { should eql(Mutant::Matcher::Methods::Instance.new(env, TestApp::Literal)) }
|
|
end
|
|
|
|
context 'with a singleton method' do
|
|
let(:attributes) { { scope_name: 'TestApp::Literal', scope_symbol: '.' } }
|
|
|
|
it { should eql(Mutant::Matcher::Methods::Singleton.new(env, TestApp::Literal)) }
|
|
end
|
|
end
|
|
end
|