I have started using minitest for Rails 3.x unit testing and since it comes with Ruby 1.9.x by default, it seems like a good direction to take my testing.
I am using the great gem by Mike Moore called minitest-rails which has a minitest dependency so I can easily have the latest version of minitest. ?This gem helps to more cleanly integrate and use minitest in our Rails 3.x projects.
As part of my setup I use Autotest so my tests run automatically when files change. ?I noticed none of my unit tests were running and upon further inspection, minitest was looking in test/unit and test/unit test directories but not in the test/models folder, which seems to be the minitest default. ?
Opening up my .autotest configuration file and adding the following:
Autotest.add_hook :initialize do |at|
?at.add_mapping(/test\/models\/.*\.rb/) do |_, m|
??at.files_matching %r%^test/(models)/.*\.rb$%
?end
end
After restarting autotest, my unit tests are now being tested. ?I hope this saves someone some time.