我正在尝试在自动测试中添加一个钩子,以便在更改javascript文件时触发测试。
下面是我正在使用的.autotest文件。语法似乎是正确的,但更新javascript文件时没有发生任何事情。
第一个钩子工作正常,第二个钩子没有。
Autotest.add_hook :initialize do |at|
at.add_mapping(%r%^spec/(selenium)/.*rb$%) { |filename, _|
filename
}
at.add_mapping(%r%^public/(javascripts)/.*js$%) do |f, _|
at.files_matching %r%^spec/(selenium)/.*rb$%
end
end
答案 0 :(得分:1)
上面的代码有效,但是Rspec Rails discovery.rb文件添加了一个例外来忽略公共目录。
在上面的autotest
文件中,需要删除public/
的例外情况。
at.remove_exception "public/"
然后在public中添加要忽略的任何文件或目录:
%w{stylesheets images assets}.each {|exception|at.add_exception(exception)}
我最终得到的是:
Autotest.add_hook :initialize do |at|
at.add_mapping(%r%^spec/(selenium)/.*rb$%) { |filename, _|
filename
}
at.remove_exception "public/"
%w{.git public/stylesheets public/images public/assets}.each {|exception|at.add_exception(exception)}
at.add_mapping(%r%^public/(javascripts)/.*js$%, true) do |f, _|
(at.files_matching %r%^spec/(selenium)/.*rb$% )
end
end