aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2015-09-25 22:37:55 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2015-09-25 22:37:55 -0300
commit9b16b49977125e767b5cb0c1d533ff7c173a2b6e (patch)
treec877a2240de6bf7e4aac2eab72584a3bfabd472e
parent854a454a916bd87bdffad7b756cb6f2f11166a77 (diff)
parent40f4f8a0c11bb012d3da913871ab3ffea0a0720d (diff)
downloadrails-9b16b49977125e767b5cb0c1d533ff7c173a2b6e.tar.gz
rails-9b16b49977125e767b5cb0c1d533ff7c173a2b6e.tar.bz2
rails-9b16b49977125e767b5cb0c1d533ff7c173a2b6e.zip
Merge pull request #21771 from ronakjangir47/missing_transform_keys_test
Added missing tests for transform_keys! which returns Enumerator
-rw-r--r--activesupport/test/core_ext/hash/transform_keys_test.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/activesupport/test/core_ext/hash/transform_keys_test.rb b/activesupport/test/core_ext/hash/transform_keys_test.rb
index a7e12117f3..5a0b99e22c 100644
--- a/activesupport/test/core_ext/hash/transform_keys_test.rb
+++ b/activesupport/test/core_ext/hash/transform_keys_test.rb
@@ -24,9 +24,21 @@ class TransformKeysTest < ActiveSupport::TestCase
assert_equal Enumerator, enumerator.class
end
+ test "transform_keys! returns an Enumerator if no block is given" do
+ original = { a: 'a', b: 'b' }
+ enumerator = original.transform_keys!
+ assert_equal Enumerator, enumerator.class
+ end
+
test "transform_keys is chainable with Enumerable methods" do
original = { a: 'a', b: 'b' }
mapped = original.transform_keys.with_index { |k, i| [k, i].join.to_sym }
assert_equal({ a0: 'a', b1: 'b' }, mapped)
end
+
+ test "transform_keys! is chainable with Enumerable methods" do
+ original = { a: 'a', b: 'b' }
+ original.transform_keys!.with_index { |k, i| [k, i].join.to_sym }
+ assert_equal({ a0: 'a', b1: 'b' }, original)
+ end
end