blob: 9b8ab864d17b9fb9f2e1d036e2d811c13c9d42fb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# 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
|