Sha256: 4271c3834f059d8e0e7d7ecfc9348396d1c672ea24ce111e669f99664fa7cbe8

Contents?: true

Size: 1.31 KB

Versions: 18

Compression:

Stored size: 1.31 KB

Contents

# encoding: utf-8

require 'spec_helper'

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

  let(:yields) { []                                           }
  let(:object) { described_class.new(cache, TestApp::Literal) }

  let(:cache) { Mutant::Cache.new }

  let(:singleton_a) { double('SingletonA', name: 'TestApp::Literal') }
  let(:singleton_b) { double('SingletonB', name: 'TestApp::Foo')     }
  let(:subject_a)   { double('SubjectA')                             }
  let(:subject_b)   { double('SubjectB')                             }

  before do
    Mutant::Matcher::Methods::Singleton.stub(:each)
      .with(cache, singleton_a)
      .and_yield(subject_a)
    Mutant::Matcher::Methods::Instance.stub(:each)
      .with(cache, singleton_a)
      .and_yield(subject_b)
    ObjectSpace.stub(each_object: [singleton_a, singleton_b])
  end

  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
        expect(subject.to_a).to eql(object.to_a)
      end
    end
  end

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

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
mutant-0.5.17 spec/unit/mutant/matcher/namespace_spec.rb
mutant-0.5.16 spec/unit/mutant/matcher/namespace_spec.rb
mutant-0.5.15 spec/unit/mutant/matcher/namespace_spec.rb
mutant-0.5.14 spec/unit/mutant/matcher/namespace_spec.rb
mutant-0.5.13 spec/unit/mutant/matcher/namespace_spec.rb
mutant-0.5.12 spec/unit/mutant/matcher/namespace_spec.rb
mutant-0.5.11 spec/unit/mutant/matcher/namespace_spec.rb
mutant-0.5.10 spec/unit/mutant/matcher/namespace_spec.rb
mutant-0.5.9 spec/unit/mutant/matcher/namespace_spec.rb
mutant-0.5.8 spec/unit/mutant/matcher/namespace_spec.rb
mutant-0.5.7 spec/unit/mutant/matcher/namespace_spec.rb
mutant-0.5.6 spec/unit/mutant/matcher/namespace_spec.rb
mutant-0.5.5 spec/unit/mutant/matcher/namespace_spec.rb
mutant-0.5.4 spec/unit/mutant/matcher/namespace_spec.rb
mutant-0.5.3 spec/unit/mutant/matcher/namespace_spec.rb
mutant-0.5.2 spec/unit/mutant/matcher/namespace_spec.rb
mutant-0.5.1 spec/unit/mutant/matcher/namespace_spec.rb
mutant-0.5.0 spec/unit/mutant/matcher/namespace_spec.rb