如何告诉自动测试正确跟踪应用程序源中的更改?
每当我的 Rails 应用程序的相关文件之一发生更改时,我希望自动测试来运行 Steak 验收测试。在研究了 Rspec 和 Cucumber 自己的自动测试配置后,我正在尝试以下映射:
Autotest.add_hook :initialize do |at|
at.add_mapping(%r%^spec/acceptance/.*_spec.rb$%, true) { |filename, _|
filename
}
at.add_mapping(%r%^app/(models|controllers|helpers|lib)/.rb$%) {
at.files_matching %r%^spec/acceptance/._spec.rb$%
}
at.add_mapping(%r%^app/views/(.*)/.rb$%) {
at.files_matching %r%^spec/acceptance/._spec.rb$%
}
结尾
第一个有效:每当牛排规格发生变化时,它就会再次运行。
但第二个和第三个没有。更改 /app 子目录下的任何源文件都会被忽略。
让这些映射发挥作用的正确方法是什么?
谢谢 奥利弗
I want to get autotest to run Steak acceptance tests whenever one of my rails app's relevant files is changed. After studying Rspec's and Cucumber's own autotest configs, I'm trying the following mappings:
Autotest.add_hook :initialize do |at|
at.add_mapping(%r%^spec/acceptance/.*_spec.rb$%, true) { |filename, _|
filename
}
at.add_mapping(%r%^app/(models|controllers|helpers|lib)/.rb$%) { at.files_matching %r%^spec/acceptance/._spec.rb$% }
at.add_mapping(%r%^app/views/(.*)/.rb$%) { at.files_matching %r%^spec/acceptance/._spec.rb$% } end
the first one works: whenever a Steak spec is changed, it gets run again.
but the second and third don't. changing any source files under the /app subdirectories just gets ignored.
what's the correct way to get these mappings to work?
thanks
Oliver
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我刚刚更改了我的
.autotest
文件以添加:这是有效的,但我不知道在其他人之前调用验收测试的附带影响(
true
标志>add_mapping)I just changed my
.autotest
file to add:And this is working but I don't know the collateral effects of invoking acceptance tests before others (the
true
flag onadd_mapping
)对于 RSpec 1.3:
我必须使用 :post_initialize 挂钩,因为内置的 RSpec 支持是通过清除所有现有映射开始的。因此,它清除了这些,然后添加默认的 RSpec 映射。但使用 :post_initialize 钩子(而不是第一行的 :initialize )修复了它。
我还必须将所有这些放入 autotest/discover.rb 而不是 .autotest 中。
For RSpec 1.3:
I had to use the :post_initialize hook because the built-in RSpec support starts by clearing all existing mappings. So it was clearing these out and then adding the default RSpec mappings. But using the :post_initialize hook (instead of :initialize on the first line) fixed it.
I also had to put all this in autotest/discover.rb instead of .autotest.