free_mutant/test_app/spec/shared/method_match_behavior.rb
Dan Kubb 7293386c26 Add magic encoding header to all ruby files
* rubocop still warns about this on ruby 1.9.3, so it was fixed so
  it produces less output on travis.
2013-07-28 16:03:06 -07:00

40 lines
1.1 KiB
Ruby

# encoding: utf-8
shared_examples_for 'a method match' do
subject { Mutant::Matcher::Method.parse(pattern).to_a }
let(:values) { defaults.merge(expectation) }
let(:method_name) { values.fetch(:method_name) }
let(:method_line) { values.fetch(:method_line) }
let(:method_arity) { values.fetch(:method_arity) }
let(:scope) { values.fetch(:scope) }
let(:node_class) { values.fetch(:node_class) }
let(:node) { mutation_subject.node }
let(:context) { mutation_subject.context }
let(:mutation_subject) { subject.first }
it 'should return one subject' do
subject.size.should be(1)
end
it 'should have correct method name' do
name(node).should eql(method_name)
end
it 'should have correct line number' do
node.line.should eql(method_line)
end
it 'should have correct arity' do
arguments(node).required.length.should eql(method_arity)
end
it 'should have correct scope in context' do
context.send(:scope).should eql(scope)
end
it 'should have the correct node class' do
node.should be_a(node_class)
end
end