Add specs for value types

This commit is contained in:
Michael Miller 2021-02-13 13:30:05 -07:00
parent 7d5c9edab7
commit 4af23751bc
No known key found for this signature in database
GPG key ID: FB9F12F7C646A4AD
2 changed files with 33 additions and 0 deletions

View file

@ -0,0 +1,15 @@
require "../spec_helper"
Spectator.describe Spectator::Lazy do
subject { Spectator::Lazy(Int32).new }
it "returns the value of the block" do
expect { subject.get { 42 } }.to eq(42)
end
it "caches the value" do
count = 0
expect { subject.get { count += 1 } }.to change { count }.from(0).to(1)
expect { subject.get { count += 1 } }.to_not change { count }
end
end