Sha256: 11956ef1cd5c9677cb43892613be2b5ed80f7b9753c6e748b3fb9d90a7ac8943
Contents?: true
Size: 857 Bytes
Versions: 7
Compression:
Stored size: 857 Bytes
Contents
# frozen_string_literal: true RSpec.describe Necromancer::ArrayConverters::StringToArrayConverter, '.call' do subject(:converter) { described_class.new(:string, :array) } it "converts empty string to array" do expect(converter.call('', strict: false)).to eq(['']) end it "fails to convert empty string to array in strict mode" do expect { converter.call('', strict: true) }.to raise_error(Necromancer::ConversionTypeError) end it "converts `1,2,3` to array" do expect(converter.call('1,2,3')).to eq([1,2,3]) end it "converts `a,b,c` to array" do expect(converter.call('a,b,c')).to eq(['a','b','c']) end it "converts '1-2-3' to array" do expect(converter.call('1-2-3')).to eq([1,2,3]) end it "converts ' 1 - 2 - 3 ' to array" do expect(converter.call(' 1 - 2 - 3 ')).to eq([1,2,3]) end end
Version data entries
7 entries across 7 versions & 2 rubygems