Sha256: df23681297d082360494c3839e1b904ae0601c59c8d9a3999c240ab48dc170a0

Contents?: true

Size: 1.37 KB

Versions: 9

Compression:

Stored size: 1.37 KB

Contents

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

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

  let(:yields) { [] }

  let(:class_under_test) do
    parent = Module.new do
      def method_d
      end

      def method_e
      end
    end

    Class.new do
      extend parent

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

9 entries across 9 versions & 1 rubygems

Version Path
mutant-0.8.7 spec/unit/mutant/matcher/methods/singleton_spec.rb
mutant-0.8.6 spec/unit/mutant/matcher/methods/singleton_spec.rb
mutant-0.8.5 spec/unit/mutant/matcher/methods/singleton_spec.rb
mutant-0.8.4 spec/unit/mutant/matcher/methods/singleton_spec.rb
mutant-0.8.3 spec/unit/mutant/matcher/methods/singleton_spec.rb
mutant-0.8.2 spec/unit/mutant/matcher/methods/singleton_spec.rb
mutant-0.8.1 spec/unit/mutant/matcher/methods/singleton_spec.rb
mutant-0.8.0 spec/unit/mutant/matcher/methods/singleton_spec.rb
mutant-0.7.9 spec/unit/mutant/matcher/methods/singleton_spec.rb