2014-08-10 17:04:05 -04:00
|
|
|
RSpec.describe Mutant::Expression::Methods do
|
2014-06-28 18:35:19 -04:00
|
|
|
|
|
|
|
let(:object) { described_class.parse(input) }
|
2014-08-10 10:45:45 -04:00
|
|
|
let(:env) { Fixtures::TEST_ENV }
|
2014-06-28 18:35:19 -04:00
|
|
|
let(:instance_methods) { 'TestApp::Literal#' }
|
|
|
|
let(:singleton_methods) { 'TestApp::Literal.' }
|
|
|
|
|
|
|
|
describe '#match_length' do
|
|
|
|
let(:input) { instance_methods }
|
|
|
|
|
|
|
|
subject { object.match_length(other) }
|
|
|
|
|
|
|
|
context 'when other is an equivalent expression' do
|
|
|
|
let(:other) { described_class.parse(object.syntax) }
|
|
|
|
|
|
|
|
it { should be(object.syntax.length) }
|
|
|
|
end
|
|
|
|
|
2014-10-08 10:56:46 -04:00
|
|
|
context 'when other is matched' do
|
|
|
|
let(:other) { described_class.parse('TestApp::Literal#foo') }
|
|
|
|
|
|
|
|
it { should be(object.syntax.length) }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when other is an not matched expression' do
|
2014-06-28 18:35:19 -04:00
|
|
|
let(:other) { described_class.parse('Foo*') }
|
|
|
|
|
|
|
|
it { should be(0) }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#matcher' do
|
2014-08-10 10:45:45 -04:00
|
|
|
subject { object.matcher(env) }
|
2014-06-28 18:35:19 -04:00
|
|
|
|
|
|
|
context 'with an instance method' do
|
|
|
|
let(:input) { instance_methods }
|
|
|
|
|
2014-08-10 10:45:45 -04:00
|
|
|
it { should eql(Mutant::Matcher::Methods::Instance.new(env, TestApp::Literal)) }
|
2014-06-28 18:35:19 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'with a singleton method' do
|
|
|
|
let(:input) { singleton_methods }
|
|
|
|
|
2014-08-10 10:45:45 -04:00
|
|
|
it { should eql(Mutant::Matcher::Methods::Singleton.new(env, TestApp::Literal)) }
|
2014-06-28 18:35:19 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|