Skip to content

Instantly share code, notes, and snippets.

@th1agoalmeida
Last active August 29, 2015 14:09
Show Gist options
  • Save th1agoalmeida/5e4cf88e7ae1b985ecaa to your computer and use it in GitHub Desktop.
Save th1agoalmeida/5e4cf88e7ae1b985ecaa to your computer and use it in GitHub Desktop.
module Geocoder
module Lookup
class Base
private
def read_fixture(file)
File.read(File.join("spec", "fixtures", "geocoder", file)).strip.gsub(/\n\s*/, "")
end
end
class Google < Base
private
def fetch_raw_data(query, reverse = false)
raise TimeoutError if query == "timeout"
raise SocketError if query == "socket_error"
file = case query
when "no results"; :no_results
when "no locality"; :no_locality
when "no city data"; :no_city_data
else :madison_square_garden
end
read_fixture "google_data.json"
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment