summaryrefslogtreecommitdiff
path: root/spec/lib/puppet_spec/files.rb
diff options
context:
space:
mode:
authorBranan Purvine-Riley <branan@puppetlabs.com>2012-05-29 13:55:26 -0700
committerBranan Purvine-Riley <branan@puppetlabs.com>2012-05-29 15:53:46 -0700
commit2247df4f6e828d6791a46cb12d4e2df2e0b98dce (patch)
tree6c402ed6bbe5cfe916db54a24ce4495719598035 /spec/lib/puppet_spec/files.rb
parentcf7ac0286043d01aa807743d75574d450536582d (diff)
downloadpuppet-stdlib-2247df4f6e828d6791a46cb12d4e2df2e0b98dce.tar.gz
puppet-stdlib-2247df4f6e828d6791a46cb12d4e2df2e0b98dce.tar.bz2
Update for new gem version of puppetlabs_spec_helper
This updates the Rakefile and spec_helper to use the common versions available in the puppetlabs_spec_helper rubygem branch. This mostly just removes a bunch of duplicated code, but it also gives us more flexibility in how the module is tested in the future.
Diffstat (limited to 'spec/lib/puppet_spec/files.rb')
-rwxr-xr-xspec/lib/puppet_spec/files.rb53
1 files changed, 0 insertions, 53 deletions
diff --git a/spec/lib/puppet_spec/files.rb b/spec/lib/puppet_spec/files.rb
deleted file mode 100755
index 30fb4fc..0000000
--- a/spec/lib/puppet_spec/files.rb
+++ /dev/null
@@ -1,53 +0,0 @@
-require 'fileutils'
-require 'tempfile'
-
-# A support module for testing files.
-module PuppetSpec::Files
- # This code exists only to support tests that run as root, pretty much.
- # Once they have finally been eliminated this can all go... --daniel 2011-04-08
- if Puppet.features.posix? then
- def self.in_tmp(path)
- path =~ /^\/tmp/ or path =~ /^\/var\/folders/
- end
- elsif Puppet.features.microsoft_windows?
- def self.in_tmp(path)
- tempdir = File.expand_path(File.join(Dir::LOCAL_APPDATA, "Temp"))
- path =~ /^#{tempdir}/
- end
- else
- fail "Help! Can't find in_tmp for this platform"
- end
-
- def self.cleanup
- $global_tempfiles ||= []
- while path = $global_tempfiles.pop do
- fail "Not deleting tmpfile #{path} outside regular tmpdir" unless in_tmp(path)
-
- begin
- FileUtils.rm_r path, :secure => true
- rescue Errno::ENOENT
- # nothing to do
- end
- end
- end
-
- def tmpfile(name)
- # Generate a temporary file, just for the name...
- source = Tempfile.new(name)
- path = source.path
- source.close!
-
- # ...record it for cleanup,
- $global_tempfiles ||= []
- $global_tempfiles << File.expand_path(path)
-
- # ...and bam.
- path
- end
-
- def tmpdir(name)
- path = tmpfile(name)
- FileUtils.mkdir_p(path)
- path
- end
-end