2011-11-06 53 views
3

我想成爲一個更好的測試者。有這麼多的問題與設置,我不知道它是否值得。Rails 3.1,rspec,guard和spork在窗口上真的很慢

有人可以幫忙嗎?

我正在運行Rails 3.1,rspec,警衛水豚和spork上的窗口框。我使用警衛寶石寶石。這是我運行bundle exec後得到的結果

看看「421.87秒完成」一行。那是一個測試!

我看到guard-spork抱怨沒有fork支持(Windows問題),但後來這行「./magazine_slave.rb:22:in`run'」出現錯誤,應該指示magazine_slave運行(Windows用雜誌而不是叉子運行spork)。

任何想法?

Guard is now watching at 'c:/Users/Andreas/My Documents/Aptana Studio 3 workspace/maktaba' 
'awk' is not recognized as an internal or external command, 
operable program or batch file. 
'awk' is not recognized as an internal or external command, 
operable program or batch file. 
Starting Spork for Test::Unit & RSpec 
ERROR: Guard::Spork failed to achieve its <start>, exception was: 
NotImplementedError: fork() function is unimplemented on this machine 
c:/Ruby/Ruby187/lib/ruby/gems/1.8/gems/guard-spork-0.3.1/lib/guard/spork/runner.rb:40:in `fork' 
c:/Ruby/Ruby187/lib/ruby/gems/1.8/gems/guard-spork-0.3.1/lib/guard/spork/runner.rb:40:in `spawn_child' 
c:/Ruby/Ruby187/lib/ruby/gems/1.8/gems/guard-spork-0.3.1/lib/guard/spork/runner.rb:23:in `launch_sporks' 
c:/Ruby/Ruby187/lib/ruby/gems/1.8/gems/guard-spork-0.3.1/lib/guard/spork.rb:17:in `start' 
c:/Ruby/Ruby187/lib/ruby/gems/1.8/gems/guard-0.8.8/lib/guard.rb:322:in `send' 
c:/Ruby/Ruby187/lib/ruby/gems/1.8/gems/guard-0.8.8/lib/guard.rb:322:in `run_supervised_task' 
c:/Ruby/Ruby187/lib/ruby/gems/1.8/gems/guard-0.8.8/lib/guard.rb:320:in `catch' 
c:/Ruby/Ruby187/lib/ruby/gems/1.8/gems/guard-0.8.8/lib/guard.rb:320:in `run_supervised_task' 
c:/Ruby/Ruby187/lib/ruby/gems/1.8/gems/guard-0.8.8/lib/guard.rb:153:in `start' 
c:/Ruby/Ruby187/lib/ruby/gems/1.8/gems/guard-0.8.8/lib/guard.rb:254:in `run_on_guards' 
c:/Ruby/Ruby187/lib/ruby/gems/1.8/gems/guard-0.8.8/lib/guard.rb:253:in `each' 
c:/Ruby/Ruby187/lib/ruby/gems/1.8/gems/guard-0.8.8/lib/guard.rb:253:in `run_on_guards' 
c:/Ruby/Ruby187/lib/ruby/gems/1.8/gems/guard-0.8.8/lib/guard.rb:252:in `catch' 
c:/Ruby/Ruby187/lib/ruby/gems/1.8/gems/guard-0.8.8/lib/guard.rb:252:in `run_on_guards' 
c:/Ruby/Ruby187/lib/ruby/gems/1.8/gems/guard-0.8.8/lib/guard.rb:251:in `each' 
c:/Ruby/Ruby187/lib/ruby/gems/1.8/gems/guard-0.8.8/lib/guard.rb:251:in `run_on_guards' 
c:/Ruby/Ruby187/lib/ruby/gems/1.8/gems/guard-0.8.8/lib/guard.rb:152:in `start' 
c:/Ruby/Ruby187/lib/ruby/gems/1.8/gems/guard-0.8.8/lib/guard/cli.rb:68:in `start' 
c:/Ruby/Ruby187/lib/ruby/gems/1.8/gems/thor-0.14.6/lib/thor/task.rb:22:in `send' 
c:/Ruby/Ruby187/lib/ruby/gems/1.8/gems/thor-0.14.6/lib/thor/task.rb:22:in `run' 
c:/Ruby/Ruby187/lib/ruby/gems/1.8/gems/thor-0.14.6/lib/thor/invocation.rb:118:in `invoke_task' 
c:/Ruby/Ruby187/lib/ruby/gems/1.8/gems/thor-0.14.6/lib/thor.rb:263:in `dispatch' 
c:/Ruby/Ruby187/lib/ruby/gems/1.8/gems/thor-0.14.6/lib/thor/base.rb:389:in `start' 
c:/Ruby/Ruby187/lib/ruby/gems/1.8/gems/guard-0.8.8/bin/guard:6 
c:/Ruby/Ruby187/lib/ruby/gems/1.8/bin/guard:19:in `load' 
c:/Ruby/Ruby187/lib/ruby/gems/1.8/bin/guard:19 

Guard::Spork has just been fired 
Guard::RSpec is running, with RSpec 2! 
Running all specs 
F 

Failures: 

    1) UserCruds Creates a new user 
Failure/Error: click_button "Submit" 
ActionView::Template::Error: 
    You have a nil object when you didn't expect it! 
    You might have expected an instance of Array. 
    The error occurred while evaluating nil.map 
# ./app/views/users/_form.html.erb:38:in `_app_views_users__form_html_erb___24339687_119563452' 
# ./app/views/users/_form.html.erb:3:in `_app_views_users__form_html_erb___24339687_119563452' 
# ./app/views/users/new.html.erb:3:in `_app_views_users_new_html_erb___963176717_119608284' 
# ./app/controllers/users_controller.rb:52 
# ./app/controllers/users_controller.rb:47:in `create' 
# (eval):2:in `send' 
# (eval):2:in `click_button' 
# ./spec/requests/user_cruds_spec.rb:16 
# ./magazine_slave.rb:22:in `run' 
# magazine_slave_provider.rb:17 

Finished in 421.87 seconds 
1 example, 1 failure 
+0

新紀錄! 「在1288.48秒內完成」 –

+0

實際上需要那麼長時間還是它是計時器錯誤? Rspec改變了它的運行方式,spork到我的知識還沒有適應 – Rasmus

+0

我沒有計時,但它離實時不遠。 –

回答

2

因爲rspec加載rails環境,速度很慢。更多的寶石,你有它得到更慢

這就是爲什麼spork是一個偉大的工具。它加載軌道環境,並且警衛可以在不重新加載軌道環境的情況下查找更改。但是守護寶石寶石中存在一個缺陷。它不適用於Windows,因爲它取決於分叉。即使是堅硬的叉子也不會在窗戶上使用叉子。 Fork在非UNIX系統上不受支持。

我研究了這個問題,並以不同的方式結束了。我建立了lib文件夾的邏輯,並且不在規範中包含spec_helper文件。然後rails不會加載,只有特定的測試邏輯。這很快,迫使我寫更多可讀代碼。

看看這個video關於科裏海恩斯的談話,瞭解更多關於這個問題。

相關問題