aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/core_ext/hash
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2015-09-25 23:35:54 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2015-09-25 23:35:54 -0300
commit767cceefd39473dbfaaa1f0adcb3c5e1c80ef262 (patch)
tree3c4581b622a9ef6f17b5f5c23678e98a2993ecc7 /activesupport/test/core_ext/hash
parenta0de04fce28c386e695935208c910a4b5d1b0748 (diff)
parent3e97bea38aab02b050452f223f69206e1a05fad0 (diff)
downloadrails-767cceefd39473dbfaaa1f0adcb3c5e1c80ef262.tar.gz
rails-767cceefd39473dbfaaa1f0adcb3c5e1c80ef262.tar.bz2
rails-767cceefd39473dbfaaa1f0adcb3c5e1c80ef262.zip
Merge pull request #21767 from ronakjangir47/missing_transform_values_test
Added missing tests for transform_values! which returns Enumerator
Diffstat (limited to 'activesupport/test/core_ext/hash')
-rw-r--r--activesupport/test/core_ext/hash/transform_values_test.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/activesupport/test/core_ext/hash/transform_values_test.rb b/activesupport/test/core_ext/hash/transform_values_test.rb
index 45ed11fef7..7c33227dc0 100644
--- a/activesupport/test/core_ext/hash/transform_values_test.rb
+++ b/activesupport/test/core_ext/hash/transform_values_test.rb
@@ -53,9 +53,21 @@ class TransformValuesTest < ActiveSupport::TestCase
assert_equal Enumerator, enumerator.class
end
+ test "transform_values! returns an Enumerator if no block is given" do
+ original = { a: 'a', b: 'b' }
+ enumerator = original.transform_values!
+ assert_equal Enumerator, enumerator.class
+ end
+
test "transform_values is chainable with Enumerable methods" do
original = { a: 'a', b: 'b' }
mapped = original.transform_values.with_index { |v, i| [v, i].join }
assert_equal({ a: 'a0', b: 'b1' }, mapped)
end
+
+ test "transform_values! is chainable with Enumerable methods" do
+ original = { a: 'a', b: 'b' }
+ original.transform_values!.with_index { |v, i| [v, i].join }
+ assert_equal({ a: 'a0', b: 'b1' }, original)
+ end
end