summaryrefslogtreecommitdiffstats
path: root/spec/unit
diff options
context:
space:
mode:
authorMatt Robinson <matt@puppetlabs.com>2011-03-22 11:31:14 -0700
committerMatt Robinson <matt@puppetlabs.com>2011-03-22 11:39:24 -0700
commitf6da3339f59bbd9243a03dc1e417b1fed7955c7e (patch)
treecc264fef5811c7d5e8000bc4048bab86b87064a0 /spec/unit
parent307df20d7dfd4f5a2a3b67fc2587491560ee951c (diff)
downloadpuppet-f6da3339f59bbd9243a03dc1e417b1fed7955c7e.tar.gz
puppet-f6da3339f59bbd9243a03dc1e417b1fed7955c7e.tar.xz
puppet-f6da3339f59bbd9243a03dc1e417b1fed7955c7e.zip
maint: Change code for finding spec_helper to work with Ruby 1.9
Running the specs under Ruby 1.9 didn't work using the lambda to recurse down directories to find the spec_helper. Standardizing the way to find spec_helper like the rest of specs seemed like the way to go. Here's the command line perl I used to make the change: perl -p -i -e "s/Dir.chdir.*lambda.*spec_helper.*$/require File.expand_path(File.dirname(__FILE__) + '\/..\/..\/spec_helper')/" `find spec -name "*_spec.rb"` Then I fixed the number of dots for files that weren't two levels from the spec dir and whose tests failed. Reviewed-by: Nick Lewis <nick@puppetlabs.com>
Diffstat (limited to 'spec/unit')
-rwxr-xr-xspec/unit/indirector/file_bucket_file/rest_spec.rb2
-rwxr-xr-xspec/unit/indirector/resource/rest_spec.rb2
-rwxr-xr-xspec/unit/indirector/status/rest_spec.rb2
-rw-r--r--spec/unit/network/http/api/v1_spec.rb2
-rwxr-xr-xspec/unit/network/xmlrpc/client_spec.rb2
-rw-r--r--spec/unit/property/ensure_spec.rb2
-rw-r--r--spec/unit/property/keyvalue_spec.rb2
-rw-r--r--spec/unit/property/list_spec.rb2
-rw-r--r--spec/unit/property/ordered_list_spec.rb2
-rwxr-xr-xspec/unit/provider/package/apt_spec.rb2
-rwxr-xr-xspec/unit/provider/package/dpkg_spec.rb2
-rw-r--r--spec/unit/provider/package/pkg_spec.rb2
-rwxr-xr-xspec/unit/provider/package/pkgdmg_spec.rb2
-rwxr-xr-xspec/unit/provider/selboolean_spec.rb2
-rwxr-xr-xspec/unit/provider/selmodule_spec.rb2
-rw-r--r--spec/unit/reports/http_spec.rb2
-rw-r--r--spec/unit/reports/rrdgraph_spec.rb2
-rw-r--r--spec/unit/reports/store_spec.rb2
-rwxr-xr-xspec/unit/reports/tagmail_spec.rb2
-rwxr-xr-xspec/unit/type/cron_spec.rb2
-rw-r--r--spec/unit/type/file/checksum_spec.rb2
-rwxr-xr-xspec/unit/type/file/content_spec.rb2
-rw-r--r--spec/unit/type/file/ctime.rb2
-rwxr-xr-xspec/unit/type/file/ensure_spec.rb2
-rwxr-xr-xspec/unit/type/file/group_spec.rb2
-rw-r--r--spec/unit/type/file/mtime.rb2
-rwxr-xr-xspec/unit/type/file/owner_spec.rb2
-rw-r--r--spec/unit/type/file/selinux_spec.rb2
-rwxr-xr-xspec/unit/type/file/source_spec.rb2
-rw-r--r--spec/unit/type/file/type.rb2
-rwxr-xr-xspec/unit/type/maillist_spec.rb2
-rwxr-xr-xspec/unit/type/selboolean_spec.rb2
-rwxr-xr-xspec/unit/type/selmodule_spec.rb2
-rwxr-xr-xspec/unit/type/zfs_spec.rb2
-rwxr-xr-xspec/unit/type/zone_spec.rb2
-rwxr-xr-xspec/unit/type/zpool_spec.rb2
-rwxr-xr-xspec/unit/util/autoload_spec.rb2
-rwxr-xr-xspec/unit/util/command_line_spec.rb2
-rwxr-xr-xspec/unit/util/errors_spec.rb2
-rwxr-xr-xspec/unit/util/feature_spec.rb2
-rwxr-xr-xspec/unit/util/file_locking_spec.rb2
-rw-r--r--spec/unit/util/filetype_spec.rb2
-rwxr-xr-xspec/unit/util/inline_docs_spec.rb2
-rwxr-xr-xspec/unit/util/log_spec.rb2
-rwxr-xr-xspec/unit/util/logging_spec.rb2
-rwxr-xr-xspec/unit/util/metric_spec.rb2
-rw-r--r--spec/unit/util/monkey_patches_spec.rb2
-rwxr-xr-xspec/unit/util/posix_spec.rb2
-rwxr-xr-xspec/unit/util/pson_spec.rb2
-rwxr-xr-xspec/unit/util/rdoc/parser_spec.rb2
-rwxr-xr-xspec/unit/util/rdoc_spec.rb2
-rw-r--r--spec/unit/util/user_attr_spec.rb2
-rwxr-xr-xspec/unit/util/zaml_spec.rb2
53 files changed, 53 insertions, 53 deletions
diff --git a/spec/unit/indirector/file_bucket_file/rest_spec.rb b/spec/unit/indirector/file_bucket_file/rest_spec.rb
index 960f60ae7..d0f714751 100755
--- a/spec/unit/indirector/file_bucket_file/rest_spec.rb
+++ b/spec/unit/indirector/file_bucket_file/rest_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") }
+require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
require 'puppet/indirector/file_bucket_file/rest'
diff --git a/spec/unit/indirector/resource/rest_spec.rb b/spec/unit/indirector/resource/rest_spec.rb
index 351aee33b..1285d338a 100755
--- a/spec/unit/indirector/resource/rest_spec.rb
+++ b/spec/unit/indirector/resource/rest_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") }
+require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
require 'puppet/indirector/resource/rest'
diff --git a/spec/unit/indirector/status/rest_spec.rb b/spec/unit/indirector/status/rest_spec.rb
index 5eed5fc93..436c86881 100755
--- a/spec/unit/indirector/status/rest_spec.rb
+++ b/spec/unit/indirector/status/rest_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") }
+require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
require 'puppet/indirector/status/rest'
diff --git a/spec/unit/network/http/api/v1_spec.rb b/spec/unit/network/http/api/v1_spec.rb
index 25f6d8fe2..257eec5de 100644
--- a/spec/unit/network/http/api/v1_spec.rb
+++ b/spec/unit/network/http/api/v1_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") }
+require File.expand_path(File.dirname(__FILE__) + '/../../../../spec_helper')
require 'puppet/network/http/api/v1'
diff --git a/spec/unit/network/xmlrpc/client_spec.rb b/spec/unit/network/xmlrpc/client_spec.rb
index 8440d39fa..7498ca4cf 100755
--- a/spec/unit/network/xmlrpc/client_spec.rb
+++ b/spec/unit/network/xmlrpc/client_spec.rb
@@ -1,7 +1,7 @@
#!/usr/bin/env ruby
require 'puppet/network/client'
-Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") }
+require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
describe Puppet::Network::XMLRPCClient do
describe "when performing the rpc call" do
diff --git a/spec/unit/property/ensure_spec.rb b/spec/unit/property/ensure_spec.rb
index f2722de89..d3029c658 100644
--- a/spec/unit/property/ensure_spec.rb
+++ b/spec/unit/property/ensure_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") }
+require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
require 'puppet/property/ensure'
diff --git a/spec/unit/property/keyvalue_spec.rb b/spec/unit/property/keyvalue_spec.rb
index a44d891d7..a0175cfa3 100644
--- a/spec/unit/property/keyvalue_spec.rb
+++ b/spec/unit/property/keyvalue_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") }
+require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
require 'puppet/property/keyvalue'
diff --git a/spec/unit/property/list_spec.rb b/spec/unit/property/list_spec.rb
index c6c5db10e..704fbe3d9 100644
--- a/spec/unit/property/list_spec.rb
+++ b/spec/unit/property/list_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") }
+require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
require 'puppet/property/list'
diff --git a/spec/unit/property/ordered_list_spec.rb b/spec/unit/property/ordered_list_spec.rb
index 7c8eceb0d..460bec79d 100644
--- a/spec/unit/property/ordered_list_spec.rb
+++ b/spec/unit/property/ordered_list_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") }
+require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
require 'puppet/property/ordered_list'
diff --git a/spec/unit/provider/package/apt_spec.rb b/spec/unit/provider/package/apt_spec.rb
index 3c6bf62af..b0ce4f799 100755
--- a/spec/unit/provider/package/apt_spec.rb
+++ b/spec/unit/provider/package/apt_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") }
+require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
provider = Puppet::Type.type(:package).provider(:apt)
diff --git a/spec/unit/provider/package/dpkg_spec.rb b/spec/unit/provider/package/dpkg_spec.rb
index 47ac9766e..444fb31c1 100755
--- a/spec/unit/provider/package/dpkg_spec.rb
+++ b/spec/unit/provider/package/dpkg_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") }
+require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
provider = Puppet::Type.type(:package).provider(:dpkg)
diff --git a/spec/unit/provider/package/pkg_spec.rb b/spec/unit/provider/package/pkg_spec.rb
index 1544b8b7e..3455c4c40 100644
--- a/spec/unit/provider/package/pkg_spec.rb
+++ b/spec/unit/provider/package/pkg_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") }
+require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
provider = Puppet::Type.type(:package).provider(:pkg)
diff --git a/spec/unit/provider/package/pkgdmg_spec.rb b/spec/unit/provider/package/pkgdmg_spec.rb
index 1fd5b4ac4..86631e596 100755
--- a/spec/unit/provider/package/pkgdmg_spec.rb
+++ b/spec/unit/provider/package/pkgdmg_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") }
+require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
provider = Puppet::Type.type(:package).provider(:pkgdmg)
diff --git a/spec/unit/provider/selboolean_spec.rb b/spec/unit/provider/selboolean_spec.rb
index b37b44b45..02a39f2a7 100755
--- a/spec/unit/provider/selboolean_spec.rb
+++ b/spec/unit/provider/selboolean_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") }
+require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
provider_class = Puppet::Type.type(:selboolean).provider(:getsetsebool)
diff --git a/spec/unit/provider/selmodule_spec.rb b/spec/unit/provider/selmodule_spec.rb
index fda6d0d78..cb143e993 100755
--- a/spec/unit/provider/selmodule_spec.rb
+++ b/spec/unit/provider/selmodule_spec.rb
@@ -5,7 +5,7 @@
# with version 1.5.0. The provided selmodule-example.pp is the first
# 256 bytes taken from /usr/share/selinux/targeted/nagios.pp on Fedora 9
-Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") }
+require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
provider_class = Puppet::Type.type(:selmodule).provider(:semodule)
diff --git a/spec/unit/reports/http_spec.rb b/spec/unit/reports/http_spec.rb
index 70742f7dc..a62793ed5 100644
--- a/spec/unit/reports/http_spec.rb
+++ b/spec/unit/reports/http_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") }
+require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
require 'puppet/reports'
diff --git a/spec/unit/reports/rrdgraph_spec.rb b/spec/unit/reports/rrdgraph_spec.rb
index ce2cf7905..5215f1dcc 100644
--- a/spec/unit/reports/rrdgraph_spec.rb
+++ b/spec/unit/reports/rrdgraph_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") }
+require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
require 'puppet/reports'
diff --git a/spec/unit/reports/store_spec.rb b/spec/unit/reports/store_spec.rb
index 9d9042386..d48f6a846 100644
--- a/spec/unit/reports/store_spec.rb
+++ b/spec/unit/reports/store_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") }
+require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
require 'puppet/reports'
require 'time'
diff --git a/spec/unit/reports/tagmail_spec.rb b/spec/unit/reports/tagmail_spec.rb
index fa8990ebb..716bcbc04 100755
--- a/spec/unit/reports/tagmail_spec.rb
+++ b/spec/unit/reports/tagmail_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") }
+require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
require 'puppet/reports'
diff --git a/spec/unit/type/cron_spec.rb b/spec/unit/type/cron_spec.rb
index 03817d20e..4d224c64b 100755
--- a/spec/unit/type/cron_spec.rb
+++ b/spec/unit/type/cron_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") }
+require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
describe Puppet::Type.type(:cron) do
before do
diff --git a/spec/unit/type/file/checksum_spec.rb b/spec/unit/type/file/checksum_spec.rb
index 8b9138b78..16e8e99e1 100644
--- a/spec/unit/type/file/checksum_spec.rb
+++ b/spec/unit/type/file/checksum_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") }
+require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
checksum = Puppet::Type.type(:file).attrclass(:checksum)
describe checksum do
diff --git a/spec/unit/type/file/content_spec.rb b/spec/unit/type/file/content_spec.rb
index bd2b2adaf..7abc7c433 100755
--- a/spec/unit/type/file/content_spec.rb
+++ b/spec/unit/type/file/content_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") }
+require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
content = Puppet::Type.type(:file).attrclass(:content)
describe content do
diff --git a/spec/unit/type/file/ctime.rb b/spec/unit/type/file/ctime.rb
index 6145cbfdc..9fb892aed 100644
--- a/spec/unit/type/file/ctime.rb
+++ b/spec/unit/type/file/ctime.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") }
+require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
describe Puppet::Type.type(:file).attrclass(:ctime) do
require 'puppet_spec/files'
diff --git a/spec/unit/type/file/ensure_spec.rb b/spec/unit/type/file/ensure_spec.rb
index dbb3a1053..c5351309e 100755
--- a/spec/unit/type/file/ensure_spec.rb
+++ b/spec/unit/type/file/ensure_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") }
+require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
property = Puppet::Type.type(:file).attrclass(:ensure)
diff --git a/spec/unit/type/file/group_spec.rb b/spec/unit/type/file/group_spec.rb
index 956cd57e7..37a6872bd 100755
--- a/spec/unit/type/file/group_spec.rb
+++ b/spec/unit/type/file/group_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") }
+require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
property = Puppet::Type.type(:file).attrclass(:group)
diff --git a/spec/unit/type/file/mtime.rb b/spec/unit/type/file/mtime.rb
index 043156ceb..fa61bc343 100644
--- a/spec/unit/type/file/mtime.rb
+++ b/spec/unit/type/file/mtime.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") }
+require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
describe Puppet::Type.type(:file).attrclass(:mtime) do
require 'puppet_spec/files'
diff --git a/spec/unit/type/file/owner_spec.rb b/spec/unit/type/file/owner_spec.rb
index bcb8e07d6..375faa237 100755
--- a/spec/unit/type/file/owner_spec.rb
+++ b/spec/unit/type/file/owner_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") }
+require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
property = Puppet::Type.type(:file).attrclass(:owner)
diff --git a/spec/unit/type/file/selinux_spec.rb b/spec/unit/type/file/selinux_spec.rb
index a2444acd9..45e8b3b14 100644
--- a/spec/unit/type/file/selinux_spec.rb
+++ b/spec/unit/type/file/selinux_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") }
+require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
[:seluser, :selrole, :seltype, :selrange].each do |param|
diff --git a/spec/unit/type/file/source_spec.rb b/spec/unit/type/file/source_spec.rb
index c07963a50..bb83e7531 100755
--- a/spec/unit/type/file/source_spec.rb
+++ b/spec/unit/type/file/source_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") }
+require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
source = Puppet::Type.type(:file).attrclass(:source)
describe Puppet::Type.type(:file).attrclass(:source) do
diff --git a/spec/unit/type/file/type.rb b/spec/unit/type/file/type.rb
index e46f0e0b0..0d38b64cd 100644
--- a/spec/unit/type/file/type.rb
+++ b/spec/unit/type/file/type.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") }
+require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
describe Puppet::Type.type(:file).attrclass(:type) do
require 'puppet_spec/files'
diff --git a/spec/unit/type/maillist_spec.rb b/spec/unit/type/maillist_spec.rb
index 04acea7dd..7e96b4760 100755
--- a/spec/unit/type/maillist_spec.rb
+++ b/spec/unit/type/maillist_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") }
+require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
maillist = Puppet::Type.type(:maillist)
diff --git a/spec/unit/type/selboolean_spec.rb b/spec/unit/type/selboolean_spec.rb
index 3b31f4306..41b254f25 100755
--- a/spec/unit/type/selboolean_spec.rb
+++ b/spec/unit/type/selboolean_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") }
+require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
describe Puppet::Type.type(:selboolean), "when validating attributes" do
[:name, :persistent].each do |param|
diff --git a/spec/unit/type/selmodule_spec.rb b/spec/unit/type/selmodule_spec.rb
index 3d126256c..37453d8ed 100755
--- a/spec/unit/type/selmodule_spec.rb
+++ b/spec/unit/type/selmodule_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") }
+require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
describe Puppet::Type.type(:selmodule), "when validating attributes" do
[:name, :selmoduledir, :selmodulepath].each do |param|
diff --git a/spec/unit/type/zfs_spec.rb b/spec/unit/type/zfs_spec.rb
index 6b0b17f3a..88193fca3 100755
--- a/spec/unit/type/zfs_spec.rb
+++ b/spec/unit/type/zfs_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") }
+require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
zfs = Puppet::Type.type(:zfs)
diff --git a/spec/unit/type/zone_spec.rb b/spec/unit/type/zone_spec.rb
index a3e748bde..e479fb1e9 100755
--- a/spec/unit/type/zone_spec.rb
+++ b/spec/unit/type/zone_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") }
+require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
zone = Puppet::Type.type(:zone)
diff --git a/spec/unit/type/zpool_spec.rb b/spec/unit/type/zpool_spec.rb
index be8cb12ba..96e7d548c 100755
--- a/spec/unit/type/zpool_spec.rb
+++ b/spec/unit/type/zpool_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") }
+require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
zpool = Puppet::Type.type(:zpool)
diff --git a/spec/unit/util/autoload_spec.rb b/spec/unit/util/autoload_spec.rb
index eb0b705f4..808885dd7 100755
--- a/spec/unit/util/autoload_spec.rb
+++ b/spec/unit/util/autoload_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") }
+require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
require 'puppet/util/autoload'
diff --git a/spec/unit/util/command_line_spec.rb b/spec/unit/util/command_line_spec.rb
index 98ddb92f6..a7d261dcf 100755
--- a/spec/unit/util/command_line_spec.rb
+++ b/spec/unit/util/command_line_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") }
+require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
require 'puppet/util/command_line'
diff --git a/spec/unit/util/errors_spec.rb b/spec/unit/util/errors_spec.rb
index 2500403d0..da1b8b0bd 100755
--- a/spec/unit/util/errors_spec.rb
+++ b/spec/unit/util/errors_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") }
+require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
require 'puppet/util/errors'
diff --git a/spec/unit/util/feature_spec.rb b/spec/unit/util/feature_spec.rb
index 8cedade7d..365428752 100755
--- a/spec/unit/util/feature_spec.rb
+++ b/spec/unit/util/feature_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") }
+require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
require 'puppet/util/feature'
diff --git a/spec/unit/util/file_locking_spec.rb b/spec/unit/util/file_locking_spec.rb
index 8fafb1d52..e9dbe9d7b 100755
--- a/spec/unit/util/file_locking_spec.rb
+++ b/spec/unit/util/file_locking_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") }
+require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
require 'puppet/util/file_locking'
diff --git a/spec/unit/util/filetype_spec.rb b/spec/unit/util/filetype_spec.rb
index 68ef9d6eb..012631b91 100644
--- a/spec/unit/util/filetype_spec.rb
+++ b/spec/unit/util/filetype_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") }
+require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
require 'puppet/util/filetype'
diff --git a/spec/unit/util/inline_docs_spec.rb b/spec/unit/util/inline_docs_spec.rb
index edfa405a1..75afb57cb 100755
--- a/spec/unit/util/inline_docs_spec.rb
+++ b/spec/unit/util/inline_docs_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") }
+require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
require 'puppet/util/inline_docs'
diff --git a/spec/unit/util/log_spec.rb b/spec/unit/util/log_spec.rb
index 29df0787a..3c8577493 100755
--- a/spec/unit/util/log_spec.rb
+++ b/spec/unit/util/log_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") }
+require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
require 'puppet/util/log'
diff --git a/spec/unit/util/logging_spec.rb b/spec/unit/util/logging_spec.rb
index 411cd17a9..97ffc0b25 100755
--- a/spec/unit/util/logging_spec.rb
+++ b/spec/unit/util/logging_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") }
+require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
require 'puppet/util/logging'
diff --git a/spec/unit/util/metric_spec.rb b/spec/unit/util/metric_spec.rb
index 600b88f85..425812297 100755
--- a/spec/unit/util/metric_spec.rb
+++ b/spec/unit/util/metric_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") }
+require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
require 'puppet/util/metric'
diff --git a/spec/unit/util/monkey_patches_spec.rb b/spec/unit/util/monkey_patches_spec.rb
index 049ed1044..8bfcd900e 100644
--- a/spec/unit/util/monkey_patches_spec.rb
+++ b/spec/unit/util/monkey_patches_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") }
+require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
require 'puppet/util/monkey_patches'
diff --git a/spec/unit/util/posix_spec.rb b/spec/unit/util/posix_spec.rb
index dbc90d9d0..6d7351220 100755
--- a/spec/unit/util/posix_spec.rb
+++ b/spec/unit/util/posix_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") }
+require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
require 'puppet/util/posix'
diff --git a/spec/unit/util/pson_spec.rb b/spec/unit/util/pson_spec.rb
index 474ddafa4..08758ee38 100755
--- a/spec/unit/util/pson_spec.rb
+++ b/spec/unit/util/pson_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") }
+require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
require 'puppet/util/pson'
diff --git a/spec/unit/util/rdoc/parser_spec.rb b/spec/unit/util/rdoc/parser_spec.rb
index 8545def54..ab54c8cd3 100755
--- a/spec/unit/util/rdoc/parser_spec.rb
+++ b/spec/unit/util/rdoc/parser_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") }
+require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
require 'puppet/resource/type_collection'
require 'puppet/util/rdoc/parser'
diff --git a/spec/unit/util/rdoc_spec.rb b/spec/unit/util/rdoc_spec.rb
index 93c4f9bfa..3b5248528 100755
--- a/spec/unit/util/rdoc_spec.rb
+++ b/spec/unit/util/rdoc_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") }
+require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
require 'puppet/util/rdoc'
require 'rdoc/rdoc'
diff --git a/spec/unit/util/user_attr_spec.rb b/spec/unit/util/user_attr_spec.rb
index 61312ef19..5acdaee58 100644
--- a/spec/unit/util/user_attr_spec.rb
+++ b/spec/unit/util/user_attr_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") }
+require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
require 'puppet/util/user_attr'
diff --git a/spec/unit/util/zaml_spec.rb b/spec/unit/util/zaml_spec.rb
index 358c6aa11..804aa8e58 100755
--- a/spec/unit/util/zaml_spec.rb
+++ b/spec/unit/util/zaml_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") }
+require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
require 'puppet/util/monkey_patches'