Sha256: a237b5e74a7fd6068e95f550df38ee636446d6f9b4cf2e66ff0ffdb711c34a51
Contents?: true
Size: 580 Bytes
Versions: 1
Compression:
Stored size: 580 Bytes
Contents
require "dry-types" describe "value coercion via dry-types" do before do module Test::Types include Dry.Types end class Test::Foo extend Dry::Initializer param :foo, type: Test::Types::Coercible::String option :bar, proc(&:to_i), default: proc { "16" } end end it "coerces assigned values" do subject = Test::Foo.new :foo, bar: "13" expect(subject.foo).to eql "foo" expect(subject.bar).to eql 13 end it "coerces defaults as well" do subject = Test::Foo.new :foo expect(subject.bar).to eql 16 end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dry-initializer-3.0.2 | spec/value_coercion_via_dry_types_spec.rb |