buildr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From boisv...@apache.org
Subject svn commit: r947448 - /buildr/trunk/spec/ide/eclipse_spec.rb
Date Sun, 23 May 2010 17:31:22 GMT
Author: boisvert
Date: Sun May 23 17:31:21 2010
New Revision: 947448

URL: http://svn.apache.org/viewvc?rev=947448&view=rev
Log:
Safely open+close files; fixes spec failures on Windows

Modified:
    buildr/trunk/spec/ide/eclipse_spec.rb

Modified: buildr/trunk/spec/ide/eclipse_spec.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/spec/ide/eclipse_spec.rb?rev=947448&r1=947447&r2=947448&view=diff
==============================================================================
--- buildr/trunk/spec/ide/eclipse_spec.rb (original)
+++ buildr/trunk/spec/ide/eclipse_spec.rb Sun May 23 17:31:21 2010
@@ -33,7 +33,7 @@ PLUGIN_BUILDERS = Buildr::Eclipse::Plugi
 module EclipseHelper
   def classpath_xml_elements
     task('eclipse').invoke
-    REXML::Document.new(File.open('.classpath')).root.elements
+    File.open('.classpath') { |f| REXML::Document.new(f).root.elements }
   end
 
   def classpath_sources(attribute='path')
@@ -63,7 +63,7 @@ module EclipseHelper
 
   def project_xml_elements
     task('eclipse').invoke
-    REXML::Document.new(File.open('.project')).root.elements
+    File.open('.project') { |f| REXML::Document.new(f).root.elements }
   end
 
   def project_natures
@@ -104,8 +104,10 @@ describe Buildr::Eclipse do
       it 'should generate a .project file' do
         define('foo')
         task('eclipse').invoke
-        REXML::Document.new(File.open('.project')).root.
-          elements.collect("name") { |e| e.text }.should == ['foo']
+        File.open('.project') do |f|
+          REXML::Document.new(f).root.
+            elements.collect("name") { |e| e.text }.should == ['foo']
+        end
       end
 
       it 'should not generate a .classpath file' do
@@ -157,8 +159,10 @@ describe Buildr::Eclipse do
           define('foo') { compile.using(:javac); package :jar }
         }
         task('eclipse').invoke
-        REXML::Document.new(File.open(File.join('foo', '.project'))).root.
-          elements.collect("name") { |e| e.text }.should == ['myproject-foo']
+        File.open(File.join('foo', '.project')) do |f|
+          REXML::Document.new(f).root.
+            elements.collect("name") { |e| e.text }.should == ['myproject-foo']
+        end
       end
 
     end
@@ -456,8 +460,10 @@ MANIFEST
           define('bar') { compile.using(:javac).with project('foo'); }
         }
         task('eclipse').invoke
-        REXML::Document.new(File.open(File.join('bar', '.classpath'))).root.
-          elements.collect("classpathentry[@kind='src']") { |n| n.attributes['path'] }.should
include('/myproject-foo')
+        File.open(File.join('bar', '.classpath')) do |f|
+          REXML::Document.new(f).root.
+            elements.collect("classpathentry[@kind='src']") { |n| n.attributes['path'] }.should
include('/myproject-foo')
+        end
       end
     end
   end



Mime
View raw message