Skip to content

Commit

Permalink
First working example of lookup by location.
Browse files Browse the repository at this point in the history
  • Loading branch information
darrencauthon committed Oct 10, 2012
1 parent d654a84 commit ab6227b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/yahoo_weatherman.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions spec/yahoo_weatherman/yahoo_weatherman_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit ab6227b

Please sign in to comment.