Added missing tests for transform_values! which returns Enumerator without blocks

This commit is contained in:
Ronak Jangir 2015-09-26 00:15:14 +05:30
parent 3c52b2000c
commit 3e97bea38a
1 changed files with 12 additions and 0 deletions

View File

@ -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