Simply running RSpec with Apartment without setting connection_class or persistent_schemas explicitly.
Expected behavior
To have no warning show up in the specs output.
Actual behavior
A lot of warnings stating that
.../lib/apartment.rb:66: warning: instance variable @connection_class not initialized
.../lib/apartment.rb:62: warning: instance variable @persistent_schemas not initialized
System configuration
Database: PG v10 and pg gem v1.1.4
Apartment version: 2.2.1
Rails (or ActiveRecord) version: 6.0.0
Ruby version: 2.5.6
Personal note
That's not really a surprise as the connection_class and persistent_schemas methods are defined in a way that would indeed raise this warning if the variables are not already set.
If you're open to it I'd be happy to make a PR that assigns those variables to the default values that are returned.
❤️
Update: this PR is a duplicate of #538 that was closed.
Update 2: My current workaround is to set the following in spec_helper.rb:
Apartment.configure do |config|
config.connection_class = ActiveRecord::Base
config.persistent_schemas = []
end
Steps to reproduce
Simply running RSpec with Apartment without setting
connection_class
orpersistent_schemas
explicitly.Expected behavior
To have no warning show up in the specs output.
Actual behavior
A lot of warnings stating that
System configuration
pg
gem v1.1.4Personal note
That's not really a surprise as the
connection_class
andpersistent_schemas
methods are defined in a way that would indeed raise this warning if the variables are not already set.If you're open to it I'd be happy to make a PR that assigns those variables to the default values that are returned.
❤️
Update: this PR is a duplicate of #538 that was closed. Update 2: My current workaround is to set the following in
spec_helper.rb
: