2011-06-26 131 views
8

這裏是我的Gemfile測試失敗後,自動測試不會停止?

source 'http://rubygems.org' 

gem 'rails', '3.0.9' 
gem 'mysql2', '~> 0.2.6' 

group :development do 
    gem 'rspec-rails' 
end 

group :test do 
    gem 'rspec' 
end 

相當簡單,沒有什麼不尋常。在一個測試通過自動測試的偉大工程,並停止像它應該

Finished in 0.1158 seconds 
4 examples, 0 failures 
/Users/alex/.rvm/rubies/ruby-1.9.2-p180/bin/ruby -rrubygems -S /Users/alex/.rvm/gems/[email protected]/gems/rspec-core-2.6.4/bin/rspec --tty '/Users/alex/Sites/slacklog/spec/controllers/pages_controller_spec.rb' 

但是當一個測試失敗了無限循環,不停地進行故障

Failures: 

    1) PagesController GET 'contact' Should have the proper title for the contact page 
    Failure/Error: response.should have_selector("contact", 
     expected following output to contain a <contact>Contact us</contact> tag: 
     <!DOCTYPE html> 
     <html> 
     <head> 
     <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> 
     <title>Slacklog</title> 
     <script src="/javascripts/jquery.js" type="text/javascript"></script><script src="/javascripts/jquery_ujs.js" type="text/javascript"></script><script src="/javascripts/application.js?1309037322" type="text/javascript"></script> 
     </head> 
     <body> 

     <h1>Pages#contact</h1> 
     <p>Find me in app/views/pages/contact.html.erb</p> 


     </body> 
     </html> 
    # ./spec/controllers/pages_controller_spec.rb:32:in `block (3 levels) in <top (required)>' 

Finished in 0.16647 seconds 
5 examples, 1 failure 

Failed examples: 

rspec ./spec/controllers/pages_controller_spec.rb:30 # PagesController GET 'contact' Should have the proper title for the contact page 
/Users/alex/.rvm/rubies/ruby-1.9.2-p180/bin/ruby -rrubygems -S /Users/alex/.rvm/gems/[email protected]/gems/rspec-core-2.6.4/bin/rspec --tty '/Users/alex/Sites/slacklog/spec/controllers/pages_controller_spec.rb' 
...F. 

Failures: 

它不斷重複

如何停止此行爲

回答

3

我有同樣的問題。 嘗試卸載ZenTest的寶石,並通過依賴關係重新安裝:

sudo gem install autotest-rails 
sudo gem install rspec-rails 
+0

沒有爲我解決任何問題。 – staackuser2

4

有是有適當的修復重複的問題: Autotest inifinitely looping

答案沒有解決它的我。但這是因爲我正在使用webrat和webrat.log正在創建,導致測試重新啓動。所以,我修改了自己的答案,包括webrat.log

下面是修改的方案:

我找到了解決辦法。可能與OSX有關(在Leopard上運行此操作)更改文件夾中的.DS_Store文件或其他臨時文件。將以下內容添加到我的.autotest中(這也阻止了自動測試查看由Ferret生成的索引文件夾)。

Autotest.add_hook :initialize do |at| 
    %w{.git webrat.log vendor index .DS_Store ._}.each {|exception| at.add_exception(exception)} 
end 
2

通過將在下面的只是固定它我.autotest 我知道這是很遲,但我希望這會幫助別人:-)

at.add_exception %r{^./log} 

.autotest現在看起來

# ./.autotest 
Autotest.add_hook(:initialize) {|at| 
    at.add_exception %r{^\.git} # ignore Version Control System 
    at.add_exception %r{^./tmp} # ignore temp files, lest autotest will run again, and again... 
    at.add_exception %r{^./spec/controllers} # ignore controllers until cache has been fixed. auto test taking too long for now 
    at.add_exception %r{^./log} # ignore temp files, lest autotest will run again, and again... 


    # at.clear_mappings   # take out the default (test/test*rb) 
    at.add_mapping(%r{^lib/.*\.rb$}) {|f, _| 
    Dir['spec/**/*_spec.rb'] 
    } 
    nil 
} 

require 'autotest/inotify' 
+0

感謝您的回答,這對我有效! (沒有要求'autotest/inotify') – lambinator

+0

很高興聽到@SteveLamb :-) – Abdo