Sha256: ed314136ad465462c93a5a1ee60de49f74c38a271c490f6eb9f56711dbdf1153

Contents?: true

Size: 1.33 KB

Versions: 54

Compression:

Stored size: 1.33 KB

Contents

require 'spec_helper'


describe Krikri::Registry do

  before(:all) do
    described_class.register(:mock, Class.new)
  end

  describe '#register' do
    it 'creates a registry entry for an item not already registered' do
      # see before block above
      expect(described_class.keys).to include :mock
    end
    it 'errors when registering a class that is already registered' do
      expect do
        described_class.register(:mock, Class.new)
      end.to raise_error 'mock is already registered.'
    end
    it 'does not error when force-registered' do
      expect do
        described_class.register!(:mock, Class.new)
      end.not_to raise_error
    end
  end

  describe '#registered?' do
    it 'knows an item has been registered' do
      expect(described_class.registered?(:mock)).to be true
    end
  end

  describe '#get' do
    it 'gets a registered item' do
      expect(described_class.get(:mock)).to be_a Class
    end
    it 'errors when unregistered' do
        expect { described_class.get('undefined') }
        .to raise_error 'undefined is not registered.'
    end
  end

  describe '#keys' do
    it 'returns an array of registered keys' do
      expect(described_class.keys).to be_a Array
    end
    it 'returns an array that contains a registered key' do
      expect(described_class.keys).to include :mock
    end
  end

end

Version data entries

54 entries across 54 versions & 1 rubygems

Version Path
krikri-0.15.2 spec/lib/krikri/registry_spec.rb
krikri-0.15.1 spec/lib/krikri/registry_spec.rb
krikri-0.15.0 spec/lib/krikri/registry_spec.rb
krikri-0.14.0 spec/lib/krikri/registry_spec.rb
krikri-0.13.2 spec/lib/krikri/registry_spec.rb
krikri-0.13.1 spec/lib/krikri/registry_spec.rb
krikri-0.13.0 spec/lib/krikri/registry_spec.rb
krikri-0.12.4 spec/lib/krikri/registry_spec.rb
krikri-0.12.3 spec/lib/krikri/registry_spec.rb
krikri-0.12.1 spec/lib/krikri/registry_spec.rb
krikri-0.12.0 spec/lib/krikri/registry_spec.rb
krikri-0.12.0.pre.rc.1 spec/lib/krikri/registry_spec.rb
krikri-0.11.2 spec/lib/krikri/registry_spec.rb
krikri-0.11.1 spec/lib/krikri/registry_spec.rb
krikri-0.11.0 spec/lib/krikri/registry_spec.rb
krikri-0.10.1 spec/lib/krikri/registry_spec.rb
krikri-0.10.0 spec/lib/krikri/registry_spec.rb
krikri-0.9.0 spec/lib/krikri/registry_spec.rb
krikri-0.8.9 spec/lib/krikri/registry_spec.rb
krikri-0.8.8 spec/lib/krikri/registry_spec.rb