vendredi 1 mai 2015

How do you use multiple tasks using Rake::TestTask?

I am running Minitest with Rake and would like to have two separate Rake tasks.

I have added the following:

require 'rake/testtask'

task :default => [:test]
task :quick => [:unit]

Rake::TestTask.new do |t|
  puts 'within test task'
  t.libs.push 'specs'
  t.pattern = 'specs/*_spec.rb'
  ENV['STACK'] = 'stack1'
  puts "test stack #{ENV['STACK']}"
end


Rake::TestTask.new('unit') do |t|
  puts 'within unit task'
  t.libs.push 'specs'
  t.pattern = 'specs/*_unit.rb'
  ENV['STACK'] = 'stack2'
  puts "test stack #{ENV['STACK']}"
end

When I run bundle exec rake quick then I get this output:

within test task
test stack stack1
within unit task
test stack stack2

I did not expect both the tasks to run. How do I create and run two separate rake tasks? As it is now, the second one always overwrites the environment variable.

Thanks

Aucun commentaire:

Enregistrer un commentaire