带有add_mapping的Ruby自动测试 [英] Ruby Autotest with add_mapping

查看:70
本文介绍了带有add_mapping的Ruby自动测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在自动测试中添加一个钩子,以在更改javascript文件时触发测试.

I am trying to add a hook in Autotest to trigger tests when javascript files are changed.

下面是我正在使用的.autotest文件.语法似乎是正确的,但是更新JavaScript文件时没有任何反应.

Below the is the .autotest file I am using. The syntax seems to be correct, but nothing is happening when a javascript file is updated.

第一个钩子工作正常,第二个钩子工作不正常.

The first hook works fine, the second does not.


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

推荐答案

上面的代码有效,但是Rspec Rails Discovery.rb文件添加了一个忽略公共目录的异常.

The above code works, however the the Rspec Rails discovery.rb file adds an exception to ignore the public directory.

在上面的autotest文件中,需要删除public/的异常.

In the above autotest file the exception for public/ needs to be removed.

 at.remove_exception "public/"

然后在公共位置添加任何要忽略的文件或目录:

Then add whatever files or directories in public to be ignored:

 %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

这篇关于带有add_mapping的Ruby自动测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆