d647563055
* 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
47 lines
969 B
Ruby
47 lines
969 B
Ruby
RSpec.describe Mutant::Expression do
|
|
let(:object) { described_class }
|
|
|
|
let(:parser) { Mutant::Config::DEFAULT.expression_parser }
|
|
|
|
describe '#prefix?' do
|
|
let(:object) { parser.call('Foo*') }
|
|
|
|
subject { object.prefix?(other) }
|
|
|
|
context 'when object is a prefix of other' do
|
|
let(:other) { parser.call('Foo::Bar') }
|
|
|
|
it { should be(true) }
|
|
end
|
|
|
|
context 'when other is not a prefix of other' do
|
|
let(:other) { parser.call('Bar') }
|
|
|
|
it { should be(false) }
|
|
end
|
|
end
|
|
|
|
describe '.try_parse' do
|
|
let(:object) do
|
|
Class.new(described_class) do
|
|
include Anima.new(:foo)
|
|
|
|
const_set(:REGEXP, /(?<foo>foo)/)
|
|
end
|
|
end
|
|
|
|
subject { object.try_parse(input) }
|
|
|
|
context 'on succesful parse' do
|
|
let(:input) { 'foo' }
|
|
|
|
it { should eql(object.new(foo: 'foo')) }
|
|
end
|
|
|
|
context 'on unsuccesful parse' do
|
|
let(:input) { 'bar' }
|
|
|
|
it { should be(nil) }
|
|
end
|
|
end
|
|
end
|