Sha256: 3ed6d458a80048ee45ec8422a2a1fb2a69ee449416f9ab4bb77594f0c52a678b

Contents?: true

Size: 1.18 KB

Versions: 1

Compression:

Stored size: 1.18 KB

Contents

require 'spec_helper'

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

  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(env, Foo, Foo.method(:method_a)).and_return([subject_a])
    matcher.stub(:new)
      .with(env, Foo, Foo.method(:method_b)).and_return([subject_b])
    matcher.stub(:new)
      .with(env, 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

1 entries across 1 versions & 1 rubygems

Version Path
mutant-0.5.24 spec/unit/mutant/matcher/methods/singleton_spec.rb