diff options
Diffstat (limited to 'activesupport/test/core_ext/hash/transform_values_test.rb')
-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 4449c94701..45ed11fef7 100644 --- a/activesupport/test/core_ext/hash/transform_values_test.rb +++ b/activesupport/test/core_ext/hash/transform_values_test.rb @@ -46,4 +46,16 @@ class TransformValuesTest < ActiveSupport::TestCase assert_equal 'a!', mapped[:a] assert_nil mapped[:b] 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 end |