Sha256: 0e363b85fc537bd4ee2008ce604a6ab5839131a735023e63069804706a328031

Contents?: true

Size: 1.07 KB

Versions: 7

Compression:

Stored size: 1.07 KB

Contents

# The effect of this private module is done at boot time.
# Hence there is no way to kill the mutations at runtime
# so we have to directly hook into the private moduel via
# reflection to redo a runtime observable interaction with
# it.
#
# Until mutant gets boot time mutation support there is no
# way to to avoid this.
RSpec.describe 'Mutant::Result::ClassMethods' do
  let(:infected_class) do
    Class.new do
      include Adamantium::Flat, Concord::Public.new(:collection)
      extend Mutant::Result.const_get(:ClassMethods)

      sum :length, :collection
    end
  end

  describe '#sum' do
    let(:object) { infected_class.new(collection) }

    def apply
      object.length
    end

    subject { apply }

    before do
      # memoization behavior
      expect(collection).to receive(:map)
        .once
        .and_call_original

      apply
    end

    context 'empty collection' do
      let(:collection) { [] }

      it { should be(0) }
    end

    context 'non-emtpy collection' do
      let(:collection) { [[1], [2, 3]] }

      it { should be(3) }
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
mutant-0.8.16 spec/unit/mutant/result/class_methods_spec.rb
mutant-0.8.15 spec/unit/mutant/result/class_methods_spec.rb
mutant-0.8.14 spec/unit/mutant/result/class_methods_spec.rb
mutant-0.8.13 spec/unit/mutant/result/class_methods_spec.rb
mutant-0.8.12 spec/unit/mutant/result/class_methods_spec.rb
mutant-0.8.11 spec/unit/mutant/result/class_methods_spec.rb
mutant-0.8.10 spec/unit/mutant/result/class_methods_spec.rb