From 3310e4a566e8b99895194cd1af4f4084fb45603d Mon Sep 17 00:00:00 2001 From: Joe Van Dyk Date: Wed, 15 Mar 2023 11:57:43 -0700 Subject: [PATCH] always set memo_wise hash if not set for some reason --- spec/memo_wise_spec.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/spec/memo_wise_spec.rb b/spec/memo_wise_spec.rb index 924f65d..885325a 100644 --- a/spec/memo_wise_spec.rb +++ b/spec/memo_wise_spec.rb @@ -351,6 +351,13 @@ def module2_method end end + let(:klass_with_initializer) do + Class.new do + include Module1 + def initialize(*); end + end + end + let(:instance) { klass.new } before(:each) do @@ -364,6 +371,16 @@ def module2_method expect(Array.new(4) { instance.module2_method }).to all eq("module2_method") expect(instance.module2_method_counter).to eq(1) end + + it "can memoize klass with initializer" do + instance = klass_with_initializer.new(true) + expect { instance.module1_method }.not_to raise_error + end + + it "can reset klass with initializer" do + instance = klass_with_initializer.new(true) + expect { instance.reset_memo_wise }.not_to raise_error + end end context "when the class, its superclass, and its module all memoize methods" do