Skip to content

Commit

Permalink
Add second working example.
Browse files Browse the repository at this point in the history
  • Loading branch information
darrencauthon committed Oct 10, 2012
1 parent ab6227b commit d489ee1
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 9 deletions.
5 changes: 4 additions & 1 deletion lib/yahoo_weatherman.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class Client
def initialize(options = {})
@options = options
@uri = options[:url] || URI
@app_id = options[:app_id]
end

#
Expand All @@ -49,7 +50,9 @@ def lookup_by_woeid(woeid)
end

def lookup_by_location(location)
lookup_by_woeid('4729347')
lookup = WoeidLookup.new(@app_id)
woeid = lookup.get_woeid(location)
lookup_by_woeid(woeid)
end

private
Expand Down
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def fahrenheight_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)
FakeWeb.register_uri(:get, "http://weather.yahooapis.com/forecastrss?w=12786745&u=c", :body => celsius_fixture)

module YAML
class << self
Expand Down
30 changes: 22 additions & 8 deletions spec/yahoo_weatherman/yahoo_weatherman_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,28 @@
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)
describe "4729347 example" do
it "should lookup by location" do
app_id = 'test_id'
location = '78923'
@client = Weatherman::Client.new( { :app_id => app_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

describe "12786745 example" do
it "should lookup by location" do
app_id = 'apple'
location = 'orange'
@client = Weatherman::Client.new( { :app_id => app_id } )
xml_result = WoeidHelper.open_test_file 'woeid_result_that_returns_12786745'
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

Expand Down

0 comments on commit d489ee1

Please sign in to comment.