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?
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.
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!
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/
来源:https://stackoverflow.com/questions/3622193/autotest-on-ubuntu-does-nothing