Sha256: 2507174bb520d3f7a6e75dd82f5c920723bee76f566808ca990370868ca79100
Contents?: true
Size: 1.04 KB
Versions: 1
Compression:
Stored size: 1.04 KB
Contents
describe 'nested type argument' do subject { Test::Xyz.new('bar' => { 'baz' => 42 }) } context 'with nested definition only' do before do class Test::Xyz extend Dry::Initializer param :foo, as: :x do option :bar, as: :y do option :baz, proc(&:to_s), as: :z option :qux, as: :w, optional: true end end end end it 'builds the type' do expect(subject.x.y.z).to eq '42' end it 'converts the nested type to hash' do expect(subject.x.to_h).to eq('y' => { 'z' => '42' }) end end context 'with nested and wrapped definitions' do before do class Test::Xyz extend Dry::Initializer param :foo, [], as: :x do option :bar, as: :y do option :baz, proc(&:to_s), as: :z option :qux, as: :w, optional: true end end end end it 'builds the type' do x = subject.x expect(x).to be_instance_of Array expect(x.first.y.z).to eq '42' end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dry-initializer-3.0.3 | spec/nested_type_spec.rb |