Sha256: c5e52a8a044654ba4a579aafce23aaec9209bd26dfce8b98e62c2573761b81cc

Contents?: true

Size: 1.38 KB

Versions: 3

Compression:

Stored size: 1.38 KB

Contents

require 'spec_helper'

describe AssemblyLine::Registry do
  let(:registry) { AssemblyLine::Registry.dup }
  let(:code_block) { lambda {} }

  after do
    registry.clear
  end

  describe "#add" do
    it "adds a new constructor to the list of registered assembly lines" do
      registry.add(:party, code_block)
      registry.list.should include(:party)
    end
  end

  describe "#list" do
    it "lists the registered assembly lines by name" do
      registry.add(:one, code_block)
      registry.add(:two, code_block)
      registry.list.should =~ [:one, :two]
    end
  end

  describe "#clear" do
    it "clears the registry" do
      registry.add(:one, code_block)
      registry.add(:two, code_block)
      expect do
        registry.clear
      end.to change { registry.list.size }.from(2).to(0)
    end
  end

  describe "#locate" do
    context "when AssemblyLine has been registered" do
      before do
        registry.add(:party, code_block)
      end

      it "returns the registered Constructor" do
        registry.locate(:party).should be_instance_of(AssemblyLine::Constructor)
      end
    end

    context "when AssemblyLine has not been registered" do
      it "raises an ArgumentError" do
        expect do
          registry.locate(:does_not_exist)
        end.to raise_error(ArgumentError, "AssemblyLine could not find definition for: ':does_not_exist'")
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
assembly_line-0.2.1 spec/assembly_line/registry_spec.rb
assembly_line-0.2.0 spec/assembly_line/registry_spec.rb
assembly_line-0.1.0 spec/assembly_line/registry_spec.rb