def database_cleaner # rubocop:disable AbcSize
      return unless defined?(DatabaseCleaner)
      ::RSpec.configure do |config|
        if config.respond_to?(:use_transactional_fixtures=)
          config.use_transactional_fixtures = false
        end
        config.add_setting :database_cleaner_strategy
        config.database_cleaner_strategy = {feature: :truncation}
        config.database_cleaner_strategy.default = :transaction
        config.add_setting :database_cleaner_options
        config.database_cleaner_options = {truncation: {except: %w[spatial_ref_sys]}}
        config.add_setting :database_cleaner_args
        config.database_cleaner_args = ->(ex) do
          strategy = ex.metadata[:concurrent] && :truncation
          strategy ||= config.database_cleaner_strategy[ex.metadata[:type]]
          options = config.database_cleaner_options[strategy] || {}
          [strategy, options]
        end
        config.around do |ex|
          DatabaseCleaner.strategy = config.database_cleaner_args.call(ex)
          DatabaseCleaner.cleaning { ex.run }
        end
      end
    end
def database_cleaner # rubocop:disable AbcSize
      return unless defined?(DatabaseCleaner)
      ::RSpec.configure do |config|
        if config.respond_to?(:use_transactional_fixtures=)
          config.use_transactional_fixtures = false
        end
        config.add_setting :database_cleaner_strategy
        config.database_cleaner_strategy = {feature: :truncation}
        config.database_cleaner_strategy.default = :transaction
        config.add_setting :database_cleaner_options
        config.database_cleaner_options = {truncation: {except: %w[spatial_ref_sys]}}
        config.add_setting :database_cleaner_args
        config.database_cleaner_args = ->(ex) do
          strategy = ex.metadata[:concurrent] && :truncation
          strategy ||= config.database_cleaner_strategy[ex.metadata[:type]]
          options = config.database_cleaner_options[strategy] || {}
          [strategy, options]
        end
        config.around do |ex|
          DatabaseCleaner.strategy = config.database_cleaner_args.call(ex)
          DatabaseCleaner.cleaning { ex.run }
        end
      end
    end
Setups database cleaner to use strategy depending on metadata.
 By default it uses `:transaction` for all examples and `:truncation`
 for features and examples with `concurrent: true`.

 Other types can be tuned with `config.cleaner_strategy` hash &
 `config.cleaner_strategy.default`.