Sha256: 0f1dda07e2abfc8e3f3649e429bac50c7e155b382466206c681e97939a35bf8a
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.3 | spec/value_coercion_via_dry_types_spec.rb |