aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test
diff options
context:
space:
mode:
authorMarc-Andre Lafortune <github@marc-andre.ca>2014-02-04 02:18:03 -0500
committerMarc-Andre Lafortune <github@marc-andre.ca>2014-02-05 16:53:58 -0500
commita476020567a47f5fbec3629707d5bf31b400a284 (patch)
tree49ab417231c91102b3b878aaaf10285f1a465785 /activesupport/test
parent13d2696c10726afecd393753fcac88c5a9907d8c (diff)
downloadrails-a476020567a47f5fbec3629707d5bf31b400a284.tar.gz
rails-a476020567a47f5fbec3629707d5bf31b400a284.tar.bz2
rails-a476020567a47f5fbec3629707d5bf31b400a284.zip
Return sized enumerator from Enumerable#index_by
Diffstat (limited to 'activesupport/test')
-rw-r--r--activesupport/test/core_ext/enumerable_test.rb4
1 files changed, 4 insertions, 0 deletions
diff --git a/activesupport/test/core_ext/enumerable_test.rb b/activesupport/test/core_ext/enumerable_test.rb
index 6b3e8364c5..6fcf6e8743 100644
--- a/activesupport/test/core_ext/enumerable_test.rb
+++ b/activesupport/test/core_ext/enumerable_test.rb
@@ -73,6 +73,10 @@ class EnumerableTests < ActiveSupport::TestCase
assert_equal({ 5 => Payment.new(5), 15 => Payment.new(15), 10 => Payment.new(10) },
payments.index_by { |p| p.price })
assert_equal Enumerator, payments.index_by.class
+ if Enumerator.method_defined? :size
+ assert_equal nil, payments.index_by.size
+ assert_equal 42, (1..42).index_by.size
+ end
assert_equal({ 5 => Payment.new(5), 15 => Payment.new(15), 10 => Payment.new(10) },
payments.index_by.each { |p| p.price })
end