How can I get autotest to notice changes in subdirectories?
-
24-10-2019 - |
سؤال
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.
نصائح أخرى
Perhaps you should investigate watchr
https://github.com/mynyml/watchr
It's similar to autotest, while being quite a bit more configurable and more easily setup.
Another interesting alternative is guard.
لا تنتمي إلى StackOverflow