spec/memoit_spec.rb in memoit-0.2.0 vs spec/memoit_spec.rb in memoit-0.3.0
- old
+ new
@@ -17,10 +17,22 @@
memoize def falsy
foo
false
end
+
+ memoize def query?
+ rand
+ end
+
+ memoize def bang!
+ rand
+ end
+
+ memoize def ☃
+ rand
+ end
end
end
let(:instance) { klass.new }
describe ".memoize" do
@@ -42,9 +54,21 @@
end
it "caches falsy values" do
expect(instance).to receive(:foo).once
expect(instance.falsy).to eq(instance.falsy)
+ end
+
+ it "handles question-mark methods" do
+ expect(instance.query?).to eq(instance.query?)
+ end
+
+ it "handles bang methods" do
+ expect(instance.bang!).to eq(instance.bang!)
+ end
+
+ it "handles non-ASCII-name methods" do
+ expect(instance.☃).to eq(instance.☃)
end
it "returns the name of the method" do
name = nil
Class.new do