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
|
end
|
||||||
|
|
||||||
def orm_strategy(strategy)
|
def orm_strategy(strategy)
|
||||||
require "database_cleaner/#{orm.to_s}/#{strategy.to_s}"
|
|
||||||
orm_module.const_get(strategy.to_s.capitalize)
|
orm_module.const_get(strategy.to_s.capitalize)
|
||||||
rescue LoadError
|
rescue NameError
|
||||||
if orm_module.respond_to? :available_strategies
|
$stderr.puts <<-TEXT
|
||||||
raise UnknownStrategySpecified, "The '#{strategy}' strategy does not exist for the #{orm} ORM! Available strategies: #{orm_module.available_strategies.join(', ')}"
|
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.
|
||||||
else
|
For example, replace `gem "database_cleaner"` with `gem "database_cleaner-active_record"` in your Gemfile. See ### for more information.
|
||||||
raise UnknownStrategySpecified, "The '#{strategy}' strategy does not exist for the #{orm} ORM!"
|
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
|
end
|
||||||
|
retry
|
||||||
end
|
end
|
||||||
|
|
||||||
def autodetect
|
def autodetect
|
||||||
|
|
|
@ -314,7 +314,6 @@ module DatabaseCleaner
|
||||||
|
|
||||||
it "loads and instantiates the described strategy" do
|
it "loads and instantiates the described strategy" do
|
||||||
stub_const "DatabaseCleaner::ActiveRecord::Cunningplan", strategy_class
|
stub_const "DatabaseCleaner::ActiveRecord::Cunningplan", strategy_class
|
||||||
expect(subject).to receive(:require).with("database_cleaner/active_record/cunningplan")
|
|
||||||
|
|
||||||
subject.strategy = :cunningplan
|
subject.strategy = :cunningplan
|
||||||
expect(subject.strategy).to be_a strategy_class
|
expect(subject.strategy).to be_a strategy_class
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue