2014-08-10 21:04:05 +00:00
|
|
|
RSpec.shared_examples_for 'a method matcher' do
|
2013-04-27 18:07:04 +02:00
|
|
|
let(:node) { mutation_subject.node }
|
|
|
|
let(:context) { mutation_subject.context }
|
2015-10-28 20:13:00 +00:00
|
|
|
let(:mutation_subject) { subject.first }
|
2013-04-27 18:07:04 +02:00
|
|
|
|
2015-10-28 20:13:00 +00:00
|
|
|
it 'returns one subject' do
|
|
|
|
expect(subject.size).to be(1)
|
2013-04-27 18:07:04 +02:00
|
|
|
end
|
|
|
|
|
2015-10-28 20:13:00 +00:00
|
|
|
it 'has expected method name' do
|
2014-01-19 21:42:21 +01:00
|
|
|
expect(name).to eql(method_name)
|
2013-04-27 18:07:04 +02:00
|
|
|
end
|
|
|
|
|
2015-11-18 14:49:20 -08:00
|
|
|
it 'has expected line number' do
|
2014-09-16 19:30:45 +00:00
|
|
|
expect(node.location.expression.line).to eql(method_line)
|
2013-04-27 18:07:04 +02:00
|
|
|
end
|
|
|
|
|
2015-10-28 20:13:00 +00:00
|
|
|
it 'has expected arity' do
|
2014-01-19 21:42:21 +01:00
|
|
|
expect(arguments.children.length).to eql(method_arity)
|
2013-04-27 18:07:04 +02:00
|
|
|
end
|
|
|
|
|
2015-10-28 20:13:00 +00:00
|
|
|
it 'has expected scope in context' do
|
2014-01-19 21:42:21 +01:00
|
|
|
expect(context.scope).to eql(scope)
|
2013-04-27 18:07:04 +02:00
|
|
|
end
|
|
|
|
|
2015-10-28 20:13:00 +00:00
|
|
|
it 'has source path in context' do
|
2015-07-28 11:50:54 -07:00
|
|
|
expect(context.source_path).to eql(source_path)
|
|
|
|
end
|
|
|
|
|
2015-10-28 20:13:00 +00:00
|
|
|
it 'has the correct node type' do
|
2014-01-19 21:42:21 +01:00
|
|
|
expect(node.type).to be(type)
|
2013-04-27 18:07:04 +02:00
|
|
|
end
|
|
|
|
end
|
2015-10-28 20:13:00 +00:00
|
|
|
|
|
|
|
RSpec.shared_examples_for 'skipped candidate' do
|
2015-11-16 01:07:31 +00:00
|
|
|
before do
|
|
|
|
expected_warnings.each do |warning|
|
|
|
|
expect(env).to receive(:warn).with(warning).and_return(env)
|
|
|
|
end
|
2015-10-28 20:13:00 +00:00
|
|
|
end
|
|
|
|
|
2015-11-16 01:07:31 +00:00
|
|
|
it 'does not emit matcher' do
|
|
|
|
expect(subject).to eql([])
|
2015-10-28 20:13:00 +00:00
|
|
|
end
|
|
|
|
end
|