From 5e7600e573ebfe8b116e47d857f805e9e9a32142 Mon Sep 17 00:00:00 2001 From: Markus Schirp Date: Thu, 9 Aug 2012 19:38:36 +0200 Subject: [PATCH] Refactor spec on method filter parsing --- spec/shared/method_filter_parse_behavior.rb | 16 ++++++++ .../classifier/class_methods/run_spec.rb | 40 ++++++------------- 2 files changed, 28 insertions(+), 28 deletions(-) create mode 100644 spec/shared/method_filter_parse_behavior.rb diff --git a/spec/shared/method_filter_parse_behavior.rb b/spec/shared/method_filter_parse_behavior.rb new file mode 100644 index 00000000..f88a8848 --- /dev/null +++ b/spec/shared/method_filter_parse_behavior.rb @@ -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 + + diff --git a/spec/unit/mutant/matcher/method/classifier/class_methods/run_spec.rb b/spec/unit/mutant/matcher/method/classifier/class_methods/run_spec.rb index 1e4ef602..9eccdbd1 100644 --- a/spec/unit/mutant/matcher/method/classifier/class_methods/run_spec.rb +++ b/spec/unit/mutant/matcher/method/classifier/class_methods/run_spec.rb @@ -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