Sha256: 02e76ce26b19102f77e513ed3be8b167c89ebca4c274e3f84b6e6d75091c840c
Contents?: true
Size: 785 Bytes
Versions: 1
Compression:
Stored size: 785 Bytes
Contents
require 'dry-types' describe 'list type argument' do before do class Test::Foo extend Dry::Initializer param :foo, [proc(&:to_s)] option :bar, [Dry::Types['strict.string']] option :baz, [] end end context 'with single items' do subject { Test::Foo.new(1, bar: '2', baz: { qux: :QUX }) } it 'coerces and wraps them to arrays' do expect(subject.foo).to eq %w[1] expect(subject.bar).to eq %w[2] expect(subject.baz).to eq [{ qux: :QUX }] end end context 'with arrays' do subject { Test::Foo.new([1], bar: %w[2], baz: [{ qux: :QUX }]) } it 'coerces elements' do expect(subject.foo).to eq %w[1] expect(subject.bar).to eq %w[2] expect(subject.baz).to eq [{ qux: :QUX }] end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dry-initializer-3.0.3 | spec/list_type_spec.rb |