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

Rspec configure overriden #1663

Open
benj-p opened this issue Sep 30, 2024 · 1 comment
Open

Rspec configure overriden #1663

benj-p opened this issue Sep 30, 2024 · 1 comment

Comments

@benj-p
Copy link

benj-p commented Sep 30, 2024

Expected behavior

Geocoder config in Rspec.configure should take precedence in test environment.

Actual behavior

I'm using :mapbox as a default lookup in my app but there's one specific callback where I need to use Nominatim instead (Geocoder.search([latitude, longitude], lookup: :nominatim)).

However, because of this, despite having setup Geocoder to use :test in my Rspec settings (Geocoder.configure(lookup: :test, ip_lookup: :test)) it's using Nominatim when that callback is executed. Removing lookup: :nominatim does make it use the :test lookup in the test environment.

Environment info

  • Geocoder version: 1.8.1
  • Rails version: 7.1.3
@alexreisner
Copy link
Owner

Thanks for this. Currently, specifying the lookup in the call to Geocoder.search overrides the global config, and that's how it should be in :production and :development environments. I think you're asking whether it should be that way in :test.

I'm not sure. If the behavior were changed, it would make it impossible to use any lookup but :test in the :test environment, and I can imagine cases where people want to make an actual API call.

I think this is best solved by stubbing out your method that calls Geocoder.search with the Nominatim lookup. Your use case is a little unusual and I'm worried that changing the default/override behavior in a single environment will lead to unexpected results. Does that make sense? Let me know if I'm missing anything.

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

2 participants