Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

warning: instance variable not initialized #655

Closed
simonc opened this issue Jul 13, 2020 · 1 comment
Closed

warning: instance variable not initialized #655

simonc opened this issue Jul 13, 2020 · 1 comment

Comments

@simonc
Copy link

simonc commented Jul 13, 2020

Steps to reproduce

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
@simonc
Copy link
Author

simonc commented Aug 9, 2021

No activity or response for a year and from what I know the gem is dying anyway so I'll close this PR since there's a workaround 😉

@simonc simonc closed this as completed Aug 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant