Sha256: f197e1746bfc27c0e1cc65a188b54d2077164b302917b5c068c7fdf796bd3286
Contents?: true
Size: 907 Bytes
Versions: 3
Compression:
Stored size: 907 Bytes
Contents
require "dry-types" describe "type constraint" do context "by dry-type" do before do module Test::Types include Dry::Types.module end class Test::Foo extend Dry::Initializer::Mixin param :foo, type: Test::Types::Strict::String 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 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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
dry-initializer-0.6.0 | spec/dry/type_constraint_spec.rb |
dry-initializer-0.5.0 | spec/dry/type_constraint_spec.rb |
dry-initializer-0.4.0 | spec/dry/type_constraint_spec.rb |