8

Here is my 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

Fairly straightforward and nothing unusual. On a passing test the autotest works great and stops like it should

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'

but when a test fails its an endless loop that keeps failing

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:

It keeps repeating

how do i stop this behavior

Matt Elhotiby
  • 43,028
  • 85
  • 218
  • 321

3 Answers3

4

There is a duplicate question that has the proper fix: Autotest inifinitely looping

The answer didn't fix it for me either, but it was because I was using webrat and webrat.log was being created, causing the tests to restart. So I modified their answer to include webrat.log

Here is the modified solution:

I found the solution. Probably has to do with OSX (running this on Leopard) changing the .DS_Store file in the folder or another temp file. Adding the following to my .autotest did the trick (this also prevents autotest looking at the index folder generated by Ferret).

Autotest.add_hook :initialize do |at|
  %w{.git webrat.log vendor index .DS_Store ._}.each {|exception| at.add_exception(exception)}
end
Community
  • 1
  • 1
staackuser2
  • 12,172
  • 4
  • 42
  • 40
3

I had the same problem. Try to uninstall your ZenTest gem and reinstall it via dependencies as:

sudo gem install autotest-rails
sudo gem install rspec-rails
Sergey
  • 103
  • 6
2

Just fixed it by putting the following in my .autotest I know this is pretty late but I hope this will help someone :-)

at.add_exception %r{^./log}

My .autotest now looks like

# ./.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'
Abdo
  • 13,549
  • 10
  • 79
  • 98