diff options
author | Ronak Jangir <ronakjangir47@gmail.com> | 2015-09-26 00:15:14 +0530 |
---|---|---|
committer | Ronak Jangir <ronakjangir47@gmail.com> | 2015-09-26 00:23:54 +0530 |
commit | 3e97bea38aab02b050452f223f69206e1a05fad0 (patch) | |
tree | 54e67e10528d3548aaaa240d82ef5658c3b3e06a /activesupport/test/core_ext | |
parent | 3c52b2000cbee716b5e449974c312c4fb552f64f (diff) | |
download | rails-3e97bea38aab02b050452f223f69206e1a05fad0.tar.gz rails-3e97bea38aab02b050452f223f69206e1a05fad0.tar.bz2 rails-3e97bea38aab02b050452f223f69206e1a05fad0.zip |
Added missing tests for transform_values! which returns Enumerator without blocks
Diffstat (limited to 'activesupport/test/core_ext')
-rw-r--r-- | activesupport/test/core_ext/hash/transform_values_test.rb | 12 |
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 |