aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/core_ext/enumerable_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport/test/core_ext/enumerable_test.rb')
-rw-r--r--activesupport/test/core_ext/enumerable_test.rb17
1 files changed, 16 insertions, 1 deletions
diff --git a/activesupport/test/core_ext/enumerable_test.rb b/activesupport/test/core_ext/enumerable_test.rb
index 1fcaa9163e..6ca41f9116 100644
--- a/activesupport/test/core_ext/enumerable_test.rb
+++ b/activesupport/test/core_ext/enumerable_test.rb
@@ -12,4 +12,19 @@ class EnumerableTests < Test::Unit::TestCase
assert_equal true, (1..10).first_match {|x| x > 9}
assert_equal :aba, {:a => 10, :aba => 50, :bac => 40}.first_match {|k, v| k if v > 45}
end
-end \ No newline at end of file
+
+ def test_group_by
+ names = %w(marcel sam david jeremy)
+ klass = Class.new
+ klass.send(:attr_accessor, :name)
+ objects = (1..50).inject([]) do |people,|
+ p = klass.new
+ p.name = names.sort_by { rand }.first
+ people << p
+ end
+
+ objects.group_by {|object| object.name}.each do |name, group|
+ assert group.all? {|person| person.name == name}
+ end
+ end
+end