[macruby-changes] [4368] MacRuby/trunk/spec/macruby/core/sandbox/pure_spec.rb

source_changes at macosforge.org source_changes at macosforge.org
Fri Jul 16 10:28:00 PDT 2010


Revision: 4368
          http://trac.macosforge.org/projects/ruby/changeset/4368
Author:   pthomson at apple.com
Date:     2010-07-16 10:27:59 -0700 (Fri, 16 Jul 2010)
Log Message:
-----------
More tests thanks to mspec's ruby_exe function.

Modified Paths:
--------------
    MacRuby/trunk/spec/macruby/core/sandbox/pure_spec.rb

Modified: MacRuby/trunk/spec/macruby/core/sandbox/pure_spec.rb
===================================================================
--- MacRuby/trunk/spec/macruby/core/sandbox/pure_spec.rb	2010-07-16 17:27:58 UTC (rev 4367)
+++ MacRuby/trunk/spec/macruby/core/sandbox/pure_spec.rb	2010-07-16 17:27:59 UTC (rev 4368)
@@ -2,9 +2,25 @@
 
 describe "Sandbox.pure_computation" do
   
-  # More specs coming to this space soon. Right now applying a sandbox profile
-  # inside a spec causes all subsequent specs to fail.
+  before(:each) do
+    @code = "Sandbox.pure_computation.apply!; "
+  end
   
+  it "should disallow spawning new processes" do
+    @code << "IO.popen('whoami')"
+    ruby_exe(@code).should =~ /posix_spawn\(\) failed/
+  end
+  
+  it "should disallow open()" do
+    @code << "open('/dev/null')"
+    ruby_exe(@code).should =~ /open\(\) failed/
+  end
+  
+  it "should disallow IO.read" do
+    @code << "p IO.read('/dev/urandom')"
+    ruby_exe(@code).should =~ /open\(\) failed/
+  end
+  
   it "should be frozen" do
     Sandbox.pure_computation.frozen?.should be_true
   end
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20100716/0ab67d5d/attachment.html>


More information about the macruby-changes mailing list