diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2011-12-02 13:00:03 +0100 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2011-12-02 13:00:56 +0100 |
commit | 4d20de8a50d889a09e6f5642984775fe796ca943 (patch) | |
tree | 10f22611c7b0b50a39ea57800500701d58538da7 /activesupport/test | |
parent | 76a3ec7f6e348681e4bafa8b02ca660ab450b0ee (diff) | |
download | rails-4d20de8a50d889a09e6f5642984775fe796ca943.tar.gz rails-4d20de8a50d889a09e6f5642984775fe796ca943.tar.bz2 rails-4d20de8a50d889a09e6f5642984775fe796ca943.zip |
Added Enumerable#pluck to wrap the common pattern of collect(&:method) *DHH*
Diffstat (limited to 'activesupport/test')
-rw-r--r-- | activesupport/test/core_ext/enumerable_test.rb | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/activesupport/test/core_ext/enumerable_test.rb b/activesupport/test/core_ext/enumerable_test.rb index cdfa991a34..7ce7c4d52d 100644 --- a/activesupport/test/core_ext/enumerable_test.rb +++ b/activesupport/test/core_ext/enumerable_test.rb @@ -126,4 +126,11 @@ class EnumerableTests < Test::Unit::TestCase assert_equal true, GenericEnumerable.new([ 1 ]).exclude?(2) assert_equal false, GenericEnumerable.new([ 1 ]).exclude?(1) end -end + + def test_pluck_single_method + person = Struct.new(:name) + people = [ person.new("David"), person.new("Jamie") ] + + assert_equal [ "David", "Jamie" ], people.pluck(:name) + end +end
\ No newline at end of file |