tasks/test.rake in nanoc-3.6.6 vs tasks/test.rake in nanoc-3.6.7
- old
+ new
@@ -1,43 +1,34 @@
# encoding: utf-8
-require 'minitest/unit'
+def run_tests(dir_glob)
+ ENV['ARGS'] ||= ''
+ ENV['QUIET'] ||= 'true'
-test = namespace :test do
+ $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + '/..'))
- # test:all
- desc 'Run all tests'
- task :all do
- ENV['QUIET'] ||= 'true'
- $VERBOSE = (ENV['VERBOSE'] == 'true')
+ # require our test helper so we don't have to in each individual test
+ require 'test/helper'
- $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + '/..'))
+ test_files = Dir["#{dir_glob}*_spec.rb"] + Dir["#{dir_glob}test_*.rb"]
+ test_files.each { |f| require f }
- # require our test helper so we don't have to in each individual test
- require 'test/helper'
+ exit MiniTest::Unit.new.run(ENV['ARGS'].split)
+end
- test_files = Dir['test/**/*_spec.rb'] + Dir['test/**/test_*.rb']
- test_files.each { |f| require f }
+namespace :test do
- exit MiniTest::Unit.new.run($VERBOSE ? %w( --verbose ) : %w())
+ # test:all
+ desc 'Run all tests'
+ task :all do
+ run_tests "test/**/"
end
# test:...
%w( base cli data_sources extra filters helpers tasks ).each do |dir|
desc "Run all #{dir} tests"
task dir.to_sym do |task|
- ENV['QUIET'] ||= 'true'
- $VERBOSE = (ENV['VERBOSE'] == 'true')
-
- $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + '/..'))
-
- # require our test helper so we don't have to in each individual test
- require 'test/helper'
-
- test_files = Dir["test/#{dir}/**/*_spec.rb"] + Dir["test/#{dir}/**/test_*.rb"]
- test_files.each { |f| require f }
-
- exit MiniTest::Unit.new.run($VERBOSE ? %w( --verbose ) : %w())
+ run_tests "test/#{dir}/**/"
end
end
end