Sha256: 4cff6a8da38cc291b422f46d157d0563113ee37c990f04aefc13185d099268c4

Contents?: true

Size: 1.11 KB

Versions: 7

Compression:

Stored size: 1.11 KB

Contents

require 'pr/field_registry'

describe 'field registry' do
  let(:registry) { PR::FieldRegistry }

  #values
  let(:klass) { double "form klass" }

  describe '.[]' do
    it 'returns a field registry for the klass' do
      expect(registry[klass]).to be_a registry
      expect(registry[klass].for).to eq klass
    end
    it 'returns the same field registry multiple times' do
      expect(registry[klass]).to eq registry[klass]
    end
  end

  describe '#initialize' do
    it 'stores the klass for retrieval' do
      expect(registry.new(klass).for).to eq klass
    end
  end

  describe 'registeration' do
    let(:name)  { double "field name" }
    let(:field) { double "field" }

    let(:specific_register) { registry.new klass }

    it 'stores the field on the register' do
      specific_register.register name, field
    end

    it 'allows retreival of that field' do
      specific_register.register name, field
      expect(specific_register.fetch name).to eq field
    end

    it 'enumerates fields' do
      specific_register.register name, field
      expect(specific_register.fields).to eq [name]
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
pr-1.0.0 spec/unit/pr/field_registry_spec.rb
pr-0.0.7 spec/unit/pr/field_registry_spec.rb
pr-0.0.6 spec/unit/pr/field_registry_spec.rb
pr-0.0.5 spec/unit/pr/field_registry_spec.rb
pr-0.0.4 spec/unit/pr/field_registry_spec.rb
pr-0.0.3 spec/unit/pr/field_registry_spec.rb
pr-0.0.2 spec/unit/pr/field_registry_spec.rb