Sha256: 2184d147ad42eb87e6d4082ab2f6dd2ca01e67e4fb11f7241a19679850513943

Contents?: true

Size: 898 Bytes

Versions: 1

Compression:

Stored size: 898 Bytes

Contents

require 'spec_helper'

describe Chain, '.build' do

  context "when a block is given" do
    subject { described_class.build(dsl, other, &block) }

    let(:dsl)       { Chain::DSL::Builder.call(registry) }
    let(:registry)  { { :test => Spec::Processor } }
    let(:other)     { [ processor ] }
    let(:processor) { Spec::FAKE_PROCESSOR }
    let(:block)     { lambda { |_| test(Spec::FAKE_HANDLER) } }

    let(:expected)  { Chain.new(dsl.processors(other, &block)) }

    it { should eql(expected) }
  end

  context "when no block is given" do
    subject { described_class.build(dsl, other) }

    let(:dsl)       { Chain::DSL::Builder.call(registry) }
    let(:registry)  { { :test => Spec::Processor } }
    let(:other)     { [ processor ] }
    let(:processor) { Spec::FAKE_PROCESSOR }

    let(:expected)  { Chain.new(dsl.processors(other)) }

    it { should eql(expected) }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
substation-0.0.8 spec/unit/substation/chain/class_methods/build_spec.rb