Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Testing with geocoder gem

I'm using the geocoder gem, but I don't know in which file I must paste this code. Can you tell me ?

like image 277
Flo Rahl Avatar asked Sep 05 '13 15:09

Flo Rahl


1 Answers

That piece of code should be in the SETUP portion of whatever test framework you are using.

If using rspec, it should go here:

describe Something do
 before(:all) do 
  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'
    }
   ]
  )
 end
end
like image 117
SomeDudeSomewhere Avatar answered Oct 02 '22 08:10

SomeDudeSomewhere