Sha256: 8aaa8878c23346f501a485dd39db025f5c0a617bb00e96d54da2e2359d58ee01
Contents?: true
Size: 1.1 KB
Versions: 6
Compression:
Stored size: 1.1 KB
Contents
require 'spec_helper' require 'mark_mapper/normalizers/fields_value' describe MarkMapper::Normalizers::FieldsValue do it "defaults to nil" do subject.call(nil).should be_nil end it "returns nil if empty string" do subject.call('').should be_nil end it "returns nil if empty array" do subject.call([]).should be_nil end it "works with array" do subject.call(['one', 'two']).should eq(['one', 'two']) end # Ruby 1.9.x was sending array [{:age => 20}], instead of hash. it "works with array that has one hash" do subject.call([{:age => 20}]).should eq({:age => 20}) end it "flattens multi-dimensional array" do subject.call([[:one, :two]]).should eq([:one, :two]) end it "works with symbol" do subject.call(:one).should eq([:one]) end it "works with array of symbols" do subject.call([:one, :two]).should eq([:one, :two]) end it "works with hash" do subject.call({:one => 1, :two => -1}).should eq({:one => 1, :two => -1}) end it "converts comma separated list to array" do subject.call('one, two').should eq(['one', 'two']) end end
Version data entries
6 entries across 6 versions & 1 rubygems