Sha256: a0e2024bdf18dad37bb9179a321a67470e287d70478f959b6d36d3ed1dbcaaf3
Contents?: true
Size: 1.01 KB
Versions: 9
Compression:
Stored size: 1.01 KB
Contents
require "dry-types" describe "type constraint" do context "by dry-type" do before do class Test::Foo extend Dry::Initializer::Mixin param :foo, type: Dry::Types["strict.string"], optional: true end end context "in case of mismatch" do subject { Test::Foo.new 1 } it "raises TypeError" do expect { subject }.to raise_error TypeError, /1/ end end context "in case of match" do subject { Test::Foo.new "foo" } it "completes the initialization" do expect { subject }.not_to raise_error end end context "if optional value not set" do subject { Test::Foo.new } it "completes the initialization" do expect { subject }.not_to raise_error end end end context "by invalid constraint" do it "raises TypeError" do expect { class Test::Foo extend Dry::Initializer::Mixin param :foo, type: String end }.to raise_error(TypeError) end end end
Version data entries
9 entries across 9 versions & 1 rubygems