我知道我不应该对特定的 ID 进行编码,但有时它只会让生活变得更轻松。我正在使用带有 RSpec 和 Postgres 的 DatabaseCleaner,我想知道在使用事务策略时是否可以在规范之间重置 id?
这是我目前的spec_helper
:
RSpec.configure do |config|
config.expect_with :rspec do |c|
c.syntax = [:should, :expect]
end
config.before(:suite) do
DatabaseCleaner.clean_with(:truncation)
DatabaseCleaner.strategy = :transaction
load_seed_data
end
config.before(:all) do
DatabaseCleaner.start
end
config.after(:all) do
DatabaseCleaner.clean
end
config.example_status_persistence_file_path = "./spec/failures.txt"
config.use_transactional_fixtures = true
config.infer_base_class_for_anonymous_controllers = false
config.order = "random"
config.include FactoryGirl::Syntax::Methods
config.include RSpec::Rails::RequestExampleGroup
config.include Requests::JsonHelpers
config.include Requests::Extensions
end