free_mutant/spec/shared/method_matcher_behavior.rb

46 lines
1.1 KiB
Ruby
Raw Normal View History

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