Sha256: b99fd76a0dbe6d37cc5b4fc99669410ebad0ac977e95f86d389696abb83f751a

Contents?: true

Size: 1.02 KB

Versions: 12

Compression:

Stored size: 1.02 KB

Contents

require 'spec_helper'

describe Mutant::Matcher::Chain, '#each' do
  subject { object.each { |entry| yields << entry } }

  let(:object) { described_class.new(matchers) }

  let(:matchers) { [matcher_a, matcher_b] }

  let(:matcher_a) { mock('Matcher A') }
  let(:matcher_b) { mock('Matcher B') }

  let(:subject_a) { mock('Subject A') }
  let(:subject_b) { mock('Subject B') }

  before do
    matcher_a.stub(:each).and_yield(subject_a).and_return(matcher_a)
    matcher_b.stub(:each).and_yield(subject_b).and_return(matcher_b)
  end

  # it_should_behave_like 'an #each method'
  context 'with no block' do
    subject { object.each }

    it { should be_instance_of(to_enum.class) }

    if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'rbx'
      pending 'FIX RBX rspec? BUG HERE'
    else
      it 'yields the expected values' do
        subject.to_a.should eql(object.to_a)
      end
    end
  end

  let(:yields) { [] }

  it 'should yield subjects' do
    expect { subject }.to change { yields }.from([]).to([subject_a, subject_b])
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
mutant-0.3.0.beta13 spec/unit/mutant/matcher/chain/each_spec.rb
mutant-0.3.0.beta12 spec/unit/mutant/matcher/chain/each_spec.rb
mutant-0.3.0.beta11 spec/unit/mutant/matcher/chain/each_spec.rb
mutant-0.3.0.beta10 spec/unit/mutant/matcher/chain/each_spec.rb
mutant-0.3.0.beta9 spec/unit/mutant/matcher/chain/each_spec.rb
mutant-0.3.0.beta8 spec/unit/mutant/matcher/chain/each_spec.rb
mutant-0.3.0.beta7 spec/unit/mutant/matcher/chain/each_spec.rb
mutant-0.3.0.beta6 spec/unit/mutant/matcher/chain/each_spec.rb
mutant-0.3.0.beta5 spec/unit/mutant/matcher/chain/each_spec.rb
mutant-0.3.0.beta4 spec/unit/mutant/matcher/chain/each_spec.rb
mutant-0.3.0.beta3 spec/unit/mutant/matcher/chain/each_spec.rb
mutant-0.3.0.beta2 spec/unit/mutant/matcher/chain/each_spec.rb