【发布时间】:2015-07-11 06:07:34
【问题描述】:
我正在使用 Rake 运行 Minitest,并希望有两个单独的 Rake 任务。
我添加了以下内容:
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
当我运行 bundle exec rake quick 时,我会得到以下输出:
within test task
test stack stack1
within unit task
test stack stack2
我没想到这两个任务都会运行。如何创建和运行两个单独的 rake 任务?就像现在一样,第二个总是覆盖环境变量。
谢谢
【问题讨论】:
标签: ruby testing rake minitest rake-task