Sha256: d6b346104018dda3db6fb3d1fd434ce66af39367ef14956cdff0807f18b59e8a

Contents?: true

Size: 974 Bytes

Versions: 14

Compression:

Stored size: 974 Bytes

Contents

require File.dirname(__FILE__) + '/../spec_helper.rb'

require 'reek/sniffer'
require 'yaml'

include Reek

describe Hash do
  before :each do
    @first = {
      'one' => {'two' => 3, 'three' => 4},
      'two' => {'four' => true}
    }
  end

  it 'should deep merge Hashes' do
    other = Hash.new {|hash,key| hash[key] = {} }
    other['one']['gunk'] = 45
    other['two']['four'] = false
    other.push_keys(@first)
    @first['two']['four'].should == false
    @first['one'].keys.length.should == 3
  end
  
  it 'should deep copy Hashes' do
    second = @first.deep_copy
    second['two'].object_id.should_not be_eql(@first['two'].object_id)
  end
  
  it 'should merge array values' do
    @first['three'] = [1,2,3]
  end
end

describe Hash, 'merging arrays' do
  it 'should merge array values' do
    first = {'key' => {'one' => [1,2,3]}}
    second = {'key' => {'one' => [4,5]}}
    second.push_keys(first)
    first['key']['one'].should == [1,2,3,4,5]
  end
end

Version data entries

14 entries across 14 versions & 2 rubygems

Version Path
kevinrutherford-reek-1.1.3.11 spec/reek/config_spec.rb
kevinrutherford-reek-1.1.3.12 spec/reek/config_spec.rb
kevinrutherford-reek-1.1.3.13 spec/reek/config_spec.rb
kevinrutherford-reek-1.1.3.14 spec/reek/config_spec.rb
kevinrutherford-reek-1.1.3.15 spec/reek/config_spec.rb
kevinrutherford-reek-1.1.3.16 spec/reek/config_spec.rb
kevinrutherford-reek-1.2.0 spec/reek/config_spec.rb
reek-1.2.6 spec/reek/config_spec.rb
reek-1.2.5 spec/reek/config_spec.rb
reek-1.2.4 spec/reek/config_spec.rb
reek-1.2.3 spec/reek/config_spec.rb
reek-1.2.2 spec/reek/config_spec.rb
reek-1.2.1 spec/reek/config_spec.rb
reek-1.2.0 spec/reek/config_spec.rb