Rails以外のアプリケーションのキュウリテストがあります。
プロジェクトにdatabase.ymlがありませんが、何らかの理由でデータベース.ymlを使用したくありません(接続設定は少し異なる形式で保存されます)。
私はいくつかのデータベースモデルを持っています。
class MyBase < ActiveRecord::Base
  self.abstract_class = true
  def self.some_extra_methods
  end 
end
class DatabaseA < MyBase
  self.abstract_class = true
  establish_connection ($configA)
end
class DatabaseB < MyBase
  self.abstract_class = true
  establish_connection ($configB)
end
# if i will not connect ActiveRecord::Base to something i get ActiveRecord::ConnectionNotEstablished errors 
# is there a better solution?
ActiveRecord::Base.establish_connection $configC;
class TableA < DatabaseA
  self.table_name =  :table_a
  self.primary_key = :id
end
#... and other tables
class TableB < DatabaseB
  self.table_name =  :table_b
  self.primary_key = :id
end
#... and other tables
今、そのデータベースをクリーンアップするために、私は次のコードを使用しようとしています。私はdatabase.ymlを持っていないので、モデルを渡すだけです。
DatabaseCleaner[:active_record, {:model => DatabaseA} ].strategy = :truncation
DatabaseCleaner[:active_record, {:model => DatabaseB} ].strategy = :truncation
Before do
  DatabaseCleaner.start
end
After do
  DatabaseCleaner.clean
end 
しかし、それはActiveRecord :: Baseによって接続されたデータベースのみをクリーンアップし、DatabaseAとDatabaseBはクリーンアップしません。何が問題なのですか?