警卫,如何暂时跟踪特定文件?

meg*_*gas 7 ruby guard

我正在使用Guard gem

在开发的某个时候,我需要仅跟踪特定文件或多个文件,而不是整个项目.

是否有一些方便的方法来临时跟踪特定文件?

我知道可以通过修改防护文件来完成,但我不认为这是一个简洁的解决方案.

Dav*_*ahn 12

实际上你可以focus: trueit语句中使用例如:

在您的Spec文件中.

it "needs to focus on this!", focus: true do
  #test written here.
end
Run Code Online (Sandbox Code Playgroud)

然后在spec/spec_helper中,您需要添加config选项.

RSpec.configure do |config| 
  config.treat_symbols_as_metadata_keys_with_true_values = true  
  config.filter_run :focus => true  
  config.run_all_when_everything_filtered = true 
end
Run Code Online (Sandbox Code Playgroud)

然后,Guard将自动选择专注的测试并仅运行它.config.run_all_when_everything_filtered = true即使名称听起来有误导性,当没有任何过滤时,告诉警卫也会运行所有测试.

我发现Ryan Bate的钢轨对GuardSpork非常有帮助.