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-07-28 17:52:05 -04:00
|
|
|
regexp = expected_class::REGEXP
|
|
|
|
should eql(expected_class.new(cache, regexp.match(input)))
|
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
|
|
|
|
|
|
|
it_should_behave_like this_spec
|
|
|
|
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
|
|
|
|
|
|
|
it_should_behave_like this_spec
|
|
|
|
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
|
|
|
|
|
|
|
it_should_behave_like this_spec
|
|
|
|
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
|