spec/spec_helper.rb in attack-barometer-0.3.2 vs spec/spec_helper.rb in attack-barometer-0.5.0
- old
+ new
@@ -14,26 +14,150 @@
def geocode_google_key_message
puts
puts "Please update the key_file '#{KEY_FILE}' with your google api key"
puts "example:"
- puts "geocode_google: YOUR_KEY_KERE"
+ puts "google: geocode: YOUR_KEY_KERE"
puts
end
if File.exists?(KEY_FILE)
keys = YAML.load_file(KEY_FILE)
- if keys["geocode_google"]
- KEY = keys["geocode_google"]
+ if keys["google"]
+ KEY = keys["google"]["geocode"]
else
geocode_google_key_message
exit
end
+ if keys["weather"]
+ WEATHER_PARTNER_KEY = keys["weather"]["partner"]
+ WEATHER_LICENSE_KEY = keys["weather"]["license"]
+ end
+
else
- File.open(KEY_FILE, 'w') {|f| f << "geocode_google: YOUR_KEY_KERE" }
+ File.open(KEY_FILE, 'w') {|f| f << "google: geocode: YOUR_KEY_KERE" }
geocode_google_key_message
exit
end
+
+
+ #
+ # for geocoding
+ #
+ geo_url = "http://maps.google.com/maps/geo?"
+ FakeWeb.register_uri(:get,
+ "#{geo_url}gl=US&q=90210&output=xml&key=#{KEY}",
+ :string => File.read(File.join(File.dirname(__FILE__),
+ 'fixtures/geocode',
+ '90210.xml')
+ )
+ )
+ FakeWeb.register_uri(:get,
+ "#{geo_url}gl=&q=#{CGI.escape("40.756054,-73.986951")}&output=xml&key=#{KEY}",
+ :string => File.read(File.join(File.dirname(__FILE__),
+ 'fixtures/geocode',
+ '40_73.xml')
+ )
+ )
+
+ # FakeWeb.register_uri(:get,
+ # "#{geo_url}gl=&q=90210&output=xml&key=#{KEY}",
+ # :string => File.read(File.join(File.dirname(__FILE__),
+ # 'fixtures/geocode',
+ # '90210.xml')
+ # )
+ # )
+ FakeWeb.register_uri(:get,
+ "#{geo_url}gl=&q=New%20York%2C%20NY&output=xml&key=#{KEY}",
+ :string => File.read(File.join(File.dirname(__FILE__),
+ 'fixtures/geocode',
+ 'newyork_ny.xml')
+ )
+ )
+ FakeWeb.register_uri(:get,
+ "#{geo_url}gl=CA&key=#{@key}&output=xml&q=T5B%204M9",
+ :string => File.read(File.join(File.dirname(__FILE__),
+ 'fixtures/geocode',
+ 'T5B4M9.xml')
+ )
+ )
+
+ FakeWeb.register_uri(:get,
+ "#{geo_url}gl=&q=T5B%204M9&output=xml&key=#{KEY}",
+ :string => File.read(File.join(File.dirname(__FILE__),
+ 'fixtures/geocode',
+ 'T5B4M9.xml')
+ )
+ )
+ FakeWeb.register_uri(:get,
+ "#{geo_url}output=xml&q=T5B%204M9&gl=CA&key=#{KEY}",
+ :string => File.read(File.join(File.dirname(__FILE__),
+ 'fixtures/geocode',
+ 'T5B4M9.xml')
+ )
+ )
+ FakeWeb.register_uri(:get,
+ "#{geo_url}gl=US&q=KSFO&output=xml&key=#{KEY}",
+ :string => File.read(File.join(File.dirname(__FILE__),
+ 'fixtures/geocode',
+ 'ksfo.xml')
+ )
+ )
+ FakeWeb.register_uri(:get,
+ "#{geo_url}gl=&q=Atlanta%2C%20GA%2C%20US&output=xml&key=#{KEY}",
+ :string => File.read(File.join(File.dirname(__FILE__),
+ 'fixtures/geocode',
+ 'atlanta.xml')
+ )
+ )
+ FakeWeb.register_uri(:get,
+ "#{geo_url}output=xml&q=Atlanta%2C%20GA%2C%20US&gl=US&key=#{KEY}",
+ :string => File.read(File.join(File.dirname(__FILE__),
+ 'fixtures/geocode',
+ 'atlanta.xml')
+ )
+ )
+ #
+ # for weather.com searches
+ #
+ FakeWeb.register_uri(:get,
+ "http://xoap.weather.com:80/search/search?where=Beverly%20Hills%2C%20CA%2C%20USA",
+ :string => File.read(File.join(File.dirname(__FILE__),
+ 'fixtures/formats/weather_id',
+ '90210.xml')
+ )
+ )
+ FakeWeb.register_uri(:get,
+ "http://xoap.weather.com:80/search/search?where=New%20York%2C%20NY",
+ :string => File.read(File.join(File.dirname(__FILE__),
+ 'fixtures/formats/weather_id',
+ 'new_york.xml')
+ )
+ )
+ FakeWeb.register_uri(:get,
+ "http://xoap.weather.com:80/search/search?where=New%20York%2C%20NY%2C%20USA",
+ :string => File.read(File.join(File.dirname(__FILE__),
+ 'fixtures/formats/weather_id',
+ 'new_york.xml')
+ )
+ )
+ FakeWeb.register_uri(:get,
+ "http://xoap.weather.com:80/search/search?where=90210",
+ :string => File.read(File.join(File.dirname(__FILE__),
+ 'fixtures/formats/weather_id',
+ '90210.xml')
+ )
+ )
+ #
+ # for yahoo.com searches
+ #
+ FakeWeb.register_uri(:get,
+ "http://weather.yahooapis.com:80/forecastrss?p=USGA0028",
+ :string => File.read(File.join(File.dirname(__FILE__),
+ 'fixtures/formats/weather_id',
+ 'from_USGA0028.xml')
+ )
+ )
Spec::Runner.configure do |config|
end