Sha256: 21c96b425b51f9355b6fa66d727eb94cad7c92a35bea7650c6712855fb601fae

Contents?: true

Size: 797 Bytes

Versions: 11

Compression:

Stored size: 797 Bytes

Contents

RSpec.describe Mutant::Matcher::Filter do
  let(:object) { described_class.new(matcher, predicate) }

  describe '#each' do
    let(:yields) { [] }
    subject { object.each { |entry| yields << entry } }

    let(:matcher)   { [subject_a, subject_b] }
    let(:predicate) { ->(subject) { subject.eql?(subject_a) } }

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

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

      it { should be_instance_of(to_enum.class) }

      it 'yields the expected values' do
        expect(subject.to_a).to eql(object.to_a)
      end
    end

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

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
mutant-0.7.4 spec/unit/mutant/matcher/filter_spec.rb
mutant-0.7.3 spec/unit/mutant/matcher/filter_spec.rb
mutant-0.7.2 spec/unit/mutant/matcher/filter_spec.rb
mutant-0.7.1 spec/unit/mutant/matcher/filter_spec.rb
mutant-0.6.7 spec/unit/mutant/matcher/filter_spec.rb
mutant-0.6.6 spec/unit/mutant/matcher/filter_spec.rb
mutant-0.6.5 spec/unit/mutant/matcher/filter_spec.rb
mutant-0.6.4 spec/unit/mutant/matcher/filter_spec.rb
mutant-0.6.3 spec/unit/mutant/matcher/filter_spec.rb
mutant-0.6.2 spec/unit/mutant/matcher/filter_spec.rb
mutant-0.6.0 spec/unit/mutant/matcher/filter_spec.rb