Simplify method matching integration spec
Should be converted to a unit spec soon
This commit is contained in:
parent
4b47d666d7
commit
a0933916ca
2 changed files with 52 additions and 49 deletions
|
@ -7,6 +7,48 @@ describe Mutant, 'method matching' do
|
|||
end
|
||||
end
|
||||
|
||||
this_example = 'Mutant method matching'
|
||||
|
||||
shared_examples_for this_example do
|
||||
subject { p Mutant::Matcher::Method.parse(pattern).to_a }
|
||||
|
||||
let(:values) { defaults.merge(expectation) }
|
||||
|
||||
let(:method_name) { values.fetch(:method_name) }
|
||||
let(:method_line) { values.fetch(:method_line) }
|
||||
let(:method_arity) { values.fetch(:method_arity) }
|
||||
let(:scope) { values.fetch(:scope) }
|
||||
let(:node_class) { values.fetch(:node_class) }
|
||||
|
||||
let(:node) { mutation_subject.node }
|
||||
let(:context) { mutation_subject.context }
|
||||
let(:mutation_subject) { subject.first }
|
||||
|
||||
it 'should return one subject' do
|
||||
subject.size.should be(1)
|
||||
end
|
||||
|
||||
it 'should have correct method name' do
|
||||
name(node).should eql(method_name)
|
||||
end
|
||||
|
||||
it 'should have correct line number' do
|
||||
node.line.should eql(method_line)
|
||||
end
|
||||
|
||||
it 'should have correct arity' do
|
||||
arguments(node).required.length.should eql(method_arity)
|
||||
end
|
||||
|
||||
it 'should have correct scope in context' do
|
||||
context.send(:scope).should eql(scope)
|
||||
end
|
||||
|
||||
it 'should have the correct node class' do
|
||||
node.should be_a(node_class)
|
||||
end
|
||||
end
|
||||
|
||||
before do
|
||||
#eval(body, TOPLEVEL_BINDING, __FILE__, 0)
|
||||
eval(body)
|
||||
|
@ -47,7 +89,7 @@ describe Mutant, 'method matching' do
|
|||
{ :method_line => 2 }
|
||||
end
|
||||
|
||||
it_should_behave_like 'a method match'
|
||||
it_should_behave_like this_example
|
||||
end
|
||||
|
||||
context 'when method is defined multiple times' do
|
||||
|
@ -68,7 +110,7 @@ describe Mutant, 'method matching' do
|
|||
}
|
||||
end
|
||||
|
||||
it_should_behave_like 'a method match'
|
||||
it_should_behave_like this_example
|
||||
end
|
||||
|
||||
context 'on the same line' do
|
||||
|
@ -87,7 +129,7 @@ describe Mutant, 'method matching' do
|
|||
}
|
||||
end
|
||||
|
||||
it_should_behave_like 'a method match'
|
||||
it_should_behave_like this_example
|
||||
end
|
||||
|
||||
context 'on the same line with differend scope' do
|
||||
|
@ -106,7 +148,7 @@ describe Mutant, 'method matching' do
|
|||
}
|
||||
end
|
||||
|
||||
it_should_behave_like 'a method match'
|
||||
it_should_behave_like this_example
|
||||
end
|
||||
|
||||
context 'when nested' do
|
||||
|
@ -131,7 +173,7 @@ describe Mutant, 'method matching' do
|
|||
}
|
||||
end
|
||||
|
||||
it_should_behave_like 'a method match'
|
||||
it_should_behave_like this_example
|
||||
end
|
||||
|
||||
context 'in module' do
|
||||
|
@ -153,7 +195,7 @@ describe Mutant, 'method matching' do
|
|||
}
|
||||
end
|
||||
|
||||
it_should_behave_like 'a method match'
|
||||
it_should_behave_like this_example
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -194,7 +236,7 @@ describe Mutant, 'method matching' do
|
|||
}
|
||||
end
|
||||
|
||||
it_should_behave_like 'a method match'
|
||||
it_should_behave_like this_example
|
||||
end
|
||||
|
||||
context 'when defined on constant' do
|
||||
|
@ -216,7 +258,7 @@ describe Mutant, 'method matching' do
|
|||
}
|
||||
end
|
||||
|
||||
it_should_behave_like 'a method match'
|
||||
it_should_behave_like this_example
|
||||
end
|
||||
|
||||
context 'outside namespace' do
|
||||
|
@ -235,7 +277,7 @@ describe Mutant, 'method matching' do
|
|||
}
|
||||
end
|
||||
|
||||
it_should_behave_like 'a method match'
|
||||
it_should_behave_like this_example
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -262,7 +304,7 @@ describe Mutant, 'method matching' do
|
|||
}
|
||||
end
|
||||
|
||||
it_should_behave_like 'a method match'
|
||||
it_should_behave_like this_example
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,39 +0,0 @@
|
|||
shared_examples_for 'a method match' do
|
||||
subject { Mutant::Matcher::Method.parse(pattern).to_a }
|
||||
|
||||
let(:values) { defaults.merge(expectation) }
|
||||
|
||||
let(:method_name) { values.fetch(:method_name) }
|
||||
let(:method_line) { values.fetch(:method_line) }
|
||||
let(:method_arity) { values.fetch(:method_arity) }
|
||||
let(:scope) { values.fetch(:scope) }
|
||||
let(:node_class) { values.fetch(:node_class) }
|
||||
|
||||
let(:node) { mutation_subject.node }
|
||||
let(:context) { mutation_subject.context }
|
||||
let(:mutation_subject) { subject.first }
|
||||
|
||||
it 'should return one subject' do
|
||||
subject.size.should be(1)
|
||||
end
|
||||
|
||||
it 'should have correct method name' do
|
||||
name(node).should eql(method_name)
|
||||
end
|
||||
|
||||
it 'should have correct line number' do
|
||||
node.line.should eql(method_line)
|
||||
end
|
||||
|
||||
it 'should have correct arity' do
|
||||
arguments(node).required.length.should eql(method_arity)
|
||||
end
|
||||
|
||||
it 'should have correct scope in context' do
|
||||
context.send(:scope).should eql(scope)
|
||||
end
|
||||
|
||||
it 'should have the correct node class' do
|
||||
node.should be_a(node_class)
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue