Sha256: 166bc47b73b774a126e4e234ee82a99fd316520abd0e380578cbac799114e527

Contents?: true

Size: 1.26 KB

Versions: 9

Compression:

Stored size: 1.26 KB

Contents

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) { mock('SingletonA', :name => 'TestApp::Literal') }
  let(:singleton_b) { mock('SingletonB', :name => 'TestApp::Foo')     }
  let(:subject_a)   { mock('SubjectA')                                }
  let(:subject_b)   { mock('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
        subject.to_a.should 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

9 entries across 9 versions & 1 rubygems

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