free_mutant/spec/unit/mutant/ast/regexp/transformer_spec.rb
John Backus 770f34eee5
Reintroduce Regexp mutations
- Reverts commit 8c0c656aec
- Fixes #595
- Adds support for `\h` and `\H`
2016-07-25 12:21:50 -07:00

19 lines
648 B
Ruby

RSpec.describe Mutant::AST::Regexp::Transformer do
before do
stub_const("#{described_class}::REGISTRY", Mutant::Registry.new)
end
it 'registers types to a given class' do
klass = Class.new(described_class) { register(:regexp_bos_anchor) }
expect(described_class.lookup(:regexp_bos_anchor)).to be(klass)
end
it 'rejects duplicate registrations' do
Class.new(described_class) { register(:regexp_bos_anchor) }
expect { Class.new(described_class) { register(:regexp_bos_anchor) } }
.to raise_error(Mutant::Registry::RegistryError)
.with_message('Duplicate type registration: :regexp_bos_anchor')
end
end