about summary refs log tree commit homepage
path: root/test/helper.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/helper.rb')
-rw-r--r--test/helper.rb30
1 files changed, 16 insertions, 14 deletions
diff --git a/test/helper.rb b/test/helper.rb
index 8f70ddc..73cde51 100644
--- a/test/helper.rb
+++ b/test/helper.rb
@@ -88,21 +88,23 @@ end
 
 require "tempfile"
 require 'tmpdir'
-class Dir
-  def Dir.mktmpdir
-    begin
-      d = "#{Dir.tmpdir}/#$$.#{rand}"
-      Dir.mkdir(d)
-    rescue Errno::EEXIST
-    end while true
-    return d unless block_given?
-    begin
-      yield d
-    ensure
-      FileUtils.remove_entry(d)
-    end
+
+# Can't rely on mktmpdir until we drop Ruby 1.9.3 support
+def yahns_mktmpdir
+  d = nil
+  begin
+    dir = "#{Dir.tmpdir}/yahns.#$$.#{rand}"
+    Dir.mkdir(dir)
+    d = dir
+  rescue Errno::EEXIST
+  end until d
+  return d unless block_given?
+  begin
+    yield d
+  ensure
+    FileUtils.remove_entry(d)
   end
-end unless Dir.respond_to?(:mktmpdir)
+end
 
 def tmpfile(*args)
   tmp = Tempfile.new(*args)