free_mutant/spec/unit/mutant/expression/method_spec.rb
Markus Schirp d647563055 Refactor expression parsing and representation
* Avoids boot time mutation of REGISTER constant
* Allows to define project specific expression parsing
* Avoids custom (slow) serialization of Expression objects speeding up
  reporter / killer IPC
* Improve specification
* Improve integration API as it now finally references an object the config
* Allow reproduction of syntax from Expression#syntax
* Allow instantiation of Expresssion objects without generating the
  syntax, much nicer for most specs & internal code, avoids generating
  a string to parse it into an expression
* Fix LSP violation in Mutant::Matcher namespace
2015-06-21 14:44:33 +00:00

44 lines
1.1 KiB
Ruby

RSpec.describe Mutant::Expression::Method do
let(:object) { parse_expression(input) }
let(:env) { Fixtures::TEST_ENV }
let(:instance_method) { 'TestApp::Literal#string' }
let(:singleton_method) { 'TestApp::Literal.string' }
describe '#match_length' do
let(:input) { instance_method }
subject { object.match_length(other) }
context 'when other is an equivalent expression' do
let(:other) { parse_expression(object.syntax) }
it { should be(object.syntax.length) }
end
context 'when other is an unequivalent expression' do
let(:other) { parse_expression('Foo*') }
it { should be(0) }
end
end
describe '#matcher' do
subject { object.matcher(env) }
context 'with an instance method' do
let(:input) { instance_method }
it 'returns correct matcher' do
expect(subject.map(&:expression)).to eql([object])
end
end
context 'with a singleton method' do
let(:input) { singleton_method }
it 'returns correct matcher' do
expect(subject.map(&:expression)).to eql([object])
end
end
end
end