Sha256: 84f351be01cf24f7f9e2481ac49f6923c9c1679a6f0e47dfe1c641ac8abffbeb
Contents?: true
Size: 1009 Bytes
Versions: 26
Compression:
Stored size: 1009 Bytes
Contents
require 'spec_helper' require 'foreplay' describe Foreplay::Utility do it 'should complain unless two hashes are passed to it' do expect { Foreplay::Utility.supermerge('x', 'y') }.to raise_error(RuntimeError) end it 'should merge two simple hashes' do expect(Foreplay::Utility.supermerge({ a: 'x' }, { b: 'y' })).to eq('a' => 'x', 'b' => 'y') end it 'should merge two hashes both with arrays at the same key' do expect(Foreplay::Utility.supermerge({ a: ['x'] }, { a: ['y'] })).to eq('a' => %w(x y)) end it 'should merge an array and a value at the same key' do expect(Foreplay::Utility.supermerge({ a: 'x' }, { a: ['y'] })).to eq('a' => %w(x y)) end it 'should replace a value at the same key' do expect(Foreplay::Utility.supermerge({ a: 'x' }, { a: 'y' })).to eq('a' => 'y') end it 'should merge two subhashes at the same key' do expect(Foreplay::Utility.supermerge({ a: { b: 'x' } }, { a: { c: 'y' } })).to eq('a' => { 'b' => 'x', 'c' => 'y' }) end end
Version data entries
26 entries across 26 versions & 1 rubygems