Sha256: b5664fd833170e212db2df261f49665b4908dccef6a90ce15714951d4b251892
Contents?: true
Size: 973 Bytes
Versions: 12
Compression:
Stored size: 973 Bytes
Contents
require 'spec_helper' describe Monolens, 'str.split' do context 'without options' do subject do Monolens.lens('str.split') end it 'splits a string as an array using space separator' do input = 'foo bar' expected = ['foo', 'bar'] expect(subject.call(input)).to eql(expected) end it 'is greedy on spaces and splits on carriage returns and tabs' do input = "foo bar\nbaz\tboz" expected = ['foo', 'bar', 'baz', 'boz'] expect(subject.call(input)).to eql(expected) end end context 'when specifying the separator' do subject do Monolens.lens('str.split' => { separator: ',' }) end it 'uses it' do input = 'foo,bar' expected = ['foo', 'bar'] expect(subject.call(input)).to eql(expected) end it 'does not make whitespace magic' do input = "foo, bar" expected = ['foo', ' bar'] expect(subject.call(input)).to eql(expected) end end end
Version data entries
12 entries across 12 versions & 1 rubygems