Sha256: 3225e71a8155681dd8d8367d21450689c7644fdcc82220bed57066a22a55209e
Contents?: true
Size: 842 Bytes
Versions: 12
Compression:
Stored size: 842 Bytes
Contents
require 'spec_helper' describe Monolens, 'skip.null' do context 'when used in a Chain' do subject do Monolens.lens(['skip.null', 'str.upcase']) end it 'allows ignoring nil' do expect(subject.call(nil)).to eql(nil) end it 'lets other lenses execute otherwise' do expect(subject.call('foo')).to eql('FOO') end end context 'when used in a Map' do subject do Monolens.lens('array.map' => ['skip.null', 'str.upcase']) end it 'maps nils' do expect(subject.call([nil, 'foo'])).to eql([nil, 'FOO']) end end context 'when used in a Map, but we want no nils' do subject do Monolens.lens(['array.compact', { 'array.map' => ['skip.null', 'str.upcase'] }]) end it 'works' do expect(subject.call([nil, 'foo'])).to eql(['FOO']) end end end
Version data entries
12 entries across 12 versions & 1 rubygems