[macruby-changes] [1459] 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:44 PDT 2009


Revision: 1459
          http://trac.macosforge.org/projects/ruby/changeset/1459
Author:   eloy.de.enige at gmail.com
Date:     2009-04-22 15:10:44 -0700 (Wed, 22 Apr 2009)
Log Message:
-----------
Spec for Array#choice in Ruby 1.8

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

Added: MacRuby/branches/experimental/spec/frozen/core/array/choice_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/array/choice_spec.rb	                        (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/array/choice_spec.rb	2009-04-22 22:10:44 UTC (rev 1459)
@@ -0,0 +1,26 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+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
+      a = [1,2,3,4]
+      b = [4,3,2,1]
+      10.times {
+        b.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
+    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)
+    end
+  end
+end
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090422/a6bafd00/attachment-0001.html>


More information about the macruby-changes mailing list