File: hash_extensions_spec.rb

package info (click to toggle)
ruby-table-print 1.5.6-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 292 kB
  • sloc: ruby: 1,821; makefile: 2
file content (20 lines) | stat: -rw-r--r-- 661 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
require 'spec_helper'

describe "#constructive_merge" do
  it "merges hashes without clobbering" do
    x = {'reviews' => {'user' => {}}}
    y = {'reviews' => {'ratings' => {}}}
    x.extend TablePrint::HashExtensions::ConstructiveMerge
    x.constructive_merge(y).should == {'reviews' => {'user' => {}, 'ratings' => {}}}
  end
end

describe "#constructive_merge!" do
  it "merges hashes in place without clobbering" do
    x = {'reviews' => {'user' => {}}}
    y = {'reviews' => {'ratings' => {}}}
    x.extend TablePrint::HashExtensions::ConstructiveMerge
    x.constructive_merge!(y)
    x.should == {'reviews' => {'user' => {}, 'ratings' => {}}}
  end
end