2

How do I manually specify which test/unit test files should be run when a non-test file gets updated?

Andrew Grimm
  • 78,473
  • 57
  • 200
  • 338

2 Answers2

3

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
  • 5,200
  • 2
  • 21
  • 20
0

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
  • 78,473
  • 57
  • 200
  • 338