mirror of
https://github.com/DatabaseCleaner/database_cleaner
synced 2023-03-27 23:22:03 -04:00
deprecate loading adapters from database_cleaner core gem.
This commit is contained in:
parent
e65c63c939
commit
29b444cec4
2 changed files with 14 additions and 7 deletions
|
@ -159,14 +159,22 @@ module DatabaseCleaner
|
|||
end
|
||||
|
||||
def orm_strategy(strategy)
|
||||
require "database_cleaner/#{orm.to_s}/#{strategy.to_s}"
|
||||
orm_module.const_get(strategy.to_s.capitalize)
|
||||
rescue LoadError
|
||||
if orm_module.respond_to? :available_strategies
|
||||
raise UnknownStrategySpecified, "The '#{strategy}' strategy does not exist for the #{orm} ORM! Available strategies: #{orm_module.available_strategies.join(', ')}"
|
||||
else
|
||||
raise UnknownStrategySpecified, "The '#{strategy}' strategy does not exist for the #{orm} ORM!"
|
||||
rescue NameError
|
||||
$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.
|
||||
For example, replace `gem "database_cleaner"` with `gem "database_cleaner-active_record"` in your Gemfile. See ### for more information.
|
||||
TEXT
|
||||
begin
|
||||
require "database_cleaner/#{orm.to_s}/#{strategy.to_s}"
|
||||
rescue LoadError
|
||||
if orm_module.respond_to?(:available_strategies)
|
||||
raise UnknownStrategySpecified, "The '#{strategy}' strategy does not exist for the #{orm} ORM! Available strategies: #{orm_module.available_strategies.join(', ')}"
|
||||
else
|
||||
raise UnknownStrategySpecified, "The '#{strategy}' strategy does not exist for the #{orm} ORM!"
|
||||
end
|
||||
end
|
||||
retry
|
||||
end
|
||||
|
||||
def autodetect
|
||||
|
|
|
@ -314,7 +314,6 @@ module DatabaseCleaner
|
|||
|
||||
it "loads and instantiates the described strategy" do
|
||||
stub_const "DatabaseCleaner::ActiveRecord::Cunningplan", strategy_class
|
||||
expect(subject).to receive(:require).with("database_cleaner/active_record/cunningplan")
|
||||
|
||||
subject.strategy = :cunningplan
|
||||
expect(subject.strategy).to be_a strategy_class
|
||||
|
|
Loading…
Reference in a new issue