如何在所有测试用例运行时配置guard-rspec忽略目录?

时间:2016-02-02 05:56:23

标签: ruby-on-rails rspec guard

假设我的spec文件夹中有三个导演;功能,测试,集成。 当我运行bundle exec guard并按回车键时,有没有办法可以配置我的Guardfile来忽略位于集成目录中的测试用例?

1 个答案:

答案 0 :(得分:1)

在Guardfile中,您可以指定the command to use when running all specs。您可以指定rSpec command with a file exclude pattern来运行除集成规范之外的所有内容:

guard :rspec,
      cmd: 'bundle exec rspec', 
      run_all: { cmd: 'bundle exec rspec --exclude-pattern "**/integrations/*_spec.rb"' } do
  # ...
end

根据您的需要,您可能需要稍微调整一下,请参阅答案中的链接以获取相关文档。