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

source_changes at macosforge.org source_changes at macosforge.org
Fri Jul 16 10:54:55 PDT 2010


Revision: 4369
          http://trac.macosforge.org/projects/ruby/changeset/4369
Author:   pthomson at apple.com
Date:     2010-07-16 10:54:55 -0700 (Fri, 16 Jul 2010)
Log Message:
-----------
More tests for Sandbox.pure_computation

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:59 UTC (rev 4368)
+++ MacRuby/trunk/spec/macruby/core/sandbox/pure_spec.rb	2010-07-16 17:54:55 UTC (rev 4369)
@@ -2,6 +2,14 @@
 
 describe "Sandbox.pure_computation" do
   
+  # These tests are applicable beyond just the pure_computation spec.
+  # Eventually the tests themselves will be farmed out to /sandbox/shared
+  # and all sandbox specs will just be aggregations of should_behave_like calls.
+  
+  before(:all) do
+    @filename = File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')
+  end
+  
   before(:each) do
     @code = "Sandbox.pure_computation.apply!; "
   end
@@ -21,6 +29,26 @@
     ruby_exe(@code).should =~ /open\(\) failed/
   end
   
+  it "should disallow most NSFileManager methods" do
+    @code << "p NSFileManager.defaultManager.currentDirectoryPath"
+    ruby_exe(@code).should =~ /nil/
+  end
+  
+  it "should disallow NSString.stringWithContentsOfFile" do
+    @code << "p NSString.stringWithContentsOfFile('#{@filename}')"
+    ruby_exe(@code).should =~ /nil/
+  end
+  
+  it "should disallow NSString.writeToFile" do
+    @code << "p 'hello'.writeToFile('#{@filename}', atomically:true)"
+    ruby_exe(@code).should =~ /0/
+  end
+  
+  it "should disallow most NSWorkspace methods" do
+    @code = "framework 'Cocoa'; " + @code + "p NSWorkspace.sharedWorkspace.launchApplication('Finder')"
+    ruby_exe(@code).should =~ /false/
+  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/8ef65800/attachment-0001.html>


More information about the macruby-changes mailing list