tasks/test.rake in nanoc-4.0.0b4 vs tasks/test.rake in nanoc-4.0.0rc1

- old
+ new

@@ -1,41 +1,25 @@ require 'rspec/core/rake_task' +require 'rake/testtask' +require 'coveralls/rake/task' -def run_tests(dir_glob) - ENV['ARGS'] ||= '' - ENV['QUIET'] ||= 'true' +Coveralls::RakeTask.new - $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + '/..')) +SUBDIRS = %w( * base cli data_sources extra filters helpers ) - # require our test helper so we don't have to in each individual test - require 'test/helper' - - test_files = Dir["#{dir_glob}*_spec.rb"] + Dir["#{dir_glob}test_*.rb"] - test_files.each { |f| require f } - - res = Minitest.run(ENV['ARGS'].split) - exit(res) if res != 0 -end - namespace :test do - # test:all - desc 'Run all tests' - task :all do - run_tests 'test/**/' - end - - # test:... - %w( base cli data_sources extra filters helpers ).each do |dir| - desc "Run all #{dir} tests" - task dir.to_sym do |_task| - run_tests "test/#{dir}/**/" + SUBDIRS.each do |dir| + Rake::TestTask.new(dir == '*' ? 'all' : dir) do |t| + t.test_files = Dir["test/#{dir}/**/*_spec.rb"] + Dir["test/#{dir}/**/test_*.rb"] + t.libs = ['./lib', '.'] + t.ruby_opts = ['-r./test/helper'] end end end RSpec::Core::RakeTask.new(:spec) do |t| t.rspec_opts = '-r ./spec/spec_helper.rb --color' t.verbose = false end -desc 'Alias for test:all + rubocop' -task test: [:spec, :'test:all', :rubocop] +desc 'Run all tests and specs' +task test: [:spec, :'test:all', :'coveralls:push']