Sha256: 3b3d7fafdebebbe4c1d87f4133d8bdda002d3a376869cfc5b3752bc05dce6ad0

Contents?: true

Size: 1.21 KB

Versions: 20

Compression:

Stored size: 1.21 KB

Contents

# encoding: utf-8

require 'spec_helper'

describe Mutant::Matcher::Methods::Singleton, '#each' do
  let(:object) { described_class.new(cache, Foo) }
  let(:cache)  { Mutant::Cache.new               }

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

  let(:yields) { [] }

  module Bar
    def method_d
    end

    def method_e
    end
  end

  class Foo
    extend Bar

    def self.method_a
    end

    def self.method_b
    end
    class << self; protected :method_b; end

    def self.method_c
    end
    private_class_method :method_c

  end

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

  let(:subjects) { [subject_a, subject_b, subject_c] }

  before do
    matcher = Mutant::Matcher::Method::Singleton
    matcher.stub(:new)
      .with(cache, Foo, Foo.method(:method_a)).and_return([subject_a])
    matcher.stub(:new)
      .with(cache, Foo, Foo.method(:method_b)).and_return([subject_b])
    matcher.stub(:new)
      .with(cache, Foo, Foo.method(:method_c)).and_return([subject_c])
  end

  it 'should yield expected subjects' do
    subject
    expect(yields).to eql(subjects)
  end

  it_should_behave_like 'an #each method'
end

Version data entries

20 entries across 20 versions & 1 rubygems

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