Sha256: 9266a4d4dcc947335fa5dae1f14ab168efd8365434e2aeef31cd2afb928caca7

Contents?: true

Size: 1.02 KB

Versions: 2

Compression:

Stored size: 1.02 KB

Contents

# encoding: utf-8

require 'spec_helper'

describe Chain, '#each' do
  subject { object.each { |tuple| yields << processor } }

  let(:object)     { described_class.new(processors) }
  let(:processors) { [ processor ] }
  let(:processor)  { Spec::FAKE_PROCESSOR }
  let(:yields)     { [] }

  before do
    object.should be_instance_of(described_class)
  end

  it_should_behave_like 'an #each method'

  it 'yields only processors' do
    subject
    yields.each { |processor| processor.should be_instance_of(Spec::Processor) }
  end

  it 'yields only processors with the expected handler' do
    expect { subject }.to change { yields.dup }.
      from([]).
      to([ processor ])
  end
end

describe Chain do
  subject { described_class.new(processors) }

  let(:processors) { [ processor ] }
  let(:processor)  { Spec::FAKE_PROCESSOR }

  before do
    subject.should be_instance_of(described_class)
  end

  it { should be_kind_of(Enumerable) }

  it 'case matches Enumerable' do
    (Enumerable === subject).should be(true)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
substation-0.0.10.beta2 spec/unit/substation/chain/each_spec.rb
substation-0.0.8 spec/unit/substation/chain/each_spec.rb