Skip to content
Snippets Groups Projects
Commit b5819ed6 authored by Alex Reisner's avatar Alex Reisner Committed by GitHub
Browse files

Merge pull request #1220 from commitshappen/master

Add coordinates for testing stubs to README
parents 7280ef8b 90611664
No related branches found
No related tags found
No related merge requests found
......@@ -1032,8 +1032,7 @@ When writing tests for an app that uses Geocoder it may be useful to avoid netwo
Geocoder::Lookup::Test.add_stub(
"New York, NY", [
{
'latitude' => 40.7143528,
'longitude' => -74.0059731,
'coordinates' => [40.7143528, -74.0059731]
'address' => 'New York, NY, USA',
'state' => 'New York',
'state_code' => 'NY',
......@@ -1043,15 +1042,14 @@ When writing tests for an app that uses Geocoder it may be useful to avoid netwo
]
)
Now, any time Geocoder looks up "New York, NY" its results array will contain one result with the above attributes. You can also set a default stub, to be returned when no other stub is found for a given query:
Now, any time Geocoder looks up "New York, NY" its results array will contain one result with the above attributes. Note each lookup requires an exact match to the text you provide as the first argument. The above example would, therefore, not match a request for "New York, NY, USA" and a second stub would need to be created to match that particular request. You can also set a default stub, to be returned when no other stub is found for a given query:
Geocoder.configure(:lookup => :test)
Geocoder::Lookup::Test.set_default_stub(
[
{
'latitude' => 40.7143528,
'longitude' => -74.0059731,
'coordinates' => [40.7143528, -74.0059731]
'address' => 'New York, NY, USA',
'state' => 'New York',
'state_code' => 'NY',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment