Sha256: c64a249de5854afea74d56c4e6e29734a49c2f31ec84af2750f864098683770a
Contents?: true
Size: 1.07 KB
Versions: 4
Compression:
Stored size: 1.07 KB
Contents
require 'test_helper' module Vedeu class TestClass include Attributes def initialize(*args); end end describe Attributes do describe '#coercer' do it 'returns an empty collection when nil or empty' do [nil, '', [], {}].each do |empty_value| Attributes.coercer(empty_value, TestClass, :key).must_equal([]) end end it 'returns a single model in a collection when a String' do Attributes.coercer('test', TestClass, :key).size.must_equal(1) end it 'returns a collection of models when a single hash' do Attributes.coercer({ :test1 => 'test1' }, TestClass, :key) .size.must_equal(1) end it 'returns a collection of models when multiple hashes' do Attributes.coercer([ { :test1 => 'test1' }, { :test2 => 'test2' } ], TestClass, :key).size.must_equal(2) end it 'returns a collection of models when a single array' do Attributes.coercer([{ :test3 => 'test3' }], TestClass, :key) .size.must_equal(1) end end end end
Version data entries
4 entries across 4 versions & 1 rubygems