Sha256: b790ec2570c221d378ca834a89d27d7f74bf584ae40128fa8fb59f3544c98a89

Contents?: true

Size: 493 Bytes

Versions: 2

Compression:

Stored size: 493 Bytes

Contents

require "spec_helper"

describe Mem do
  describe "#memoize" do
    let(:klass) do
      Class.new do
        extend Mem

        def foo(&block)
          bar(&block)
        end
        memoize :foo

        def bar
          yield
        end
      end
    end

    let(:object) do
      klass.new
    end

    it "memoizes the result of specified method call" do
      expect(object).to receive(:bar).once.and_call_original
      expect(object.foo { "foo" }).to eq "foo"
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mem-0.0.2 spec/mem_spec.rb
mem-0.0.1 spec/mem_spec.rb