Sha256: 0d6ddf808c0f423c13314eb458e5f03e2335870a9f5b9602912d0c52ccf4cf09
Contents?: true
Size: 974 Bytes
Versions: 1
Compression:
Stored size: 974 Bytes
Contents
require "spec_helper" require "hamster/immutable" describe Hamster::Immutable do class Fixture include Hamster::Immutable def initialize(&block) @block = block end def call @block.call end memoize :call def copy transform {} end end let(:immutable) { Fixture.new { @count += 1 } } describe "#memoize" do before(:each) do @count = 0 immutable.call end it "should still freezes be immutable" do expect(immutable).to be_immutable end context "when called multiple times" do before(:each) do immutable.call end it "doesn't evaluate the memoized method more than once" do expect(@count).to eq(1) end end describe "when making a copy" do let(:copy) { immutable.copy } before(:each) do copy.call end it "should clear all memory" do expect(@count).to eq(2) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
hamster-1.0.1.pre.rc.1 | spec/hamster/immutable/memoize_spec.rb |