Skip to content

Commit

Permalink
Added missing tests for transform_values! which returns Enumerator wi…
Browse files Browse the repository at this point in the history
…thout blocks
  • Loading branch information
ronakjangir47 committed Sep 25, 2015
1 parent 3c52b20 commit 3e97bea
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions activesupport/test/core_ext/hash/transform_values_test.rb
Expand Up @@ -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

0 comments on commit 3e97bea

Please sign in to comment.