Autotest.add_hook :initialize do |at| at.clear_mappings at.add_mapping(%r%^lib/(.*)\.rb$%) do |_, m| at.files_matching %r%^spec/#{m[1]}_spec\.rb$% end at.add_mapping(%r%^spec/.*\_spec\.rb$%) { |filename, _| filename } end