2014-08-10 21:04:05 +00:00
|
|
|
RSpec.describe Mutant::Expression::Methods do
|
2015-06-21 14:44:33 +00:00
|
|
|
let(:env) { Fixtures::TEST_ENV }
|
|
|
|
let(:object) { described_class.new(attributes) }
|
2014-06-28 22:35:19 +00:00
|
|
|
|
|
|
|
describe '#match_length' do
|
2015-06-21 14:44:33 +00:00
|
|
|
let(:attributes) { { scope_name: 'TestApp::Literal', scope_symbol: '#' } }
|
2014-06-28 22:35:19 +00:00
|
|
|
|
|
|
|
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-06-28 22:35:19 +00:00
|
|
|
|
|
|
|
it { should be(object.syntax.length) }
|
|
|
|
end
|
|
|
|
|
2014-10-08 14:56:46 +00:00
|
|
|
context 'when other is matched' do
|
2015-06-21 14:44:33 +00:00
|
|
|
let(:other) { parse_expression('TestApp::Literal#foo') }
|
2014-10-08 14:56:46 +00:00
|
|
|
|
|
|
|
it { should be(object.syntax.length) }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when other is an not matched expression' do
|
2015-06-21 14:44:33 +00:00
|
|
|
let(:other) { parse_expression('Foo*') }
|
2014-06-28 22:35:19 +00:00
|
|
|
|
|
|
|
it { should be(0) }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-06-21 14:44:33 +00:00
|
|
|
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
|
|
|
|
|
2014-06-28 22:35:19 +00:00
|
|
|
describe '#matcher' do
|
2014-08-10 14:45:45 +00:00
|
|
|
subject { object.matcher(env) }
|
2014-06-28 22:35:19 +00:00
|
|
|
|
|
|
|
context 'with an instance method' do
|
2015-06-21 14:44:33 +00:00
|
|
|
let(:attributes) { { scope_name: 'TestApp::Literal', scope_symbol: '#' } }
|
2014-06-28 22:35:19 +00:00
|
|
|
|
2014-08-10 14:45:45 +00:00
|
|
|
it { should eql(Mutant::Matcher::Methods::Instance.new(env, TestApp::Literal)) }
|
2014-06-28 22:35:19 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'with a singleton method' do
|
2015-06-21 14:44:33 +00:00
|
|
|
let(:attributes) { { scope_name: 'TestApp::Literal', scope_symbol: '.' } }
|
2014-06-28 22:35:19 +00:00
|
|
|
|
2014-08-10 14:45:45 +00:00
|
|
|
it { should eql(Mutant::Matcher::Methods::Singleton.new(env, TestApp::Literal)) }
|
2014-06-28 22:35:19 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|