You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The text was updated successfully, but these errors were encountered:
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.
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. Removinglookup: :nominatim
does make it use the:test
lookup in the test environment.Environment info
The text was updated successfully, but these errors were encountered: