Sha256: a3eb936aa7ce4e4f1a7dcb1905e49c030b67a06ae9d1efd2c888065774551665

Contents?: true

Size: 1.48 KB

Versions: 4

Compression:

Stored size: 1.48 KB

Contents

require 'spec_helper'

describe Mutant::Matcher::Namespace do
  let(:object) { described_class.new(cache, 'TestApp::Literal') }
  let(:yields) { []                                             }

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

  subject { object.each { |item| yields << item } }

  describe '#each' do

    let(:singleton_a) { double('SingletonA', name: 'TestApp::Literal')      }
    let(:singleton_b) { double('SingletonB', name: 'TestApp::Foo')          }
    let(:singleton_c) { double('SingletonC', name: 'TestApp::LiteralOther') }
    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, singleton_c])
    end

    context 'with no block' do
      subject { object.each }

      it { should be_instance_of(to_enum.class) }

      if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'rbx'
        skip '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
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mutant-0.5.23 spec/unit/mutant/matcher/namespace_spec.rb
mutant-0.5.22 spec/unit/mutant/matcher/namespace_spec.rb
mutant-0.5.21 spec/unit/mutant/matcher/namespace_spec.rb
mutant-0.5.20 spec/unit/mutant/matcher/namespace_spec.rb