Skip to content

Instantly share code, notes, and snippets.

@dstnbrkr
Created October 16, 2009 03:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dstnbrkr/211536 to your computer and use it in GitHub Desktop.
Save dstnbrkr/211536 to your computer and use it in GitHub Desktop.
From 092ae12aec59cc8883f6f6454f111df56260338e Mon Sep 17 00:00:00 2001
From: Dustin Barker <dustin.barker@gmail.com>
Date: Thu, 15 Oct 2009 20:49:22 -0700
Subject: [PATCH] If a mock dir exists and is a symlink, resolve it
Fixes specs that fail on Mac OS X due to symlink /var -> /private/var
---
core/dir/fixtures/common.rb | 12 +++++++++++-
1 files changed, 11 insertions(+), 1 deletions(-)
diff --git a/core/dir/fixtures/common.rb b/core/dir/fixtures/common.rb
index 3ae640d..5936ead 100644
--- a/core/dir/fixtures/common.rb
+++ b/core/dir/fixtures/common.rb
@@ -2,7 +2,15 @@ require 'fileutils'
module DirSpecs
def DirSpecs.mock_dir(dirs = ['mock'])
- File.expand_path(tmp(File.join(dirs)))
+ dir = File.expand_path(tmp(File.join(dirs)))
+
+ return dir unless File.exists?(dir)
+
+ segments = dir.split(File::SEPARATOR)
+ root = "#{File::SEPARATOR}#{segments[1]}"
+ realroot = "#{File::SEPARATOR}#{File.readlink(root)}"
+ realdir = File.join(realroot, segments[2, segments.size - 2])
+ realdir
end
def DirSpecs.nonexistent
@@ -135,6 +143,8 @@ module DirSpecs
subdir_two
]
end
+
+
end
--
1.6.4.4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment