2013-07-28 19:03:06 -04:00
|
|
|
# encoding: utf-8
|
|
|
|
|
2013-01-21 16:56:52 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2013-09-11 16:10:46 -04:00
|
|
|
describe Mutant::CLI::Classifier, '.run' do
|
|
|
|
subject { described_class.run(cache, input) }
|
2013-06-27 16:18:07 -04:00
|
|
|
|
2013-07-14 13:01:30 -04:00
|
|
|
let(:cache) { double('Cache') }
|
2013-01-21 16:56:52 -05:00
|
|
|
|
|
|
|
this_spec = 'Mutant::CLI::Classifier.build'
|
|
|
|
|
|
|
|
shared_examples_for this_spec do
|
|
|
|
it 'shoud return expected instance' do
|
2013-09-13 16:28:04 -04:00
|
|
|
should eql(expected_matcher)
|
2013-01-21 16:56:52 -05:00
|
|
|
end
|
2013-06-27 16:18:07 -04:00
|
|
|
|
2013-07-14 13:01:30 -04:00
|
|
|
let(:expected_class) { Mutant::CLI::Classifier::Method }
|
2013-01-21 16:56:52 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'with explicit toplevel scope' do
|
|
|
|
|
2013-07-14 13:01:30 -04:00
|
|
|
let(:input) { '::TestApp::Literal#string' }
|
2013-01-21 16:56:52 -05:00
|
|
|
|
2013-09-13 16:28:04 -04:00
|
|
|
let(:expected_matcher) do
|
|
|
|
Mutant::Matcher::Method::Instance.new(cache, TestApp::Literal, TestApp::Literal.instance_method(:string))
|
|
|
|
end
|
|
|
|
|
|
|
|
include_examples this_spec
|
2013-01-21 16:56:52 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'with instance method notation' do
|
|
|
|
|
2013-07-14 13:01:30 -04:00
|
|
|
let(:input) { 'TestApp::Literal#string' }
|
2013-01-21 16:56:52 -05:00
|
|
|
|
2013-09-13 16:28:04 -04:00
|
|
|
let(:expected_matcher) do
|
|
|
|
Mutant::Matcher::Method::Instance.new(cache, TestApp::Literal, TestApp::Literal.instance_method(:string))
|
|
|
|
end
|
|
|
|
|
|
|
|
include_examples this_spec
|
2013-01-21 16:56:52 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'with singleton method notation' do
|
2013-07-14 13:01:30 -04:00
|
|
|
let(:input) { 'TestApp::Literal.string' }
|
2013-01-21 16:56:52 -05:00
|
|
|
|
2013-09-13 16:28:04 -04:00
|
|
|
let(:expected_matcher) do
|
|
|
|
Mutant::Matcher::Method::Singleton.new(cache, TestApp::Literal, TestApp::Literal.method(:string))
|
|
|
|
end
|
|
|
|
|
|
|
|
include_examples this_spec
|
2013-01-21 16:56:52 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'with invalid notation' do
|
|
|
|
let(:input) { '::' }
|
|
|
|
|
|
|
|
it 'should return nil' do
|
2013-09-08 18:05:49 -04:00
|
|
|
expect { subject }.to raise_error(Mutant::CLI::Error, "No matcher handles: #{input.inspect}")
|
2013-01-21 16:56:52 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|