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