Skip to content

Commit

Permalink
Merge pull request #21767 from ronakjangir47/missing_transform_values…
Browse files Browse the repository at this point in the history
…_test

Added missing tests for transform_values! which returns Enumerator
  • Loading branch information
rafaelfranca committed Sep 26, 2015
2 parents a0de04f + 3e97bea commit 767ccee
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
Original file line number Diff line number Diff line change
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 767ccee

Please sign in to comment.