rspec - 配置 rspec 以排除文件夹,除非它被明确指定给 rspec 运行
问题描述
我想从 rspec 测试中排除一个文件夹,除非它明确地作为命令行参数运行。例如
RSpec.configure do |config|
unless rspec_args.any? { |arg| =~ /shared/ } # do not explicitly run shared folder
config.exclude_pattern = 'shared/**/*_spec.rb'
end
end
我正在使用 rspec v3.9
我有两个问题:
配置似乎不会从测试中排除共享文件夹以运行
exlude_pattern
。config.exclude_pattern = 'shared/**/*_spec.rb'
但是当我运行rspec --exclude-pattern shared/**/*_spec.rb
共享文件夹时,会从测试套件中排除如何从代码中的命令行获取传递给 rspec 的参数?
解决方案
我能够通过以下配置实现这一点:
# .rspec
--require spec_helper
# spec_helper.rb
RSpec.configure do |config|
config.exclude_pattern = 'shared/**/*_spec.rb'
end
推荐阅读
- python - 达到输出大小限制后,缓冲数据被截断
- python - 将dict的一部分与重复项合并
- c# - 值未通过在返回视图中返回 json 值时
- python-3.6 - python3'ascii'编解码器无法解码位置 1233 中的字节 0xc2:序数不在范围内(128)
- reactjs - 单页应用程序的身份验证
- assembly - 使用 ARMv8 程序集和 Uinput 模拟击键
- python - How to reduce dimensionality of matrix when calculating rolling covariance?
- r - 矩阵上的多个循环
- angular - Angular jasmine 测试无法触发使用 fromEvent rxjs 运算符创建的 Observable
- c# - 如何启用/禁用列表视图子项编辑