6

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

Cœur
  • 37,241
  • 25
  • 195
  • 267
Mateusz Urbański
  • 7,352
  • 15
  • 68
  • 133

1 Answers1

8

According to the gem documentation on Github, you can use a test lookup in your tests, to avoid doing actual requests:

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'
    }
  ]
)
fivedigit
  • 18,464
  • 6
  • 54
  • 58