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,165 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Forecast Array" do
4
+
5
+ describe "instance methods" do
6
+
7
+ before(:each) do
8
+ @array = Measurement::ForecastArray.new
9
+ end
10
+
11
+ describe "'<<'" do
12
+
13
+ it "requires ForecastMeasurement" do
14
+ lambda { @array << "invalid" }.should raise_error(ArgumentError)
15
+ end
16
+
17
+ it "adds ForecastMeasurement" do
18
+ @array.size.should == 0
19
+ forecast = Measurement::Forecast.new
20
+ @array << forecast
21
+ @array.size.should == 1
22
+ end
23
+
24
+ end
25
+
26
+ describe "when searching forecasts using 'for'" do
27
+
28
+ before(:each) do
29
+ 1.upto(4) do |i|
30
+ forecast_measurement = Measurement::Forecast.new
31
+ forecast_measurement.date = Date.parse((Time.now + (i * 60 * 60 * 24)).to_s)
32
+ @array << forecast_measurement
33
+ end
34
+ @array.size.should == 4
35
+
36
+ @tommorrow = (Time.now + (60 * 60 * 24))
37
+ end
38
+
39
+ it "returns nil when there are no forecasts" do
40
+ @array = Measurement::ForecastArray.new
41
+ @array.size.should == 0
42
+ @array.for(@tommorrow).should be_nil
43
+ end
44
+
45
+ it "finds the date using a String" do
46
+ tommorrow = @tommorrow.to_s
47
+ tommorrow.class.should == String
48
+ @array.for(tommorrow).should == @array.first
49
+ end
50
+
51
+ it "finds the date using a Date" do
52
+ tommorrow = Date.parse(@tommorrow.to_s)
53
+ tommorrow.class.should == Date
54
+ @array.for(tommorrow).should == @array.first
55
+ end
56
+
57
+ it "finds the date using a DateTime" do
58
+ tommorrow = DateTime.parse(@tommorrow.to_s)
59
+ tommorrow.class.should == DateTime
60
+ @array.for(tommorrow).should == @array.first
61
+ end
62
+
63
+ it "finds the date using a Time" do
64
+ @tommorrow.class.should == Time
65
+ @array.for(@tommorrow).should == @array.first
66
+ end
67
+
68
+ it "finds the date using Data::LocalDateTime" do
69
+ tommorrow = Data::LocalDateTime.parse(@tommorrow.to_s)
70
+ tommorrow.class.should == Data::LocalDateTime
71
+ @array.for(tommorrow).should == @array.first
72
+ end
73
+
74
+ it "finds nothing when there is not a match" do
75
+ yesterday = (Time.now - (60 * 60 * 24))
76
+ yesterday.class.should == Time
77
+ @array.for(yesterday).should be_nil
78
+ end
79
+
80
+ it "finds using '[]'" do
81
+ tommorrow = @tommorrow.to_s
82
+ tommorrow.class.should == String
83
+ @array[tommorrow].should == @array.first
84
+ end
85
+
86
+ end
87
+
88
+ end
89
+
90
+ describe "simple questions" do
91
+
92
+ before(:each) do
93
+ @array = Measurement::ForecastArray.new
94
+ #@early = Data::LocalTime("6:00 am")
95
+ #@noon = Data::LocalTime("12:00 pm")
96
+ #@late = Data::LocalTime("8:00 pm")
97
+ @now = Time.utc(2009,5,5,10,30,25)
98
+
99
+ @sun_icons = %w(sunny)
100
+
101
+ 0.upto(1) do |i|
102
+ forecast_measurement = Measurement::Forecast.new
103
+ forecast_measurement.date = Date.parse((@now + (i * 60 * 60 * 24)).to_s)
104
+ wind = Data::Speed.new
105
+ wind << (i * 5)
106
+ forecast_measurement.wind = wind
107
+ forecast_measurement.sun = Data::Sun.new(
108
+ Data::LocalTime.parse("9:00 am"), Data::LocalTime.parse("3:00 pm"))
109
+ forecast_measurement.icon = "sunny"
110
+ forecast_measurement.pop = 40
111
+ forecast_measurement.humidity = 95
112
+ @array << forecast_measurement
113
+ end
114
+ @array.size.should == 2
115
+ @tommorrow = (@now + (60 * 60 * 24))
116
+ @yesterday = (@now - (60 * 60 * 24))
117
+ @earlier = (@now - (60 * 60 * 3))
118
+ @later = (@now + (60 * 60 * 6))
119
+ end
120
+
121
+ it "answers windy?" do
122
+ @array.windy?(@tommorrow).should be_false
123
+ @array.windy?(@tommorrow,1).should be_true
124
+ @array.windy?(@yesterday).should be_nil
125
+ end
126
+
127
+ it "answers day?" do
128
+ @array.day?(@yesterday).should be_nil
129
+ @array.day?(@earlier).should be_false
130
+ @array.day?(@later).should be_false
131
+ @array.day?(@tommorrow).should be_true
132
+ @array.day?(@now).should be_true
133
+ end
134
+
135
+ it "answers sunny?" do
136
+ @array.sunny?(@tommorrow,%w(rain)).should be_false
137
+ @array.sunny?(@tommorrow,@sun_icons).should be_true
138
+ @array.sunny?(@yesterday).should be_nil
139
+ end
140
+
141
+ describe "wet?" do
142
+
143
+ it "answers via pop" do
144
+ @array.wet?(@tommorrow).should be_false
145
+ @array.wet?(@tommorrow,nil,50).should be_false
146
+ @array.wet?(@tommorrow,nil,30).should be_true
147
+ end
148
+
149
+ it "answers via humidity" do
150
+ @array.wet?(@tommorrow).should be_false
151
+ @array.wet?(@tommorrow,nil,50,99).should be_false
152
+ @array.wet?(@tommorrow,nil,50,90).should be_true
153
+ end
154
+
155
+ it "answers via icon" do
156
+ @array.wet?(@tommorrow,%w(rain)).should be_false
157
+ # pretend that "sun" means wet
158
+ @array.wet?(@tommorrow,@sun_icons).should be_true
159
+ end
160
+
161
+ end
162
+
163
+ end
164
+
165
+ end
@@ -0,0 +1,135 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Forecast Measurement" do
4
+
5
+ describe "when initialized" do
6
+
7
+ before(:each) do
8
+ @forecast = Measurement::Forecast.new
9
+ end
10
+
11
+ it "responds to date" do
12
+ @forecast.date.should be_nil
13
+ end
14
+
15
+ it "responds to low" do
16
+ @forecast.low.should be_nil
17
+ end
18
+
19
+ it "responds to high" do
20
+ @forecast.high.should be_nil
21
+ end
22
+
23
+ it "responds to pop" do
24
+ @forecast.pop.should be_nil
25
+ end
26
+
27
+ it "responds to night" do
28
+ @forecast.night.should be_nil
29
+ end
30
+
31
+ end
32
+
33
+ describe "when writing data" do
34
+
35
+ before(:each) do
36
+ @forecast = Measurement::Forecast.new
37
+ end
38
+
39
+ it "only accepts Date for date" do
40
+ invalid_data = 1
41
+ invalid_data.class.should_not == Date
42
+ lambda { @forecast.date = invalid_data }.should raise_error(ArgumentError)
43
+
44
+ valid_data = Date.new
45
+ valid_data.class.should == Date
46
+ lambda { @forecast.date = valid_data }.should_not raise_error(ArgumentError)
47
+ end
48
+
49
+ it "only accepts Data::Temperature for high" do
50
+ invalid_data = 1
51
+ invalid_data.class.should_not == Data::Temperature
52
+ lambda { @forecast.high = invalid_data }.should raise_error(ArgumentError)
53
+
54
+ valid_data = Data::Temperature.new
55
+ valid_data.class.should == Data::Temperature
56
+ lambda { @forecast.high = valid_data }.should_not raise_error(ArgumentError)
57
+ end
58
+
59
+ it "only accepts Data::Temperature for low" do
60
+ invalid_data = 1
61
+ invalid_data.class.should_not == Data::Temperature
62
+ lambda { @forecast.low = invalid_data }.should raise_error(ArgumentError)
63
+
64
+ valid_data = Data::Temperature.new
65
+ valid_data.class.should == Data::Temperature
66
+ lambda { @forecast.low = valid_data }.should_not raise_error(ArgumentError)
67
+ end
68
+
69
+ it "only accepts Fixnum for pop" do
70
+ invalid_data = "test"
71
+ invalid_data.class.should_not == Fixnum
72
+ lambda { @forecast.pop = invalid_data }.should raise_error(ArgumentError)
73
+
74
+ valid_data = 50
75
+ valid_data.class.should == Fixnum
76
+ lambda { @forecast.pop = valid_data }.should_not raise_error(ArgumentError)
77
+ end
78
+
79
+ it "only accepts Measurement::ForecastNight for night" do
80
+ invalid_data = 1
81
+ invalid_data.class.should_not == Measurement::ForecastNight
82
+ lambda { @forecast.night = invalid_data }.should raise_error(ArgumentError)
83
+
84
+ valid_data = Measurement::ForecastNight.new
85
+ valid_data.class.should == Measurement::ForecastNight
86
+ lambda { @forecast.night = valid_data }.should_not raise_error(ArgumentError)
87
+ end
88
+
89
+ end
90
+
91
+ describe "answer simple questions, like" do
92
+
93
+ before(:each) do
94
+ @forecast = Measurement::Forecast.new
95
+ end
96
+
97
+ describe "wet?" do
98
+
99
+ describe "wet_by_pop?" do
100
+
101
+ it "requires real threshold number (or nil)" do
102
+ lambda { @forecast.send("_wet_by_pop?","invalid") }.should raise_error(ArgumentError)
103
+ lambda { @forecast.send("_wet_by_pop?") }.should_not raise_error(ArgumentError)
104
+ lambda { @forecast.send("_wet_by_pop?",50) }.should_not raise_error(ArgumentError)
105
+ end
106
+
107
+ it "returns nil when no pop" do
108
+ @forecast.pop?.should be_false
109
+ @forecast.send("_wet_by_pop?",50).should be_nil
110
+ @forecast.wet?.should be_nil
111
+ @forecast.pop = 60
112
+ @forecast.pop?.should be_true
113
+ @forecast.send("_wet_by_pop?",50).should_not be_nil
114
+ @forecast.wet?.should_not be_nil
115
+ end
116
+
117
+ it "return true when current pop over threshold" do
118
+ @forecast.pop = 60
119
+ @forecast.send("_wet_by_pop?",50).should be_true
120
+ @forecast.wet?.should be_true
121
+ end
122
+
123
+ it "return false when current pop under threshold" do
124
+ @forecast.pop = 40
125
+ @forecast.send("_wet_by_pop?",50).should be_false
126
+ @forecast.wet?.should be_false
127
+ end
128
+
129
+ end
130
+
131
+ end
132
+
133
+ end
134
+
135
+ end
@@ -5,7 +5,7 @@ describe "Measurement" do
5
5
  describe "when initialized" do
6
6
 
7
7
  before(:each) do
8
- @measurement = Data::Measurement.new
8
+ @measurement = Barometer::Measurement.new
9
9
  end
10
10
 
11
11
  it "responds to source" do
@@ -14,7 +14,7 @@ describe "Measurement" do
14
14
 
15
15
  it "stores the source" do
16
16
  source = :wunderground
17
- measurement = Data::Measurement.new(source)
17
+ measurement = Barometer::Measurement.new(source)
18
18
  measurement.source.should_not be_nil
19
19
  measurement.source.should == source
20
20
  end
@@ -48,7 +48,7 @@ describe "Measurement" do
48
48
  end
49
49
 
50
50
  it "responds to current?" do
51
- @measurement.current?.should be_false
51
+ @measurement.current?.should be_true
52
52
  end
53
53
 
54
54
  it "responds to metric" do
@@ -76,7 +76,7 @@ describe "Measurement" do
76
76
  describe "when writing data" do
77
77
 
78
78
  before(:each) do
79
- @measurement = Data::Measurement.new
79
+ @measurement = Barometer::Measurement.new
80
80
  end
81
81
 
82
82
  it "only accepts Symbol for source" do
@@ -101,21 +101,21 @@ describe "Measurement" do
101
101
 
102
102
  it "only accepts Data::CurrentMeasurement for current" do
103
103
  invalid_data = "invalid"
104
- invalid_data.class.should_not == Data::CurrentMeasurement
104
+ invalid_data.class.should_not == Measurement::Current
105
105
  lambda { @measurement.current = invalid_data }.should raise_error(ArgumentError)
106
106
 
107
- valid_data = Data::CurrentMeasurement.new
108
- valid_data.class.should == Data::CurrentMeasurement
107
+ valid_data = Measurement::Current.new
108
+ valid_data.class.should == Measurement::Current
109
109
  lambda { @measurement.current = valid_data }.should_not raise_error(ArgumentError)
110
110
  end
111
111
 
112
- it "only accepts Array for forecast" do
112
+ it "only accepts Data::ForecastArray for forecast" do
113
113
  invalid_data = 1
114
- invalid_data.class.should_not == Array
114
+ invalid_data.class.should_not == Measurement::ForecastArray
115
115
  lambda { @measurement.forecast = invalid_data }.should raise_error(ArgumentError)
116
116
 
117
- valid_data = []
118
- valid_data.class.should == Array
117
+ valid_data = Measurement::ForecastArray.new
118
+ valid_data.class.should == Measurement::ForecastArray
119
119
  lambda { @measurement.forecast = valid_data }.should_not raise_error(ArgumentError)
120
120
  end
121
121
 
@@ -184,7 +184,7 @@ describe "Measurement" do
184
184
  describe "and the helpers" do
185
185
 
186
186
  before(:each) do
187
- @measurement = Data::Measurement.new
187
+ @measurement = Barometer::Measurement.new
188
188
  end
189
189
 
190
190
  it "changes state to successful (if successful)" do
@@ -194,7 +194,7 @@ describe "Measurement" do
194
194
  @measurement.current.should be_nil
195
195
  @measurement.success.should be_false
196
196
 
197
- @measurement.current = Data::CurrentMeasurement.new
197
+ @measurement.current = Measurement::Current.new
198
198
  @measurement.current.temperature = Data::Temperature.new
199
199
  @measurement.current.temperature.c = 10
200
200
  @measurement.utc_time_stamp.should_not be_nil
@@ -203,7 +203,7 @@ describe "Measurement" do
203
203
  end
204
204
 
205
205
  it "returns successful state" do
206
- @measurement.current = Data::CurrentMeasurement.new
206
+ @measurement.current = Measurement::Current.new
207
207
  @measurement.current.temperature = Data::Temperature.new
208
208
  @measurement.current.temperature.c = 10
209
209
  @measurement.success!
@@ -224,11 +224,11 @@ describe "Measurement" do
224
224
 
225
225
  it "indicates if current" do
226
226
  @measurement.current.should be_nil
227
- @measurement.current?.should be_false
227
+ @measurement.current?.should be_true
228
228
 
229
- @measurement.current = Data::CurrentMeasurement.new
229
+ @measurement.current = Measurement::Current.new
230
230
  @measurement.current.current_at.should be_nil
231
- @measurement.current?.should be_false
231
+ @measurement.current?.should be_true
232
232
 
233
233
  @measurement.current.current_at = Data::LocalTime.new(9,0,0)
234
234
  @measurement.current?.should be_true
@@ -255,7 +255,7 @@ describe "Measurement" do
255
255
  describe "changing units" do
256
256
 
257
257
  before(:each) do
258
- @measurement = Data::Measurement.new
258
+ @measurement = Barometer::Measurement.new
259
259
  end
260
260
 
261
261
  it "indicates if metric?" do
@@ -286,13 +286,13 @@ describe "Measurement" do
286
286
  describe "when searching forecasts using 'for'" do
287
287
 
288
288
  before(:each) do
289
- @measurement = Data::Measurement.new
289
+ @measurement = Barometer::Measurement.new
290
290
 
291
291
  # create a measurement object with a forecast array that includes
292
292
  # dates for 4 consecutive days starting with tommorrow
293
- @measurement.forecast = []
293
+ @measurement.forecast = Measurement::ForecastArray.new
294
294
  1.upto(4) do |i|
295
- forecast_measurement = Data::ForecastMeasurement.new
295
+ forecast_measurement = Measurement::Forecast.new
296
296
  forecast_measurement.date = Date.parse((Time.now + (i * 60 * 60 * 24)).to_s)
297
297
  @measurement.forecast << forecast_measurement
298
298
  end
@@ -302,7 +302,7 @@ describe "Measurement" do
302
302
  end
303
303
 
304
304
  it "returns nil when there are no forecasts" do
305
- @measurement.forecast = []
305
+ @measurement.forecast = Measurement::ForecastArray.new
306
306
  @measurement.forecast.size.should == 0
307
307
  @measurement.for.should be_nil
308
308
  end
@@ -347,85 +347,70 @@ describe "Measurement" do
347
347
  describe "when answering the simple questions," do
348
348
 
349
349
  before(:each) do
350
- @measurement = Data::Measurement.new(:wunderground)
350
+ @measurement = Barometer::Measurement.new(:wunderground)
351
+ @measurement.current = Measurement::Current.new
351
352
  @now = Data::LocalDateTime.parse("2009-05-01 2:05 pm")
352
353
  end
353
354
 
355
+ # def windy?(time_string=nil, threshold=10)
356
+ # local_time = Data::LocalTime.parse(time_string)
357
+ # if current?(local_time)
358
+ # return nil unless current
359
+ # current.windy?(threshold)
360
+ # else
361
+ # return nil unless forecast && (future = forecast[local_time])
362
+ # future.windy?(threshold)
363
+ # end
364
+ # end
365
+
354
366
  describe "windy?" do
355
367
 
356
- it "requires threshold as a number" do
357
- lambda { @measurement.windy?("a") }.should raise_error(ArgumentError)
358
- lambda { @measurement.windy?(1) }.should_not raise_error(ArgumentError)
359
- lambda { @measurement.windy?(1.1) }.should_not raise_error(ArgumentError)
360
- end
361
-
362
- it "requires time as a Time object" do
363
- #lambda { @measurement.windy?(1,false) }.should raise_error(ArgumentError)
364
- lambda { @measurement.windy?(1,@now) }.should_not raise_error(ArgumentError)
365
- end
366
-
367
- it "returns true if a source returns true" do
368
- module Barometer; class WeatherService
369
- def self.windy?(a=nil,b=nil,c=nil); true; end
368
+ it "returns true if a current_measurement returns true" do
369
+ module Barometer; class Measurement::Current < Measurement::Common
370
+ def windy?(a=nil); true; end
370
371
  end; end
371
372
  @measurement.windy?.should be_true
372
373
  end
373
374
 
374
- it "returns false if a measurement returns false" do
375
- module Barometer; class WeatherService
376
- def self.windy?(a=nil,b=nil,c=nil); false; end
375
+ it "returns false if a current_measurement returns false" do
376
+ module Barometer; class Measurement::Current < Measurement::Common
377
+ def windy?(a=nil); false; end
377
378
  end; end
378
379
  @measurement.windy?.should be_false
379
380
  end
380
381
 
381
382
  end
382
383
 
383
- describe "wet?" do
384
-
385
- it "requires threshold as a number" do
386
- lambda { @measurement.wet?("a") }.should raise_error(ArgumentError)
387
- lambda { @measurement.wet?(1) }.should_not raise_error(ArgumentError)
388
- lambda { @measurement.wet?(1.1) }.should_not raise_error(ArgumentError)
389
- end
390
-
391
- it "requires time as a Time object" do
392
- #lambda { @measurement.wet?(1,"a") }.should raise_error(ArgumentError)
393
- lambda { @measurement.wet?(1,@now) }.should_not raise_error(ArgumentError)
394
- end
395
-
396
- it "returns true if a source returns true" do
397
- module Barometer; class WeatherService
398
- def self.wet?(a=nil,b=nil,c=nil); true; end
399
- end; end
400
- @measurement.wet?.should be_true
401
- end
402
-
403
- it "returns false if a measurement returns false" do
404
- module Barometer; class WeatherService
405
- def self.wet?(a=nil,b=nil,c=nil); false; end
406
- end; end
407
- @measurement.wet?.should be_false
408
- end
409
-
410
- end
411
-
384
+ describe "wet?" do
385
+
386
+ it "returns true if the current_measurement returns true" do
387
+ module Barometer; class Measurement::Current < Measurement::Common
388
+ def wet?(a=nil,b=nil,c=nil); true; end
389
+ end; end
390
+ @measurement.wet?.should be_true
391
+ end
392
+
393
+ it "returns false if the current_measurement returns false" do
394
+ module Barometer; class Measurement::Current < Measurement::Common
395
+ def wet?(a=nil,b=nil,c=nil); false; end
396
+ end; end
397
+ @measurement.wet?.should be_false
398
+ end
399
+
400
+ end
401
+
412
402
  describe "day?" do
413
-
414
- it "requires time as a Time object" do
415
- #lambda { @measurement.day?("a") }.should raise_error(ArgumentError)
416
- lambda { @measurement.day?(@now) }.should_not raise_error(ArgumentError)
417
- end
418
-
419
- it "returns true if a source returns true" do
420
- module Barometer; class WeatherService
421
- def self.day?(a=nil,b=nil); true; end
403
+
404
+ it "returns true if the current_measurement returns true" do
405
+ module Barometer; class Measurement::Current < Measurement::Common
406
+ def day?(a=nil); true; end
422
407
  end; end
423
408
  @measurement.day?.should be_true
424
409
  end
425
-
426
- it "returns false if a measurement returns false" do
427
- module Barometer; class WeatherService
428
- def self.day?(a=nil,b=nil); false; end
410
+
411
+ it "returns false if the current_measurement returns false" do
412
+ module Barometer; class Measurement::Current < Measurement::Common
413
+ def day?(a=nil); false; end
429
414
  end; end
430
415
  @measurement.day?.should be_false
431
416
  end
@@ -434,45 +419,39 @@ describe "Measurement" do
434
419
 
435
420
  describe "sunny?" do
436
421
 
437
- it "requires time as a Time object" do
438
- #lambda { @measurement.sunny?("a") }.should raise_error(ArgumentError)
439
- lambda { @measurement.sunny?(@now) }.should_not raise_error(ArgumentError)
440
- end
441
-
442
- it "returns true if a source returns true" do
443
- module Barometer; class WeatherService
444
- def self.day?(a=nil,b=nil); true; end
422
+ it "returns true if the current_measurement returns true and day" do
423
+ module Barometer; class Measurement::Current < Measurement::Common
424
+ def day?(a=nil); true; end
445
425
  end; end
446
- module Barometer; class WeatherService
447
- def self.sunny?(a=nil,b=nil); true; end
426
+ module Barometer; class Measurement::Current < Measurement::Common
427
+ def sunny?(a=nil,b=nil); true; end
448
428
  end; end
429
+ @measurement.day?.should be_true
449
430
  @measurement.sunny?.should be_true
450
431
  end
451
-
452
- it "returns false if a measurement returns false" do
453
- module Barometer; class WeatherService
454
- def self.day?(a=nil,b=nil); true; end
432
+
433
+ it "returns false if the current_measurement returns false and day" do
434
+ module Barometer; class Measurement::Current < Measurement::Common
435
+ def day?(a=nil); true; end
455
436
  end; end
456
- module Barometer; class WeatherService
457
- def self.sunny?(a=nil,b=nil); false; end
437
+ module Barometer; class Measurement::Current < Measurement::Common
438
+ def sunny?(a=nil,b=nil); false; end
458
439
  end; end
440
+ @measurement.day?.should be_true
459
441
  @measurement.sunny?.should be_false
460
442
  end
461
443
 
462
444
  it "returns false if night time" do
463
- module Barometer; class WeatherService
464
- def self.day?(a=nil,b=nil); true; end
445
+ module Barometer; class Measurement::Current < Measurement::Common
446
+ def day?(a=nil); false; end
465
447
  end; end
466
- module Barometer; class WeatherService
467
- def self.sunny?(a=nil,b=nil); true; end
468
- end; end
469
- @measurement.sunny?.should be_true
470
- module Barometer; class WeatherService
471
- def self.day?(a=nil,b=nil); false; end
448
+ module Barometer; class Measurement::Current < Measurement::Common
449
+ def sunny?(a=nil,b=nil); true; end
472
450
  end; end
451
+ @measurement.day?.should be_false
473
452
  @measurement.sunny?.should be_false
474
453
  end
475
-
454
+
476
455
  end
477
456
 
478
457
  end