aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/core_ext/hash_ext_test.rb
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2007-07-09 21:49:37 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2007-07-09 21:49:37 +0000
commitcb2381696029ad839ecddad08afea061d07685fb (patch)
tree019bdde1381a1fd2e9423c494c13d76a048e4366 /activesupport/test/core_ext/hash_ext_test.rb
parent5b2be6293443a4c25aab7cf3e74fc84cb70e2199 (diff)
downloadrails-cb2381696029ad839ecddad08afea061d07685fb.tar.gz
rails-cb2381696029ad839ecddad08afea061d07685fb.tar.bz2
rails-cb2381696029ad839ecddad08afea061d07685fb.zip
Added Hash#except which is the inverse of Hash#slice -- return the hash except the keys that are specified [DHH]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7172 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/test/core_ext/hash_ext_test.rb')
-rw-r--r--activesupport/test/core_ext/hash_ext_test.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/activesupport/test/core_ext/hash_ext_test.rb b/activesupport/test/core_ext/hash_ext_test.rb
index cae19a9335..c2b7a7f1eb 100644
--- a/activesupport/test/core_ext/hash_ext_test.rb
+++ b/activesupport/test/core_ext/hash_ext_test.rb
@@ -277,6 +277,19 @@ class HashExtTest < Test::Unit::TestCase
assert_equal expected, copy
end
end
+
+ def test_except
+ original = { :a => 'x', :b => 'y', :c => 10 }
+ expected = { :a => 'x', :b => 'y' }
+
+ # Should return a new hash with only the given keys.
+ assert_equal expected, original.except(:c)
+ assert_not_equal expected, original
+
+ # Should replace the hash with only the given keys.
+ assert_equal expected, original.except!(:c)
+ assert_equal expected, original
+ end
end
class IWriteMyOwnXML