Sha256: afa63fda0fec17431eee7bb497f443195b5b9f27b32b4aec54cafaa49c44822f
Contents?: true
Size: 1.13 KB
Versions: 1
Compression:
Stored size: 1.13 KB
Contents
require 'helper' require 'plucky/normalizers/fields_value' describe Plucky::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' => 1, 'two' => 1}) 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 => 1, :two => 1}) end it "works with symbol" do subject.call(:one).should eq({:one => 1}) end it "works with array of symbols" do subject.call([:one, :two]).should eq({:one => 1, :two => 1}) 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' => 1, 'two' => 1}) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
plucky-0.8.0 | spec/plucky/normalizers/fields_value_spec.rb |