Skip to content

Commit

Permalink
Handle spaces in the location requests.
Browse files Browse the repository at this point in the history
  • Loading branch information
darrencauthon committed Oct 11, 2012
1 parent cd5baa9 commit 5467964
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/yahoo_weatherman/woeid_lookup.rb
@@ -1,3 +1,5 @@
require 'uri'

module Weatherman
class WoeidLookup

Expand All @@ -16,7 +18,7 @@ def get_woeid(location)
private

def query_string(location)
"http://where.yahooapis.com/v1/places.q('#{location}')?appid=#{@app_id}"
"http://where.yahooapis.com/v1/places.q('#{location.gsub(' ', '%20')}')?appid=#{@app_id}"
end

def get(url)
Expand Down
15 changes: 15 additions & 0 deletions spec/yahoo_weatherman/woeid_lookup_spec.rb
Expand Up @@ -63,4 +63,19 @@
response.should == nil
end
end

describe "request with spaces" do
before do
@app_id = 'test_api_id'
@lookup = Weatherman::WoeidLookup.new(@app_id)

xml_result = WoeidHelper.open_test_file('woeid_result_that_returns_12786745')
WoeidHelper.register_this_woeid_lookup_result(xml_result, @app_id, "San%20Francisco,%20CA")
end

it "should retrieve the woeid" do
response = @lookup.get_woeid("San Francisco, CA")
response.should == "12786745"
end
end
end

0 comments on commit 5467964

Please sign in to comment.