Sha256: fdf25730544e9fe49dcc8e2af9a55041bbc4859b538cb68c3f97aab395227f39

Contents?: true

Size: 1.21 KB

Versions: 20

Compression:

Stored size: 1.21 KB

Contents

# frozen_string_literal: true

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

  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) { instance_double(Mutant::Subject, 'A') }
  let(:subject_b) { instance_double(Mutant::Subject, 'B') }
  let(:subject_c) { instance_double(Mutant::Subject, 'C') }

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

  before do
    matcher = Mutant::Matcher::Method::Singleton

    {
      method_a: subject_a,
      method_b: subject_b,
      method_c: subject_c
    }.each do |method, subject|
      allow(matcher).to receive(:new)
        .with(class_under_test, class_under_test.method(method))
        .and_return(Mutant::Matcher::Static.new([subject]))
    end
  end

  it 'returns expected subjects' do
    expect(object.call(env)).to eql(subjects)
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
mutant-0.9.11 spec/unit/mutant/matcher/methods/singleton_spec.rb
mutant-0.9.10 spec/unit/mutant/matcher/methods/singleton_spec.rb
mutant-0.9.9 spec/unit/mutant/matcher/methods/singleton_spec.rb
mutant-0.9.8 spec/unit/mutant/matcher/methods/singleton_spec.rb
mutant-0.9.7 spec/unit/mutant/matcher/methods/singleton_spec.rb
mutant-0.9.6 spec/unit/mutant/matcher/methods/singleton_spec.rb
mutant-0.9.5 spec/unit/mutant/matcher/methods/singleton_spec.rb
mutant-0.9.4 spec/unit/mutant/matcher/methods/singleton_spec.rb
mutant-0.9.3 spec/unit/mutant/matcher/methods/singleton_spec.rb
mutant-0.9.2 spec/unit/mutant/matcher/methods/singleton_spec.rb
mutant-0.9.1 spec/unit/mutant/matcher/methods/singleton_spec.rb
mutant-0.9.0 spec/unit/mutant/matcher/methods/singleton_spec.rb
mutant-0.8.24 spec/unit/mutant/matcher/methods/singleton_spec.rb
mutant-0.8.23 spec/unit/mutant/matcher/methods/singleton_spec.rb
mutant-0.8.22 spec/unit/mutant/matcher/methods/singleton_spec.rb
mutant-0.8.21 spec/unit/mutant/matcher/methods/singleton_spec.rb
mutant-0.8.20 spec/unit/mutant/matcher/methods/singleton_spec.rb
mutant-0.8.19 spec/unit/mutant/matcher/methods/singleton_spec.rb
mutant-0.8.18 spec/unit/mutant/matcher/methods/singleton_spec.rb
mutant-0.8.17 spec/unit/mutant/matcher/methods/singleton_spec.rb