1

Running either $autotest or $autotest -f gives the same result:

# Waiting since [timestamp]

Changing a controller or spec file just gets that line repeated (with a newer timestamp). If I try $autotest -v, it does not include the spec or controller among the list of files for which no tests match, which I suppose is good; but it doesn't show anything else besides the #waiting line.

If I make a change to a spec or controller while running -v, the output is a hash repeated twice with {[path/to/changed/file] => [timestamp]}.

This is Ubuntu 9.04, Ruby 1.9.2, Rails 3, autotest 4.3.2, autotest-rails 4.1.0, and rspec 2.0.0.beta.20. (I should also say that rspec /spec on its own works fine.) Any ideas?

bgates
  • 2,333
  • 1
  • 18
  • 12

3 Answers3

2

Aha! I was doing this as part of my first experiment with rvm, but I had ZenTest as a gem in /usr/lib/ruby. Even after I set 'rvm use ___' to the gemset I wanted - the one with the autotest and autotest-rails-pure gems - the command 'autotest' was still picking up the file at /usr/bin/autotest that the older ZenTest had put in place. So for anybody following the railstutorial.org - make sure you don't have gems from pre-rvm use (or from sudo gem installs) that are leaving files in places you don't expect.

For me, 'sudo gem uninstall ZenTest' turned out to do the trick.

bgates
  • 2,333
  • 1
  • 18
  • 12
0

I have the exact same environment, except Windows instead of Ubuntu. I am having the same problem. I determined that it is not actually using the rails_app/autotest/discover.rb I setup like this (tried changing order, didn't matter, added output statements and they never got run.):

Autotest.add_discovery { "rspec2" }
Autotest.add_discovery { "rails" }

I found the solution:

in my Gemfile for bundler I had specified ZenTest, and needed to swap it out for these beauties (autotest-rails depends on ZenTest, but this made all the difference):

gem 'autotest'
gem 'autotest-rails'

And now it works (almost but at least now I have an unrelated 'Windowsy' problem). I think this will help you!

Well autotest, still doesn't work, but bundle exec autotest does, and that's good enough!

Peter H. Boling
  • 512
  • 5
  • 14
  • Alas, that's not it for me. I had 'autotest' in the Gemfile, and adding 'autotest-rails' just got me to an error related to the fact that I'm using the mynyml-redgreen gem instead of redgreen. Thanks though! – bgates Sep 02 '10 at 01:51
  • The redgreen gem (all flavors) should be taken out of your stack with RSpec2, as it does it's own coloring. That could well be your problem. I've read of people having that issue elsewhere. RSpec2 coloring explained at the bottom of this wiki: http://github.com/dchelimsky/rspec/wiki/autotest-integration And now I see you've solved it on your own. Really though, take out redgreen. :) – Peter H. Boling Oct 15 '10 at 12:07
0

My problem was solved by adding the following to my autotest/discover.rb file:

Autotest.add_discovery { "rails" }
Autotest.add_discovery { "rspec2" }

Autotest.add_hook(:initialize) do |at|
  at.add_mapping(%r%^(models|controllers|routing|views|helpers|mailers|requests|lib)/.*rb$%)      do |filename, _|
    filename
  end
end

This will force autotest to load all your files and correctly fire your specs when you save a change to either an application file or a spec file.

I blogged about it here: http://itshouldbeuseful.wordpress.com/2011/03/08/force-autotest-to-load-all-your-application-files/

grokling
  • 76
  • 3