Sha256: 2377965d47e793dd25753fde9376d5a6f5f0385aa062c90616638fc517856603

Contents?: true

Size: 775 Bytes

Versions: 16

Compression:

Stored size: 775 Bytes

Contents

require File.instance_eval { expand_path join(dirname(__FILE__), 'test_helper') }
require 'freighthopper'

class HashTest < Test::Unit::TestCase
  context 'map_keys' do
    should 'replace keys with their mapped replacement' do
      base = {:hello => :world}
      expected = {:howdy => :world}
      assert_equal expected, base.map_keys(:hello => :howdy)
    end
    
    should 'not modify keys that are not specified' do
      base = {:a => 1, :b => 2}
      mapping = {:a => :hello}
      expected = {:hello => 1, :b => 2}
      
      assert_equal expected, base.map_keys(mapping)
    end
    
    should 'ignore mappings that do not exist' do
      base = {:a => 1, :b => 2}
      mapping = {:q => :r}

      assert_equal base, base.map_keys(mapping)
    end
  end
end

Version data entries

16 entries across 16 versions & 2 rubygems

Version Path
freighthopper-0.1.14 test/hash_test.rb
freighthopper-0.1.13 test/hash_test.rb
freighthopper-0.1.12 test/hash_test.rb
freighthopper-0.1.11 test/hash_test.rb
freighthopper-0.1.9 test/hash_test.rb
freighthopper-0.1.8 test/hash_test.rb
freighthopper-0.1.7 test/hash_test.rb
freighthopper-0.1.6 test/hash_test.rb
freighthopper-0.1.5 test/hash_test.rb
freighthopper-0.1.4 test/hash_test.rb
simply_stated-0.0.5 vendor/gems/ruby/1.8/gems/freighthopper-0.1.2/test/hash_test.rb
simply_stated-0.0.4 vendor/gems/ruby/1.8/gems/freighthopper-0.1.2/test/hash_test.rb
freighthopper-0.1.3 test/hash_test.rb
freighthopper-0.1.2 test/hash_test.rb
freighthopper-0.1.1 test/hash_test.rb
freighthopper-0.1.0 test/hash_test.rb