2013-04-27 12:07:04 -04:00
|
|
|
shared_examples_for 'a method matcher' do
|
2013-06-27 16:18:07 -04:00
|
|
|
|
|
|
|
before { subject }
|
2013-04-27 12:07:04 -04:00
|
|
|
|
|
|
|
let(:node) { mutation_subject.node }
|
|
|
|
let(:context) { mutation_subject.context }
|
2013-06-25 03:37:45 -04:00
|
|
|
let(:mutation_subject) { yields.first }
|
2013-04-27 12:07:04 -04:00
|
|
|
|
|
|
|
it 'should return one subject' do
|
2014-01-19 15:42:21 -05:00
|
|
|
expect(yields.size).to be(1)
|
2013-04-27 12:07:04 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it_should_behave_like 'an #each method'
|
|
|
|
|
|
|
|
it 'should have correct method name' do
|
2014-01-19 15:42:21 -05:00
|
|
|
expect(name).to eql(method_name)
|
2013-04-27 12:07:04 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'should have correct line number' do
|
2014-01-19 15:42:21 -05:00
|
|
|
expect(node.location.expression.line - base).to eql(method_line)
|
2013-04-27 12:07:04 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'should have correct arity' do
|
2014-01-19 15:42:21 -05:00
|
|
|
expect(arguments.children.length).to eql(method_arity)
|
2013-04-27 12:07:04 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'should have correct scope in context' do
|
2014-01-19 15:42:21 -05:00
|
|
|
expect(context.scope).to eql(scope)
|
2013-04-27 12:07:04 -04:00
|
|
|
end
|
|
|
|
|
2013-06-04 13:22:33 -04:00
|
|
|
it 'should have the correct node type' do
|
2014-01-19 15:42:21 -05:00
|
|
|
expect(node.type).to be(type)
|
2013-04-27 12:07:04 -04:00
|
|
|
end
|
|
|
|
end
|