aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/core_ext/hash_ext_test.rb
diff options
context:
space:
mode:
authorIgor Pstyga <igor.pstyga@gmail.com>2016-06-03 04:54:34 -0700
committerIgor Pstyga <igor.pstyga@gmail.com>2016-06-03 04:54:34 -0700
commit0dd23446a32b4e4974572a39582ea4c11475b80a (patch)
tree10eac836cce15f96f0615c011dd6f6a8823173fe /activesupport/test/core_ext/hash_ext_test.rb
parent082a5158251c6578714132e5c4f71bd39f462d71 (diff)
downloadrails-0dd23446a32b4e4974572a39582ea4c11475b80a.tar.gz
rails-0dd23446a32b4e4974572a39582ea4c11475b80a.tar.bz2
rails-0dd23446a32b4e4974572a39582ea4c11475b80a.zip
Improve Hash#compact! documentation and tests
Make it clear what should be returned when no changes were made to the hash. { c: true }.compact! # => nil
Diffstat (limited to 'activesupport/test/core_ext/hash_ext_test.rb')
-rw-r--r--activesupport/test/core_ext/hash_ext_test.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/activesupport/test/core_ext/hash_ext_test.rb b/activesupport/test/core_ext/hash_ext_test.rb
index f0a4c4dddc..e70680c773 100644
--- a/activesupport/test/core_ext/hash_ext_test.rb
+++ b/activesupport/test/core_ext/hash_ext_test.rb
@@ -999,6 +999,10 @@ class HashExtTest < ActiveSupport::TestCase
h = hash_with_only_nil_values.dup
assert_equal({}, h.compact)
assert_equal(hash_with_only_nil_values, h)
+
+ h = @symbols.dup
+ assert_equal(@symbols, h.compact)
+ assert_equal(@symbols, h)
end
def test_compact!
@@ -1012,6 +1016,10 @@ class HashExtTest < ActiveSupport::TestCase
h = hash_with_only_nil_values.dup
assert_equal({}, h.compact!)
assert_equal({}, h)
+
+ h = @symbols.dup
+ assert_equal(nil, h.compact!)
+ assert_equal(@symbols, h)
end
def test_new_with_to_hash_conversion