free_mutant/spec/shared/method_matcher_behavior.rb
Markus Schirp 6df5811a87 Use RSpec as receiver for rspec DSL methods
* I dislike the global infection RSpec does. This commit is a first step
  to get a rid of it.
* Also remove the need for `require 'spec_helper` in each spec file with
  adjusting `.rspec`.
2014-08-10 21:04:07 +00:00

34 lines
844 B
Ruby

RSpec.shared_examples_for 'a method matcher' do
before { subject }
let(:node) { mutation_subject.node }
let(:context) { mutation_subject.context }
let(:mutation_subject) { yields.first }
it 'should return one subject' do
expect(yields.size).to be(1)
end
it_should_behave_like 'an #each method'
it 'should have correct method name' do
expect(name).to eql(method_name)
end
it 'should have correct line number' do
expect(node.location.expression.line - base).to eql(method_line)
end
it 'should have correct arity' do
expect(arguments.children.length).to eql(method_arity)
end
it 'should have correct scope in context' do
expect(context.scope).to eql(scope)
end
it 'should have the correct node type' do
expect(node.type).to be(type)
end
end