Andrew Grimm
Andrew Grimm

Reputation: 81530

How do I manually specify the test files to run in autotest?

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

Upvotes: 2

Views: 224

Answers (2)

Priit
Priit

Reputation: 5248

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.

Upvotes: 3

Andrew Grimm
Andrew Grimm

Reputation: 81530

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.

Upvotes: 0

Related Questions