2014-08-10 21:04:05 +00:00
|
|
|
RSpec.describe Mutant::Expression::Namespace::Recursive do
|
2014-05-31 01:02:15 +00:00
|
|
|
|
2015-06-21 14:44:33 +00:00
|
|
|
let(:object) { parse_expression(input) }
|
|
|
|
let(:input) { 'TestApp::Literal*' }
|
|
|
|
let(:env) { Fixtures::TEST_ENV }
|
2014-05-31 01:02:15 +00:00
|
|
|
|
|
|
|
describe '#matcher' do
|
2014-08-10 14:45:45 +00:00
|
|
|
subject { object.matcher(env) }
|
|
|
|
|
|
|
|
it { should eql(Mutant::Matcher::Namespace.new(env, object)) }
|
2014-05-31 01:02:15 +00:00
|
|
|
end
|
|
|
|
|
2015-06-21 14:44:33 +00:00
|
|
|
describe '#syntax' do
|
|
|
|
subject { object.syntax }
|
|
|
|
|
|
|
|
it { should eql(input) }
|
|
|
|
end
|
|
|
|
|
2014-05-31 01:02:15 +00:00
|
|
|
describe '#match_length' do
|
|
|
|
subject { object.match_length(other) }
|
|
|
|
|
|
|
|
context 'when other is an equivalent expression' do
|
2015-06-21 14:44:33 +00:00
|
|
|
let(:other) { parse_expression(object.syntax) }
|
2014-05-31 01:02:15 +00:00
|
|
|
|
|
|
|
it { should be(0) }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when other expression describes a shorter prefix' do
|
2015-06-21 14:44:33 +00:00
|
|
|
let(:other) { parse_expression('TestApp') }
|
2014-05-31 01:02:15 +00:00
|
|
|
|
|
|
|
it { should be(0) }
|
|
|
|
end
|
|
|
|
|
2014-06-06 20:28:01 +00:00
|
|
|
context 'when other expression describes adjacent namespace' do
|
2015-06-21 14:44:33 +00:00
|
|
|
let(:other) { parse_expression('TestApp::LiteralFoo') }
|
2014-06-06 20:28:01 +00:00
|
|
|
|
|
|
|
it { should be(0) }
|
|
|
|
end
|
|
|
|
|
2014-09-17 00:54:38 +00:00
|
|
|
context 'when other expression describes root namespace' do
|
2015-06-21 14:44:33 +00:00
|
|
|
let(:other) { parse_expression('TestApp::Literal') }
|
2014-09-17 00:54:38 +00:00
|
|
|
|
|
|
|
it { should be(16) }
|
|
|
|
end
|
|
|
|
|
2014-05-31 01:02:15 +00:00
|
|
|
context 'when other expression describes a longer prefix' do
|
2014-06-29 21:42:18 +00:00
|
|
|
context 'on constants' do
|
2015-06-21 14:44:33 +00:00
|
|
|
let(:other) { parse_expression('TestApp::Literal::Deep') }
|
2014-05-31 01:02:15 +00:00
|
|
|
|
2014-06-29 21:42:18 +00:00
|
|
|
it { should be(input[0..-2].length) }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'on singleton method' do
|
2015-06-21 14:44:33 +00:00
|
|
|
let(:other) { parse_expression('TestApp::Literal.foo') }
|
2014-06-29 21:42:18 +00:00
|
|
|
|
|
|
|
it { should be(input[0..-2].length) }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'on instance method' do
|
2015-06-21 14:44:33 +00:00
|
|
|
let(:other) { parse_expression('TestApp::Literal#foo') }
|
2014-06-29 21:42:18 +00:00
|
|
|
|
|
|
|
it { should be(input[0..-2].length) }
|
|
|
|
end
|
2014-05-31 01:02:15 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|