【问题标题】:autotest wont stop after a test fails?测试失败后自动测试不会停止?
【发布时间】:2011-06-26 20:06:35
【问题描述】:

这是我的 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:

不断重复

如何阻止这种行为

【问题讨论】:

    标签: ruby-on-rails ruby-on-rails-3 rspec autotest


    【解决方案1】:

    有一个重复的问题有正确的修复: 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】:

      我遇到了同样的问题。 尝试卸载 ZenTest gem 并通过依赖项重新安装它:

      sudo gem install autotest-rails
      sudo gem install rspec-rails
      

      【讨论】:

        【解决方案3】:

        只需将以下内容放入我的.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'
        

        【讨论】:

        • 感谢您的回答,这对我有用! (没有要求'autotest/inotify')
        猜你喜欢
        • 1970-01-01
        • 2021-03-19
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-04-17
        • 1970-01-01
        • 1970-01-01
        • 2012-05-11
        相关资源
        最近更新 更多