← til

Autotest and RSpec problems

January 29, 2012
rspec, ruby

I was experiencing problems with running specs with autotest. By default it's configured to run only Test::Unit files and googling around retrieved several solutions. Some of them included creating ~/.autotest file which is read before any autotest session. In that file you should add

Autotest.add_hook :ran_command do |at|
  at.add_mapping(%r{^lib/.*\.rb$}) {|f, _|
    Dir['spec/**/*.rb']
  }
end

This however, didn't work for me. Running autotest -v provided verbose output including:

No tests matched spec/requests/emails_about_cancellation.rb
No tests matched spec/requests/emails_when_owner_schedules.rb
No tests matched spec/helpers/showings_helper_spec.rb

So basically autotest was unable to recognize rspec for some reason.

After an hour of research I've finally found the solution which is as simple as:

$ autotest -s rspec2

And now the autotest runs my specs and is watching them for changes. Why is this not documented anywhere remains a mystery to me.


Did you like this article? You can follow me on Twitter, subscribe to the newsletter or subscribe to the RSS feed if you'd like to follow along.

Unsubscribe anytime. By submitting your email, you agree to our privacy policy.