gpt4 book ai didi

configuration - RSpec - 如何排除子目录中的规范文件?

转载 作者:行者123 更新时间:2023-12-04 07:29:13 25 4
gpt4 key购买 nike

说我有以下 spec子目录:

lib
models
observers
workers

在 spec_helper.rb 文件中,如何告诉 rspec 排除 lib 子目录中的所有规范文件?
Spork.prefork do

ENV['RAILS_ENV'] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'

Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}

RSpec.configure do |config|
config.mock_with :rspec
config.use_transactional_fixtures = false

config.before(:suite) do
DatabaseCleaner.clean_with :truncation
DatabaseCleaner.strategy = :transaction
end

config.before(:each) do
DatabaseCleaner.start
end

config.after(:each) do
DatabaseCleaner.clean
end

config.treat_symbols_as_metadata_keys_with_true_values = true
config.filter_run :focus => true
end

end

Spork.each_run do
FactoryGirl.reload
end

仅供引用 - 我正在使用 guard 来自动重新加载测试。

最佳答案

不知道如何排除,但您可以在 guard 中包含一个列表,如下所示:

guard 'rspec', :spec_paths => ['spec/models', 'spec/workers', 'spec/observers'] do
# ...
end

关于configuration - RSpec - 如何排除子目录中的规范文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11485023/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com