aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/core_ext/array_ext_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport/test/core_ext/array_ext_test.rb')
-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