配置rspec以排除文件夹,除非明确指定rspec运行该文件夹

配置rspec以排除文件夹,除非明确指定rspec运行该文件夹,rspec,configuration,rspec3,Rspec,Configuration,Rspec3,我想从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 我正在使用rspecv3.9 我有两个问题: 使用config

我想从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
我正在使用rspecv3.9

我有两个问题:

  • 使用
    config.exclude\u pattern='shared/***\u spec.rb'
    配置
    exlude\u pattern
    似乎不会将共享文件夹从要运行的测试中排除。但是当我运行
    rspec--exclude pattern shared/***\u spec.rb
    时,共享文件夹被从测试套件中排除

  • 如何在代码中从命令行获取传递给rspec的参数


  • 我能够通过以下配置实现这一点:

    # .rspec
    --require spec_helper
    

    # spec_helper.rb
    RSpec.configure do |config|
      config.exclude_pattern = 'shared/**/*_spec.rb' 
    end