不知怎的,Rspec和Cucumber正在将它变成我的默认rake任务(这很好,因为我想要它们).但我已尝试将其他任务添加到默认任务,但它没有任何效果.
将任务添加到默认rake任务的正确方法是什么?
dav*_*nes 47
通常你的Rakefile会有这样的东西:
task :default => [:spec]
Run Code Online (Sandbox Code Playgroud)
您只需要在此列表中添加更多任务.
来自davogenes的答案对于非命名空间的 rake 任务是正确的。
如果你想在命名空间中有一个默认任务,你需要执行以下操作
namespace :mynamespace do
desc "This should be the default"
task :mydefault do
Do.something_by_default
end
desc "Another task in this namespace"
task :other do
Do.something
end
end
desc "This is the default task of mynamespace"
task mynamespace: 'mynamespace:mydefault'
Run Code Online (Sandbox Code Playgroud)
然后你可以rake mynamespace像rake mynamespace:other或一样运行rake mynamespace:mydefault。