2014-08-10 17:04:05 -04:00
|
|
|
RSpec.shared_examples_for 'a method matcher' do
|
2013-04-27 12:07:04 -04:00
|
|
|
let(:node) { mutation_subject.node }
|
|
|
|
let(:context) { mutation_subject.context }
|
2015-10-28 16:13:00 -04:00
|
|
|
let(:mutation_subject) { subject.first }
|
2013-04-27 12:07:04 -04:00
|
|
|
|
2015-10-28 16:13:00 -04:00
|
|
|
it 'returns one subject' do
|
|
|
|
expect(subject.size).to be(1)
|
2013-04-27 12:07:04 -04:00
|
|
|
end
|
|
|
|
|
2015-10-28 16:13:00 -04:00
|
|
|
it 'has expected 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
|
|
|
|
|
2015-11-18 17:49:20 -05:00
|
|
|
it 'has expected line number' do
|
2014-09-16 15:30:45 -04:00
|
|
|
expect(node.location.expression.line).to eql(method_line)
|
2013-04-27 12:07:04 -04:00
|
|
|
end
|
|
|
|
|
2015-10-28 16:13:00 -04:00
|
|
|
it 'has expected 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
|
|
|
|
|
2015-10-28 16:13:00 -04:00
|
|
|
it 'has expected 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
|
|
|
|
|
2015-10-28 16:13:00 -04:00
|
|
|
it 'has source path in context' do
|
2015-07-28 14:50:54 -04:00
|
|
|
expect(context.source_path).to eql(source_path)
|
|
|
|
end
|
|
|
|
|
2015-10-28 16:13:00 -04:00
|
|
|
it 'has 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
|
2015-10-28 16:13:00 -04:00
|
|
|
|
|
|
|
RSpec.shared_examples_for 'skipped candidate' do
|
2015-11-15 20:07:31 -05:00
|
|
|
before do
|
|
|
|
expected_warnings.each do |warning|
|
|
|
|
expect(env).to receive(:warn).with(warning).and_return(env)
|
|
|
|
end
|
2015-10-28 16:13:00 -04:00
|
|
|
end
|
|
|
|
|
2015-11-15 20:07:31 -05:00
|
|
|
it 'does not emit matcher' do
|
|
|
|
expect(subject).to eql([])
|
2015-10-28 16:13:00 -04:00
|
|
|
end
|
|
|
|
end
|