2011-09-30 54 views
9

Rake任務遭受與運行測試相同的問題:Rails啓動過程需要很長時間才能運行任務。spork可以使用rake任務嗎?

有沒有辦法將spork和rake結合在一起?

+0

我加了下面的宙斯(HTTPS我自己的答案:// github上。 COM /伯克/宙斯)。還有DHH正在開發的rails/command gem(https://github.com/rails/commands)。 – matthuhiggins

回答

4

我今天發現了宙斯。這是有史以來最好的東西,所以我改變了我的答案宙斯:

https://github.com/burke/zeus

宙斯耙我:特殊:任務

+0

迷人的...... *打開tricorder * – thekingoftruth

+0

宙斯在Windows上不工作,所以它不適合我。 –

1

我知道沒有標準的開箱即用解決方案。

Rake沒有--drb選項,spork在這裏沒有幫助。 當然,自定義解決方案是可能的。這將需要擴展耙子。

我認爲rake任務的運行並不像測試那麼頻繁,爲什麼問題還沒有解決。

+0

謝謝。我基本上想要像spin這樣的東西(https://github.com/jstorimer/spin),它分叉了一個加載的Rails進程和所有的gem。 – matthuhiggins

3
rake test:units 
testdrb -I test/ test/unit/ 

rake test:functionals 
testdrb -I test/ test/functional/ 

rake test:integration 
testdrb -I test/ test/integration/ 
+0

哦,上帝,我愛你的男人......這是我需要的命令:D – lfzawacki

7

您可以使用irake gem,它可以從控制檯執行rake任務。

一下添加到Gemfile中:

gem 'irake' 

然後捆綁並啓動控制檯

$ bundle install 
$ rails console 

...並等待Rails環境載入(僅一次)。然後,你可以這樣做:

rake "db:migrate" 

如果要列出的任務,您可以:

Rake::Task.tasks.each{|t| puts t.name }; nil