我有一些这样组织的子模型:

|-- app
|   |-- models
|   |   |-- foo
|   |   |   |-- foo-1.rb
|   |   |   |-- foo-2.rb
|   |   |   |-- foo-3.rb
|   |   |-- foo.rb

我如何使自动化注意到对foo - *。rb进行的更改,然后运行适当的规格?

有帮助吗?

解决方案

您可以使用映射填充自动访问/discover.rb文件:

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

您可以找到更多如何使用映射和钩子 在API文档中.

其他提示

也许您应该调查Watchr

https://github.com/mynyml/watchr

它类似于AutoTest,同时更加可配置和更容易设置。

另一个有趣的选择是 警卫.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top