Sha256: a493018ee1211801b977deac00d07d90109b6199643128ed2860857e13bbfaee

Contents?: true

Size: 856 Bytes

Versions: 11

Compression:

Stored size: 856 Bytes

Contents

describe Hash do
  context '#supermerge' do
    it 'should complain unless two hashes are passed to it' do
      expect { {}.supermerge('y') }.to raise_error(RuntimeError)
    end

    it 'should merge two simple hashes' do
      expect({ a: 'x' }.supermerge(b: 'y')).to eq(a: 'x', b: 'y')
    end

    it 'should merge two hashes both with arrays at the same key' do
      expect({ a: ['x'] }.supermerge(a: ['y'])).to eq(a: %w(x y))
    end

    it 'should merge an array and a value at the same key' do
      expect({ a: 'x' }.supermerge(a: ['y'])).to eq(a: %w(x y))
    end

    it 'should replace a value at the same key' do
      expect({ a: 'x' }.supermerge(a: 'y')).to eq(a: 'y')
    end

    it 'should merge two subhashes at the same key' do
      expect({ a: { b: 'x' } }.supermerge(a: { c: 'y' })).to eq(a: { b: 'x', c: 'y' })
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
foreplay-0.15.4 spec/lib/hash_spec.rb
foreplay-0.15.2 spec/lib/hash_spec.rb
foreplay-0.15.1 spec/lib/hash_spec.rb
foreplay-0.15.0 spec/lib/hash_spec.rb
foreplay-0.13.5 spec/lib/hash_spec.rb
foreplay-0.13.4 spec/lib/hash_spec.rb
foreplay-0.13.3 spec/lib/hash_spec.rb
foreplay-0.13.2 spec/lib/hash_spec.rb
foreplay-0.13.1 spec/lib/hash_spec.rb
foreplay-0.13.0 spec/lib/hash_spec.rb
foreplay-0.11.2 spec/lib/hash_spec.rb