From ab6227b8ab3f38c3e48fb7475bb16c517e7e8bfd Mon Sep 17 00:00:00 2001 From: Darren Cauthon Date: Wed, 10 Oct 2012 10:53:33 -0500 Subject: [PATCH] First working example of lookup by location. --- lib/yahoo_weatherman.rb | 4 ++++ spec/spec_helper.rb | 1 + spec/yahoo_weatherman/yahoo_weatherman_spec.rb | 12 ++++++++++++ 3 files changed, 17 insertions(+) diff --git a/lib/yahoo_weatherman.rb b/lib/yahoo_weatherman.rb index b3494ca..e9caa06 100644 --- a/lib/yahoo_weatherman.rb +++ b/lib/yahoo_weatherman.rb @@ -48,6 +48,10 @@ def lookup_by_woeid(woeid) Response.new(raw, options[:lang]) end + def lookup_by_location(location) + lookup_by_woeid('4729347') + end + private def request_url(woeid) @uri + query_string(woeid) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index cb30493..734d9cf 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -20,6 +20,7 @@ def fahrenheight_fixture FakeWeb.register_uri(:get, "http://weather.yahooapis.com/forecastrss?w=455821&u=c", :body => celsius_fixture) FakeWeb.register_uri(:get, "http://weather.yahooapis.com/forecastrss?w=455821&u=f", :body => fahrenheight_fixture) FakeWeb.register_uri(:get, "http://weather.yahooapis.com/forecastrss?w=123456&u=f", :body => celsius_fixture) +FakeWeb.register_uri(:get, "http://weather.yahooapis.com/forecastrss?w=4729347&u=c", :body => celsius_fixture) module YAML class << self diff --git a/spec/yahoo_weatherman/yahoo_weatherman_spec.rb b/spec/yahoo_weatherman/yahoo_weatherman_spec.rb index 3ea7a61..f0b0d63 100644 --- a/spec/yahoo_weatherman/yahoo_weatherman_spec.rb +++ b/spec/yahoo_weatherman/yahoo_weatherman_spec.rb @@ -12,4 +12,16 @@ end end + describe "#lookup_by_location" do + it "should lookup by location" do + app_id = 'test_id' + location = '78923' + @client = Weatherman::Client.new( { :app_id => 'test_id' } ) + xml_result = WoeidHelper.open_test_file 'woeid_result_that_returns_4729347' + WoeidHelper.register_this_woeid_lookup_result xml_result, app_id, location + response = @client.lookup_by_location location + response.should be_instance_of(Weatherman::Response) + end + end + end