Sha256: 37e30c47e24ad1fa0bde73dc868666f4701a5e0148fbc001dd28bb347d55b752

Contents?: true

Size: 1.28 KB

Versions: 8

Compression:

Stored size: 1.28 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) { 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
        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

8 entries across 8 versions & 1 rubygems

Version Path
mutant-0.3.0.beta21 spec/unit/mutant/matcher/namespace/each_spec.rb
mutant-0.3.0.beta20 spec/unit/mutant/matcher/namespace/each_spec.rb
mutant-0.3.0.beta19 spec/unit/mutant/matcher/namespace/each_spec.rb
mutant-0.3.0.beta18 spec/unit/mutant/matcher/namespace/each_spec.rb
mutant-0.3.0.beta17 spec/unit/mutant/matcher/namespace/each_spec.rb
mutant-0.3.0.beta16 spec/unit/mutant/matcher/namespace/each_spec.rb
mutant-0.3.0.beta15 spec/unit/mutant/matcher/namespace/each_spec.rb
mutant-0.3.0.beta14 spec/unit/mutant/matcher/namespace/each_spec.rb