aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/core_ext
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2007-09-15 21:39:04 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2007-09-15 21:39:04 +0000
commit3f29043f456af423c4ec7599040625c87321aa77 (patch)
tree2a36b04caf5607069001b3f6aab20d4da9b72a04 /activesupport/test/core_ext
parent0b0931e15066a04bb5aea8dac910497ddb5f9b33 (diff)
downloadrails-3f29043f456af423c4ec7599040625c87321aa77.tar.gz
rails-3f29043f456af423c4ec7599040625c87321aa77.tar.bz2
rails-3f29043f456af423c4ec7599040625c87321aa77.zip
Added Array#rand (closes #9170) [norbert]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7486 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/test/core_ext')
-rw-r--r--activesupport/test/core_ext/array_ext_test.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/activesupport/test/core_ext/array_ext_test.rb b/activesupport/test/core_ext/array_ext_test.rb
index 8c2edfc457..a5bae8c900 100644
--- a/activesupport/test/core_ext/array_ext_test.rb
+++ b/activesupport/test/core_ext/array_ext_test.rb
@@ -200,3 +200,19 @@ class ArrayExtractOptionsTests < Test::Unit::TestCase
assert_equal({:a=>:b}, [1, {:a=>:b}].extract_options!)
end
end
+
+uses_mocha "ArrayExtRandomTests" do
+
+class ArrayExtRandomTests < Test::Unit::TestCase
+ def test_random_element_from_array
+ assert_nil [].rand
+
+ Kernel.expects(:rand).with(1).returns(0)
+ assert_equal 'x', ['x'].rand
+
+ Kernel.expects(:rand).with(3).returns(1)
+ assert_equal 2, [1, 2, 3].rand
+ end
+end
+
+end