public
Last active

database cleaner multiple connections single orm outside of rails

  • Download Gist
gistfile1.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
RSpec.configure do |config|
config.before(:suite) do
ActiveRecord::Base.establish_connection database['one']
DatabaseCleaner.strategy = :deletion
ActiveRecord::Base.establish_connection config.database['two']
DatabaseCleaner.strategy = :deletion
end
 
config.before(:each) do
ActiveRecord::Base.establish_connection database['one']
DatabaseCleaner.start
ActiveRecord::Base.establish_connection database['two']
DatabaseCleaner.start
end
 
config.after(:each) do
ActiveRecord::Base.establish_connection database['one']
DatabaseCleaner.clean
ActiveRecord::Base.establish_connection database['two']
DatabaseCleaner.clean
end

After two hours of trial and error.. this gist has saved my morning

Glad I could help. I seem to remember that problem burning up a few hours
when I first ran into it.

On Fri, Mar 2, 2012 at 7:02 AM, Fernando Guillen <
reply@reply.github.com

wrote:

After two hours of trial and error.. this gist has saved my morning


Reply to this email directly or view it on GitHub:
https://gist.github.com/1109325

Michael Greenly
http://logic-refinery.com

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.