Open coderberry opened 4 months ago
@coderberry Interesting problem. I'm not 100% sure what could be the problem.
Here are some options:
config.before(:each) do
DatabaseCleaner[:active_record, db: :primary].start
DatabaseCleaner[:active_record, db: :cache].start
end
config.after(:each) do
DatabaseCleaner[:active_record, db: :primary].clean
DatabaseCleaner[:active_record, db: :cache].clean
end
config.around(:each) do |example|
DatabaseCleaner.cleaning do
example.run
end
end
Could you test with one (cleaning) or the other (start+clean)?
If you get the same results, I'd probably keep the start+clean and get rid of the cleaning call.
Another idea is that you could test this PR: https://github.com/DatabaseCleaner/database_cleaner-active_record/pull/108 -- it might be related to your problem.
This might be a rare use case, but I have an app that uses two databases. Here's a snippet from my
database.yml
file:I have one ActiveRecord model (
RawDatum
) set up to read/write to/from the secondary database.Here's a summarized version of my RSpec spec:
Here is my
spec/support/database_cleaner.rb
file: