Sha256: 15a688e7f7aa0f0fe3fd7772689b8f02d1e62793ff57902bc2c9931f0b072122

Contents?: true

Size: 553 Bytes

Versions: 4

Compression:

Stored size: 553 Bytes

Contents

require_relative '../../spec_helper'

module LazyDoc
  describe Memoizer do
    let(:memoizer) { Memoizer.new }

    it 'returns the value of the block' do
      memoized_value = memoizer.memoize(:foo) { 'hello world' }

      expect(memoized_value).to eq('hello world')
    end

    it 'returns the original block value given for subsequent access to the attribute' do
      memoizer.memoize(:foo) { 'hello world' }

      memoized_value = memoizer.memoize(:foo) { :doesnt_matter }

      expect(memoized_value).to eq('hello world')
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
lazy_doc-0.4.0 spec/lib/lazy_doc/memoizer_spec.rb
lazy_doc-0.3.0 spec/lib/lazy_doc/memoizer_spec.rb
lazy_doc-0.2.1 spec/lib/lazy_doc/memoizer_spec.rb
lazy_doc-0.1.0 spec/lib/lazy_doc/memoizer_spec.rb