Disable geocoding in a test environment

In my Ruby on Rails application, I use Geocoder. It works great, but my tests are ten times slower! I found some solution, but, in my opinion, are they not very clear? Is there a way to disable Geocoder in a test environment?

+5
source share
1 answer

According to the gem documentation on Github , you can use a test search in your tests to avoid executing real queries:

Geocoder.configure(:lookup => :test) Geocoder::Lookup::Test.add_stub( "New York, NY", [ { 'latitude' => 40.7143528, 'longitude' => -74.0059731, 'address' => 'New York, NY, USA', 'state' => 'New York', 'state_code' => 'NY', 'country' => 'United States', 'country_code' => 'US' } ] ) 
+7
source

Source: https://habr.com/ru/post/1209158/


All Articles