2014-08-10 17:04:05 -04:00
|
|
|
RSpec.describe Mutant::Expression::Method do
|
2015-06-21 10:44:33 -04:00
|
|
|
let(:object) { parse_expression(input) }
|
|
|
|
let(:env) { Fixtures::TEST_ENV }
|
|
|
|
let(:instance_method) { 'TestApp::Literal#string' }
|
|
|
|
let(:singleton_method) { 'TestApp::Literal.string' }
|
2014-05-30 21:02:15 -04:00
|
|
|
|
|
|
|
describe '#match_length' do
|
|
|
|
let(:input) { instance_method }
|
|
|
|
|
|
|
|
subject { object.match_length(other) }
|
|
|
|
|
|
|
|
context 'when other is an equivalent expression' do
|
2015-06-21 10:44:33 -04:00
|
|
|
let(:other) { parse_expression(object.syntax) }
|
2014-05-30 21:02:15 -04:00
|
|
|
|
|
|
|
it { should be(object.syntax.length) }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when other is an unequivalent expression' do
|
2015-06-21 10:44:33 -04:00
|
|
|
let(:other) { parse_expression('Foo*') }
|
2014-05-30 21:02:15 -04:00
|
|
|
|
|
|
|
it { should be(0) }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#matcher' do
|
2015-10-28 16:13:00 -04:00
|
|
|
subject { object.matcher }
|
2014-05-30 21:02:15 -04:00
|
|
|
|
|
|
|
context 'with an instance method' do
|
|
|
|
let(:input) { instance_method }
|
|
|
|
|
2014-06-02 08:57:14 -04:00
|
|
|
it 'returns correct matcher' do
|
2015-10-28 16:13:00 -04:00
|
|
|
expect(subject.call(env).map(&:expression)).to eql([object])
|
2014-06-02 08:57:14 -04:00
|
|
|
end
|
2014-05-30 21:02:15 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'with a singleton method' do
|
|
|
|
let(:input) { singleton_method }
|
|
|
|
|
2015-06-21 10:44:33 -04:00
|
|
|
it 'returns correct matcher' do
|
2015-10-28 16:13:00 -04:00
|
|
|
expect(subject.call(env).map(&:expression)).to eql([object])
|
2015-06-21 10:44:33 -04:00
|
|
|
end
|
2014-05-30 21:02:15 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|