Sha256: 84c3dc6bf641f0b2ae8ab8d54ecd9c5a7b0efc7d9472ff033cab6973915f9ad9
Contents?: true
Size: 1.12 KB
Versions: 23
Compression:
Stored size: 1.12 KB
Contents
require 'spec_helper' describe Hash do describe 'which is one level deep' do describe '#to_array' do it 'returns [] if key is not present in Hash' do {}.to_array(:a).should eql [] end it 'returns [] if key is nil ' do { :a => nil }.to_array(:a).should eql [] end it 'returns [value] if value is not an Array' do { :a => 1 }.to_array(:a).should eql [1] end it 'returns Array if value is an Array' do { :a => [1,2,3] }.to_array(:a).should eql [1,2,3] end end end describe 'which is two levels deep' do describe '#to_array' do it 'returns [] if key is not present in Hash' do { :a => {} }.to_array(:a, :b).should eql [] end it 'returns [] if key is nil ' do { :a => { :b => nil } }.to_array(:a, :b).should eql [] end it 'returns [value] if value is not an Array' do { :a => { :b => 1 } }.to_array(:a, :b).should eql [1] end it 'returns Array if value is an Array' do { :a => { :b => [1,2,3] } }.to_array(:a, :b).should eql [1,2,3] end end end end
Version data entries
23 entries across 23 versions & 1 rubygems