2012-12-06 22 views
4

我已經建立了spec/javascripts/spec.js.coffee,並有spec/javascripts 3個測試的一個spec文件。當我在瀏覽器中運行茉莉花時,3個測試運行。從命令行運行守衛茉莉花不運行任何規格

當我跑衛和啓動並運行後衛,茉莉,它發現並運行了所有的考試,就像這樣:

$ bundle exec guard 
Guard uses GNTP to send notifications. 
Guard is now watching at '/workpath' 
Guard::Jasmine starts Unicorn test server on port 52512 in development environment. 
Waiting for Jasmine test runner at http://localhost:52512/jasmine 
Run all Jasmine suites 
Run Jasmine suite at http://localhost:52512/jasmine 

Finished in 0.013 seconds 
3 specs, 0 failures 
Done. 

但是,當我從終端運行guard-jasmine,沒有規範的發現:

$ guard-jasmine 
Guard::Jasmine starts Unicorn test server on port 53307 in test environment. 
Waiting for Jasmine test runner at http://localhost:53307/jasmine 
Run all Jasmine suites 
Run Jasmine suite at http://localhost:53307/jasmine 

Finished in 0.001 seconds 
0 specs, 0 failures 
Done. 

Guard::Jasmine stops server. 

任何想法,我需要改變,以幫助CLI亞軍找到我的規格?

謝謝。

編輯:加入相關Guardfile信息:

guard :jasmine, timeout: 120, server_timeout: 120, server_env: "test" do 
    watch(%r{spec/javascripts/spec\.(js\.coffee|js|coffee)$}) { 'spec/javascripts' } 
    watch(%r{spec/javascripts/.+_spec\.(js\.coffee|js|coffee)$}) 
    watch(%r{app/assets/javascripts/(.+?)\.(js\.coffee|js|coffee)(?:\.\w+)*$}) { |m| "spec/javascripts/#{ m[1] }_spec.#{ m[2] }" } 
end 
+0

你可以顯示你的Guardfile嗎? – Rahul

+0

絕對,但它現在已經修復! (請參閱我自己的答案)。 – jcm

回答

2

的問題是guard在默認情況下發展的環境下運行,而rake任務和可執行guard-jasmine做測試。

我通過將config.assets.debug = true添加到測試環境配置來修復它。

+0

你能更具體地說明你添加的地方嗎?這是爲了讓它在開發環境中運行,對 - 使用server_env:「development」應該可以做到這一點嗎? –