Refactor spec on method filter parsing

This commit is contained in:
Markus Schirp 2012-08-09 19:38:36 +02:00
parent 455970ab1b
commit 5e7600e573
2 changed files with 28 additions and 28 deletions

View file

@ -0,0 +1,16 @@
shared_examples_for 'a method filter parse result' do
before do
expected_class.stub(:new => response)
end
let(:response) { mock('Response') }
it { should be(response) }
it 'should initialize method filter with correct arguments' do
expected_class.should_receive(:new).with('Foo', :bar).and_return(response)
subject
end
end

View file

@ -1,40 +1,24 @@
require 'spec_helper'
shared_examples_for 'a method filter parse result' do
it { should be(response) }
it 'should initialize method filter with correct arguments' do
expected_class.should_receive(:new).with('Foo', :bar).and_return(response)
subject
end
end
describe Mutant::Matcher::Method::Classifier, '.run' do
subject { described_class.run(input) }
context 'with format' do
before do
expected_class.stub(:new => response)
end
let(:response) { mock('Response') }
context 'with instance method notation' do
let(:input) { 'Foo#bar' }
let(:expected_class) { Mutant::Matcher::Method::Instance }
context 'in instance method notation' do
let(:input) { 'Foo#bar' }
let(:expected_class) { Mutant::Matcher::Method::Instance }
it_should_behave_like 'a method filter parse result'
end
context 'when input is in singleton method notation' do
let(:input) { 'Foo.bar' }
let(:expected_class) { Mutant::Matcher::Method::Singleton }
it_should_behave_like 'a method filter parse result'
end
it_should_behave_like 'a method filter parse result'
end
context 'when input is not in a valid format' do
context 'with singleton method notation' do
let(:input) { 'Foo.bar' }
let(:expected_class) { Mutant::Matcher::Method::Singleton }
it_should_behave_like 'a method filter parse result'
end
context 'with invalid notation' do
let(:input) { 'Foo' }
it 'should raise error' do