shard-spectator/spec/spectator/wrapper_spec.cr
2021-02-13 13:30:05 -07:00

18 lines
469 B
Crystal

require "../spec_helper"
Spectator.describe Spectator::Wrapper do
it "stores a value" do
wrapper = described_class.new(42)
expect(wrapper.get(Int32)).to eq(42)
end
it "retrieves a value using the block trick" do
wrapper = described_class.new(Int32)
expect(wrapper.get { Int32 }).to eq(Int32)
end
it "raises on invalid cast" do
wrapper = described_class.new(42)
expect { wrapper.get(String) }.to raise_error(TypeCastError)
end
end