mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Test value types
This commit is contained in:
parent
8b5fd099bb
commit
35946dc993
3 changed files with 97 additions and 0 deletions
34
spec/spectator/block_spec.cr
Normal file
34
spec/spectator/block_spec.cr
Normal file
|
@ -0,0 +1,34 @@
|
|||
require "../spec_helper"
|
||||
|
||||
Spectator.describe Spectator::Block do
|
||||
describe "#value" do
|
||||
it "calls the block" do
|
||||
called = false
|
||||
block = described_class.new { called = true }
|
||||
expect { block.value }.to change { called }.to(true)
|
||||
end
|
||||
|
||||
it "can be called multiple times (doesn't cache the value)" do
|
||||
count = 0
|
||||
block = described_class.new { count += 1 }
|
||||
block.value # Call once, count should be 1.
|
||||
expect { block.value }.to change { count }.from(1).to(2)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#to_s" do
|
||||
let(block) do
|
||||
described_class.new("Test Label") { 42 }
|
||||
end
|
||||
|
||||
subject { block.to_s }
|
||||
|
||||
it "contains the label" do
|
||||
is_expected.to contain("Test Label")
|
||||
end
|
||||
|
||||
it "contains the value" do
|
||||
is_expected.to contain("42")
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue