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