First of all, this is a great gem, thank you for sharing it with us!
I've added it in an app and it's working great, though I'm trying to validate with some specs that READs actually go to the read replica, and it doesn't seem to make this switch automatically in a test environment.
Here's a simple spec, please let me know if specific configuration is needed to make the gem work in a test environment:
it "fetches from the read replica" do
expect { User.count }.to exactly_query_databases({ primary_replica: :reading })
end
and I get back { primary: :writing }, not { primary_replica: :reading }
If I manually switch to the read replica, then I get back what I'm expecting:
it "fetches from the read replica" do
ActiveRecord::Base.connected_to(role: :reading) do
expect { User.count }.to exactly_query_databases({ primary_replica: :reading })
end
end
I must be missing something though it's not obvious to me.
Thank you
First of all, this is a great gem, thank you for sharing it with us!
I've added it in an app and it's working great, though I'm trying to validate with some specs that READs actually go to the read replica, and it doesn't seem to make this switch automatically in a
testenvironment.Here's a simple spec, please let me know if specific configuration is needed to make the gem work in a
testenvironment:and I get back
{ primary: :writing }, not{ primary_replica: :reading }If I manually switch to the read replica, then I get back what I'm expecting:
I must be missing something though it's not obvious to me.
Thank you