Sha256: 190273dcdc206a53c78452a808cfa2600e584b0e2d7e2ec1eea9cec5ac9b84b8

Contents?: true

Size: 1.13 KB

Versions: 5

Compression:

Stored size: 1.13 KB

Contents

RSpec.describe Mutant::Registry do
  let(:lookup)  { object.lookup(type)           }
  let(:object)  { described_class.new           }
  let(:mutator) { class_double(Mutant::Mutator) }

  def register_mutator
    object.register(type, mutator)
  end

  context 'on registered type' do
    subject { register_mutator }

    let(:type) { :true }

    before { subject }

    it 'returns registered mutator' do
      expect(lookup).to be(mutator)
    end

    it_behaves_like 'a command method'

    context 'when registered twice' do
      it 'fails upon registration' do
        expect { register_mutator }.to raise_error(described_class::RegistryError, 'Duplicate type registration: :true')
      end
    end
  end

  context 'on unknown type' do
    let(:type) { :unknown }

    it 'raises error' do
      expect { lookup }.to raise_error(described_class::RegistryError, 'No entry for: :unknown')
    end
  end

  context 'when registering an invalid node type' do
    let(:type) { :invalid }

    it 'raises error' do
      expect { register_mutator }.to raise_error(described_class::RegistryError, 'Invalid type registration: :invalid')
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
mutant-0.8.16 spec/unit/mutant/registry_spec.rb
mutant-0.8.15 spec/unit/mutant/registry_spec.rb
mutant-0.8.14 spec/unit/mutant/registry_spec.rb
mutant-0.8.13 spec/unit/mutant/registry_spec.rb
mutant-0.8.12 spec/unit/mutant/registry_spec.rb