Some Hints and help:-
-
You have to create a config setting for your target database on database.yml
-
or you can create conditional connection in database.yml example:- https://medium.com/productboard-engineering/setting-up-rspec-and-databasecleaner-to-support-multiple-databases-c42bfe251112
-
You can tag your specs https://rubyyagi.com/run-specific-tests-on-rspec-using-tag/ to run when tag is passed (say target database)
-
Establish db connection based on ENV variable rake spec TARGET_DB=true https://stackoverflow.com/questions/1528868/rails-rspec-with-multiple-databases