diff options
author | Abraham Chan <abraham@rangeme.com> | 2018-09-28 18:28:30 +1000 |
---|---|---|
committer | Abraham Chan <abraham@rangeme.com> | 2018-09-28 18:28:56 +1000 |
commit | b2ea8310734b734c29b806f272c866045fc9bca7 (patch) | |
tree | b60fe55248cb8ce1f0065e756e010d07854439e9 /activesupport/test | |
parent | 2ab0df00b69335986f1116b7bea17c1ed0f52d9f (diff) | |
download | rails-b2ea8310734b734c29b806f272c866045fc9bca7.tar.gz rails-b2ea8310734b734c29b806f272c866045fc9bca7.tar.bz2 rails-b2ea8310734b734c29b806f272c866045fc9bca7.zip |
Fix HashWithIndifferentAccess#without bug
Diffstat (limited to 'activesupport/test')
-rw-r--r-- | activesupport/test/hash_with_indifferent_access_test.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/activesupport/test/hash_with_indifferent_access_test.rb b/activesupport/test/hash_with_indifferent_access_test.rb index eebff18ef1..af67ed21c8 100644 --- a/activesupport/test/hash_with_indifferent_access_test.rb +++ b/activesupport/test/hash_with_indifferent_access_test.rb @@ -672,6 +672,17 @@ class HashWithIndifferentAccessTest < ActiveSupport::TestCase assert_equal "bender", slice["login"] end + def test_indifferent_without + original = { a: "x", b: "y", c: 10 }.with_indifferent_access + expected = { c: 10 }.with_indifferent_access + + [["a", "b"], [:a, :b]].each do |keys| + # Should return a new hash without the given keys. + assert_equal expected, original.without(*keys), keys.inspect + assert_not_equal expected, original + end + end + def test_indifferent_extract original = { :a => 1, "b" => 2, :c => 3, "d" => 4 }.with_indifferent_access expected = { a: 1, b: 2 }.with_indifferent_access |