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

Version Path
monolens-0.6.4 spec/monolens/stdlib/skip/test_null.rb
monolens-0.6.3 spec/monolens/stdlib/skip/test_null.rb
monolens-0.6.2 spec/monolens/stdlib/skip/test_null.rb
monolens-0.6.1 spec/monolens/stdlib/skip/test_null.rb
monolens-0.6.0 spec/monolens/stdlib/skip/test_null.rb
monolens-0.5.3 spec/monolens/skip/test_null.rb
monolens-0.5.2 spec/monolens/skip/test_null.rb
monolens-0.5.1 spec/monolens/skip/test_null.rb
monolens-0.5.0 spec/monolens/skip/test_null.rb
monolens-0.4.0 spec/monolens/skip/test_null.rb
monolens-0.3.0 spec/monolens/skip/test_null.rb
monolens-0.2.0 spec/monolens/skip/test_null.rb