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

Refactor: add read_fixture method.

parent b5c8ccf1
No related branches found
No related tags found
No related merge requests found
......@@ -47,12 +47,19 @@ require "geocoder/lookups/base"
#
module Geocoder
module Lookup
class Base
private #-----------------------------------------------------------------
def read_fixture(file)
File.read(File.join("test", "fixtures", file)).strip.gsub(/\n\s*/, "")
end
end
class Google < Base
private #-----------------------------------------------------------------
def fetch_raw_data(query, reverse = false)
raise TimeoutError if query == "timeout"
file = query == "no results" ? :no_results : :madison_square_garden
File.read(File.join("test", "fixtures", "google_#{file}.json"))
read_fixture "google_#{file}.json"
end
end
......@@ -61,7 +68,7 @@ module Geocoder
def fetch_raw_data(query, reverse = false)
raise TimeoutError if query == "timeout"
file = query == "no results" ? :no_results : :madison_square_garden
File.read(File.join("test", "fixtures", "yahoo_#{file}.json"))
read_fixture "yahoo_#{file}.json"
end
end
......@@ -69,7 +76,7 @@ module Geocoder
private #-----------------------------------------------------------------
def fetch_raw_data(query, reverse = false)
raise TimeoutError if query == "timeout"
File.read(File.join("test", "fixtures", "freegeoip_74_200_247_59.json"))
read_fixture "freegeoip_74_200_247_59.json"
end
end
end
......
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