diff options
author | Josh Cheek <josh.cheek@gmail.com> | 2019-06-03 03:09:31 -0500 |
---|---|---|
committer | Kyrylo Silin <silin@kyrylo.org> | 2019-06-03 11:09:31 +0300 |
commit | 6cc6e55f205c421ca6ca010a8afcafc3ed7dc299 (patch) | |
tree | db2cff1e834bd1624b30d46858c27db67c2475ac /spec | |
parent | 29bdd2e403c3d7e30435a6acc1f66689dd32f4a8 (diff) | |
download | pry-6cc6e55f205c421ca6ca010a8afcafc3ed7dc299.tar.gz |
MemoizedValue memoizes nil results (#2053)
I moved the existing `subject` into the test because it didn't make sense for the second test I added.
Diffstat (limited to 'spec')
-rw-r--r-- | spec/config/memoized_value_spec.rb | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/spec/config/memoized_value_spec.rb b/spec/config/memoized_value_spec.rb index 22e278dc..9b8ab864 100644 --- a/spec/config/memoized_value_spec.rb +++ b/spec/config/memoized_value_spec.rb @@ -2,10 +2,20 @@ RSpec.describe Pry::Config::MemoizedValue do describe "#call" do - subject { described_class.new { rand } } - it "memoizes the result of call" do - expect(subject.call).to eq(subject.call) + instance = described_class.new { rand } + expect(instance.call).to eq(instance.call) + end + + it "doesn't conflate falsiness with unmemoizedness" do + count = 0 + instance = described_class.new do + count += 1 + nil + end + expect(instance.call).to eq nil + expect(instance.call).to eq nil + expect(count).to eq 1 end end end |