weatherzone 0.7.1 → 0.7.2
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.
- data/lib/weatherzone.rb +1 -1
- data/lib/weatherzone/finder.rb +4 -2
- data/test/test_finder.rb +2 -2
- data/test/test_response_parser.rb +22 -0
- metadata +4 -3
data/lib/weatherzone.rb
CHANGED
data/lib/weatherzone/finder.rb
CHANGED
@@ -40,8 +40,9 @@ module Weatherzone
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def find(connection, options, location_code=nil)
|
43
|
+
url_only = options.delete(:url_only)
|
43
44
|
set_options(connection, options)
|
44
|
-
make_request(connection, build_params(location_code, options))
|
45
|
+
make_request(connection, build_params(location_code, options), url_only)
|
45
46
|
end
|
46
47
|
|
47
48
|
def find_by_location_code(connection, location_code, options={})
|
@@ -119,7 +120,8 @@ module Weatherzone
|
|
119
120
|
self.temperature_unit = options.delete(:temperature_unit)
|
120
121
|
end
|
121
122
|
|
122
|
-
def make_request(connection, params)
|
123
|
+
def make_request(connection, params, url_only)
|
124
|
+
return connection.wz_url_for(params) if url_only
|
123
125
|
response = connection.request(params)
|
124
126
|
parse(response)
|
125
127
|
end
|
data/test/test_finder.rb
CHANGED
@@ -27,7 +27,7 @@ class TestFinder < Test::Unit::TestCase
|
|
27
27
|
|
28
28
|
def test_should_parse_response
|
29
29
|
f = File.open("test/response/everything.xml")
|
30
|
-
@connection.stubs(:request).returns(
|
30
|
+
@connection.stubs(:request).returns(f)
|
31
31
|
SomeResource.expects(:parse).with(f)
|
32
32
|
SomeResource.find_by_location_code(@connection, 9770, :include => [:forecast])
|
33
33
|
end
|
@@ -56,7 +56,7 @@ class TestFinder < Test::Unit::TestCase
|
|
56
56
|
SomeResource.expects(:build_params).with(nil, :include => [:moon_phases])
|
57
57
|
SomeResource.find(@connection, :include => [:moon_phases])
|
58
58
|
end
|
59
|
-
|
59
|
+
|
60
60
|
def test_should_include_location_parameter_string
|
61
61
|
assert_equal "&lc=9770", SomeResource.build_params(9770,{})
|
62
62
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
+
|
3
|
+
class TestResponseParser < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
response = File.open("test/response/everything.xml")
|
7
|
+
@weather = Weather.parse(response)
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_should_be_an_instance_of_weather
|
11
|
+
assert_kind_of Weather, @weather
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_should_have_countries
|
15
|
+
assert @weather.countries.any?
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_countries_should_be_countries
|
19
|
+
assert_kind_of Country, @weather.countries.first
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 7
|
8
|
-
-
|
9
|
-
version: 0.7.
|
8
|
+
- 2
|
9
|
+
version: 0.7.2
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Ben Askins
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-05-
|
17
|
+
date: 2010-05-05 00:00:00 +10:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -151,6 +151,7 @@ test_files:
|
|
151
151
|
- test/test_moon_phase.rb
|
152
152
|
- test/test_news_item.rb
|
153
153
|
- test/test_point_forecast.rb
|
154
|
+
- test/test_response_parser.rb
|
154
155
|
- test/test_snow_report.rb
|
155
156
|
- test/test_state_forecast.rb
|
156
157
|
- test/test_surf_report.rb
|