summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Davis <ryand@zenspider.com>2011-01-05 02:26:20 -0800
committerRyan Davis <ryand@zenspider.com>2011-01-05 02:26:20 -0800
commita7a2093eee8500845415416d7f4cc21614d3c707 (patch)
treeea9d10914e4001bd55b98c4f2b5c122d3100b87a
parent5aab31d703ed97a3e580197449a9e0b75cea41bb (diff)
downloadhoe-a7a2093eee8500845415416d7f4cc21614d3c707.tar.gz
+ Added Hoe::Test#test_prelude to allow for code to run before test loading.
+ Added support for rubygems-test. See http://www.gem-testers.org/ [git-p4: depot-paths = "//src/hoe/dev/": change = 6105]
-rw-r--r--lib/hoe/test.rb25
-rw-r--r--test/test_hoe.rb2
2 files changed, 26 insertions, 1 deletions
diff --git a/lib/hoe/test.rb b/lib/hoe/test.rb
index c294b3b..ffe70bb 100644
--- a/lib/hoe/test.rb
+++ b/lib/hoe/test.rb
@@ -37,6 +37,11 @@ module Hoe::Test
attr_accessor :testlib
##
+ # Optional: Additional ruby to run before the test framework is loaded.
+
+ attr_accessor :test_prelude
+
+ ##
# Optional: RSpec dirs. [default: %w(spec lib)]
attr_accessor :rspec_dirs
@@ -52,6 +57,7 @@ module Hoe::Test
def initialize_test
self.multiruby_skip ||= []
self.testlib ||= :testunit
+ self.test_prelude ||= nil
self.rspec_dirs ||= %w(spec lib)
self.rspec_options ||= []
end
@@ -125,6 +131,23 @@ module Hoe::Test
desc 'Run the default task(s).'
task :default => default_tasks
+ unless default_tasks.empty? then
+ ##
+ # This is for Erik Hollensbe's rubygems-test project. Hoe is
+ # test-happy, so by using this plugin you're already testable. For
+ # more information, see: <https://github.com/erikh/rubygems-test>
+ # and/or <http://www.gem-testers.org/>
+
+ self.spec.files += [".gemtest"]
+
+ pkg = pkg_path
+ turd = "#{pkg}/.gemtest"
+
+ task pkg do
+ touch turd
+ end
+ end
+
desc 'Run ZenTest against the package.'
task :audit do
libs = %w(lib test ext).join(File::PATH_SEPARATOR)
@@ -143,6 +166,8 @@ module Hoe::Test
test_globs.map { |g| Dir.glob(g) }.flatten
tests.map! {|f| %(require "#{f}")}
+ tests.insert 1, test_prelude if test_prelude
+
cmd = "#{Hoe::RUBY_FLAGS} -e '#{tests.join("; ")}' -- #{FILTER}"
if multi then
diff --git a/test/test_hoe.rb b/test/test_hoe.rb
index 154981e..36422a8 100644
--- a/test/test_hoe.rb
+++ b/test/test_hoe.rb
@@ -24,7 +24,7 @@ class TestHoe < MiniTest::Unit::TestCase
developer 'author', 'email'
end
- files = File.read("Manifest.txt").split(/\n/)
+ files = File.read("Manifest.txt").split(/\n/) + [".gemtest"]
spec = hoe.spec