Sha256: 16e4722af875f55a650bd5be5de12ce238ac030a51be7e8609b6f29d671075e3

Contents?: true

Size: 690 Bytes

Versions: 7

Compression:

Stored size: 690 Bytes

Contents

require 'spec_helper'
require 'gorillib/hash/reverse_merge'

describe Hash, :hashlike_spec => true do
  describe 'reverse_merge' do

    before do
      @defaults = { :a => "x", :b => "y", :c => 10 }.freeze
      @options  = { :a => 1, :b => 2 }
      @expected = { :a => 1, :b => 2, :c => 10 }
    end

    it 'Should merge defaults into options, creating a new hash' do
      @options.reverse_merge(@defaults).should == @expected
      @options.should_not == @expected
    end


    it 'Should merge! defaults into options, replacing options.' do
      @merged = @options.dup
      @merged.reverse_merge!(@defaults).should == @expected
      @merged.should == @expected
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
gorillib-0.6.0 spec/gorillib/hash/reverse_merge_spec.rb
gorillib-0.5.2 spec/gorillib/hash/reverse_merge_spec.rb
gorillib-0.5.0 spec/gorillib/hash/reverse_merge_spec.rb
gorillib-0.4.2 spec/gorillib/hash/reverse_merge_spec.rb
gorillib-0.4.2pre spec/gorillib/hash/reverse_merge_spec.rb
gorillib-0.4.0pre spec/gorillib/hash/reverse_merge_spec.rb
gorillib-0.4.1pre spec/gorillib/hash/reverse_merge_spec.rb