[macruby-changes] [1460] MacRuby/branches/experimental/spec/frozen/core/array/choice_spec.rb

source_changes at macosforge.org source_changes at macosforge.org
Wed Apr 22 15:10:55 PDT 2009


Revision: 1460
          http://trac.macosforge.org/projects/ruby/changeset/1460
Author:   eloy.de.enige at gmail.com
Date:     2009-04-22 15:10:55 -0700 (Wed, 22 Apr 2009)
Log Message:
-----------
Correcting last patch.

* Array#choice was introduced in Ruby 1.8.7, adding guard for 1.8.6
* Fixing ranges
* Fixing descriptions.

Modified Paths:
--------------
    MacRuby/branches/experimental/spec/frozen/core/array/choice_spec.rb

Modified: MacRuby/branches/experimental/spec/frozen/core/array/choice_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/array/choice_spec.rb	2009-04-22 22:10:44 UTC (rev 1459)
+++ MacRuby/branches/experimental/spec/frozen/core/array/choice_spec.rb	2009-04-22 22:10:55 UTC (rev 1460)
@@ -2,25 +2,28 @@
 require File.dirname(__FILE__) + '/fixtures/classes'
 
 describe "Array#choice" do
-  ruby_version_is "" .. "1.9" do
-    it "should select an value from the array" do
+  ruby_version_is "" ... "1.8.7" do
+    it "raises NoMethodError" do
+      lambda { [].choice }.should raise_error(NoMethodError)
+    end
+  end
+
+  ruby_version_is "1.8.7" ... "1.9" do
+    it "selects a random value from the array" do
       a = [1,2,3,4]
-      b = [4,3,2,1]
       10.times {
-        b.include?(a.choice).should be_true
+        a.include?(a.choice).should be_true
       }
     end
 
-    it "should return a nil value if the array is empty" do
-      a = []
-      a.choice.should be_nil
+    it "returns nil for empty arrays" do
+      [].choice.should be_nil
     end
   end
 
   ruby_version_is "1.9" do
-    it "should raise NoMethodError in ruby 1.9" do
-      a = [1,2,3,4]
-      lambda { a.choice }.should raise_error(NoMethodError)
+    it "raises NoMethodError" do
+      lambda { [].choice }.should raise_error(NoMethodError)
     end
   end
 end
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090422/aaef4d58/attachment-0001.html>


More information about the macruby-changes mailing list