Sha256: a9d415ead15a73998e7675ad9247bb585d5eb9faa3e5636dfd3b99657ffba6c8
Contents?: true
Size: 1.36 KB
Versions: 6
Compression:
Stored size: 1.36 KB
Contents
# encoding: utf-8 require 'spec_helper' require File.expand_path('../fixtures/classes', __FILE__) describe Adamantium, '#memoize' do subject { object.memoize(method, value) } let(:described_class) { Class.new(AdamantiumSpecs::Object) } let(:object) { described_class.new } let(:method) { :test } before do described_class.memoize(method) end context 'when the value is frozen' do let(:value) { String.new.freeze } it 'sets the memoized value for the method to the value' do subject object.send(method).should equal(value) end it 'creates a method that returns a frozen value' do subject object.send(method).should be_frozen end end context 'when the value is not frozen' do let(:value) { String.new } it 'sets the memoized value for the method to the value' do subject object.send(method).should eql(value) end it 'creates a method that returns a frozen value' do subject object.send(method).should be_frozen end end context 'when the method is already memoized' do let(:value) { stub } let(:original) { nil } before do object.memoize(method, original) end it 'does not change the value' do expect { subject }.to_not change { object.send(method) } end end end
Version data entries
6 entries across 6 versions & 1 rubygems