mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Avoid using subject with structs
This commit is contained in:
parent
4af23751bc
commit
79d6ad93b3
1 changed files with 5 additions and 5 deletions
|
@ -1,15 +1,15 @@
|
||||||
require "../spec_helper"
|
require "../spec_helper"
|
||||||
|
|
||||||
Spectator.describe Spectator::Lazy do
|
Spectator.describe Spectator::Lazy do
|
||||||
subject { Spectator::Lazy(Int32).new }
|
|
||||||
|
|
||||||
it "returns the value of the block" do
|
it "returns the value of the block" do
|
||||||
expect { subject.get { 42 } }.to eq(42)
|
lazy = Spectator::Lazy(Int32).new
|
||||||
|
expect { lazy.get { 42 } }.to eq(42)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "caches the value" do
|
it "caches the value" do
|
||||||
|
lazy = Spectator::Lazy(Int32).new
|
||||||
count = 0
|
count = 0
|
||||||
expect { subject.get { count += 1 } }.to change { count }.from(0).to(1)
|
expect { lazy.get { count += 1 } }.to change { count }.from(0).to(1)
|
||||||
expect { subject.get { count += 1 } }.to_not change { count }
|
expect { lazy.get { count += 1 } }.to_not change { count }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue