How do I manually specify which test/unit test files should be run when a non-test file gets updated?
A:
Redefine Autotest#test_files_for(filename) to return an array of strings of the test file names.
Some tutorials refer to tests_for_file, but that was the old name of the method: it was changed in ZenTest 3.9.0 to test_files_for.
Similarly, redefining tests_files_for won't help.
Andrew Grimm
2009-12-31 02:04:24
+1
A:
You can create custom mappings in ~/.autotest or <project_path>/.autotest file like this:
Autotest.add_hook :initialize do |at|
at.add_mapping(/lib\/foo\/(.*).rb/, true) do |filename, matchdata|
["spec/lib/foo/#{matchdata[1]}_spec.rb"]
end
end
This matches specs in spec/lib/foo directory to lib/foo files, so these specs will run once files under lib/foo are being changed. I guess you can do the same with test directory.
Priit
2009-12-31 09:17:58