barometer 0.5.0 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. data/README.rdoc +51 -9
  2. data/VERSION.yml +2 -2
  3. data/bin/barometer +57 -7
  4. data/lib/barometer.rb +11 -0
  5. data/lib/barometer/base.rb +3 -0
  6. data/lib/barometer/data.rb +11 -6
  7. data/lib/barometer/data/sun.rb +10 -0
  8. data/lib/barometer/data/zone.rb +79 -188
  9. data/lib/barometer/formats/coordinates.rb +4 -1
  10. data/lib/barometer/formats/geocode.rb +9 -7
  11. data/lib/barometer/formats/icao.rb +2 -2
  12. data/lib/barometer/formats/weather_id.rb +2 -2
  13. data/lib/barometer/measurements/common.rb +113 -0
  14. data/lib/barometer/{data → measurements}/current.rb +17 -42
  15. data/lib/barometer/measurements/forecast.rb +62 -0
  16. data/lib/barometer/measurements/forecast_array.rb +72 -0
  17. data/lib/barometer/{data → measurements}/measurement.rb +57 -45
  18. data/lib/barometer/measurements/night.rb +27 -0
  19. data/lib/barometer/query.rb +55 -5
  20. data/lib/barometer/services.rb +3 -1
  21. data/lib/barometer/translations/icao_country_codes.yml +274 -1
  22. data/lib/barometer/translations/weather_country_codes.yml +189 -6
  23. data/lib/barometer/translations/zone_codes.yml +360 -0
  24. data/lib/barometer/weather.rb +5 -4
  25. data/lib/barometer/weather_services/google.rb +19 -35
  26. data/lib/barometer/weather_services/service.rb +113 -255
  27. data/lib/barometer/weather_services/weather_bug.rb +291 -2
  28. data/lib/barometer/weather_services/weather_dot_com.rb +45 -54
  29. data/lib/barometer/weather_services/wunderground.rb +83 -89
  30. data/lib/barometer/weather_services/yahoo.rb +44 -91
  31. data/lib/barometer/web_services/geocode.rb +1 -0
  32. data/lib/barometer/web_services/timezone.rb +40 -0
  33. data/lib/barometer/web_services/weather_id.rb +17 -2
  34. data/lib/demometer/demometer.rb +28 -0
  35. data/lib/demometer/public/css/master.css +259 -1
  36. data/lib/demometer/public/css/print.css +94 -0
  37. data/lib/demometer/public/css/syntax.css +64 -0
  38. data/lib/demometer/public/images/link-out.gif +0 -0
  39. data/lib/demometer/views/about.erb +10 -0
  40. data/lib/demometer/views/index.erb +2 -0
  41. data/lib/demometer/views/layout.erb +3 -2
  42. data/lib/demometer/views/measurement.erb +4 -1
  43. data/lib/demometer/views/readme.erb +116 -88
  44. data/spec/data/sun_spec.rb +53 -0
  45. data/spec/data/zone_spec.rb +330 -100
  46. data/spec/fixtures/formats/weather_id/ksfo.xml +1 -0
  47. data/spec/fixtures/services/weather_bug/90210_current.xml +1 -0
  48. data/spec/fixtures/services/weather_bug/90210_forecast.xml +1 -0
  49. data/spec/formats/weather_id_spec.rb +10 -5
  50. data/spec/measurements/common_spec.rb +352 -0
  51. data/spec/{data → measurements}/current_spec.rb +40 -103
  52. data/spec/measurements/forecast_array_spec.rb +165 -0
  53. data/spec/measurements/forecast_spec.rb +135 -0
  54. data/spec/{data → measurements}/measurement_spec.rb +86 -107
  55. data/spec/measurements/night_measurement_spec.rb +49 -0
  56. data/spec/query_spec.rb +12 -2
  57. data/spec/spec_helper.rb +28 -1
  58. data/spec/weather_services/google_spec.rb +27 -117
  59. data/spec/weather_services/services_spec.rb +49 -1024
  60. data/spec/weather_services/weather_bug_spec.rb +274 -0
  61. data/spec/weather_services/weather_dot_com_spec.rb +45 -125
  62. data/spec/weather_services/wunderground_spec.rb +42 -136
  63. data/spec/weather_services/yahoo_spec.rb +26 -116
  64. data/spec/weather_spec.rb +45 -45
  65. metadata +27 -11
  66. data/lib/barometer/data/forecast.rb +0 -84
  67. data/lib/barometer/data/night.rb +0 -69
  68. data/lib/barometer/extensions/graticule.rb +0 -51
  69. data/spec/data/forecast_spec.rb +0 -192
  70. data/spec/data/night_measurement_spec.rb +0 -136
@@ -11,15 +11,19 @@ describe "Wunderground" do
11
11
  describe "the class methods" do
12
12
 
13
13
  it "defines accepted_formats" do
14
- WeatherService::Wunderground.accepted_formats.should == @accepted_formats
14
+ WeatherService::Wunderground._accepted_formats.should == @accepted_formats
15
15
  end
16
16
 
17
- it "defines get_current" do
18
- WeatherService::Wunderground.respond_to?("get_current").should be_true
17
+ it "defines source_name" do
18
+ WeatherService::Wunderground._source_name.should == :wunderground
19
19
  end
20
20
 
21
- it "defines get_forecast" do
22
- WeatherService::Wunderground.respond_to?("get_forecast").should be_true
21
+ it "defines fetch_current" do
22
+ WeatherService::Wunderground.respond_to?("_fetch_current").should be_true
23
+ end
24
+
25
+ it "defines fetch_forecast" do
26
+ WeatherService::Wunderground.respond_to?("_fetch_forecast").should be_true
23
27
  end
24
28
 
25
29
  end
@@ -27,18 +31,18 @@ describe "Wunderground" do
27
31
  describe "building the current data" do
28
32
 
29
33
  it "defines the build method" do
30
- WeatherService::Wunderground.respond_to?("build_current").should be_true
34
+ WeatherService::Wunderground.respond_to?("_build_current").should be_true
31
35
  end
32
36
 
33
37
  it "requires Hash input" do
34
- lambda { WeatherService::Wunderground.build_current }.should raise_error(ArgumentError)
35
- WeatherService::Wunderground.build_current({})
36
- lambda { WeatherService::Wunderground.build_current({}) }.should_not raise_error(ArgumentError)
38
+ lambda { WeatherService::Wunderground._build_current }.should raise_error(ArgumentError)
39
+ WeatherService::Wunderground._build_current({})
40
+ lambda { WeatherService::Wunderground._build_current({}) }.should_not raise_error(ArgumentError)
37
41
  end
38
42
 
39
43
  it "returns Barometer::CurrentMeasurement object" do
40
- current = WeatherService::Wunderground.build_current({})
41
- current.is_a?(Data::CurrentMeasurement).should be_true
44
+ current = WeatherService::Wunderground._build_current({})
45
+ current.is_a?(Measurement::Current).should be_true
42
46
  end
43
47
 
44
48
  end
@@ -46,16 +50,16 @@ describe "Wunderground" do
46
50
  describe "building the forecast data" do
47
51
 
48
52
  it "defines the build method" do
49
- WeatherService::Wunderground.respond_to?("build_forecast").should be_true
53
+ WeatherService::Wunderground.respond_to?("_build_forecast").should be_true
50
54
  end
51
55
 
52
56
  it "requires Hash input" do
53
- lambda { WeatherService::Wunderground.build_forecast }.should raise_error(ArgumentError)
54
- lambda { WeatherService::Wunderground.build_forecast({}) }.should_not raise_error(ArgumentError)
57
+ lambda { WeatherService::Wunderground._build_forecast }.should raise_error(ArgumentError)
58
+ lambda { WeatherService::Wunderground._build_forecast({}) }.should_not raise_error(ArgumentError)
55
59
  end
56
60
 
57
61
  it "returns Array object" do
58
- current = WeatherService::Wunderground.build_forecast({})
62
+ current = WeatherService::Wunderground._build_forecast({})
59
63
  current.is_a?(Array).should be_true
60
64
  end
61
65
 
@@ -64,16 +68,16 @@ describe "Wunderground" do
64
68
  describe "building the station data" do
65
69
 
66
70
  it "defines the build method" do
67
- WeatherService::Wunderground.respond_to?("build_station").should be_true
71
+ WeatherService::Wunderground.respond_to?("_build_station").should be_true
68
72
  end
69
73
 
70
74
  it "requires Hash input" do
71
- lambda { WeatherService::Wunderground.build_station }.should raise_error(ArgumentError)
72
- lambda { WeatherService::Wunderground.build_station({}) }.should_not raise_error(ArgumentError)
75
+ lambda { WeatherService::Wunderground._build_station }.should raise_error(ArgumentError)
76
+ lambda { WeatherService::Wunderground._build_station({}) }.should_not raise_error(ArgumentError)
73
77
  end
74
78
 
75
79
  it "returns Barometer::Location object" do
76
- station = WeatherService::Wunderground.build_station({})
80
+ station = WeatherService::Wunderground._build_station({})
77
81
  station.is_a?(Data::Location).should be_true
78
82
  end
79
83
 
@@ -82,16 +86,16 @@ describe "Wunderground" do
82
86
  describe "building the location data" do
83
87
 
84
88
  it "defines the build method" do
85
- WeatherService::Wunderground.respond_to?("build_location").should be_true
89
+ WeatherService::Wunderground.respond_to?("_build_location").should be_true
86
90
  end
87
91
 
88
92
  it "requires Hash input" do
89
- lambda { WeatherService::Wunderground.build_location }.should raise_error(ArgumentError)
90
- lambda { WeatherService::Wunderground.build_location({}) }.should_not raise_error(ArgumentError)
93
+ lambda { WeatherService::Wunderground._build_location }.should raise_error(ArgumentError)
94
+ lambda { WeatherService::Wunderground._build_location({}) }.should_not raise_error(ArgumentError)
91
95
  end
92
96
 
93
97
  it "returns Barometer::Location object" do
94
- location = WeatherService::Wunderground.build_location({})
98
+ location = WeatherService::Wunderground._build_location({})
95
99
  location.is_a?(Data::Location).should be_true
96
100
  end
97
101
 
@@ -100,39 +104,34 @@ describe "Wunderground" do
100
104
  describe "building the timezone" do
101
105
 
102
106
  it "defines the build method" do
103
- WeatherService::Wunderground.respond_to?("build_timezone").should be_true
107
+ WeatherService::Wunderground.respond_to?("_parse_full_timezone").should be_true
104
108
  end
105
109
 
106
110
  it "requires Hash input" do
107
- lambda { WeatherService::Wunderground.build_timezone }.should raise_error(ArgumentError)
108
- lambda { WeatherService::Wunderground.build_timezone({}) }.should_not raise_error(ArgumentError)
111
+ lambda { WeatherService::Wunderground._parse_full_timezone }.should raise_error(ArgumentError)
112
+ lambda { WeatherService::Wunderground._parse_full_timezone({}) }.should_not raise_error(ArgumentError)
109
113
  end
110
114
 
111
115
  end
112
116
 
113
117
  describe "building the sun data" do
114
118
 
115
- before(:each) do
116
- @zone = Data::Zone.new("Europe/Paris")
117
- end
118
-
119
119
  it "defines the build method" do
120
- WeatherService::Wunderground.respond_to?("build_sun").should be_true
120
+ WeatherService::Wunderground.respond_to?("_build_sun").should be_true
121
121
  end
122
122
 
123
123
  it "requires Hash input" do
124
- lambda { WeatherService::Wunderground.build_sun }.should raise_error(ArgumentError)
125
- lambda { WeatherService::Wunderground.build_sun({},@zone) }.should_not raise_error(ArgumentError)
124
+ lambda { WeatherService::Wunderground._build_sun }.should raise_error(ArgumentError)
125
+ lambda { WeatherService::Wunderground._build_sun({}) }.should_not raise_error(ArgumentError)
126
126
  end
127
127
 
128
128
  it "requires Barometer::Zone input" do
129
- lambda { WeatherService::Wunderground.build_sun({}) }.should raise_error(ArgumentError)
130
- lambda { WeatherService::Wunderground.build_sun({}, "invalid") }.should raise_error(ArgumentError)
131
- lambda { WeatherService::Wunderground.build_sun({},@zone) }.should_not raise_error(ArgumentError)
129
+ lambda { WeatherService::Wunderground._build_sun({}, "invalid") }.should raise_error(ArgumentError)
130
+ lambda { WeatherService::Wunderground._build_sun({}) }.should_not raise_error(ArgumentError)
132
131
  end
133
132
 
134
133
  it "returns Barometer::Sun object" do
135
- sun = WeatherService::Wunderground.build_sun({},@zone)
134
+ sun = WeatherService::Wunderground._build_sun({})
136
135
  sun.is_a?(Data::Sun).should be_true
137
136
  end
138
137
 
@@ -142,7 +141,7 @@ describe "Wunderground" do
142
141
 
143
142
  before(:each) do
144
143
  @query = Barometer::Query.new("Calgary,AB")
145
- @measurement = Data::Measurement.new
144
+ @measurement = Barometer::Measurement.new
146
145
 
147
146
  FakeWeb.register_uri(:get,
148
147
  "http://api.wunderground.com/auto/wui/geo/WXCurrentObXML/index.xml?query=#{CGI.escape(@query.q)}",
@@ -182,114 +181,20 @@ describe "Wunderground" do
182
181
 
183
182
  it "returns a Barometer::Measurement object" do
184
183
  result = WeatherService::Wunderground._measure(@measurement, @query)
185
- result.is_a?(Data::Measurement).should be_true
186
- result.current.is_a?(Data::CurrentMeasurement).should be_true
184
+ result.is_a?(Barometer::Measurement).should be_true
185
+ result.current.is_a?(Measurement::Current).should be_true
187
186
  result.forecast.is_a?(Array).should be_true
188
-
189
- result.source.should == :wunderground
190
- end
191
-
192
- end
193
-
194
- end
195
-
196
- describe "when answering the simple questions," do
197
-
198
- before(:each) do
199
- @measurement = Data::Measurement.new
200
- end
201
-
202
- describe "currently_wet_by_icon?" do
203
-
204
- before(:each) do
205
- @measurement.current = Data::CurrentMeasurement.new
206
- end
207
-
208
- it "returns true if matching icon code" do
209
- @measurement.current.icon = "rain"
210
- @measurement.current.icon?.should be_true
211
- WeatherService::Wunderground.currently_wet_by_icon?(@measurement.current).should be_true
212
- end
213
-
214
- it "returns false if NO matching icon code" do
215
- @measurement.current.icon = "sunny"
216
- @measurement.current.icon?.should be_true
217
- WeatherService::Wunderground.currently_wet_by_icon?(@measurement.current).should be_false
218
- end
219
-
220
- end
221
-
222
- describe "forecasted_wet_by_icon?" do
223
-
224
- before(:each) do
225
- @measurement.forecast = [Data::ForecastMeasurement.new]
226
- @measurement.forecast.first.date = Date.today
227
- @measurement.forecast.size.should == 1
228
- end
229
-
230
- it "returns true if matching icon code" do
231
- @measurement.forecast.first.icon = "rain"
232
- @measurement.forecast.first.icon?.should be_true
233
- WeatherService::Wunderground.forecasted_wet_by_icon?(@measurement.forecast.first).should be_true
234
- end
235
-
236
- it "returns false if NO matching icon code" do
237
- @measurement.forecast.first.icon = "sunny"
238
- @measurement.forecast.first.icon?.should be_true
239
- WeatherService::Wunderground.forecasted_wet_by_icon?(@measurement.forecast.first).should be_false
240
- end
241
-
242
- end
243
-
244
- describe "currently_sunny_by_icon?" do
245
-
246
- before(:each) do
247
- @measurement.current = Data::CurrentMeasurement.new
248
- end
249
-
250
- it "returns true if matching icon code" do
251
- @measurement.current.icon = "sunny"
252
- @measurement.current.icon?.should be_true
253
- WeatherService::Wunderground.currently_sunny_by_icon?(@measurement.current).should be_true
254
- end
255
-
256
- it "returns false if NO matching icon code" do
257
- @measurement.current.icon = "rain"
258
- @measurement.current.icon?.should be_true
259
- WeatherService::Wunderground.currently_sunny_by_icon?(@measurement.current).should be_false
260
187
  end
261
188
 
262
189
  end
263
-
264
- describe "forecasted_sunny_by_icon?" do
265
-
266
- before(:each) do
267
- @measurement.forecast = [Data::ForecastMeasurement.new]
268
- @measurement.forecast.first.date = Date.today
269
- @measurement.forecast.size.should == 1
270
- end
271
190
 
272
- it "returns true if matching icon code" do
273
- @measurement.forecast.first.icon = "sunny"
274
- @measurement.forecast.first.icon?.should be_true
275
- WeatherService::Wunderground.forecasted_sunny_by_icon?(@measurement.forecast.first).should be_true
276
- end
277
-
278
- it "returns false if NO matching icon code" do
279
- @measurement.forecast.first.icon = "rain"
280
- @measurement.forecast.first.icon?.should be_true
281
- WeatherService::Wunderground.forecasted_sunny_by_icon?(@measurement.forecast.first).should be_false
282
- end
283
-
284
- end
285
-
286
191
  end
287
192
 
288
193
  describe "overall data correctness" do
289
194
 
290
195
  before(:each) do
291
196
  @query = Barometer::Query.new("Calgary,AB")
292
- @measurement = Data::Measurement.new
197
+ @measurement = Barometer::Measurement.new
293
198
 
294
199
  FakeWeb.register_uri(:get,
295
200
  "http://api.wunderground.com/auto/wui/geo/WXCurrentObXML/index.xml?query=#{CGI.escape(@query.q)}",
@@ -312,7 +217,8 @@ describe "Wunderground" do
312
217
  result = WeatherService::Wunderground._measure(@measurement, @query)
313
218
 
314
219
  # build timezone
315
- @measurement.timezone.timezone.should == "America/Edmonton"
220
+ @measurement.timezone.zone_full.should == "America/Edmonton"
221
+ @measurement.timezone.current.should == "America/Edmonton"
316
222
 
317
223
  # time = Time.local(2009, 4, 23, 18, 00, 0)
318
224
  # rise = Time.local(time.year, time.month, time.day, 6, 23)
@@ -11,11 +11,15 @@ describe "Yahoo" do
11
11
  describe "the class methods" do
12
12
 
13
13
  it "defines accepted_formats" do
14
- WeatherService::Yahoo.accepted_formats.should == @accepted_formats
14
+ WeatherService::Yahoo._accepted_formats.should == @accepted_formats
15
+ end
16
+
17
+ it "defines source_name" do
18
+ WeatherService::Yahoo._source_name.should == :yahoo
15
19
  end
16
20
 
17
21
  it "defines get_all" do
18
- WeatherService::Yahoo.respond_to?("fetch").should be_true
22
+ WeatherService::Yahoo.respond_to?("_fetch").should be_true
19
23
  end
20
24
 
21
25
  end
@@ -23,17 +27,17 @@ describe "Yahoo" do
23
27
  describe "building the current data" do
24
28
 
25
29
  it "defines the build method" do
26
- WeatherService::Yahoo.respond_to?("build_current").should be_true
30
+ WeatherService::Yahoo.respond_to?("_build_current").should be_true
27
31
  end
28
32
 
29
33
  it "requires Hash input" do
30
- lambda { WeatherService::Yahoo.build_current }.should raise_error(ArgumentError)
31
- lambda { WeatherService::Yahoo.build_current({}) }.should_not raise_error(ArgumentError)
34
+ lambda { WeatherService::Yahoo._build_current }.should raise_error(ArgumentError)
35
+ lambda { WeatherService::Yahoo._build_current({}) }.should_not raise_error(ArgumentError)
32
36
  end
33
37
 
34
38
  it "returns Barometer::CurrentMeasurement object" do
35
- current = WeatherService::Yahoo.build_current({})
36
- current.is_a?(Data::CurrentMeasurement).should be_true
39
+ current = WeatherService::Yahoo._build_current({})
40
+ current.is_a?(Measurement::Current).should be_true
37
41
  end
38
42
 
39
43
  end
@@ -41,16 +45,16 @@ describe "Yahoo" do
41
45
  describe "building the forecast data" do
42
46
 
43
47
  it "defines the build method" do
44
- WeatherService::Yahoo.respond_to?("build_forecast").should be_true
48
+ WeatherService::Yahoo.respond_to?("_build_forecast").should be_true
45
49
  end
46
50
 
47
51
  it "requires Hash input" do
48
- lambda { WeatherService::Yahoo.build_forecast }.should raise_error(ArgumentError)
49
- lambda { WeatherService::Yahoo.build_forecast({}) }.should_not raise_error(ArgumentError)
52
+ lambda { WeatherService::Yahoo._build_forecast }.should raise_error(ArgumentError)
53
+ lambda { WeatherService::Yahoo._build_forecast({}) }.should_not raise_error(ArgumentError)
50
54
  end
51
55
 
52
56
  it "returns Array object" do
53
- current = WeatherService::Yahoo.build_forecast({})
57
+ current = WeatherService::Yahoo._build_forecast({})
54
58
  current.is_a?(Array).should be_true
55
59
  end
56
60
 
@@ -59,22 +63,22 @@ describe "Yahoo" do
59
63
  describe "building the location data" do
60
64
 
61
65
  it "defines the build method" do
62
- WeatherService::Yahoo.respond_to?("build_location").should be_true
66
+ WeatherService::Yahoo.respond_to?("_build_location").should be_true
63
67
  end
64
68
 
65
69
  it "requires Hash input" do
66
- lambda { WeatherService::Yahoo.build_location }.should raise_error(ArgumentError)
67
- lambda { WeatherService::Yahoo.build_location({}) }.should_not raise_error(ArgumentError)
70
+ lambda { WeatherService::Yahoo._build_location }.should raise_error(ArgumentError)
71
+ lambda { WeatherService::Yahoo._build_location({}) }.should_not raise_error(ArgumentError)
68
72
  end
69
73
 
70
74
  it "requires Barometer::Geo input" do
71
75
  geo = Data::Geo.new({})
72
- lambda { WeatherService::Yahoo.build_location({}, {}) }.should raise_error(ArgumentError)
73
- lambda { WeatherService::Yahoo.build_location({}, geo) }.should_not raise_error(ArgumentError)
76
+ lambda { WeatherService::Yahoo._build_location({}, {}) }.should raise_error(ArgumentError)
77
+ lambda { WeatherService::Yahoo._build_location({}, geo) }.should_not raise_error(ArgumentError)
74
78
  end
75
79
 
76
80
  it "returns Barometer::Location object" do
77
- location = WeatherService::Yahoo.build_location({})
81
+ location = WeatherService::Yahoo._build_location({})
78
82
  location.is_a?(Data::Location).should be_true
79
83
  end
80
84
 
@@ -84,7 +88,7 @@ describe "Yahoo" do
84
88
 
85
89
  before(:each) do
86
90
  @query = Barometer::Query.new("90210")
87
- @measurement = Data::Measurement.new
91
+ @measurement = Barometer::Measurement.new
88
92
 
89
93
  FakeWeb.register_uri(:get,
90
94
  "http://weather.yahooapis.com:80/forecastrss?u=c&p=#{CGI.escape(@query.q)}",
@@ -111,120 +115,26 @@ describe "Yahoo" do
111
115
  it "requires a Barometer::Query query" do
112
116
  lambda { WeatherService::Yahoo._measure }.should raise_error(ArgumentError)
113
117
  lambda { WeatherService::Yahoo._measure(@measurement, 1) }.should raise_error(ArgumentError)
114
-
118
+
115
119
  lambda { WeatherService::Yahoo._measure(@measurement, @query) }.should_not raise_error(ArgumentError)
116
120
  end
117
121
 
118
122
  it "returns a Barometer::Measurement object" do
119
123
  result = WeatherService::Yahoo._measure(@measurement, @query)
120
- result.is_a?(Data::Measurement).should be_true
121
- result.current.is_a?(Data::CurrentMeasurement).should be_true
124
+ result.is_a?(Barometer::Measurement).should be_true
125
+ result.current.is_a?(Measurement::Current).should be_true
122
126
  result.forecast.is_a?(Array).should be_true
123
-
124
- result.source.should == :yahoo
125
127
  end
126
128
 
127
129
  end
128
130
 
129
131
  end
130
132
 
131
- describe "when answering the simple questions," do
132
-
133
- before(:each) do
134
- @measurement = Data::Measurement.new
135
- end
136
-
137
- describe "currently_wet_by_icon?" do
138
-
139
- before(:each) do
140
- @measurement.current = Data::CurrentMeasurement.new
141
- end
142
-
143
- it "returns true if matching icon code" do
144
- @measurement.current.icon = "4"
145
- @measurement.current.icon?.should be_true
146
- WeatherService::Yahoo.currently_wet_by_icon?(@measurement.current).should be_true
147
- end
148
-
149
- it "returns false if NO matching icon code" do
150
- @measurement.current.icon = "32"
151
- @measurement.current.icon?.should be_true
152
- WeatherService::Yahoo.currently_wet_by_icon?(@measurement.current).should be_false
153
- end
154
-
155
- end
156
-
157
- describe "forecasted_wet_by_icon?" do
158
-
159
- before(:each) do
160
- @measurement.forecast = [Data::ForecastMeasurement.new]
161
- @measurement.forecast.first.date = Date.today
162
- @measurement.forecast.size.should == 1
163
- end
164
-
165
- it "returns true if matching icon code" do
166
- @measurement.forecast.first.icon = "4"
167
- @measurement.forecast.first.icon?.should be_true
168
- WeatherService::Yahoo.forecasted_wet_by_icon?(@measurement.forecast.first).should be_true
169
- end
170
-
171
- it "returns false if NO matching icon code" do
172
- @measurement.forecast.first.icon = "32"
173
- @measurement.forecast.first.icon?.should be_true
174
- WeatherService::Yahoo.forecasted_wet_by_icon?(@measurement.forecast.first).should be_false
175
- end
176
-
177
- end
178
-
179
- describe "currently_sunny_by_icon?" do
180
-
181
- before(:each) do
182
- @measurement.current = Data::CurrentMeasurement.new
183
- end
184
-
185
- it "returns true if matching icon code" do
186
- @measurement.current.icon = "32"
187
- @measurement.current.icon?.should be_true
188
- WeatherService::Yahoo.currently_sunny_by_icon?(@measurement.current).should be_true
189
- end
190
-
191
- it "returns false if NO matching icon code" do
192
- @measurement.current.icon = "4"
193
- @measurement.current.icon?.should be_true
194
- WeatherService::Yahoo.currently_sunny_by_icon?(@measurement.current).should be_false
195
- end
196
-
197
- end
198
-
199
- describe "forecasted_sunny_by_icon?" do
200
-
201
- before(:each) do
202
- @measurement.forecast = [Data::ForecastMeasurement.new]
203
- @measurement.forecast.first.date = Date.today
204
- @measurement.forecast.size.should == 1
205
- end
206
-
207
- it "returns true if matching icon code" do
208
- @measurement.forecast.first.icon = "32"
209
- @measurement.forecast.first.icon?.should be_true
210
- WeatherService::Yahoo.forecasted_sunny_by_icon?(@measurement.forecast.first).should be_true
211
- end
212
-
213
- it "returns false if NO matching icon code" do
214
- @measurement.forecast.first.icon = "4"
215
- @measurement.forecast.first.icon?.should be_true
216
- WeatherService::Yahoo.forecasted_sunny_by_icon?(@measurement.forecast.first).should be_false
217
- end
218
-
219
- end
220
-
221
- end
222
-
223
133
  describe "overall data correctness" do
224
134
 
225
135
  before(:each) do
226
136
  @query = Barometer::Query.new("90210")
227
- @measurement = Data::Measurement.new
137
+ @measurement = Barometer::Measurement.new
228
138
 
229
139
  FakeWeb.register_uri(:get,
230
140
  "http://weather.yahooapis.com:80/forecastrss?u=c&p=#{CGI.escape(@query.q)}",