Sha256: b7a682404581f324c073684716e0abd2f0d5e6813c2be86f538ff6222bce77d7

Contents?: true

Size: 1.34 KB

Versions: 3

Compression:

Stored size: 1.34 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/spec_helper')

describe AssemblyLine do
  context "API" do
    subject { AssemblyLine }
    it { should respond_to(:define) }
    it { should respond_to(:assemble) }

  end

  describe ".define" do
    it "adds the AssemblyLine to the Registry" do
      definition = lambda {}
      AssemblyLine::Registry.should_receive(:add).with(:user_with_address, definition)
      AssemblyLine.define(:user_with_address, &definition)
    end
  end

  describe ".assemble" do
    let(:rspec_context) { mock('rspec context') }

    context "cannot locate the AssemblyLine" do
      it "raises an error" do
        expect do
          AssemblyLine.assemble(:does_not_exist, rspec_context)
        end.to raise_error(ArgumentError)
      end
    end

    context "AssemblyLine exists" do
      it "assembles the AssemblyLine" do
        constructor = mock('constructor')
        constructor.should_receive(:assemble).with(rspec_context, options)
        AssemblyLine::Registry.stub(:locate => constructor)
        AssemblyLine.assemble(:party, rspec_context)
      end
    end
  end

  describe "#Assemble" do
    it "delegates to AssemblyLine.assemble" do
      klass = Class.new do
        extend AssemblyLine
      end
      AssemblyLine.should_receive(:assemble).with(:party, klass, {})
      klass.Assemble(:party)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

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