Sha256: 45c160395a772233ee19a22e2029e32fcee880093b3f2a528aa739d6394eb367

Contents?: true

Size: 1.08 KB

Versions: 8

Compression:

Stored size: 1.08 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', '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

8 entries across 8 versions & 1 rubygems

Version Path
plucky-0.7.0 spec/plucky/normalizers/fields_value_spec.rb
plucky-0.6.6 spec/plucky/normalizers/fields_value_spec.rb
plucky-0.6.5 spec/plucky/normalizers/fields_value_spec.rb
plucky-0.6.4 spec/plucky/normalizers/fields_value_spec.rb
plucky-0.6.3 spec/plucky/normalizers/fields_value_spec.rb
plucky-0.6.2 spec/plucky/normalizers/fields_value_spec.rb
plucky-0.6.1 spec/plucky/normalizers/fields_value_spec.rb
plucky-0.6.0 spec/plucky/normalizers/fields_value_spec.rb