diff options
author | Marcel Molina <marcel@vernix.org> | 2006-01-08 21:29:47 +0000 |
---|---|---|
committer | Marcel Molina <marcel@vernix.org> | 2006-01-08 21:29:47 +0000 |
commit | 36fc181a575d2c300742a41abd45d7b1a7207288 (patch) | |
tree | 4c111de2fd513bbbdb14cef6ae4781ac83b80cde /activesupport/test | |
parent | b30ccefe6f143e2c907f9cfc71b251cdd88ba7af (diff) | |
download | rails-36fc181a575d2c300742a41abd45d7b1a7207288.tar.gz rails-36fc181a575d2c300742a41abd45d7b1a7207288.tar.bz2 rails-36fc181a575d2c300742a41abd45d7b1a7207288.zip |
Make HashWithIndifferentAccess#update behave like Hash#update by returning the hash. Closes #3419, #3425
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3388 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/test')
-rw-r--r-- | activesupport/test/core_ext/hash_ext_test.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/activesupport/test/core_ext/hash_ext_test.rb b/activesupport/test/core_ext/hash_ext_test.rb index 4ae2dd8e7c..a62dc3fbca 100644 --- a/activesupport/test/core_ext/hash_ext_test.rb +++ b/activesupport/test/core_ext/hash_ext_test.rb @@ -93,6 +93,29 @@ class HashExtTest < Test::Unit::TestCase assert_equal hash[3], 3 end + def test_indifferent_update + hash = HashWithIndifferentAccess.new + hash[:a] = 'a' + hash['b'] = 'b' + + updated_with_strings = hash.update(@strings) + updated_with_symbols = hash.update(@symbols) + updated_with_mixed = hash.update(@mixed) + + assert_equal updated_with_strings[:a], 1 + assert_equal updated_with_strings['a'], 1 + assert_equal updated_with_strings['b'], 2 + + assert_equal updated_with_symbols[:a], 1 + assert_equal updated_with_symbols['b'], 2 + assert_equal updated_with_symbols[:b], 2 + + assert_equal updated_with_mixed[:a], 1 + assert_equal updated_with_mixed['b'], 2 + + assert [updated_with_strings, updated_with_symbols, updated_with_mixed].all? {|hash| hash.keys.size == 2} + end + def test_assert_valid_keys assert_nothing_raised do { :failure => "stuff", :funny => "business" }.assert_valid_keys([ :failure, :funny ]) |