mirror of
https://github.com/DatabaseCleaner/database_cleaner
synced 2023-03-27 23:22:03 -04:00
extract method.
This commit is contained in:
parent
63f3c47964
commit
ed0e38f441
1 changed files with 8 additions and 6 deletions
|
@ -163,15 +163,17 @@ module DatabaseCleaner
|
||||||
rescue NameError
|
rescue NameError
|
||||||
$stderr.puts <<-TEXT
|
$stderr.puts <<-TEXT
|
||||||
Requiring the `database_cleaner` gem directly is deprecated, and will raise an error in database_cleaner 2.0. Instead, please require the specific gem (or gems) for your ORM.
|
Requiring the `database_cleaner` gem directly is deprecated, and will raise an error in database_cleaner 2.0. Instead, please require the specific gem (or gems) for your ORM.
|
||||||
For example, replace `gem "database_cleaner"` with `gem "database_cleaner-active_record"` in your Gemfile. See ### for more information.
|
For example, replace `gem "database_cleaner"` with `gem "database_cleaner-#{orm}"` in your Gemfile.
|
||||||
TEXT
|
TEXT
|
||||||
begin
|
require_orm_strategy(orm, strategy)
|
||||||
|
retry
|
||||||
|
end
|
||||||
|
|
||||||
|
def require_orm_strategy(orm, strategy)
|
||||||
require "database_cleaner/#{orm.to_s}/#{strategy.to_s}"
|
require "database_cleaner/#{orm.to_s}/#{strategy.to_s}"
|
||||||
rescue LoadError
|
rescue LoadError
|
||||||
raise UnknownStrategySpecified, "The '#{strategy}' strategy does not exist for the #{orm} ORM! Available strategies: #{orm_module.available_strategies.join(', ')}"
|
raise UnknownStrategySpecified, "The '#{strategy}' strategy does not exist for the #{orm} ORM! Available strategies: #{orm_module.available_strategies.join(', ')}"
|
||||||
end
|
end
|
||||||
retry
|
|
||||||
end
|
|
||||||
|
|
||||||
def autodetect
|
def autodetect
|
||||||
@autodetected = true
|
@autodetected = true
|
||||||
|
|
Loading…
Reference in a new issue