barometer 0.5.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -0,0 +1,274 @@
1
+ require 'spec_helper'
2
+ include Barometer
3
+
4
+ describe "WeatherBug" do
5
+
6
+ before(:each) do
7
+ @accepted_formats = [:short_zipcode, :coordinates]
8
+ end
9
+
10
+ describe "the class methods" do
11
+
12
+ it "defines accepted_formats" do
13
+ WeatherService::WeatherBug._accepted_formats.should == @accepted_formats
14
+ end
15
+
16
+ it "defines source_name" do
17
+ WeatherService::WeatherBug._source_name.should == :weather_bug
18
+ end
19
+
20
+ it "defines fetch_current" do
21
+ WeatherService::WeatherBug.respond_to?("_fetch_current").should be_true
22
+ end
23
+
24
+ it "defines fetch_forecast" do
25
+ WeatherService::WeatherBug.respond_to?("_fetch_forecast").should be_true
26
+ end
27
+
28
+ it "defines _requires_keys?" do
29
+ WeatherService::WeatherBug.respond_to?("_requires_keys?").should be_true
30
+ WeatherService::WeatherBug._requires_keys?.should be_true
31
+ end
32
+
33
+ it "defines _has_keys?" do
34
+ WeatherService::WeatherBug.respond_to?("_has_keys?").should be_true
35
+ WeatherService::WeatherBug._has_keys?.should be_false
36
+ WeatherService::WeatherBug.keys = { :code => WEATHERBUG_CODE }
37
+ WeatherService::WeatherBug._has_keys?.should be_true
38
+ end
39
+
40
+ end
41
+
42
+ describe "building the current data" do
43
+
44
+ it "defines the build method" do
45
+ WeatherService::WeatherBug.respond_to?("_build_current").should be_true
46
+ end
47
+
48
+ it "requires Hash input" do
49
+ lambda { WeatherService::WeatherBug._build_current }.should raise_error(ArgumentError)
50
+ lambda { WeatherService::WeatherBug._build_current({}) }.should_not raise_error(ArgumentError)
51
+ end
52
+
53
+ it "returns Measurement::Current object" do
54
+ current = WeatherService::WeatherBug._build_current({})
55
+ current.is_a?(Measurement::Current).should be_true
56
+ end
57
+
58
+ end
59
+
60
+ describe "building the forecast data" do
61
+
62
+ it "defines the build method" do
63
+ WeatherService::WeatherBug.respond_to?("_build_forecast").should be_true
64
+ end
65
+
66
+ it "requires Hash input" do
67
+ lambda { WeatherService::WeatherBug._build_forecast }.should raise_error(ArgumentError)
68
+ lambda { WeatherService::WeatherBug._build_forecast({}) }.should_not raise_error(ArgumentError)
69
+ end
70
+
71
+ it "returns Array object" do
72
+ current = WeatherService::WeatherBug._build_forecast({})
73
+ current.is_a?(Array).should be_true
74
+ end
75
+
76
+ end
77
+
78
+ describe "building the location data" do
79
+
80
+ it "defines the build method" do
81
+ WeatherService::WeatherBug.respond_to?("_build_location").should be_true
82
+ end
83
+
84
+ it "requires Hash input" do
85
+ lambda { WeatherService::WeatherBug._build_location }.should raise_error(ArgumentError)
86
+ lambda { WeatherService::WeatherBug._build_location({}) }.should_not raise_error(ArgumentError)
87
+ end
88
+
89
+ it "requires Barometer::Geo input" do
90
+ geo = Data::Geo.new({})
91
+ lambda { WeatherService::WeatherBug._build_location({}, {}) }.should raise_error(ArgumentError)
92
+ lambda { WeatherService::WeatherBug._build_location({}, geo) }.should_not raise_error(ArgumentError)
93
+ end
94
+
95
+ it "returns Barometer::Location object" do
96
+ location = WeatherService::WeatherBug._build_location({})
97
+ location.is_a?(Data::Location).should be_true
98
+ end
99
+
100
+ end
101
+
102
+ describe "building the sun data" do
103
+
104
+ it "defines the build method" do
105
+ WeatherService::WeatherBug.respond_to?("_build_sun").should be_true
106
+ end
107
+
108
+ it "requires Hash input" do
109
+ lambda { WeatherService::WeatherBug._build_sun }.should raise_error(ArgumentError)
110
+ lambda { WeatherService::WeatherBug._build_sun({}) }.should_not raise_error(ArgumentError)
111
+ end
112
+
113
+ it "returns Barometer::Sun object" do
114
+ sun = WeatherService::WeatherBug._build_sun({})
115
+ sun.is_a?(Data::Sun).should be_true
116
+ end
117
+
118
+ end
119
+
120
+ describe "builds other data" do
121
+
122
+ it "defines _build_extra" do
123
+ WeatherService::WeatherBug.respond_to?("_build_extra").should be_true
124
+ end
125
+
126
+ it "defines _parse_local_time" do
127
+ WeatherService::WeatherBug.respond_to?("_parse_local_time").should be_true
128
+ end
129
+
130
+ it "defines _build_timezone" do
131
+ WeatherService::WeatherBug.respond_to?("_build_timezone").should be_true
132
+ end
133
+
134
+ end
135
+
136
+ describe "when measuring" do
137
+
138
+ before(:each) do
139
+ @query = Barometer::Query.new("90210")
140
+ @measurement = Barometer::Measurement.new
141
+
142
+ url = "http://#{WEATHERBUG_CODE}.api.wxbug.net:80/getLiveWeatherRSS.aspx?"
143
+ FakeWeb.register_uri(:get,
144
+ "#{url}ACode=#{WEATHERBUG_CODE}&OutputType=1&UnitType=1&zipCode=90210",
145
+ :string => File.read(File.join(File.dirname(__FILE__),
146
+ '../fixtures/services/weather_bug',
147
+ '90210_current.xml')
148
+ )
149
+ )
150
+
151
+ url2 = "http://#{WEATHERBUG_CODE}.api.wxbug.net:80/getForecastRSS.aspx?"
152
+ FakeWeb.register_uri(:get,
153
+ "#{url2}ACode=#{WEATHERBUG_CODE}&OutputType=1&UnitType=1&zipCode=90210",
154
+ :string => File.read(File.join(File.dirname(__FILE__),
155
+ '../fixtures/services/weather_bug',
156
+ '90210_forecast.xml')
157
+ )
158
+ )
159
+ end
160
+
161
+ describe "all" do
162
+
163
+ it "responds to _measure" do
164
+ WeatherService::WeatherBug.respond_to?("_measure").should be_true
165
+ end
166
+
167
+ it "requires a Barometer::Measurement object" do
168
+ lambda { WeatherService::WeatherBug._measure(nil, @query) }.should raise_error(ArgumentError)
169
+ lambda { WeatherService::WeatherBug._measure("invalid", @query) }.should raise_error(ArgumentError)
170
+
171
+ lambda { WeatherService::WeatherBug._measure(@measurement, @query) }.should_not raise_error(ArgumentError)
172
+ end
173
+
174
+ it "requires a Barometer::Query query" do
175
+ lambda { WeatherService::WeatherBug._measure }.should raise_error(ArgumentError)
176
+ lambda { WeatherService::WeatherBug._measure(@measurement, 1) }.should raise_error(ArgumentError)
177
+
178
+ lambda { WeatherService::WeatherBug._measure(@measurement, @query) }.should_not raise_error(ArgumentError)
179
+ end
180
+
181
+ it "returns a Barometer::Measurement object" do
182
+ result = WeatherService::WeatherBug._measure(@measurement, @query)
183
+ result.is_a?(Barometer::Measurement).should be_true
184
+ result.current.is_a?(Measurement::Current).should be_true
185
+ result.forecast.is_a?(Measurement::ForecastArray).should be_true
186
+ end
187
+
188
+ end
189
+
190
+ end
191
+
192
+ describe "overall data correctness" do
193
+
194
+ before(:each) do
195
+ @query = Barometer::Query.new("90210")
196
+ @measurement = Barometer::Measurement.new
197
+
198
+ url = "http://#{WEATHERBUG_CODE}.api.wxbug.net:80/getLiveWeatherRSS.aspx?"
199
+ FakeWeb.register_uri(:get,
200
+ "#{url}ACode=#{WEATHERBUG_CODE}&OutputType=1&UnitType=1&zipCode=90210",
201
+ :string => File.read(File.join(File.dirname(__FILE__),
202
+ '../fixtures/services/weather_bug',
203
+ '90210_current.xml')
204
+ )
205
+ )
206
+
207
+ url2 = "http://#{WEATHERBUG_CODE}.api.wxbug.net:80/getForecastRSS.aspx?"
208
+ FakeWeb.register_uri(:get,
209
+ "#{url2}ACode=#{WEATHERBUG_CODE}&OutputType=1&UnitType=1&zipCode=90210",
210
+ :string => File.read(File.join(File.dirname(__FILE__),
211
+ '../fixtures/services/weather_bug',
212
+ '90210_forecast.xml')
213
+ )
214
+ )
215
+ end
216
+
217
+ it "should correctly build the data" do
218
+ result = WeatherService::WeatherBug._measure(@measurement, @query)
219
+
220
+ # build current
221
+ @measurement.current.humidity.to_i.should == 62
222
+ @measurement.current.condition.should == "Hazy"
223
+ @measurement.current.icon.should == "23"
224
+ @measurement.current.temperature.to_i.should == 22
225
+ @measurement.current.dew_point.to_i.should == 14
226
+ @measurement.current.wind_chill.to_i.should == 22
227
+ @measurement.current.wind.to_i.should == 11
228
+ @measurement.current.wind.direction.should == "SE"
229
+ @measurement.current.pressure.to_f.should == 1011.31
230
+
231
+ # build sun
232
+ @measurement.current.sun.rise.to_s.should == "05:52 am"
233
+ @measurement.current.sun.set.to_s.should == "07:48 pm"
234
+
235
+ # build station
236
+ @measurement.station.id.should == "LSNGH"
237
+ @measurement.station.name.should == "Milken Community HS"
238
+ @measurement.station.city.should == "Los Angeles"
239
+ @measurement.station.state_code.should == "CA"
240
+ @measurement.station.country.should == "USA"
241
+ @measurement.station.zip_code.should == "90049"
242
+ @measurement.station.latitude.to_f.should == 34.1258316040039
243
+ @measurement.station.longitude.to_f.should == -118.478332519531
244
+
245
+ # builds location
246
+ @measurement.location.city.should == "Beverly Hills"
247
+ @measurement.location.state_code.should == "CA"
248
+ @measurement.location.zip_code.should == "90210"
249
+
250
+ # builds forecasts
251
+ @measurement.forecast.size.should == 7
252
+
253
+ @measurement.forecast[0].date.should == Date.parse("May 15")
254
+ @measurement.forecast[0].condition.should == "Partly Cloudy"
255
+ @measurement.forecast[0].icon.should == "3"
256
+ @measurement.forecast[0].high.to_i.should == 27
257
+ @measurement.forecast[0].low.to_i.should == 17
258
+
259
+ @measurement.forecast[0].sun.rise.to_s.should == "05:52 am"
260
+ @measurement.forecast[0].sun.set.to_s.should == "07:48 pm"
261
+
262
+ # builds local time
263
+ @measurement.measured_at.to_s.should == "11:00 am"
264
+ @measurement.current.current_at.to_s.should == "11:00 am"
265
+
266
+ # builds timezone
267
+ @measurement.timezone.code.should == Data::Zone.new("PDT").code
268
+ @measurement.timezone.offset.should == Data::Zone.new("PDT").offset
269
+ @measurement.timezone.today.should == Data::Zone.new("PDT").today
270
+ end
271
+
272
+ end
273
+
274
+ end
@@ -5,18 +5,32 @@ describe "WeatherDotCom" do
5
5
 
6
6
  before(:each) do
7
7
  @accepted_formats = [:short_zipcode, :weather_id]
8
- #Barometer.config = { 1 => { :weather => { :keys => { :partner => WEATHER_PARTNER_KEY, :license => WEATHER_LICENSE_KEY }}}}
9
- WeatherService::WeatherDotCom.keys = { :partner => WEATHER_PARTNER_KEY, :license => WEATHER_LICENSE_KEY }
10
8
  end
11
9
 
12
10
  describe "the class methods" do
13
11
 
14
12
  it "defines accepted_formats" do
15
- WeatherService::WeatherDotCom.accepted_formats.should == @accepted_formats
13
+ WeatherService::WeatherDotCom._accepted_formats.should == @accepted_formats
14
+ end
15
+
16
+ it "defines source_name" do
17
+ WeatherService::WeatherDotCom._source_name.should == :weather_dot_com
16
18
  end
17
19
 
18
20
  it "defines get_all" do
19
- WeatherService::WeatherDotCom.respond_to?("fetch").should be_true
21
+ WeatherService::WeatherDotCom.respond_to?("_fetch").should be_true
22
+ end
23
+
24
+ it "defines _requires_keys?" do
25
+ WeatherService::WeatherDotCom.respond_to?("_requires_keys?").should be_true
26
+ WeatherService::WeatherDotCom._requires_keys?.should be_true
27
+ end
28
+
29
+ it "defines _has_keys?" do
30
+ WeatherService::WeatherDotCom.respond_to?("_has_keys?").should be_true
31
+ WeatherService::WeatherDotCom._has_keys?.should be_false
32
+ WeatherService::WeatherDotCom.keys = { :partner => WEATHER_PARTNER_KEY, :license => WEATHER_LICENSE_KEY }
33
+ WeatherService::WeatherDotCom._has_keys?.should be_true
20
34
  end
21
35
 
22
36
  end
@@ -24,17 +38,17 @@ describe "WeatherDotCom" do
24
38
  describe "building the current data" do
25
39
 
26
40
  it "defines the build method" do
27
- WeatherService::WeatherDotCom.respond_to?("build_current").should be_true
41
+ WeatherService::WeatherDotCom.respond_to?("_build_current").should be_true
28
42
  end
29
43
 
30
44
  it "requires Hash input" do
31
- lambda { WeatherService::WeatherDotCom.build_current }.should raise_error(ArgumentError)
32
- lambda { WeatherService::WeatherDotCom.build_current({}) }.should_not raise_error(ArgumentError)
45
+ lambda { WeatherService::WeatherDotCom._build_current }.should raise_error(ArgumentError)
46
+ lambda { WeatherService::WeatherDotCom._build_current({}) }.should_not raise_error(ArgumentError)
33
47
  end
34
48
 
35
- it "returns Data::CurrentMeasurement object" do
36
- current = WeatherService::WeatherDotCom.build_current({})
37
- current.is_a?(Data::CurrentMeasurement).should be_true
49
+ it "returns Measurement::Current object" do
50
+ current = WeatherService::WeatherDotCom._build_current({})
51
+ current.is_a?(Measurement::Current).should be_true
38
52
  end
39
53
 
40
54
  end
@@ -42,16 +56,16 @@ describe "WeatherDotCom" do
42
56
  describe "building the forecast data" do
43
57
 
44
58
  it "defines the build method" do
45
- WeatherService::WeatherDotCom.respond_to?("build_forecast").should be_true
59
+ WeatherService::WeatherDotCom.respond_to?("_build_forecast").should be_true
46
60
  end
47
61
 
48
62
  it "requires Hash input" do
49
- lambda { WeatherService::WeatherDotCom.build_forecast }.should raise_error(ArgumentError)
50
- lambda { WeatherService::WeatherDotCom.build_forecast({}) }.should_not raise_error(ArgumentError)
63
+ lambda { WeatherService::WeatherDotCom._build_forecast }.should raise_error(ArgumentError)
64
+ lambda { WeatherService::WeatherDotCom._build_forecast({}) }.should_not raise_error(ArgumentError)
51
65
  end
52
66
 
53
67
  it "returns Array object" do
54
- current = WeatherService::WeatherDotCom.build_forecast({})
68
+ current = WeatherService::WeatherDotCom._build_forecast({})
55
69
  current.is_a?(Array).should be_true
56
70
  end
57
71
 
@@ -60,22 +74,22 @@ describe "WeatherDotCom" do
60
74
  describe "building the location data" do
61
75
 
62
76
  it "defines the build method" do
63
- WeatherService::WeatherDotCom.respond_to?("build_location").should be_true
77
+ WeatherService::WeatherDotCom.respond_to?("_build_location").should be_true
64
78
  end
65
79
 
66
80
  it "requires Hash input" do
67
- lambda { WeatherService::WeatherDotCom.build_location }.should raise_error(ArgumentError)
68
- lambda { WeatherService::WeatherDotCom.build_location({}) }.should_not raise_error(ArgumentError)
81
+ lambda { WeatherService::WeatherDotCom._build_location }.should raise_error(ArgumentError)
82
+ lambda { WeatherService::WeatherDotCom._build_location({}) }.should_not raise_error(ArgumentError)
69
83
  end
70
84
 
71
85
  it "requires Barometer::Geo input" do
72
86
  geo = Data::Geo.new({})
73
- lambda { WeatherService::WeatherDotCom.build_location({}, {}) }.should raise_error(ArgumentError)
74
- lambda { WeatherService::WeatherDotCom.build_location({}, geo) }.should_not raise_error(ArgumentError)
87
+ lambda { WeatherService::WeatherDotCom._build_location({}, {}) }.should raise_error(ArgumentError)
88
+ lambda { WeatherService::WeatherDotCom._build_location({}, geo) }.should_not raise_error(ArgumentError)
75
89
  end
76
90
 
77
91
  it "returns Barometer::Location object" do
78
- location = WeatherService::WeatherDotCom.build_location({})
92
+ location = WeatherService::WeatherDotCom._build_location({})
79
93
  location.is_a?(Data::Location).should be_true
80
94
  end
81
95
 
@@ -84,16 +98,16 @@ describe "WeatherDotCom" do
84
98
  describe "building the sun data" do
85
99
 
86
100
  it "defines the build method" do
87
- WeatherService::WeatherDotCom.respond_to?("build_sun").should be_true
101
+ WeatherService::WeatherDotCom.respond_to?("_build_sun").should be_true
88
102
  end
89
103
 
90
104
  it "requires Hash input" do
91
- lambda { WeatherService::WeatherDotCom.build_sun }.should raise_error(ArgumentError)
92
- lambda { WeatherService::WeatherDotCom.build_sun({}) }.should_not raise_error(ArgumentError)
105
+ lambda { WeatherService::WeatherDotCom._build_sun }.should raise_error(ArgumentError)
106
+ lambda { WeatherService::WeatherDotCom._build_sun({}) }.should_not raise_error(ArgumentError)
93
107
  end
94
108
 
95
109
  it "returns Barometer::Sun object" do
96
- sun = WeatherService::WeatherDotCom.build_sun({})
110
+ sun = WeatherService::WeatherDotCom._build_sun({})
97
111
  sun.is_a?(Data::Sun).should be_true
98
112
  end
99
113
 
@@ -103,7 +117,7 @@ describe "WeatherDotCom" do
103
117
 
104
118
  before(:each) do
105
119
  @query = Barometer::Query.new("90210")
106
- @measurement = Data::Measurement.new
120
+ @measurement = Barometer::Measurement.new
107
121
 
108
122
  url = "http://xoap.weather.com:80/weather/local/"
109
123
 
@@ -124,8 +138,8 @@ describe "WeatherDotCom" do
124
138
 
125
139
  it "requires a Barometer::Measurement object" do
126
140
  lambda { WeatherService::WeatherDotCom._measure(nil, @query) }.should raise_error(ArgumentError)
127
- lambda { WeatherService::WeatherDotCom._measure("invlaid", @query) }.should raise_error(ArgumentError)
128
-
141
+ lambda { WeatherService::WeatherDotCom._measure("invalid", @query) }.should raise_error(ArgumentError)
142
+
129
143
  lambda { WeatherService::WeatherDotCom._measure(@measurement, @query) }.should_not raise_error(ArgumentError)
130
144
  end
131
145
 
@@ -138,114 +152,20 @@ describe "WeatherDotCom" do
138
152
 
139
153
  it "returns a Barometer::Measurement object" do
140
154
  result = WeatherService::WeatherDotCom._measure(@measurement, @query)
141
- result.is_a?(Data::Measurement).should be_true
142
- result.current.is_a?(Data::CurrentMeasurement).should be_true
143
- result.forecast.is_a?(Array).should be_true
144
-
145
- result.source.should == :weather_dot_com
155
+ result.is_a?(Barometer::Measurement).should be_true
156
+ result.current.is_a?(Measurement::Current).should be_true
157
+ result.forecast.is_a?(Measurement::ForecastArray).should be_true
146
158
  end
147
159
 
148
160
  end
149
161
 
150
162
  end
151
163
 
152
- describe "when answering the simple questions," do
153
-
154
- before(:each) do
155
- @measurement = Data::Measurement.new
156
- end
157
-
158
- describe "currently_wet_by_icon?" do
159
-
160
- before(:each) do
161
- @measurement.current = Data::CurrentMeasurement.new
162
- end
163
-
164
- it "returns true if matching icon code" do
165
- @measurement.current.icon = "4"
166
- @measurement.current.icon?.should be_true
167
- WeatherService::WeatherDotCom.currently_wet_by_icon?(@measurement.current).should be_true
168
- end
169
-
170
- it "returns false if NO matching icon code" do
171
- @measurement.current.icon = "32"
172
- @measurement.current.icon?.should be_true
173
- WeatherService::WeatherDotCom.currently_wet_by_icon?(@measurement.current).should be_false
174
- end
175
-
176
- end
177
-
178
- describe "forecasted_wet_by_icon?" do
179
-
180
- before(:each) do
181
- @measurement.forecast = [Data::ForecastMeasurement.new]
182
- @measurement.forecast.first.date = Date.today
183
- @measurement.forecast.size.should == 1
184
- end
185
-
186
- it "returns true if matching icon code" do
187
- @measurement.forecast.first.icon = "4"
188
- @measurement.forecast.first.icon?.should be_true
189
- WeatherService::WeatherDotCom.forecasted_wet_by_icon?(@measurement.forecast.first).should be_true
190
- end
191
-
192
- it "returns false if NO matching icon code" do
193
- @measurement.forecast.first.icon = "32"
194
- @measurement.forecast.first.icon?.should be_true
195
- WeatherService::WeatherDotCom.forecasted_wet_by_icon?(@measurement.forecast.first).should be_false
196
- end
197
-
198
- end
199
-
200
- describe "currently_sunny_by_icon?" do
201
-
202
- before(:each) do
203
- @measurement.current = Data::CurrentMeasurement.new
204
- end
205
-
206
- it "returns true if matching icon code" do
207
- @measurement.current.icon = "32"
208
- @measurement.current.icon?.should be_true
209
- WeatherService::WeatherDotCom.currently_sunny_by_icon?(@measurement.current).should be_true
210
- end
211
-
212
- it "returns false if NO matching icon code" do
213
- @measurement.current.icon = "4"
214
- @measurement.current.icon?.should be_true
215
- WeatherService::WeatherDotCom.currently_sunny_by_icon?(@measurement.current).should be_false
216
- end
217
-
218
- end
219
-
220
- describe "forecasted_sunny_by_icon?" do
221
-
222
- before(:each) do
223
- @measurement.forecast = [Data::ForecastMeasurement.new]
224
- @measurement.forecast.first.date = Date.today
225
- @measurement.forecast.size.should == 1
226
- end
227
-
228
- it "returns true if matching icon code" do
229
- @measurement.forecast.first.icon = "32"
230
- @measurement.forecast.first.icon?.should be_true
231
- WeatherService::WeatherDotCom.forecasted_sunny_by_icon?(@measurement.forecast.first).should be_true
232
- end
233
-
234
- it "returns false if NO matching icon code" do
235
- @measurement.forecast.first.icon = "4"
236
- @measurement.forecast.first.icon?.should be_true
237
- WeatherService::WeatherDotCom.forecasted_sunny_by_icon?(@measurement.forecast.first).should be_false
238
- end
239
-
240
- end
241
-
242
- end
243
-
244
164
  describe "overall data correctness" do
245
165
 
246
166
  before(:each) do
247
167
  @query = Barometer::Query.new("90210")
248
- @measurement = Data::Measurement.new
168
+ @measurement = Barometer::Measurement.new
249
169
 
250
170
  url = "http://xoap.weather.com:80/weather/local/"
251
171