diff options
Diffstat (limited to 'activesupport/test')
-rw-r--r-- | activesupport/test/core_ext/hash_ext_test.rb | 13 |
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 |