autotest on ubuntu does nothing

霸气de小男生 提交于 2019-12-08 17:33:34

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/

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!