summaryrefslogtreecommitdiff
path: root/spec/support
diff options
context:
space:
mode:
authorjkeiser <jkeiser@opscode.com>2013-01-04 15:04:35 -0800
committerJohn Keiser <jkeiser@opscode.com>2013-06-07 13:12:16 -0700
commit2b450f0606bd29cb65b9da59f4480aa1e87b5c15 (patch)
tree042a04a29055c3c7adbea5e101f47b8aab4fe671 /spec/support
parent8816deca2bc5de2b33b59d95e18cb8e58577b386 (diff)
downloadchef-2b450f0606bd29cb65b9da59f4480aa1e87b5c15.tar.gz
Make cwd detection work when repo dir is a symlink
Diffstat (limited to 'spec/support')
-rw-r--r--spec/support/shared/integration/integration_helper.rb28
1 files changed, 28 insertions, 0 deletions
diff --git a/spec/support/shared/integration/integration_helper.rb b/spec/support/shared/integration/integration_helper.rb
index fde763c5e4..b15e90c440 100644
--- a/spec/support/shared/integration/integration_helper.rb
+++ b/spec/support/shared/integration/integration_helper.rb
@@ -73,10 +73,22 @@ module IntegrationSupport
end
end
+ def symlink(relative_path, relative_dest)
+ filename = path_to(relative_path)
+ dir = File.dirname(filename)
+ FileUtils.mkdir_p(dir) unless dir == '.'
+ dest_filename = path_to(relative_dest)
+ File.symlink(dest_filename, filename)
+ end
+
def path_to(relative_path)
File.expand_path(relative_path, (@parent_path || @repository_dir))
end
+ def self.path_to(relative_path)
+ File.expand_path(relative_path, (@parent_path || @repository_dir))
+ end
+
def self.directory(relative_path, &block)
before :each do
directory(relative_path, &block)
@@ -89,6 +101,22 @@ module IntegrationSupport
end
end
+ def self.symlink(relative_path, relative_dest)
+ before :each do
+ symlink(relative_path, relative_dest)
+ end
+ end
+
+ def self.cwd(relative_path)
+ before :each do
+ @old_cwd = Dir.pwd
+ Dir.chdir(path_to(relative_path))
+ end
+ after :each do
+ Dir.chdir(@old_cwd)
+ end
+ end
+
instance_eval(&block)
end
end