ruby-on-rails – 测试失败后自动测试不会停止?

前端之家收集整理的这篇文章主要介绍了ruby-on-rails – 测试失败后自动测试不会停止?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
这是我的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/ruby-1.9.2-p180@rails3/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/ruby-1.9.2-p180@rails3/gems/rspec-core-2.6.4/bin/rspec --tty '/Users/alex/Sites/slacklog/spec/controllers/pages_controller_spec.rb'
...F.

Failures:

它不断重复

我该如何阻止这种行为

解决方法

有一个重复的问题有适当的修复:
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
原文链接:https://www.f2er.com/ruby/270098.html

猜你在找的Ruby相关文章