summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMatt Robinson <matt@puppetlabs.com>2010-07-02 22:19:28 -0700
committerJames Turnbull <james@lovedthanlost.net>2010-09-03 02:53:01 +1000
commit07d0be4684f75e6edc6fbb5d1397dd79b8ca2b6b (patch)
tree9e8aa9c180f8cdff17bc6c000f9d4ce5dcc560d8 /test
parent9e696164237821fb6b48a913395240d376f8c3da (diff)
downloadpuppet-07d0be4684f75e6edc6fbb5d1397dd79b8ca2b6b.tar.gz
puppet-07d0be4684f75e6edc6fbb5d1397dd79b8ca2b6b.tar.xz
puppet-07d0be4684f75e6edc6fbb5d1397dd79b8ca2b6b.zip
[#4308] Remove puppettest from specs
The less stuff being done in the spec_helper the better for reasoning about what's happening in the tests. puppettest.rb does a lot of things that aren't necessary for the specs, so this patch gets those things out of the spec_helper. Reviewed by: Jesse Wolfe
Diffstat (limited to 'test')
-rw-r--r--test/lib/mocha_standalone.rb2
-rwxr-xr-xtest/lib/puppettest.rb22
-rw-r--r--test/lib/puppettest/fakes.rb2
-rw-r--r--test/lib/puppettest/support/assertions.rb2
-rw-r--r--test/lib/puppettest/support/utils.rb45
5 files changed, 27 insertions, 46 deletions
diff --git a/test/lib/mocha_standalone.rb b/test/lib/mocha_standalone.rb
deleted file mode 100644
index ce605811a..000000000
--- a/test/lib/mocha_standalone.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-require 'mocha/standalone'
-require 'mocha/object'
diff --git a/test/lib/puppettest.rb b/test/lib/puppettest.rb
index 294d0ef8d..0b3a89a72 100755
--- a/test/lib/puppettest.rb
+++ b/test/lib/puppettest.rb
@@ -6,17 +6,6 @@ mainlib = File.expand_path(File.join(File.dirname(__FILE__), '../../lib'))
$LOAD_PATH.unshift(mainlib) unless $LOAD_PATH.include?(mainlib)
require 'puppet'
-
-# include any gems in vendor/gems
-Dir["#{mainlib}/../vendor/gems/**"].each do |path|
- libpath = File.join(path, "lib")
- if File.directory?(libpath)
- $LOAD_PATH.unshift(libpath)
- else
- $LOAD_PATH.unshift(path)
- end
-end
-
require 'mocha'
# Only load the test/unit class if we're not in the spec directory.
@@ -31,16 +20,7 @@ if ARGV.include?("-d")
$console = true
end
-# Some monkey-patching to allow us to test private methods.
-class Class
- def publicize_methods(*methods)
- saved_private_instance_methods = methods.empty? ? self.private_instance_methods : methods
-
- self.class_eval { public(*saved_private_instance_methods) }
- yield
- self.class_eval { private(*saved_private_instance_methods) }
- end
-end
+require File.expand_path(File.join(File.dirname(__FILE__), '../../spec/monkey_patches/publicize_methods'))
module PuppetTest
# These need to be here for when rspec tests use these
diff --git a/test/lib/puppettest/fakes.rb b/test/lib/puppettest/fakes.rb
index aaa711004..712332b74 100644
--- a/test/lib/puppettest/fakes.rb
+++ b/test/lib/puppettest/fakes.rb
@@ -1,4 +1,4 @@
-require 'puppettest'
+require File.expand_path(File.join(File.dirname(__FILE__), '../../../lib/puppet/util'))
module PuppetTest
# A baseclass for the faketypes.
diff --git a/test/lib/puppettest/support/assertions.rb b/test/lib/puppettest/support/assertions.rb
index 7f326b119..31fa3f1da 100644
--- a/test/lib/puppettest/support/assertions.rb
+++ b/test/lib/puppettest/support/assertions.rb
@@ -1,8 +1,6 @@
-require 'puppettest'
require 'puppettest/support/utils'
require 'fileutils'
-
module PuppetTest
include PuppetTest::Support::Utils
def assert_logged(level, regex, msg = nil)
diff --git a/test/lib/puppettest/support/utils.rb b/test/lib/puppettest/support/utils.rb
index edc81d3d6..e022f123c 100644
--- a/test/lib/puppettest/support/utils.rb
+++ b/test/lib/puppettest/support/utils.rb
@@ -1,5 +1,3 @@
-require 'puppettest'
-
module PuppetTest::Support
end
module PuppetTest::Support::Utils
@@ -7,6 +5,30 @@ module PuppetTest::Support::Utils
Puppet.warning "#{type}: #{ObjectSpace.each_object(type) { |o| }}"
end
+ def basedir(*list)
+ unless defined? @@basedir
+ Dir.chdir(File.dirname(__FILE__)) do
+ @@basedir = File.dirname(File.dirname(File.dirname(File.dirname(Dir.getwd))))
+ end
+ end
+ if list.empty?
+ @@basedir
+ else
+ File.join(@@basedir, *list)
+ end
+ end
+
+ def fakedata(dir,pat='*')
+ glob = "#{basedir}/test/#{dir}/#{pat}"
+ files = Dir.glob(glob,File::FNM_PATHNAME)
+ raise Puppet::DevError, "No fakedata matching #{glob}" if files.empty?
+ files
+ end
+
+ def datadir(*list)
+ File.join(basedir, "test", "data", *list)
+ end
+
#
# TODO: I think this method needs to be renamed to something a little more
# explanatory.
@@ -38,10 +60,6 @@ module PuppetTest::Support::Utils
config
end
- # stop any services that might be hanging around
- def stopservices
- end
-
# TODO: rewrite this to use the 'etc' module.
# Define a variable that contains the name of my user.
@@ -84,7 +102,7 @@ module PuppetTest::Support::Utils
end
def fakefile(name)
- ary = [PuppetTest.basedir, "test"]
+ ary = [basedir, "test"]
ary += name.split("/")
file = File.join(ary)
raise Puppet::DevError, "No fakedata file #{file}" unless FileTest.exists?(file)
@@ -140,16 +158,3 @@ module PuppetTest::Support::Utils
config
end
end
-
-module PuppetTest
- include PuppetTest::Support::Utils
-
- def fakedata(dir,pat='*')
- glob = "#{basedir}/test/#{dir}/#{pat}"
- files = Dir.glob(glob,File::FNM_PATHNAME)
- raise Puppet::DevError, "No fakedata matching #{glob}" if files.empty?
- files
- end
- module_function :fakedata
-
-end