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

Version Path
foreplay-0.7.3 spec/lib/foreplay/utility_spec.rb
foreplay-0.7.2 spec/lib/foreplay/utility_spec.rb
foreplay-0.7.1 spec/lib/foreplay/utility_spec.rb
foreplay-0.7.0 spec/lib/foreplay/utility_spec.rb
foreplay-0.5.4 spec/lib/foreplay/utility_spec.rb
foreplay-0.6.0 spec/lib/foreplay/utility_spec.rb
foreplay-0.5.3 spec/lib/foreplay/utility_spec.rb
foreplay-0.5.2 spec/lib/foreplay/utility_spec.rb
foreplay-0.5.1 spec/lib/foreplay/utility_spec.rb
foreplay-0.5.0 spec/lib/foreplay/utility_spec.rb
foreplay-0.4.0 spec/lib/foreplay/utility_spec.rb
foreplay-0.3.6 spec/lib/foreplay/utility_spec.rb
foreplay-0.3.5 spec/lib/foreplay/utility_spec.rb
foreplay-0.3.4 spec/lib/foreplay/utility_spec.rb
foreplay-0.3.3 spec/lib/foreplay/utility_spec.rb
foreplay-0.3.2 spec/lib/foreplay/utility_spec.rb
foreplay-0.3.1 spec/lib/foreplay/utility_spec.rb
foreplay-0.3.0 spec/lib/foreplay/utility_spec.rb
foreplay-0.2.3 spec/lib/foreplay/utility_spec.rb
foreplay-0.2.2 spec/lib/foreplay/utility_spec.rb