weather-api 1.0.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +7 -0
  2. data/.travis.yml +1 -1
  3. data/Gemfile +1 -7
  4. data/README.md +3 -4
  5. data/Rakefile +1 -1
  6. data/lib/weather-api.rb +47 -25
  7. data/lib/weather-api/astronomy.rb +3 -3
  8. data/lib/weather-api/atmosphere.rb +4 -4
  9. data/lib/weather-api/condition.rb +5 -5
  10. data/lib/weather-api/forecast.rb +7 -7
  11. data/lib/weather-api/image.rb +2 -18
  12. data/lib/weather-api/location.rb +4 -4
  13. data/lib/weather-api/response.rb +14 -18
  14. data/lib/weather-api/units.rb +5 -5
  15. data/lib/weather-api/utils.rb +3 -3
  16. data/lib/weather-api/version.rb +2 -2
  17. data/lib/weather-api/wind.rb +4 -4
  18. data/spec/fixtures/cassettes/Weather_Astronomy/should_contain_Time_objects_for_sunrise_and_sunset.yml +62 -0
  19. data/spec/fixtures/cassettes/Weather_Atmosphere/should_contain_a_float_indicating_atmospheric_pressure.yml +62 -0
  20. data/spec/fixtures/cassettes/Weather_Atmosphere/should_contain_a_string_indicating_barometric_pressure.yml +62 -0
  21. data/spec/fixtures/cassettes/Weather_Atmosphere/should_contain_integers_representing_humidity_and_visibility.yml +62 -0
  22. data/spec/fixtures/cassettes/Weather_Condition/should_contain_a_weather_condition_code_a_date_a_temperature_and_a_description.yml +62 -0
  23. data/spec/fixtures/cassettes/Weather_Forecast/should_contain_high_and_low_forecasts.yml +62 -0
  24. data/spec/fixtures/cassettes/Weather_Forecast/should_contain_the_name_of_the_day_associated_with_the_forecast.yml +62 -0
  25. data/spec/fixtures/cassettes/Weather_Forecast/should_have_a_brief_description_of_the_forecasted_conditions.yml +62 -0
  26. data/spec/fixtures/cassettes/Weather_Forecast/should_have_a_weather_condition_code.yml +62 -0
  27. data/spec/fixtures/cassettes/Weather_Forecast/should_have_an_associated_date.yml +62 -0
  28. data/spec/fixtures/cassettes/Weather_Image/should_contain_a_string_for_the_image_url.yml +62 -0
  29. data/spec/fixtures/cassettes/Weather_Location/should_be_able_to_look_up_Nice_France.yml +62 -0
  30. data/spec/fixtures/cassettes/Weather_Location/should_be_able_to_look_up_Seattle_WA.yml +62 -0
  31. data/spec/fixtures/cassettes/Weather_Location/should_be_able_to_look_up_Victoria_BC.yml +62 -0
  32. data/spec/fixtures/cassettes/Weather_Location/should_contain_city_country_and_region_as_strings.yml +62 -0
  33. data/spec/fixtures/cassettes/Weather_Response/should_contain_a_HTML_description_summarizing_weather_conditions.yml +62 -0
  34. data/spec/fixtures/cassettes/Weather_Response/should_contain_a_String_title.yml +62 -0
  35. data/spec/fixtures/cassettes/Weather_Response/should_contain_a_Weather_Astronomy_object.yml +62 -0
  36. data/spec/fixtures/cassettes/Weather_Response/should_contain_a_Weather_Atmosphere_object.yml +62 -0
  37. data/spec/fixtures/cassettes/Weather_Response/should_contain_a_Weather_Condition_object.yml +62 -0
  38. data/spec/fixtures/cassettes/Weather_Response/should_contain_a_Weather_Image_object.yml +62 -0
  39. data/spec/fixtures/cassettes/Weather_Response/should_contain_a_Weather_Location_object.yml +62 -0
  40. data/spec/fixtures/cassettes/Weather_Response/should_contain_a_Weather_Units_object.yml +62 -0
  41. data/spec/fixtures/cassettes/Weather_Response/should_contain_a_Weather_Wind_object.yml +62 -0
  42. data/spec/fixtures/cassettes/Weather_Response/should_contain_a_collection_of_Weather_Forecast_objects.yml +62 -0
  43. data/spec/fixtures/cassettes/Weather_Response/should_contain_latitude_and_longitude_in_floats.yml +62 -0
  44. data/spec/fixtures/cassettes/Weather_Response/should_contain_the_WOEID_of_the_request_location_and_the_requested_URL.yml +62 -0
  45. data/spec/fixtures/cassettes/Weather_Units/defaults/should_default_to_imperial_units.yml +62 -0
  46. data/spec/fixtures/cassettes/Weather_Units/defaults/should_switch_to_metric_if_specified.yml +62 -0
  47. data/spec/fixtures/cassettes/Weather_Wind/should_contain_chill_direction_and_speed_as_integers.yml +62 -0
  48. data/spec/lib/astronomy_spec.rb +12 -0
  49. data/spec/lib/atmosphere_spec.rb +20 -0
  50. data/spec/lib/condition_spec.rb +14 -0
  51. data/spec/lib/forecast_spec.rb +28 -0
  52. data/spec/lib/image_spec.rb +11 -0
  53. data/spec/lib/location_spec.rb +36 -0
  54. data/spec/lib/response_spec.rb +57 -0
  55. data/spec/lib/units_spec.rb +30 -0
  56. data/spec/lib/utils_spec.rb +11 -0
  57. data/spec/lib/version_spec.rb +7 -0
  58. data/spec/lib/wind_spec.rb +13 -0
  59. data/spec/{helper.rb → spec_helper.rb} +3 -5
  60. data/weather-api.gemspec +9 -11
  61. metadata +127 -88
  62. data/Guardfile +0 -19
  63. data/lib/weather-api/api.rb +0 -33
  64. data/spec/cases/api_spec.rb +0 -8
  65. data/spec/cases/astronomy_spec.rb +0 -15
  66. data/spec/cases/atmosphere_spec.rb +0 -23
  67. data/spec/cases/condition_spec.rb +0 -17
  68. data/spec/cases/forecast_spec.rb +0 -32
  69. data/spec/cases/image_spec.rb +0 -21
  70. data/spec/cases/location_spec.rb +0 -41
  71. data/spec/cases/response_spec.rb +0 -60
  72. data/spec/cases/units_spec.rb +0 -36
  73. data/spec/cases/utils_spec.rb +0 -13
  74. data/spec/cases/version_spec.rb +0 -8
  75. data/spec/cases/wind_spec.rb +0 -16
@@ -0,0 +1,62 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://query.yahooapis.com/v1/public/yql?format=json&q=select%20*%20from%20weather.forecast%20where%20woeid=9848%20and%20u='f'
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - '*/*'
14
+ User-Agent:
15
+ - Ruby
16
+ Host:
17
+ - query.yahooapis.com
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ X-Yql-Host:
24
+ - engine6.yql.ne1.yahoo.com
25
+ Access-Control-Allow-Origin:
26
+ - '*'
27
+ Cache-Control:
28
+ - public, max-age=3599
29
+ Content-Type:
30
+ - application/json;charset=utf-8
31
+ Vary:
32
+ - Accept-Encoding
33
+ Date:
34
+ - Fri, 29 Mar 2013 06:50:18 GMT
35
+ Server:
36
+ - YTS/1.20.13
37
+ Age:
38
+ - '1531'
39
+ Content-Length:
40
+ - '880'
41
+ Connection:
42
+ - keep-alive
43
+ body:
44
+ encoding: UTF-8
45
+ string: '{"query":{"count":1,"created":"2013-03-29T06:50:19Z","lang":"en-US","results":{"channel":{"title":"Yahoo!
46
+ Weather - Victoria, CA","link":"http://us.rd.yahoo.com/dailynews/rss/weather/Victoria__CA/*http://weather.yahoo.com/forecast/CAXX0523_f.html","description":"Yahoo!
47
+ Weather for Victoria, CA","language":"en-us","lastBuildDate":"Thu, 28 Mar
48
+ 2013 8:59 pm PDT","ttl":"60","location":{"city":"Victoria","country":"Canada","region":"BC"},"units":{"distance":"mi","pressure":"in","speed":"mph","temperature":"F"},"wind":{"chill":"46","direction":"230","speed":"5"},"atmosphere":{"humidity":"82","pressure":"30.11","rising":"1","visibility":""},"astronomy":{"sunrise":"6:59
49
+ am","sunset":"7:36 pm"},"image":{"title":"Yahoo! Weather","width":"142","height":"18","link":"http://weather.yahoo.com","url":"http://l.yimg.com/a/i/brand/purplelogo//uh/us/news-wea.gif"},"item":{"title":"Conditions
50
+ for Victoria, CA at 8:59 pm PDT","lat":"48.43","long":"-123.36","link":"http://us.rd.yahoo.com/dailynews/rss/weather/Victoria__CA/*http://weather.yahoo.com/forecast/CAXX0523_f.html","pubDate":"Thu,
51
+ 28 Mar 2013 8:59 pm PDT","condition":{"code":"29","date":"Thu, 28 Mar 2013
52
+ 8:59 pm PDT","temp":"48","text":"Partly Cloudy"},"description":"\n<img src=\"http://l.yimg.com/a/i/us/we/52/29.gif\"/><br
53
+ />\n<b>Current Conditions:</b><br />\nPartly Cloudy, 48 F<BR />\n<BR /><b>Forecast:</b><BR
54
+ />\nThu - Clear. High: 55 Low: 43<br />\nFri - AM Clouds/PM Sun. High: 55
55
+ Low: 44<br />\n<br />\n<a href=\"http://us.rd.yahoo.com/dailynews/rss/weather/Victoria__CA/*http://weather.yahoo.com/forecast/CAXX0523_f.html\">Full
56
+ Forecast at Yahoo! Weather</a><BR/><BR/>\n(provided by <a href=\"http://www.weather.com\"
57
+ >The Weather Channel</a>)<br/>\n","forecast":[{"code":"31","date":"28 Mar
58
+ 2013","day":"Thu","high":"55","low":"43","text":"Clear"},{"code":"30","date":"29
59
+ Mar 2013","day":"Fri","high":"55","low":"44","text":"AM Clouds/PM Sun"}],"guid":{"isPermaLink":"false","content":"CAXX0523_2013_03_29_7_00_PDT"}}}}}}'
60
+ http_version:
61
+ recorded_at: Fri, 29 Mar 2013 07:15:50 GMT
62
+ recorded_with: VCR 2.4.0
@@ -0,0 +1,62 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://query.yahooapis.com/v1/public/yql?format=json&q=select%20*%20from%20weather.forecast%20where%20woeid=9848%20and%20u='f'
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - '*/*'
14
+ User-Agent:
15
+ - Ruby
16
+ Host:
17
+ - query.yahooapis.com
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ X-Yql-Host:
24
+ - engine1.yql.ne1.yahoo.com
25
+ Access-Control-Allow-Origin:
26
+ - '*'
27
+ Cache-Control:
28
+ - public, max-age=3600
29
+ Content-Type:
30
+ - application/json;charset=utf-8
31
+ Vary:
32
+ - Accept-Encoding
33
+ Date:
34
+ - Fri, 29 Mar 2013 06:53:56 GMT
35
+ Server:
36
+ - YTS/1.20.13
37
+ Age:
38
+ - '1313'
39
+ Content-Length:
40
+ - '880'
41
+ Connection:
42
+ - keep-alive
43
+ body:
44
+ encoding: UTF-8
45
+ string: '{"query":{"count":1,"created":"2013-03-29T06:53:57Z","lang":"en-US","results":{"channel":{"title":"Yahoo!
46
+ Weather - Victoria, CA","link":"http://us.rd.yahoo.com/dailynews/rss/weather/Victoria__CA/*http://weather.yahoo.com/forecast/CAXX0523_f.html","description":"Yahoo!
47
+ Weather for Victoria, CA","language":"en-us","lastBuildDate":"Thu, 28 Mar
48
+ 2013 8:59 pm PDT","ttl":"60","location":{"city":"Victoria","country":"Canada","region":"BC"},"units":{"distance":"mi","pressure":"in","speed":"mph","temperature":"F"},"wind":{"chill":"46","direction":"230","speed":"5"},"atmosphere":{"humidity":"82","pressure":"30.11","rising":"1","visibility":""},"astronomy":{"sunrise":"6:59
49
+ am","sunset":"7:36 pm"},"image":{"title":"Yahoo! Weather","width":"142","height":"18","link":"http://weather.yahoo.com","url":"http://l.yimg.com/a/i/brand/purplelogo//uh/us/news-wea.gif"},"item":{"title":"Conditions
50
+ for Victoria, CA at 8:59 pm PDT","lat":"48.43","long":"-123.36","link":"http://us.rd.yahoo.com/dailynews/rss/weather/Victoria__CA/*http://weather.yahoo.com/forecast/CAXX0523_f.html","pubDate":"Thu,
51
+ 28 Mar 2013 8:59 pm PDT","condition":{"code":"29","date":"Thu, 28 Mar 2013
52
+ 8:59 pm PDT","temp":"48","text":"Partly Cloudy"},"description":"\n<img src=\"http://l.yimg.com/a/i/us/we/52/29.gif\"/><br
53
+ />\n<b>Current Conditions:</b><br />\nPartly Cloudy, 48 F<BR />\n<BR /><b>Forecast:</b><BR
54
+ />\nThu - Clear. High: 55 Low: 43<br />\nFri - AM Clouds/PM Sun. High: 55
55
+ Low: 44<br />\n<br />\n<a href=\"http://us.rd.yahoo.com/dailynews/rss/weather/Victoria__CA/*http://weather.yahoo.com/forecast/CAXX0523_f.html\">Full
56
+ Forecast at Yahoo! Weather</a><BR/><BR/>\n(provided by <a href=\"http://www.weather.com\"
57
+ >The Weather Channel</a>)<br/>\n","forecast":[{"code":"31","date":"28 Mar
58
+ 2013","day":"Thu","high":"55","low":"43","text":"Clear"},{"code":"30","date":"29
59
+ Mar 2013","day":"Fri","high":"55","low":"44","text":"AM Clouds/PM Sun"}],"guid":{"isPermaLink":"false","content":"CAXX0523_2013_03_29_7_00_PDT"}}}}}}'
60
+ http_version:
61
+ recorded_at: Fri, 29 Mar 2013 07:15:49 GMT
62
+ recorded_with: VCR 2.4.0
@@ -0,0 +1,62 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://query.yahooapis.com/v1/public/yql?format=json&q=select%20*%20from%20weather.forecast%20where%20woeid=9848%20and%20u='f'
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - '*/*'
14
+ User-Agent:
15
+ - Ruby
16
+ Host:
17
+ - query.yahooapis.com
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ X-Yql-Host:
24
+ - engine6.yql.ne1.yahoo.com
25
+ Access-Control-Allow-Origin:
26
+ - '*'
27
+ Cache-Control:
28
+ - public, max-age=3599
29
+ Content-Type:
30
+ - application/json;charset=utf-8
31
+ Vary:
32
+ - Accept-Encoding
33
+ Date:
34
+ - Fri, 29 Mar 2013 06:50:18 GMT
35
+ Server:
36
+ - YTS/1.20.13
37
+ Age:
38
+ - '1532'
39
+ Content-Length:
40
+ - '880'
41
+ Connection:
42
+ - keep-alive
43
+ body:
44
+ encoding: UTF-8
45
+ string: '{"query":{"count":1,"created":"2013-03-29T06:50:19Z","lang":"en-US","results":{"channel":{"title":"Yahoo!
46
+ Weather - Victoria, CA","link":"http://us.rd.yahoo.com/dailynews/rss/weather/Victoria__CA/*http://weather.yahoo.com/forecast/CAXX0523_f.html","description":"Yahoo!
47
+ Weather for Victoria, CA","language":"en-us","lastBuildDate":"Thu, 28 Mar
48
+ 2013 8:59 pm PDT","ttl":"60","location":{"city":"Victoria","country":"Canada","region":"BC"},"units":{"distance":"mi","pressure":"in","speed":"mph","temperature":"F"},"wind":{"chill":"46","direction":"230","speed":"5"},"atmosphere":{"humidity":"82","pressure":"30.11","rising":"1","visibility":""},"astronomy":{"sunrise":"6:59
49
+ am","sunset":"7:36 pm"},"image":{"title":"Yahoo! Weather","width":"142","height":"18","link":"http://weather.yahoo.com","url":"http://l.yimg.com/a/i/brand/purplelogo//uh/us/news-wea.gif"},"item":{"title":"Conditions
50
+ for Victoria, CA at 8:59 pm PDT","lat":"48.43","long":"-123.36","link":"http://us.rd.yahoo.com/dailynews/rss/weather/Victoria__CA/*http://weather.yahoo.com/forecast/CAXX0523_f.html","pubDate":"Thu,
51
+ 28 Mar 2013 8:59 pm PDT","condition":{"code":"29","date":"Thu, 28 Mar 2013
52
+ 8:59 pm PDT","temp":"48","text":"Partly Cloudy"},"description":"\n<img src=\"http://l.yimg.com/a/i/us/we/52/29.gif\"/><br
53
+ />\n<b>Current Conditions:</b><br />\nPartly Cloudy, 48 F<BR />\n<BR /><b>Forecast:</b><BR
54
+ />\nThu - Clear. High: 55 Low: 43<br />\nFri - AM Clouds/PM Sun. High: 55
55
+ Low: 44<br />\n<br />\n<a href=\"http://us.rd.yahoo.com/dailynews/rss/weather/Victoria__CA/*http://weather.yahoo.com/forecast/CAXX0523_f.html\">Full
56
+ Forecast at Yahoo! Weather</a><BR/><BR/>\n(provided by <a href=\"http://www.weather.com\"
57
+ >The Weather Channel</a>)<br/>\n","forecast":[{"code":"31","date":"28 Mar
58
+ 2013","day":"Thu","high":"55","low":"43","text":"Clear"},{"code":"30","date":"29
59
+ Mar 2013","day":"Fri","high":"55","low":"44","text":"AM Clouds/PM Sun"}],"guid":{"isPermaLink":"false","content":"CAXX0523_2013_03_29_7_00_PDT"}}}}}}'
60
+ http_version:
61
+ recorded_at: Fri, 29 Mar 2013 07:15:50 GMT
62
+ recorded_with: VCR 2.4.0
@@ -0,0 +1,62 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://query.yahooapis.com/v1/public/yql?format=json&q=select%20*%20from%20weather.forecast%20where%20woeid=9848%20and%20u='c'
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - '*/*'
14
+ User-Agent:
15
+ - Ruby
16
+ Host:
17
+ - query.yahooapis.com
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ X-Yql-Host:
24
+ - engine5.yql.ne1.yahoo.com
25
+ Access-Control-Allow-Origin:
26
+ - '*'
27
+ Cache-Control:
28
+ - public, max-age=3600
29
+ Content-Type:
30
+ - application/json;charset=utf-8
31
+ Vary:
32
+ - Accept-Encoding
33
+ Date:
34
+ - Fri, 29 Mar 2013 07:08:11 GMT
35
+ Server:
36
+ - YTS/1.20.13
37
+ Age:
38
+ - '459'
39
+ Content-Length:
40
+ - '881'
41
+ Connection:
42
+ - keep-alive
43
+ body:
44
+ encoding: UTF-8
45
+ string: '{"query":{"count":1,"created":"2013-03-29T07:08:12Z","lang":"en-US","results":{"channel":{"title":"Yahoo!
46
+ Weather - Victoria, CA","link":"http://us.rd.yahoo.com/dailynews/rss/weather/Victoria__CA/*http://weather.yahoo.com/forecast/CAXX0523_c.html","description":"Yahoo!
47
+ Weather for Victoria, CA","language":"en-us","lastBuildDate":"Thu, 28 Mar
48
+ 2013 8:59 pm PDT","ttl":"60","location":{"city":"Victoria","country":"Canada","region":"BC"},"units":{"distance":"km","pressure":"mb","speed":"km/h","temperature":"C"},"wind":{"chill":"8","direction":"230","speed":"8.05"},"atmosphere":{"humidity":"82","pressure":"1015.92","rising":"1","visibility":""},"astronomy":{"sunrise":"6:59
49
+ am","sunset":"7:36 pm"},"image":{"title":"Yahoo! Weather","width":"142","height":"18","link":"http://weather.yahoo.com","url":"http://l.yimg.com/a/i/brand/purplelogo//uh/us/news-wea.gif"},"item":{"title":"Conditions
50
+ for Victoria, CA at 8:59 pm PDT","lat":"48.43","long":"-123.36","link":"http://us.rd.yahoo.com/dailynews/rss/weather/Victoria__CA/*http://weather.yahoo.com/forecast/CAXX0523_c.html","pubDate":"Thu,
51
+ 28 Mar 2013 8:59 pm PDT","condition":{"code":"29","date":"Thu, 28 Mar 2013
52
+ 8:59 pm PDT","temp":"9","text":"Partly Cloudy"},"description":"\n<img src=\"http://l.yimg.com/a/i/us/we/52/29.gif\"/><br
53
+ />\n<b>Current Conditions:</b><br />\nPartly Cloudy, 9 C<BR />\n<BR /><b>Forecast:</b><BR
54
+ />\nThu - Clear. High: 13 Low: 6<br />\nFri - AM Clouds/PM Sun. High: 13 Low:
55
+ 7<br />\n<br />\n<a href=\"http://us.rd.yahoo.com/dailynews/rss/weather/Victoria__CA/*http://weather.yahoo.com/forecast/CAXX0523_c.html\">Full
56
+ Forecast at Yahoo! Weather</a><BR/><BR/>\n(provided by <a href=\"http://www.weather.com\"
57
+ >The Weather Channel</a>)<br/>\n","forecast":[{"code":"31","date":"28 Mar
58
+ 2013","day":"Thu","high":"13","low":"6","text":"Clear"},{"code":"30","date":"29
59
+ Mar 2013","day":"Fri","high":"13","low":"7","text":"AM Clouds/PM Sun"}],"guid":{"isPermaLink":"false","content":"CAXX0523_2013_03_29_7_00_PDT"}}}}}}'
60
+ http_version:
61
+ recorded_at: Fri, 29 Mar 2013 07:15:50 GMT
62
+ recorded_with: VCR 2.4.0
@@ -0,0 +1,62 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://query.yahooapis.com/v1/public/yql?format=json&q=select%20*%20from%20weather.forecast%20where%20woeid=9848%20and%20u='f'
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - '*/*'
14
+ User-Agent:
15
+ - Ruby
16
+ Host:
17
+ - query.yahooapis.com
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ X-Yql-Host:
24
+ - engine6.yql.ne1.yahoo.com
25
+ Access-Control-Allow-Origin:
26
+ - '*'
27
+ Cache-Control:
28
+ - public, max-age=3599
29
+ Content-Type:
30
+ - application/json;charset=utf-8
31
+ Vary:
32
+ - Accept-Encoding
33
+ Date:
34
+ - Fri, 29 Mar 2013 06:50:18 GMT
35
+ Server:
36
+ - YTS/1.20.13
37
+ Age:
38
+ - '1532'
39
+ Content-Length:
40
+ - '880'
41
+ Connection:
42
+ - keep-alive
43
+ body:
44
+ encoding: UTF-8
45
+ string: '{"query":{"count":1,"created":"2013-03-29T06:50:19Z","lang":"en-US","results":{"channel":{"title":"Yahoo!
46
+ Weather - Victoria, CA","link":"http://us.rd.yahoo.com/dailynews/rss/weather/Victoria__CA/*http://weather.yahoo.com/forecast/CAXX0523_f.html","description":"Yahoo!
47
+ Weather for Victoria, CA","language":"en-us","lastBuildDate":"Thu, 28 Mar
48
+ 2013 8:59 pm PDT","ttl":"60","location":{"city":"Victoria","country":"Canada","region":"BC"},"units":{"distance":"mi","pressure":"in","speed":"mph","temperature":"F"},"wind":{"chill":"46","direction":"230","speed":"5"},"atmosphere":{"humidity":"82","pressure":"30.11","rising":"1","visibility":""},"astronomy":{"sunrise":"6:59
49
+ am","sunset":"7:36 pm"},"image":{"title":"Yahoo! Weather","width":"142","height":"18","link":"http://weather.yahoo.com","url":"http://l.yimg.com/a/i/brand/purplelogo//uh/us/news-wea.gif"},"item":{"title":"Conditions
50
+ for Victoria, CA at 8:59 pm PDT","lat":"48.43","long":"-123.36","link":"http://us.rd.yahoo.com/dailynews/rss/weather/Victoria__CA/*http://weather.yahoo.com/forecast/CAXX0523_f.html","pubDate":"Thu,
51
+ 28 Mar 2013 8:59 pm PDT","condition":{"code":"29","date":"Thu, 28 Mar 2013
52
+ 8:59 pm PDT","temp":"48","text":"Partly Cloudy"},"description":"\n<img src=\"http://l.yimg.com/a/i/us/we/52/29.gif\"/><br
53
+ />\n<b>Current Conditions:</b><br />\nPartly Cloudy, 48 F<BR />\n<BR /><b>Forecast:</b><BR
54
+ />\nThu - Clear. High: 55 Low: 43<br />\nFri - AM Clouds/PM Sun. High: 55
55
+ Low: 44<br />\n<br />\n<a href=\"http://us.rd.yahoo.com/dailynews/rss/weather/Victoria__CA/*http://weather.yahoo.com/forecast/CAXX0523_f.html\">Full
56
+ Forecast at Yahoo! Weather</a><BR/><BR/>\n(provided by <a href=\"http://www.weather.com\"
57
+ >The Weather Channel</a>)<br/>\n","forecast":[{"code":"31","date":"28 Mar
58
+ 2013","day":"Thu","high":"55","low":"43","text":"Clear"},{"code":"30","date":"29
59
+ Mar 2013","day":"Fri","high":"55","low":"44","text":"AM Clouds/PM Sun"}],"guid":{"isPermaLink":"false","content":"CAXX0523_2013_03_29_7_00_PDT"}}}}}}'
60
+ http_version:
61
+ recorded_at: Fri, 29 Mar 2013 07:15:50 GMT
62
+ recorded_with: VCR 2.4.0
@@ -0,0 +1,12 @@
1
+ require 'spec_helper'
2
+
3
+ describe Weather::Astronomy, :vcr do
4
+ let(:response) { Weather.lookup 9848 }
5
+
6
+ subject { response.astronomy }
7
+
8
+ it 'should contain Time objects for sunrise and sunset' do
9
+ expect(subject.sunrise).to be_a Time
10
+ expect(subject.sunset).to be_a Time
11
+ end
12
+ end
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+
3
+ describe Weather::Atmosphere, :vcr do
4
+ let(:response) { Weather.lookup 9848 }
5
+
6
+ subject { response.atmosphere }
7
+
8
+ it 'should contain a string indicating barometric pressure' do
9
+ expect(subject.barometer).to be_a String
10
+ end
11
+
12
+ it 'should contain integers representing humidity and visibility' do
13
+ expect(subject.humidity).to be_a Integer
14
+ expect(subject.visibility).to be_a Integer
15
+ end
16
+
17
+ it 'should contain a float indicating atmospheric pressure' do
18
+ expect(subject.pressure).to be_a Float
19
+ end
20
+ end
@@ -0,0 +1,14 @@
1
+ require 'spec_helper'
2
+
3
+ describe Weather::Condition, :vcr do
4
+ let(:response) { Weather.lookup 9848 }
5
+
6
+ subject { response.condition }
7
+
8
+ it 'should contain a weather condition code, a date, a temperature, and a description' do
9
+ expect(subject.code).to be_a Integer
10
+ expect(subject.date).to be_a Time
11
+ expect(subject.temp).to be_a Integer
12
+ expect(subject.text).to be_a String
13
+ end
14
+ end
@@ -0,0 +1,28 @@
1
+ require 'spec_helper'
2
+
3
+ describe Weather::Forecast, :vcr do
4
+ let(:response) { Weather.lookup 9848 }
5
+
6
+ subject { response.forecasts[0] }
7
+
8
+ it 'should have an associated date' do
9
+ expect(subject.date).to be_a Time
10
+ end
11
+
12
+ it 'should contain high and low forecasts' do
13
+ expect(subject.high).to be_a Integer
14
+ expect(subject.low).to be_a Integer
15
+ end
16
+
17
+ it 'should contain the name of the day associated with the forecast' do
18
+ expect(subject.day).to be_a String
19
+ end
20
+
21
+ it 'should have a weather condition code' do
22
+ expect(subject.code).to be_a Integer
23
+ end
24
+
25
+ it 'should have a brief description of the forecasted conditions' do
26
+ expect(subject.text).to be_a String
27
+ end
28
+ end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ describe Weather::Image, :vcr do
4
+ let(:response) { Weather.lookup 9848 }
5
+
6
+ subject { response.image }
7
+
8
+ it 'should contain a string for the image url' do
9
+ expect(subject.url).to be_a String
10
+ end
11
+ end
@@ -0,0 +1,36 @@
1
+ require 'spec_helper'
2
+
3
+ describe Weather::Location, :vcr do
4
+ it 'should contain city, country, and region as strings' do
5
+ response = Weather.lookup 9848
6
+
7
+ expect(response.location.city).to be_a String
8
+ expect(response.location.city).to be_a String
9
+ expect(response.location.region).to be_a String
10
+ expect(response.location.country).to be_a String
11
+ end
12
+
13
+ it 'should be able to look up Seattle, WA' do
14
+ response = Weather.lookup 2490383
15
+
16
+ expect(response.location.city).to eq 'Seattle'
17
+ expect(response.location.region).to eq 'WA'
18
+ expect(response.location.country).to eq 'United States'
19
+ end
20
+
21
+ it 'should be able to look up Victoria, BC' do
22
+ response = Weather.lookup 9848
23
+
24
+ expect(response.location.city).to eq 'Victoria'
25
+ expect(response.location.region).to eq 'BC'
26
+ expect(response.location.country).to eq 'Canada'
27
+ end
28
+
29
+ it 'should be able to look up Nice, France' do
30
+ response = Weather.lookup 614274
31
+
32
+ expect(response.location.city).to eq 'Nice'
33
+ expect(response.location.region).to eq ''
34
+ expect(response.location.country).to eq 'France'
35
+ end
36
+ end