1
0
Fork 0
mirror of https://github.com/pry/pry.git synced 2022-11-09 12:35:05 -05:00
pry--pry/spec/config/memoized_value_spec.rb
Josh Cheek 6cc6e55f20 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.
2019-06-03 11:09:31 +03:00

21 lines
520 B
Ruby

# frozen_string_literal: true
RSpec.describe Pry::Config::MemoizedValue do
describe "#call" do
it "memoizes the result of call" do
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