barometer 0.3.2 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (108) hide show
  1. data/README.rdoc +78 -70
  2. data/VERSION.yml +2 -2
  3. data/bin/barometer +100 -37
  4. data/lib/barometer.rb +12 -8
  5. data/lib/barometer/base.rb +48 -20
  6. data/lib/barometer/data.rb +5 -1
  7. data/lib/barometer/data/current.rb +23 -15
  8. data/lib/barometer/data/distance.rb +15 -5
  9. data/lib/barometer/data/forecast.rb +23 -5
  10. data/lib/barometer/data/geo.rb +16 -54
  11. data/lib/barometer/data/local_datetime.rb +137 -0
  12. data/lib/barometer/data/local_time.rb +134 -0
  13. data/lib/barometer/data/location.rb +6 -1
  14. data/lib/barometer/data/measurement.rb +71 -42
  15. data/lib/barometer/data/night.rb +69 -0
  16. data/lib/barometer/data/pressure.rb +15 -5
  17. data/lib/barometer/data/speed.rb +16 -5
  18. data/lib/barometer/data/sun.rb +8 -20
  19. data/lib/barometer/data/temperature.rb +22 -9
  20. data/lib/barometer/data/units.rb +10 -19
  21. data/lib/barometer/data/zone.rb +135 -9
  22. data/lib/barometer/formats.rb +12 -0
  23. data/lib/barometer/formats/coordinates.rb +42 -0
  24. data/lib/barometer/formats/format.rb +46 -0
  25. data/lib/barometer/formats/geocode.rb +51 -0
  26. data/lib/barometer/formats/icao.rb +37 -0
  27. data/lib/barometer/formats/postalcode.rb +22 -0
  28. data/lib/barometer/formats/short_zipcode.rb +17 -0
  29. data/lib/barometer/formats/weather_id.rb +107 -0
  30. data/lib/barometer/formats/zipcode.rb +31 -0
  31. data/lib/barometer/query.rb +61 -232
  32. data/lib/barometer/services.rb +14 -4
  33. data/lib/barometer/translations/icao_country_codes.yml +9 -0
  34. data/lib/barometer/translations/weather_country_codes.yml +17 -0
  35. data/lib/barometer/weather.rb +51 -30
  36. data/lib/barometer/{services → weather_services}/google.rb +23 -26
  37. data/lib/barometer/weather_services/noaa.rb +6 -0
  38. data/lib/barometer/{services → weather_services}/service.rb +101 -92
  39. data/lib/barometer/weather_services/weather_bug.rb +6 -0
  40. data/lib/barometer/weather_services/weather_dot_com.rb +261 -0
  41. data/lib/barometer/{services → weather_services}/wunderground.rb +58 -76
  42. data/lib/barometer/{services → weather_services}/yahoo.rb +91 -121
  43. data/lib/barometer/web_services/geocode.rb +33 -0
  44. data/lib/barometer/web_services/weather_id.rb +37 -0
  45. data/lib/barometer/web_services/web_service.rb +32 -0
  46. data/lib/demometer/demometer.rb +31 -4
  47. data/lib/demometer/views/forecast.erb +20 -0
  48. data/lib/demometer/views/index.erb +10 -3
  49. data/lib/demometer/views/measurement.erb +8 -3
  50. data/lib/demometer/views/readme.erb +63 -24
  51. data/spec/barometer_spec.rb +18 -36
  52. data/spec/{data_current_spec.rb → data/current_spec.rb} +73 -49
  53. data/spec/{data_distance_spec.rb → data/distance_spec.rb} +30 -30
  54. data/spec/{data_forecast_spec.rb → data/forecast_spec.rb} +57 -15
  55. data/spec/data/geo_spec.rb +91 -0
  56. data/spec/data/local_datetime_spec.rb +269 -0
  57. data/spec/data/local_time_spec.rb +239 -0
  58. data/spec/{data_location_spec.rb → data/location_spec.rb} +12 -1
  59. data/spec/{data_measurement_spec.rb → data/measurement_spec.rb} +135 -66
  60. data/spec/data/night_measurement_spec.rb +136 -0
  61. data/spec/{data_pressure_spec.rb → data/pressure_spec.rb} +29 -29
  62. data/spec/{data_speed_spec.rb → data/speed_spec.rb} +30 -30
  63. data/spec/data/sun_spec.rb +49 -0
  64. data/spec/{data_temperature_spec.rb → data/temperature_spec.rb} +44 -44
  65. data/spec/{units_spec.rb → data/units_spec.rb} +6 -6
  66. data/spec/{data_zone_spec.rb → data/zone_spec.rb} +15 -15
  67. data/spec/fixtures/formats/weather_id/90210.xml +1 -0
  68. data/spec/fixtures/formats/weather_id/atlanta.xml +1 -0
  69. data/spec/fixtures/formats/weather_id/from_USGA0028.xml +1 -0
  70. data/spec/fixtures/formats/weather_id/new_york.xml +1 -0
  71. data/spec/fixtures/{geocode_40_73.xml → geocode/40_73.xml} +0 -0
  72. data/spec/fixtures/{geocode_90210.xml → geocode/90210.xml} +0 -0
  73. data/spec/fixtures/{geocode_T5B4M9.xml → geocode/T5B4M9.xml} +0 -0
  74. data/spec/fixtures/geocode/atlanta.xml +1 -0
  75. data/spec/fixtures/{geocode_calgary_ab.xml → geocode/calgary_ab.xml} +0 -0
  76. data/spec/fixtures/{geocode_ksfo.xml → geocode/ksfo.xml} +0 -0
  77. data/spec/fixtures/{geocode_newyork_ny.xml → geocode/newyork_ny.xml} +0 -0
  78. data/spec/fixtures/{google_calgary_ab.xml → services/google/calgary_ab.xml} +0 -0
  79. data/spec/fixtures/services/weather_dot_com/90210.xml +1 -0
  80. data/spec/fixtures/{current_calgary_ab.xml → services/wunderground/current_calgary_ab.xml} +0 -0
  81. data/spec/fixtures/{forecast_calgary_ab.xml → services/wunderground/forecast_calgary_ab.xml} +0 -0
  82. data/spec/fixtures/{yahoo_90210.xml → services/yahoo/90210.xml} +0 -0
  83. data/spec/formats/coordinates_spec.rb +158 -0
  84. data/spec/formats/format_spec.rb +73 -0
  85. data/spec/formats/geocode_spec.rb +179 -0
  86. data/spec/formats/icao_spec.rb +61 -0
  87. data/spec/formats/postalcode_spec.rb +59 -0
  88. data/spec/formats/short_zipcode_spec.rb +53 -0
  89. data/spec/formats/weather_id_spec.rb +191 -0
  90. data/spec/formats/zipcode_spec.rb +111 -0
  91. data/spec/query_spec.rb +261 -288
  92. data/spec/spec_helper.rb +128 -4
  93. data/spec/{service_google_spec.rb → weather_services/google_spec.rb} +46 -46
  94. data/spec/weather_services/services_spec.rb +1118 -0
  95. data/spec/weather_services/weather_dot_com_spec.rb +327 -0
  96. data/spec/weather_services/wunderground_spec.rb +332 -0
  97. data/spec/{service_yahoo_spec.rb → weather_services/yahoo_spec.rb} +65 -81
  98. data/spec/weather_spec.rb +73 -61
  99. data/spec/web_services/geocode_spec.rb +45 -0
  100. data/spec/web_services/web_services_spec.rb +26 -0
  101. metadata +88 -36
  102. data/lib/barometer/services/noaa.rb +0 -6
  103. data/lib/barometer/services/weather_bug.rb +0 -6
  104. data/lib/barometer/services/weather_dot_com.rb +0 -6
  105. data/spec/data_geo_spec.rb +0 -94
  106. data/spec/data_sun_spec.rb +0 -76
  107. data/spec/service_wunderground_spec.rb +0 -330
  108. data/spec/services_spec.rb +0 -1106
@@ -5,11 +5,7 @@ describe "Current Measurement" do
5
5
  describe "when initialized" do
6
6
 
7
7
  before(:each) do
8
- @current = Barometer::CurrentMeasurement.new
9
- end
10
-
11
- it "responds to time" do
12
- @current.time.should be_nil
8
+ @current = Data::CurrentMeasurement.new
13
9
  end
14
10
 
15
11
  it "responds to humidity" do
@@ -56,24 +52,22 @@ describe "Current Measurement" do
56
52
  @current.sun.should be_nil
57
53
  end
58
54
 
55
+ it "responds to current_at" do
56
+ @current.current_at.should be_nil
57
+ end
58
+
59
+ it "responds to updated_at" do
60
+ @current.updated_at.should be_nil
61
+ end
62
+
59
63
  end
60
64
 
61
65
  describe "when writing data" do
62
66
 
63
67
  before(:each) do
64
- @current = Barometer::CurrentMeasurement.new
68
+ @current = Data::CurrentMeasurement.new
65
69
  end
66
70
 
67
- # it "only accepts Time for time" do
68
- # invalid_data = 1
69
- # invalid_data.class.should_not == Time
70
- # lambda { @current.time = invalid_data }.should raise_error(ArgumentError)
71
- #
72
- # valid_data = Time.new
73
- # valid_data.class.should == Time
74
- # lambda { @current.time = valid_data }.should_not raise_error(ArgumentError)
75
- # end
76
-
77
71
  it "only accepts Fixnum or Float for humidity" do
78
72
  invalid_data = "invalid"
79
73
  invalid_data.class.should_not == Fixnum
@@ -109,92 +103,122 @@ describe "Current Measurement" do
109
103
  lambda { @current.condition = valid_data }.should_not raise_error(ArgumentError)
110
104
  end
111
105
 
112
- it "only accepts Barometer::Temperature for temperature" do
106
+ it "only accepts Data::Temperature for temperature" do
113
107
  invalid_data = 1
114
- invalid_data.class.should_not == Barometer::Temperature
108
+ invalid_data.class.should_not == Data::Temperature
115
109
  lambda { @current.temperature = invalid_data }.should raise_error(ArgumentError)
116
110
 
117
- valid_data = Barometer::Temperature.new
118
- valid_data.class.should == Barometer::Temperature
111
+ valid_data = Data::Temperature.new
112
+ valid_data.class.should == Data::Temperature
119
113
  lambda { @current.temperature = valid_data }.should_not raise_error(ArgumentError)
120
114
  end
121
115
 
122
- it "only accepts Barometer::Temperature for dew_point" do
116
+ it "only accepts Data::Temperature for dew_point" do
123
117
  invalid_data = 1
124
- invalid_data.class.should_not == Barometer::Temperature
118
+ invalid_data.class.should_not == Data::Temperature
125
119
  lambda { @current.dew_point = invalid_data }.should raise_error(ArgumentError)
126
120
 
127
- valid_data = Barometer::Temperature.new
128
- valid_data.class.should == Barometer::Temperature
121
+ valid_data = Data::Temperature.new
122
+ valid_data.class.should == Data::Temperature
129
123
  lambda { @current.dew_point = valid_data }.should_not raise_error(ArgumentError)
130
124
  end
131
125
 
132
- it "only accepts Barometer::Temperature for heat_index" do
126
+ it "only accepts Data::Temperature for heat_index" do
133
127
  invalid_data = 1
134
- invalid_data.class.should_not == Barometer::Temperature
128
+ invalid_data.class.should_not == Data::Temperature
135
129
  lambda { @current.heat_index = invalid_data }.should raise_error(ArgumentError)
136
130
 
137
- valid_data = Barometer::Temperature.new
138
- valid_data.class.should == Barometer::Temperature
131
+ valid_data = Data::Temperature.new
132
+ valid_data.class.should == Data::Temperature
139
133
  lambda { @current.heat_index = valid_data }.should_not raise_error(ArgumentError)
140
134
  end
141
135
 
142
- it "only accepts Barometer::Temperature for wind_chill" do
136
+ it "only accepts Data::Temperature for wind_chill" do
143
137
  invalid_data = 1
144
- invalid_data.class.should_not == Barometer::Temperature
138
+ invalid_data.class.should_not == Data::Temperature
145
139
  lambda { @current.wind_chill = invalid_data }.should raise_error(ArgumentError)
146
140
 
147
- valid_data = Barometer::Temperature.new
148
- valid_data.class.should == Barometer::Temperature
141
+ valid_data = Data::Temperature.new
142
+ valid_data.class.should == Data::Temperature
149
143
  lambda { @current.wind_chill = valid_data }.should_not raise_error(ArgumentError)
150
144
  end
151
145
 
152
- it "only accepts Barometer::Speed for wind" do
146
+ it "only accepts Data::Speed for wind" do
153
147
  invalid_data = 1
154
- invalid_data.class.should_not == Barometer::Speed
148
+ invalid_data.class.should_not == Data::Speed
155
149
  lambda { @current.wind = invalid_data }.should raise_error(ArgumentError)
156
150
 
157
- valid_data = Barometer::Speed.new
158
- valid_data.class.should == Barometer::Speed
151
+ valid_data = Data::Speed.new
152
+ valid_data.class.should == Data::Speed
159
153
  lambda { @current.wind = valid_data }.should_not raise_error(ArgumentError)
160
154
  end
161
155
 
162
- it "only accepts Barometer::Pressure for pressure" do
156
+ it "only accepts Data::Pressure for pressure" do
163
157
  invalid_data = 1
164
- invalid_data.class.should_not == Barometer::Pressure
158
+ invalid_data.class.should_not == Data::Pressure
165
159
  lambda { @current.pressure = invalid_data }.should raise_error(ArgumentError)
166
160
 
167
- valid_data = Barometer::Pressure.new
168
- valid_data.class.should == Barometer::Pressure
161
+ valid_data = Data::Pressure.new
162
+ valid_data.class.should == Data::Pressure
169
163
  lambda { @current.pressure = valid_data }.should_not raise_error(ArgumentError)
170
164
  end
171
165
 
172
- it "only accepts Barometer::Distance for visibility" do
166
+ it "only accepts Data::Distance for visibility" do
173
167
  invalid_data = 1
174
- invalid_data.class.should_not == Barometer::Distance
168
+ invalid_data.class.should_not == Data::Distance
175
169
  lambda { @current.visibility = invalid_data }.should raise_error(ArgumentError)
176
170
 
177
- valid_data = Barometer::Distance.new
178
- valid_data.class.should == Barometer::Distance
171
+ valid_data = Data::Distance.new
172
+ valid_data.class.should == Data::Distance
179
173
  lambda { @current.visibility = valid_data }.should_not raise_error(ArgumentError)
180
174
  end
181
175
 
182
- it "only accepts Barometer::Sun for sun" do
176
+ it "only accepts Data::Sun for sun" do
183
177
  invalid_data = 1
184
- invalid_data.class.should_not == Barometer::Sun
178
+ invalid_data.class.should_not == Data::Sun
185
179
  lambda { @current.sun = invalid_data }.should raise_error(ArgumentError)
186
180
 
187
- valid_data = Barometer::Sun.new
188
- valid_data.class.should == Barometer::Sun
181
+ valid_data = Data::Sun.new
182
+ valid_data.class.should == Data::Sun
189
183
  lambda { @current.sun = valid_data }.should_not raise_error(ArgumentError)
190
184
  end
191
185
 
186
+ it "only accepts Data::LocalTime || Data::LocalDateTime current_at" do
187
+ invalid_data = 1
188
+ invalid_data.class.should_not == Data::LocalTime
189
+ invalid_data.class.should_not == Data::LocalDateTime
190
+ lambda { @current.current_at = invalid_data }.should raise_error(ArgumentError)
191
+
192
+ valid_data = Data::LocalTime.new
193
+ valid_data.class.should == Data::LocalTime
194
+ lambda { @current.current_at = valid_data }.should_not raise_error(ArgumentError)
195
+
196
+ valid_data = Data::LocalDateTime.new(2009,1,1)
197
+ valid_data.class.should == Data::LocalDateTime
198
+ lambda { @current.current_at = valid_data }.should_not raise_error(ArgumentError)
199
+ end
200
+
201
+ it "only accepts Data::LocalTime || Data::LocalDateTime current_at" do
202
+ invalid_data = 1
203
+ invalid_data.class.should_not == Data::LocalTime
204
+ invalid_data.class.should_not == Data::LocalDateTime
205
+ lambda { @current.updated_at = invalid_data }.should raise_error(ArgumentError)
206
+
207
+ valid_data = Data::LocalTime.new
208
+ valid_data.class.should == Data::LocalTime
209
+ lambda { @current.updated_at = valid_data }.should_not raise_error(ArgumentError)
210
+
211
+ valid_data = Data::LocalDateTime.new(2009,1,1)
212
+ valid_data.class.should == Data::LocalDateTime
213
+ lambda { @current.updated_at = valid_data }.should_not raise_error(ArgumentError)
214
+ end
215
+
192
216
  end
193
217
 
194
218
  describe "method missing" do
195
219
 
196
220
  before(:each) do
197
- @current = Barometer::CurrentMeasurement.new
221
+ @current = Data::CurrentMeasurement.new
198
222
  end
199
223
 
200
224
  it "responds to method + ?" do
@@ -1,21 +1,21 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe "Distance" do
3
+ describe "Data::Distance" do
4
4
 
5
5
  describe "when initialized" do
6
6
 
7
7
  it "defines METRIC_UNITS" do
8
- Barometer::Distance.const_defined?("METRIC_UNITS").should be_true
9
- Barometer::Distance::METRIC_UNITS.should == "km"
8
+ Data::Distance.const_defined?("METRIC_UNITS").should be_true
9
+ Data::Distance::METRIC_UNITS.should == "km"
10
10
  end
11
11
 
12
12
  it "defines IMPERIAL_UNITS" do
13
- Barometer::Distance.const_defined?("IMPERIAL_UNITS").should be_true
14
- Barometer::Distance::IMPERIAL_UNITS.should == "m"
13
+ Data::Distance.const_defined?("IMPERIAL_UNITS").should be_true
14
+ Data::Distance::IMPERIAL_UNITS.should == "m"
15
15
  end
16
16
 
17
17
  before(:each) do
18
- @distance = Barometer::Distance.new
18
+ @distance = Data::Distance.new
19
19
  end
20
20
 
21
21
  it "responds to kilometers" do
@@ -52,20 +52,20 @@ describe "Distance" do
52
52
  end
53
53
 
54
54
  it "requires a value, that is either Integer or Float" do
55
- Barometer::Distance.km_to_m(nil).should be_nil
56
- Barometer::Distance.m_to_km(nil).should be_nil
55
+ Data::Distance.km_to_m(nil).should be_nil
56
+ Data::Distance.m_to_km(nil).should be_nil
57
57
 
58
58
  not_float_or_integer = "string"
59
- Barometer::Distance.km_to_m(not_float_or_integer).should be_nil
60
- Barometer::Distance.m_to_km(not_float_or_integer).should be_nil
59
+ Data::Distance.km_to_m(not_float_or_integer).should be_nil
60
+ Data::Distance.m_to_km(not_float_or_integer).should be_nil
61
61
  end
62
62
 
63
63
  it "converts KM to M" do
64
- ((Barometer::Distance.km_to_m(@km)*10).round/10.0).should == @m
64
+ ((Data::Distance.km_to_m(@km)*10).round/10.0).should == @m
65
65
  end
66
66
 
67
67
  it "converts M to KM" do
68
- ((Barometer::Distance.m_to_km(@m)*10).round/10.0).should == @km
68
+ ((Data::Distance.m_to_km(@m)*10).round/10.0).should == @km
69
69
  end
70
70
 
71
71
  end
@@ -73,7 +73,7 @@ describe "Distance" do
73
73
  describe "updating" do
74
74
 
75
75
  before(:each) do
76
- @distance = Barometer::Distance.new
76
+ @distance = Data::Distance.new
77
77
  @m = 26.2
78
78
  @km = 42.2
79
79
  end
@@ -123,7 +123,7 @@ describe "Distance" do
123
123
  describe "storing" do
124
124
 
125
125
  before(:each) do
126
- @distance = Barometer::Distance.new
126
+ @distance = Data::Distance.new
127
127
  @m = 26.2
128
128
  @km = 42.2
129
129
  end
@@ -165,7 +165,7 @@ describe "Distance" do
165
165
  describe "retrieving" do
166
166
 
167
167
  before(:each) do
168
- @distance = Barometer::Distance.new
168
+ @distance = Data::Distance.new
169
169
  @m = 26.2
170
170
  @km = 42.16
171
171
  end
@@ -233,52 +233,52 @@ describe "Distance" do
233
233
  before(:each) do
234
234
  @m = 26.2
235
235
  @km = 42.16
236
- @distance_low = Barometer::Distance.new
236
+ @distance_low = Data::Distance.new
237
237
  @distance_low.km = (@m - 1.0)
238
- @distance_high = Barometer::Distance.new
238
+ @distance_high = Data::Distance.new
239
239
  @distance_high.km = (@km + 1.0)
240
- @distance = Barometer::Distance.new
240
+ @distance = Data::Distance.new
241
241
  @distance.km = @km
242
- @distance_same = Barometer::Distance.new
242
+ @distance_same = Data::Distance.new
243
243
  @distance_same.km = @km
244
244
  end
245
245
 
246
246
  it "defines <=>" do
247
- Barometer::Distance.method_defined?("<=>").should be_true
247
+ Data::Distance.method_defined?("<=>").should be_true
248
248
  (@distance_low <=> @distance_high).should == -1
249
249
  (@distance_high <=> @distance_low).should == 1
250
250
  (@distance <=> @distance_same).should == 0
251
251
  end
252
252
 
253
253
  it "defines <" do
254
- Barometer::Distance.method_defined?("<").should be_true
254
+ Data::Distance.method_defined?("<").should be_true
255
255
  @distance_low.should < @distance_high
256
256
  @distance_high.should_not < @distance_low
257
257
  @distance.should_not < @distance_same
258
258
  end
259
259
 
260
260
  it "defines >" do
261
- Barometer::Distance.method_defined?(">").should be_true
261
+ Data::Distance.method_defined?(">").should be_true
262
262
  @distance_low.should_not > @distance_high
263
263
  @distance_high.should > @distance_low
264
264
  @distance.should_not > @distance_same
265
265
  end
266
266
 
267
267
  it "defines ==" do
268
- Barometer::Distance.method_defined?("==").should be_true
268
+ Data::Distance.method_defined?("==").should be_true
269
269
  @distance_low.should_not == @distance_high
270
270
  @distance.should == @distance_same
271
271
  end
272
272
 
273
273
  it "defines <=" do
274
- Barometer::Distance.method_defined?("<=").should be_true
274
+ Data::Distance.method_defined?("<=").should be_true
275
275
  @distance_low.should <= @distance_high
276
276
  @distance_high.should_not <= @distance_low
277
277
  @distance.should <= @distance_same
278
278
  end
279
279
 
280
280
  it "defines >=" do
281
- Barometer::Distance.method_defined?(">=").should be_true
281
+ Data::Distance.method_defined?(">=").should be_true
282
282
  @distance_low.should_not >= @distance_high
283
283
  @distance_high.should >= @distance_low
284
284
  @distance.should >= @distance_same
@@ -291,7 +291,7 @@ describe "Distance" do
291
291
  before(:each) do
292
292
  @m = 26.2
293
293
  @km = 42.16
294
- @distance = Barometer::Distance.new
294
+ @distance = Data::Distance.new
295
295
  @distance.km = @km
296
296
  end
297
297
 
@@ -315,20 +315,20 @@ describe "Distance" do
315
315
 
316
316
  it "returns just the integer value with units" do
317
317
  @distance.metric?.should be_true
318
- @distance.to_s.should == "#{@km.to_i} #{Barometer::Distance::METRIC_UNITS}"
318
+ @distance.to_s.should == "#{@km.to_i} #{Data::Distance::METRIC_UNITS}"
319
319
 
320
320
  @distance.imperial!
321
321
  @distance.metric?.should be_false
322
- @distance.to_s.should == "#{@m.to_i} #{Barometer::Distance::IMPERIAL_UNITS}"
322
+ @distance.to_s.should == "#{@m.to_i} #{Data::Distance::IMPERIAL_UNITS}"
323
323
  end
324
324
 
325
325
  it "returns just the units" do
326
326
  @distance.metric?.should be_true
327
- @distance.units.should == Barometer::Distance::METRIC_UNITS
327
+ @distance.units.should == Data::Distance::METRIC_UNITS
328
328
 
329
329
  @distance.imperial!
330
330
  @distance.metric?.should be_false
331
- @distance.units.should == Barometer::Distance::IMPERIAL_UNITS
331
+ @distance.units.should == Data::Distance::IMPERIAL_UNITS
332
332
  end
333
333
 
334
334
  end
@@ -5,7 +5,7 @@ describe "Forecast Measurement" do
5
5
  describe "when initialized" do
6
6
 
7
7
  before(:each) do
8
- @forecast = Barometer::ForecastMeasurement.new
8
+ @forecast = Data::ForecastMeasurement.new
9
9
  end
10
10
 
11
11
  it "responds to date" do
@@ -32,16 +32,28 @@ describe "Forecast Measurement" do
32
32
  @forecast.pop.should be_nil
33
33
  end
34
34
 
35
+ it "responds to humidity" do
36
+ @forecast.humidity.should be_nil
37
+ end
38
+
39
+ it "responds to wind" do
40
+ @forecast.wind.should be_nil
41
+ end
42
+
35
43
  it "responds to sun" do
36
44
  @forecast.sun.should be_nil
37
45
  end
38
46
 
47
+ it "responds to night" do
48
+ @forecast.night.should be_nil
49
+ end
50
+
39
51
  end
40
52
 
41
53
  describe "when writing data" do
42
54
 
43
55
  before(:each) do
44
- @forecast = Barometer::ForecastMeasurement.new
56
+ @forecast = Data::ForecastMeasurement.new
45
57
  end
46
58
 
47
59
  it "only accepts Date for date" do
@@ -74,23 +86,23 @@ describe "Forecast Measurement" do
74
86
  lambda { @forecast.condition = valid_data }.should_not raise_error(ArgumentError)
75
87
  end
76
88
 
77
- it "only accepts Barometer::Temperature for high" do
89
+ it "only accepts Data::Temperature for high" do
78
90
  invalid_data = 1
79
- invalid_data.class.should_not == Barometer::Temperature
91
+ invalid_data.class.should_not == Data::Temperature
80
92
  lambda { @forecast.high = invalid_data }.should raise_error(ArgumentError)
81
93
 
82
- valid_data = Barometer::Temperature.new
83
- valid_data.class.should == Barometer::Temperature
94
+ valid_data = Data::Temperature.new
95
+ valid_data.class.should == Data::Temperature
84
96
  lambda { @forecast.high = valid_data }.should_not raise_error(ArgumentError)
85
97
  end
86
98
 
87
- it "only accepts Barometer::Temperature for low" do
99
+ it "only accepts Data::Temperature for low" do
88
100
  invalid_data = 1
89
- invalid_data.class.should_not == Barometer::Temperature
101
+ invalid_data.class.should_not == Data::Temperature
90
102
  lambda { @forecast.low = invalid_data }.should raise_error(ArgumentError)
91
103
 
92
- valid_data = Barometer::Temperature.new
93
- valid_data.class.should == Barometer::Temperature
104
+ valid_data = Data::Temperature.new
105
+ valid_data.class.should == Data::Temperature
94
106
  lambda { @forecast.low = valid_data }.should_not raise_error(ArgumentError)
95
107
  end
96
108
 
@@ -104,22 +116,52 @@ describe "Forecast Measurement" do
104
116
  lambda { @forecast.pop = valid_data }.should_not raise_error(ArgumentError)
105
117
  end
106
118
 
107
- it "only accepts Barometer::Sun for sun" do
119
+ it "only accepts Data::Speed for wind" do
120
+ invalid_data = "test"
121
+ invalid_data.class.should_not == Data::Speed
122
+ lambda { @forecast.wind = invalid_data }.should raise_error(ArgumentError)
123
+
124
+ valid_data = Data::Speed.new
125
+ valid_data.class.should == Data::Speed
126
+ lambda { @forecast.wind = valid_data }.should_not raise_error(ArgumentError)
127
+ end
128
+
129
+ it "only accepts Fixnum for humidity" do
130
+ invalid_data = "test"
131
+ invalid_data.class.should_not == Fixnum
132
+ lambda { @forecast.humidity = invalid_data }.should raise_error(ArgumentError)
133
+
134
+ valid_data = 50
135
+ valid_data.class.should == Fixnum
136
+ lambda { @forecast.humidity = valid_data }.should_not raise_error(ArgumentError)
137
+ end
138
+
139
+ it "only accepts Data::Sun for sun" do
108
140
  invalid_data = 1
109
- invalid_data.class.should_not == Barometer::Sun
141
+ invalid_data.class.should_not == Data::Sun
110
142
  lambda { @forecast.sun = invalid_data }.should raise_error(ArgumentError)
111
143
 
112
- valid_data = Barometer::Sun.new
113
- valid_data.class.should == Barometer::Sun
144
+ valid_data = Data::Sun.new
145
+ valid_data.class.should == Data::Sun
114
146
  lambda { @forecast.sun = valid_data }.should_not raise_error(ArgumentError)
115
147
  end
116
148
 
149
+ it "only accepts Data::NightMeasurement for sun" do
150
+ invalid_data = 1
151
+ invalid_data.class.should_not == Data::NightMeasurement
152
+ lambda { @forecast.night = invalid_data }.should raise_error(ArgumentError)
153
+
154
+ valid_data = Data::NightMeasurement.new
155
+ valid_data.class.should == Data::NightMeasurement
156
+ lambda { @forecast.night = valid_data }.should_not raise_error(ArgumentError)
157
+ end
158
+
117
159
  end
118
160
 
119
161
  describe "method missing" do
120
162
 
121
163
  before(:each) do
122
- @forecast = Barometer::ForecastMeasurement.new
164
+ @forecast = Data::ForecastMeasurement.new
123
165
  end
124
166
 
125
167
  it "responds to method + ?" do