I have some submodules organized like this:
|-- app
| |-- models
| | |-- foo
| | | |-- foo-1.rb
| | | |-- foo-2.rb
| | | |-- foo-3.rb
| | |-- foo.rb
How can I get autotest to notice changes made to foo-*.rb, and then run the appropriate specs?
You can populate your autotest/discover.rb file with mappings:
Autotest.add_hook :initialize do |at|
# match the model name (the whole Regex object is in _)
at.add_mapping(%r%^app/models/(foo)/\w+\.rb$%, true) do |filename, _|
"spec/models/#{_[1]}_spec.rb"
end
end
You can find more how to use the mappings and hooks in the API docs.