Active 0.0.14 → 0.0.17
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -0
- data/lib/Active.rb +15 -0
- data/lib/services/IActivity.rb +34 -17
- data/lib/services/active_works.rb +5 -4
- data/lib/services/activity.rb +253 -70
- data/lib/services/address.rb +17 -0
- data/lib/services/ats.rb +82 -35
- data/lib/services/gsa.rb +153 -0
- data/lib/services/reg_center.rb +43 -21
- data/lib/services/sanitize.rb +108 -0
- data/lib/services/search.rb +101 -18
- data/lib/services/search.txt +403 -0
- data/lib/services/validators.rb +91 -0
- data/spec/Active_spec.rb +24 -1
- data/spec/activeworks_spec.rb +1 -1
- data/spec/activity_spec.rb +101 -170
- data/spec/ats_spec.rb +9 -3
- data/spec/gsa_spec.rb +123 -0
- data/spec/reg_spec.rb +17 -8
- data/spec/search_memcached_spec.rb +49 -0
- data/spec/search_spec.rb +404 -356
- data/version.txt +1 -1
- metadata +30 -6
data/spec/search_spec.rb
CHANGED
@@ -5,391 +5,439 @@ require File.join(File.dirname(__FILE__), %w[custom_matchers_spec])
|
|
5
5
|
require File.join(File.dirname(__FILE__), %w[ .. lib services search])
|
6
6
|
require File.join(File.dirname(__FILE__), %w[ .. lib services activity])
|
7
7
|
include Active::Services
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
it "should not all search.active.com by default"
|
12
|
-
it "should call search.active.com when told to"
|
13
|
-
end
|
14
|
-
|
15
|
-
describe "Search URL Construction" do
|
8
|
+
Active.memcache_host "localhost:11211"
|
9
|
+
|
10
|
+
describe Search do
|
16
11
|
include CustomMatchers
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
# uri.query.should_not have_param("l=")
|
22
|
-
end
|
23
|
-
|
24
|
-
it "should place lat and lng in the l param" do
|
25
|
-
location = {:latitude=>"37.785895", :longitude=>"-122.40638"}
|
26
|
-
uri = URI.parse( Search.new(location).end_point )
|
27
|
-
uri.query.should have_param("l=37.785895;-122.40638")
|
28
|
-
end
|
29
|
-
|
30
|
-
it "should escape the location" do
|
31
|
-
s = Search.new()
|
32
|
-
s.location.should eql("")
|
33
|
-
s = Search.new({:location => "San Diego"})
|
34
|
-
s.location.should eql("San+Diego")
|
35
|
-
end
|
36
|
-
|
37
|
-
it "should have an array of keywords" do
|
38
|
-
s = Search.new()
|
39
|
-
s.should have(0).keywords
|
40
|
-
s = Search.new({:keywords => "Dog,Cat,Cow"})
|
41
|
-
s.should have(3).keywords
|
42
|
-
s = Search.new({:keywords => %w(Dog Cat Cow)})
|
43
|
-
s.should have(3).keywords
|
44
|
-
s = Search.new({:keywords => ["Dog","Cat","Cow"]})
|
45
|
-
s.should have(3).keywords
|
12
|
+
describe "Set up" do
|
13
|
+
it "should set the api key"
|
14
|
+
it "should not all search.active.com by default"
|
15
|
+
it "should call search.active.com when told to"
|
46
16
|
end
|
17
|
+
describe "Search URL Construction" do
|
47
18
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
s = Search.new({:channels => %w(running swimming yoga)})
|
54
|
-
s.should have(3).channels
|
55
|
-
s = Search.new({:channels => ["running","swimming","yoga"]})
|
56
|
-
s.should have(3).channels
|
57
|
-
end
|
58
|
-
|
59
|
-
it "should have defaults set" do
|
60
|
-
s = Search.new()
|
61
|
-
uri = URI.parse( s.end_point )
|
62
|
-
uri.query.include?("f=#{Facet.ACTIVITIES}").should be_true
|
63
|
-
uri.query.include?("s=#{Sort.DATE_ASC}").should be_true
|
64
|
-
uri.query.include?("r=50").should be_true
|
65
|
-
uri.query.include?("v=json").should be_true
|
66
|
-
uri.query.include?("page=1").should be_true
|
67
|
-
uri.query.should have_param("num=10")
|
68
|
-
uri.query.should have_param("daterange:today..+")
|
69
|
-
uri.query.should_not have_param("assetId=")
|
70
|
-
end
|
71
|
-
|
72
|
-
it "should construct a valid url with location" do
|
73
|
-
s = Search.new( {:location => "San Diego, CA, US"} )
|
74
|
-
uri = URI.parse(s.end_point)
|
75
|
-
uri.scheme.should eql("http")
|
76
|
-
uri.host.should eql("search.active.com")
|
77
|
-
uri.query.should have_param("l=#{CGI.escape("San Diego, CA, US")}")
|
78
|
-
end
|
79
|
-
|
80
|
-
it "should send an array of zips" do
|
81
|
-
uri = URI.parse( Search.new( {:zips => "92121, 92078, 92114"} ).end_point )
|
82
|
-
uri.query.should have_param("l=92121,92078,92114")
|
83
|
-
uri = URI.parse( Search.new( {:zips => [92121, 92078, 92114]} ).end_point )
|
84
|
-
uri.query.should have_param("l=92121,92078,92114")
|
85
|
-
end
|
86
|
-
|
87
|
-
# it "should construct a valid url from a zip code" do
|
88
|
-
# s = Search.new( {:zip => "92121"} )
|
89
|
-
# uri = URI.parse(s.end_point)
|
90
|
-
# uri.query.should have_param("l=#{CGI.escape("92121")}")
|
91
|
-
# end
|
92
|
-
|
93
|
-
it "should construct a valid url with CSV keywords" do
|
94
|
-
s = Search.new( {:keywords => "running, tri"} )
|
95
|
-
uri = URI.parse( s.end_point )
|
96
|
-
uri.query.should have_param("k=running+tri")
|
97
|
-
s = Search.new( {:keywords => ["running","tri","cycling"]} )
|
98
|
-
uri = URI.parse( s.end_point )
|
99
|
-
uri.query.should have_param("k=running+tri+cycling")
|
100
|
-
end
|
19
|
+
it "should search by city" do
|
20
|
+
uri = URI.parse( Search.new({:city=>"Oceanside"}).end_point )
|
21
|
+
uri.query.should have_param("meta:city=Oceanside")
|
22
|
+
uri.query.should_not have_param("l=")
|
23
|
+
end
|
101
24
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
uri.query.should have_param("m=meta:channel=Running+OR+meta:channel=Cycling+OR+meta:channel=Mind%2520%2526%2520Body%255CYoga")
|
106
|
-
end
|
107
|
-
|
108
|
-
it "should send valid channel info" do
|
109
|
-
uri = URI.parse( Search.new({:channels => [:running,:triathlon]}).end_point )
|
110
|
-
uri.query.include?("meta:channel=Running+OR+meta:channel=Triathlon").should be_true
|
111
|
-
end
|
112
|
-
|
113
|
-
it "should send the correct channel value for everything in Search.CHANNELS" do
|
114
|
-
Categories.CHANNELS.each do |key,value|
|
115
|
-
uri = URI.parse( Search.new({:channels => [key]}).end_point )
|
116
|
-
value = URI.escape(value, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))
|
117
|
-
value = URI.escape(value, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))
|
118
|
-
value.gsub!(/\-/,"%252D")
|
119
|
-
uri.query.should have_param("meta:channel=#{value}")
|
25
|
+
it "should double encode the city" do
|
26
|
+
uri = URI.parse( Search.new({:city=>"San Marcos"}).end_point )
|
27
|
+
uri.query.should have_param("meta:city=San%2520Marcos")
|
120
28
|
end
|
121
|
-
end
|
122
|
-
|
123
|
-
it "should send a valid start and end date" do
|
124
|
-
uri = URI.parse( Search.new().end_point )
|
125
|
-
uri.query.should have_param("daterange:today..+")
|
126
|
-
end
|
127
29
|
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
it "should be valid with date range and channels" do
|
134
|
-
uri = URI.parse( Search.new({:channels => [:running, :triathlon],
|
135
|
-
:start_date => Date.new(2010, 11, 1),
|
136
|
-
:end_date => Date.new(2010, 11, 15)}).end_point )
|
137
|
-
uri.query.should have_param("meta:channel=Running+OR+meta:channel=Triathlon")
|
138
|
-
uri.query.should have_param("daterange:11%2F01%2F2010..11%2F15%2F2010")
|
139
|
-
end
|
140
|
-
|
141
|
-
it "should pass the search radius" do
|
142
|
-
uri = URI.parse( Search.new({:radius => '666'}).end_point )
|
143
|
-
uri.query.should have_param("r=666")
|
144
|
-
end
|
145
|
-
|
146
|
-
it "should pass the given asset_id" do
|
147
|
-
s = Search.new({:asset_id => "12-34" })
|
148
|
-
s.should have(1).asset_ids
|
149
|
-
end
|
150
|
-
|
151
|
-
it "should pass the given asset_id's" do
|
152
|
-
s = Search.new({:asset_ids => ["12-34","5-67","77-7"] })
|
153
|
-
s.should have(3).asset_ids
|
154
|
-
uri = URI.parse( s.end_point )
|
155
|
-
uri.query.should_not have_param("m=+AND+")
|
156
|
-
uri.query.should have_param("meta:assetId%3D12%252d34+OR+meta:assetId%3D5%252d67+OR+meta:assetId%3D77%252d7")
|
157
|
-
end
|
158
|
-
|
159
|
-
it "should pass a query" do
|
160
|
-
# uri = URI.parse( Search.search({:num_results => 50, :radius => "50", :query => "soccer"}).end_point )
|
161
|
-
# uri.query.should have_param("q=soccer")
|
162
|
-
pending
|
163
|
-
end
|
164
|
-
|
165
|
-
it "should probably encode the query value" do
|
166
|
-
pending
|
167
|
-
# uri = URI.parse( Search.search({:num_results => 50, :radius => "50", :query => "soccer balls"}).end_point )
|
168
|
-
# uri.query.should have_param("q=soccer+balls") What kind of encoding do we need
|
169
|
-
end
|
170
|
-
|
171
|
-
it "should decode this JSON" do
|
172
|
-
# if the location is not in the correct format there is a json error.
|
173
|
-
# s = Active::Services::Search.search({:location => "belvedere-tiburon-ca"})
|
174
|
-
# /search?api_key=&num=10&page=1&l=belvedere-tiburon-ca&f=activities&v=json&r=50&s=date_asc&k=&m=meta:startDate:daterange:today..+
|
175
|
-
# I think the JSON spec says that only arrays or objects can be at the top level.
|
176
|
-
# JSON::ParserError: A JSON text must at least contain two octets!
|
177
|
-
pending
|
178
|
-
end
|
179
|
-
|
180
|
-
end
|
30
|
+
it "should pass California as the meta state" do
|
31
|
+
uri = URI.parse( Search.new({:state=>"California"}).end_point )
|
32
|
+
uri.query.should have_param("meta:state=California")
|
33
|
+
uri.query.should_not have_param("l=")
|
34
|
+
end
|
181
35
|
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
it "should follow a 302" do
|
188
|
-
FakeWeb.register_uri(:get, "http://search.active.com/search?api_key=&num=10&page=1&l=San+Diego%2C+CA%2C+US&f=activities&v=json&r=50&s=date_asc&k=&m=meta:startDate:daterange:today..+",
|
189
|
-
:body => '{"endIndex":3,"numberOfResults":3,"pageSize":3,"searchTime":0.600205,"_results":[{"escapedUrl": "http://www.active.com/running/calabasas-ca/calabasas-classic-5k-10k-runs-2010","language": "en","title": "Calabasas Classic 2010 - 5k \u003cb\u003e10k\u003c/b\u003e Runs | Calabasas, California 91302 \u003cb\u003e...\u003c/b\u003e","url": "http://www.active.com/running/calabasas-ca/calabasas-classic-5k-10k-runs-2010","summary": "\u003cb\u003e...\u003c/b\u003e Calabasas Classic 2010 - 5k \u003cb\u003e10k\u003c/b\u003e Runs. Based on 0 reviews. \u003cb\u003e...\u003c/b\u003e Recent Reviews Calabasas\u003cbr\u003e Classic 2010 - 5k \u003cb\u003e10k\u003c/b\u003e Runs reviews. Get Directions. Start Address. End Address \u003cb\u003e...\u003c/b\u003e ","meta": {"startDate": "2010-11-14","eventDate": "2010-11-14T08:00:00-08:00","location": "Calabasas Park Centre","tag": ["event:10", "Green:10", "Running:10"],"state": "California","eventLongitude": "-118.6789","endDate": "2010-11-14","locationName": "Calabasas Park Centre","splitMediaType": ["Event", "1 mile", "10K", "5K"],"endTime": "8:00:00","mediaType": ["Event", "Event\\1 mile", "Event\\10K", "Event\\5K"],"google-site-verification": "","city": "Calabasas","startTime": "8:00:00","assetId": ["11B01475-8C65-4F9C-A4AC-2A3FA55FE8CD", "11b01475-8c65-4f9c-a4ac-2a3fa55fe8cd"],"eventId": "1810531","participationCriteria": "All","description": "","longitude": "-118.6789","onlineDonationAvailable": "false","substitutionUrl": "1810531","assetName": ["Calabasas Classic 2010 - 5k 10k Runs", "Calabasas Classic 2010 - 5k 10k Runs"],"zip": "91302","contactPhone": "818-715-0428","sortDate": "2000-11-14","eventState": "California","eventLatitude": "34.12794","keywords": "Event","eventAddress": "23975 Park Sorrento","contactEmail": "rot10kd@yahoo.com","onlineMembershipAvailable": "false","trackbackurl": "http://www.active.com/running/calabasas-ca/calabasas-classic-5k-10k-runs-2010","country": "United States","onlineRegistrationAvailable": "true","category": "Activities","image1": "http://www.active.com/images/events/hotrace.gif","assetTypeId": "EA4E860A-9DCD-4DAA-A7CA-4A77AD194F65","lastModifiedDate": "2010-03-04 07:30:26.307","eventZip": "91302","latitude": "34.12794","UpdateDateTime": "8/18/2010 10:16:26 AM","channel": ["Running", "Walking"]}},
|
190
|
-
{"escapedUrl": "http://www.active.com/10k-race/seattle-wa/fitness-for-vitality-5k10k-3race-series-919-2010","language": "en","title": "Fitness For Vitality 5k/\u003cb\u003e10k\u003c/b\u003e 3-Race Series (9/19, 10/17, 11/21) \u003cb\u003e...\u003c/b\u003e","url": "http://www.active.com/10k-race/seattle-wa/fitness-for-vitality-5k10k-3race-series-919-2010","summary": "\u003cb\u003e...\u003c/b\u003e Fitness For Vitality 5k/\u003cb\u003e10k\u003c/b\u003e 3-Race Series (9/19, 10/17, 11/21). Based on 0 reviews. \u003cb\u003e...\u003c/b\u003e\u003cbr\u003e Reviews of Fitness For Vitality 5k/\u003cb\u003e10k\u003c/b\u003e 3-Race Series (9/19, 10. \u003cb\u003e...\u003c/b\u003e ","meta": {"summary": "\u003cp style\u003dtext-align:left\u003e\u003cfont style\u003dfont-family:UniversEmbedded;font-size:12;color:#000000; LETTERSPACING\u003d0 KERNING\u003d0\u003eRace or walk on a flat, fast, and fun course! The entire event is along the Puget Sound. Do all 3 events in the series and watch your time and fitness improve! Oatmeal post-race. 10% proceeds sh","startDate": "2010-09-19","eventDate": "2010-09-19","location": "Alki Beach Park, Seattle","tag": ["event:10", "Running:10"],"state": "Washington","endDate": "2010-11-22","locationName": "1702 Alki Ave. SW","splitMediaType": ["5K", "difficulty:Beginner", "difficulty:Advanced", "Event", "difficulty:Intermediate", "10K"],"lastModifiedDateTime": "2010-08-19 23:35:50.117","endTime": "07:59:59","mediaType": ["5K", "difficulty:Beginner", "difficulty:Advanced", "Event", "difficulty:Intermediate", "10K"],"google-site-verification": "","city": "Seattle","startTime": "07:00:00","assetId": ["39e8177e-dd0e-42a2-8a2b-24055e5325f3", "39e8177e-dd0e-42a2-8a2b-24055e5325f3"],"eventId": "E-000NGFS9","participationCriteria": "Kids,Family","description": "","longitude": "-122.3912","substitutionUrl": "E-000NGFS9","assetName": ["Fitness For Vitality 5k/10k 3-Race Series (9/19, 10/17, 11/21)", "Fitness For Vitality 5k/10k 3-Race Series (9/19, 10/17, 11/21)"],"zip": "98136","contactPhone": "n/a","eventState": "WA","sortDate": "2000-09-19","keywords": "Event","eventAddress": "1702 Alki Ave. SW","contactEmail": "n/a","dma": "Seattle - Tacoma","trackbackurl": "http://www.active.com/10k-race/seattle-wa/fitness-for-vitality-5k10k-3race-series-919-2010","seourl": "http://www.active.com/10k-race/seattle-wa/fitness-for-vitality-5k10k-3race-series-919-2010","country": "United States","onlineRegistrationAvailable": "true","category": "Activities","image1": "http://photos-images.active.com/file/3/1/optimized/9015e50d-3a2e-4ce4-9ddc-80b05b973b01.jpg","allText": "\u003cp style\u003dtext-align:left\u003e\u003cfont style\u003dfont-family:UniversEmbedded;font-size:12;color:#000000; LETTERSPACING\u003d0 KERNING\u003d0\u003eRace or walk on a flat, fast, and fun course! The entire event is along the Puget Sound. Do all 3 events in the series and watch your time and fitness improve! Oatmeal post-race. 10% proceeds sh","address": "1702 Alki Ave. SW","assetTypeId": "DFAA997A-D591-44CA-9FB7-BF4A4C8984F1","lastModifiedDate": "2010-08-19","eventZip": "98136","latitude": "47.53782","UpdateDateTime": "8/18/2010 10:16:08 AM","channel": "Running"}},
|
191
|
-
{"escapedUrl": "http://www.active.com/running/calabasas-ca/calabasas-classic-5k-10k-runs-2010","language": "en","title": "Calabasas Classic 2010 - 5k \u003cb\u003e10k\u003c/b\u003e Runs | Calabasas, California 91302 \u003cb\u003e...\u003c/b\u003e","url": "http://www.active.com/running/calabasas-ca/calabasas-classic-5k-10k-runs-2010","summary": "\u003cb\u003e...\u003c/b\u003e Calabasas Classic 2010 - 5k \u003cb\u003e10k\u003c/b\u003e Runs. Based on 0 reviews. \u003cb\u003e...\u003c/b\u003e Recent Reviews Calabasas\u003cbr\u003e Classic 2010 - 5k \u003cb\u003e10k\u003c/b\u003e Runs reviews. Get Directions. Start Address. End Address \u003cb\u003e...\u003c/b\u003e ","meta": {"startDate": "2010-11-14","eventDate": "2010-11-14T08:00:00-08:00","location": "Calabasas Park Centre","tag": ["event:10", "Green:10", "Running:10"],"state": "California","eventLongitude": "-118.6789","endDate": "2010-11-14","locationName": "Calabasas Park Centre","splitMediaType": ["Event", "1 mile", "10K", "5K"],"endTime": "8:00:00","mediaType": ["Event", "Event\\1 mile", "Event\\10K", "Event\\5K"],"google-site-verification": "","city": "Calabasas","startTime": "8:00:00","assetId": ["11B01475-8C65-4F9C-A4AC-2A3FA55FE8CD", "11b01475-8c65-4f9c-a4ac-2a3fa55fe8cd"],"eventId": "1810531","participationCriteria": "All","description": "","longitude": "-118.6789","onlineDonationAvailable": "false","substitutionUrl": "1810531","assetName": ["Calabasas Classic 2010 - 5k 10k Runs", "Calabasas Classic 2010 - 5k 10k Runs"],"zip": "91302","contactPhone": "818-715-0428","sortDate": "2000-11-14","eventState": "California","eventLatitude": "34.12794","keywords": "Event","eventAddress": "23975 Park Sorrento","contactEmail": "rot10kd@yahoo.com","onlineMembershipAvailable": "false","trackbackurl": "http://www.active.com/running/calabasas-ca/calabasas-classic-5k-10k-runs-2010","country": "United States","onlineRegistrationAvailable": "true","category": "Activities","image1": "http://www.active.com/images/events/hotrace.gif","assetTypeId": "EA4E860A-9DCD-4DAA-A7CA-4A77AD194F65","lastModifiedDate": "2010-03-04 07:30:26.307","eventZip": "91302","latitude": "34.12794","UpdateDateTime": "8/18/2010 10:16:26 AM","channel": ["Running", "Walking"]}}]}',
|
192
|
-
:status => ["302", "Found"])
|
193
|
-
s = Search.search( {:location => "San Diego, CA, US"} )
|
194
|
-
s.should have(3).results
|
195
|
-
end
|
196
|
-
|
197
|
-
end
|
36
|
+
it "should search by the SF DMA" do
|
37
|
+
uri = URI.parse( Search.new({:dma=>"San Francisco - Oakland - San Jose"}).end_point )
|
38
|
+
uri.query.should have_param("meta:dma=San%2520Francisco%2520%252D%2520Oakland%2520%252D%2520San%2520Jose")
|
39
|
+
uri.query.should_not have_param("l=")
|
40
|
+
end
|
198
41
|
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
it "should have some channels" do
|
205
|
-
Categories.CHANNELS.should_not be_nil
|
206
|
-
end
|
207
|
-
|
208
|
-
it "should describe pagination info on search object" do
|
209
|
-
FakeWeb.register_uri(:get, "http://search.active.com/search?api_key=&num=10&page=1&l=San+Diego%2C+CA%2C+US&f=activities&v=json&r=50&s=date_asc&k=&m=meta:startDate:daterange:today..+",
|
210
|
-
:body => '{"endIndex":3,"numberOfResults":3,"pageSize":5,"searchTime":0.600205,"_results":[{"escapedUrl": "http://www.active.com/running/calabasas-ca/calabasas-classic-5k-10k-runs-2010","language": "en","title": "Calabasas Classic 2010 - 5k \u003cb\u003e10k\u003c/b\u003e Runs | Calabasas, California 91302 \u003cb\u003e...\u003c/b\u003e","url": "http://www.active.com/running/calabasas-ca/calabasas-classic-5k-10k-runs-2010","summary": "\u003cb\u003e...\u003c/b\u003e Calabasas Classic 2010 - 5k \u003cb\u003e10k\u003c/b\u003e Runs. Based on 0 reviews. \u003cb\u003e...\u003c/b\u003e Recent Reviews Calabasas\u003cbr\u003e Classic 2010 - 5k \u003cb\u003e10k\u003c/b\u003e Runs reviews. Get Directions. Start Address. End Address \u003cb\u003e...\u003c/b\u003e ","meta": {"startDate": "2010-11-14","eventDate": "2010-11-14T08:00:00-08:00","location": "Calabasas Park Centre","tag": ["event:10", "Green:10", "Running:10"],"state": "California","eventLongitude": "-118.6789","endDate": "2010-11-14","locationName": "Calabasas Park Centre","splitMediaType": ["Event", "1 mile", "10K", "5K"],"endTime": "8:00:00","mediaType": ["Event", "Event\\1 mile", "Event\\10K", "Event\\5K"],"google-site-verification": "","city": "Calabasas","startTime": "8:00:00","assetId": ["11B01475-8C65-4F9C-A4AC-2A3FA55FE8CD", "11b01475-8c65-4f9c-a4ac-2a3fa55fe8cd"],"eventId": "1810531","participationCriteria": "All","description": "","longitude": "-118.6789","onlineDonationAvailable": "false","substitutionUrl": "1810531","assetName": ["Calabasas Classic 2010 - 5k 10k Runs", "Calabasas Classic 2010 - 5k 10k Runs"],"zip": "91302","contactPhone": "818-715-0428","sortDate": "2000-11-14","eventState": "California","eventLatitude": "34.12794","keywords": "Event","eventAddress": "23975 Park Sorrento","contactEmail": "rot10kd@yahoo.com","onlineMembershipAvailable": "false","trackbackurl": "http://www.active.com/running/calabasas-ca/calabasas-classic-5k-10k-runs-2010","country": "United States","onlineRegistrationAvailable": "true","category": "Activities","image1": "http://www.active.com/images/events/hotrace.gif","assetTypeId": "EA4E860A-9DCD-4DAA-A7CA-4A77AD194F65","lastModifiedDate": "2010-03-04 07:30:26.307","eventZip": "91302","latitude": "34.12794","UpdateDateTime": "8/18/2010 10:16:26 AM","channel": ["Running", "Walking"]}},
|
211
|
-
{"escapedUrl": "http://www.active.com/10k-race/seattle-wa/fitness-for-vitality-5k10k-3race-series-919-2010","language": "en","title": "Fitness For Vitality 5k/\u003cb\u003e10k\u003c/b\u003e 3-Race Series (9/19, 10/17, 11/21) \u003cb\u003e...\u003c/b\u003e","url": "http://www.active.com/10k-race/seattle-wa/fitness-for-vitality-5k10k-3race-series-919-2010","summary": "\u003cb\u003e...\u003c/b\u003e Fitness For Vitality 5k/\u003cb\u003e10k\u003c/b\u003e 3-Race Series (9/19, 10/17, 11/21). Based on 0 reviews. \u003cb\u003e...\u003c/b\u003e\u003cbr\u003e Reviews of Fitness For Vitality 5k/\u003cb\u003e10k\u003c/b\u003e 3-Race Series (9/19, 10. \u003cb\u003e...\u003c/b\u003e ","meta": {"summary": "\u003cp style\u003dtext-align:left\u003e\u003cfont style\u003dfont-family:UniversEmbedded;font-size:12;color:#000000; LETTERSPACING\u003d0 KERNING\u003d0\u003eRace or walk on a flat, fast, and fun course! The entire event is along the Puget Sound. Do all 3 events in the series and watch your time and fitness improve! Oatmeal post-race. 10% proceeds sh","startDate": "2010-09-19","eventDate": "2010-09-19","location": "Alki Beach Park, Seattle","tag": ["event:10", "Running:10"],"state": "Washington","endDate": "2010-11-22","locationName": "1702 Alki Ave. SW","splitMediaType": ["5K", "difficulty:Beginner", "difficulty:Advanced", "Event", "difficulty:Intermediate", "10K"],"lastModifiedDateTime": "2010-08-19 23:35:50.117","endTime": "07:59:59","mediaType": ["5K", "difficulty:Beginner", "difficulty:Advanced", "Event", "difficulty:Intermediate", "10K"],"google-site-verification": "","city": "Seattle","startTime": "07:00:00","assetId": ["39e8177e-dd0e-42a2-8a2b-24055e5325f3", "39e8177e-dd0e-42a2-8a2b-24055e5325f3"],"eventId": "E-000NGFS9","participationCriteria": "Kids,Family","description": "","longitude": "-122.3912","substitutionUrl": "E-000NGFS9","assetName": ["Fitness For Vitality 5k/10k 3-Race Series (9/19, 10/17, 11/21)", "Fitness For Vitality 5k/10k 3-Race Series (9/19, 10/17, 11/21)"],"zip": "98136","contactPhone": "n/a","eventState": "WA","sortDate": "2000-09-19","keywords": "Event","eventAddress": "1702 Alki Ave. SW","contactEmail": "n/a","dma": "Seattle - Tacoma","trackbackurl": "http://www.active.com/10k-race/seattle-wa/fitness-for-vitality-5k10k-3race-series-919-2010","seourl": "http://www.active.com/10k-race/seattle-wa/fitness-for-vitality-5k10k-3race-series-919-2010","country": "United States","onlineRegistrationAvailable": "true","category": "Activities","image1": "http://photos-images.active.com/file/3/1/optimized/9015e50d-3a2e-4ce4-9ddc-80b05b973b01.jpg","allText": "\u003cp style\u003dtext-align:left\u003e\u003cfont style\u003dfont-family:UniversEmbedded;font-size:12;color:#000000; LETTERSPACING\u003d0 KERNING\u003d0\u003eRace or walk on a flat, fast, and fun course! The entire event is along the Puget Sound. Do all 3 events in the series and watch your time and fitness improve! Oatmeal post-race. 10% proceeds sh","address": "1702 Alki Ave. SW","assetTypeId": "DFAA997A-D591-44CA-9FB7-BF4A4C8984F1","lastModifiedDate": "2010-08-19","eventZip": "98136","latitude": "47.53782","UpdateDateTime": "8/18/2010 10:16:08 AM","channel": "Running"}},
|
212
|
-
{"escapedUrl": "http://www.active.com/running/calabasas-ca/calabasas-classic-5k-10k-runs-2010","language": "en","title": "Calabasas Classic 2010 - 5k \u003cb\u003e10k\u003c/b\u003e Runs | Calabasas, California 91302 \u003cb\u003e...\u003c/b\u003e","url": "http://www.active.com/running/calabasas-ca/calabasas-classic-5k-10k-runs-2010","summary": "\u003cb\u003e...\u003c/b\u003e Calabasas Classic 2010 - 5k \u003cb\u003e10k\u003c/b\u003e Runs. Based on 0 reviews. \u003cb\u003e...\u003c/b\u003e Recent Reviews Calabasas\u003cbr\u003e Classic 2010 - 5k \u003cb\u003e10k\u003c/b\u003e Runs reviews. Get Directions. Start Address. End Address \u003cb\u003e...\u003c/b\u003e ","meta": {"startDate": "2010-11-14","eventDate": "2010-11-14T08:00:00-08:00","location": "Calabasas Park Centre","tag": ["event:10", "Green:10", "Running:10"],"state": "California","eventLongitude": "-118.6789","endDate": "2010-11-14","locationName": "Calabasas Park Centre","splitMediaType": ["Event", "1 mile", "10K", "5K"],"endTime": "8:00:00","mediaType": ["Event", "Event\\1 mile", "Event\\10K", "Event\\5K"],"google-site-verification": "","city": "Calabasas","startTime": "8:00:00","assetId": ["11B01475-8C65-4F9C-A4AC-2A3FA55FE8CD", "11b01475-8c65-4f9c-a4ac-2a3fa55fe8cd"],"eventId": "1810531","participationCriteria": "All","description": "","longitude": "-118.6789","onlineDonationAvailable": "false","substitutionUrl": "1810531","assetName": ["Calabasas Classic 2010 - 5k 10k Runs", "Calabasas Classic 2010 - 5k 10k Runs"],"zip": "91302","contactPhone": "818-715-0428","sortDate": "2000-11-14","eventState": "California","eventLatitude": "34.12794","keywords": "Event","eventAddress": "23975 Park Sorrento","contactEmail": "rot10kd@yahoo.com","onlineMembershipAvailable": "false","trackbackurl": "http://www.active.com/running/calabasas-ca/calabasas-classic-5k-10k-runs-2010","country": "United States","onlineRegistrationAvailable": "true","category": "Activities","image1": "http://www.active.com/images/events/hotrace.gif","assetTypeId": "EA4E860A-9DCD-4DAA-A7CA-4A77AD194F65","lastModifiedDate": "2010-03-04 07:30:26.307","eventZip": "91302","latitude": "34.12794","UpdateDateTime": "8/18/2010 10:16:26 AM","channel": ["Running", "Walking"]}}]}',
|
213
|
-
:status => ["200", "Found"])
|
214
|
-
s = Search.search( {:location => "San Diego, CA, US"} )
|
215
|
-
s.should be_a_kind_of(Search)
|
216
|
-
s.should have(3).results
|
217
|
-
s.endIndex.should == 3
|
218
|
-
s.numberOfResults.should == 3
|
219
|
-
s.pageSize.should == 5
|
220
|
-
s.searchTime.should == 0.600205
|
221
|
-
|
222
|
-
end
|
223
|
-
|
224
|
-
it "should raise and error during a 404" do
|
225
|
-
FakeWeb.register_uri(:get, "http://search.active.com/search?api_key=&num=10&page=1&l=San+Diego%2C+CA%2C+US&f=activities&v=json&r=50&s=date_asc&k=&m=meta:startDate:daterange:today..+",
|
226
|
-
:body => "Nothing to be found 'round here", :status => ["404", "Not Found"])
|
227
|
-
lambda { Search.search( {:location => "San Diego, CA, US"} ) }.should raise_error(RuntimeError)
|
228
|
-
end
|
229
|
-
|
230
|
-
it "should search by location (san diego)" do
|
231
|
-
FakeWeb.register_uri(:get, "http://search.active.com/search?api_key=&num=10&page=1&l=San+Diego%2C+CA%2C+US&f=activities&v=json&r=50&s=date_asc&k=&m=meta:startDate:daterange:today..+",
|
232
|
-
:body => '{"endIndex":3,"numberOfResults":3,"pageSize":5,"searchTime":0.600205,"_results":[{"escapedUrl": "http://www.active.com/running/calabasas-ca/calabasas-classic-5k-10k-runs-2010","language": "en","title": "Calabasas Classic 2010 - 5k \u003cb\u003e10k\u003c/b\u003e Runs | Calabasas, California 91302 \u003cb\u003e...\u003c/b\u003e","url": "http://www.active.com/running/calabasas-ca/calabasas-classic-5k-10k-runs-2010","summary": "\u003cb\u003e...\u003c/b\u003e Calabasas Classic 2010 - 5k \u003cb\u003e10k\u003c/b\u003e Runs. Based on 0 reviews. \u003cb\u003e...\u003c/b\u003e Recent Reviews Calabasas\u003cbr\u003e Classic 2010 - 5k \u003cb\u003e10k\u003c/b\u003e Runs reviews. Get Directions. Start Address. End Address \u003cb\u003e...\u003c/b\u003e ","meta": {"startDate": "2010-11-14","eventDate": "2010-11-14T08:00:00-08:00","location": "Calabasas Park Centre","tag": ["event:10", "Green:10", "Running:10"],"state": "California","eventLongitude": "-118.6789","endDate": "2010-11-14","locationName": "Calabasas Park Centre","splitMediaType": ["Event", "1 mile", "10K", "5K"],"endTime": "8:00:00","mediaType": ["Event", "Event\\1 mile", "Event\\10K", "Event\\5K"],"google-site-verification": "","city": "Calabasas","startTime": "8:00:00","assetId": ["11B01475-8C65-4F9C-A4AC-2A3FA55FE8CD", "11b01475-8c65-4f9c-a4ac-2a3fa55fe8cd"],"eventId": "1810531","participationCriteria": "All","description": "","longitude": "-118.6789","onlineDonationAvailable": "false","substitutionUrl": "1810531","assetName": ["Calabasas Classic 2010 - 5k 10k Runs", "Calabasas Classic 2010 - 5k 10k Runs"],"zip": "91302","contactPhone": "818-715-0428","sortDate": "2000-11-14","eventState": "California","eventLatitude": "34.12794","keywords": "Event","eventAddress": "23975 Park Sorrento","contactEmail": "rot10kd@yahoo.com","onlineMembershipAvailable": "false","trackbackurl": "http://www.active.com/running/calabasas-ca/calabasas-classic-5k-10k-runs-2010","country": "United States","onlineRegistrationAvailable": "true","category": "Activities","image1": "http://www.active.com/images/events/hotrace.gif","assetTypeId": "EA4E860A-9DCD-4DAA-A7CA-4A77AD194F65","lastModifiedDate": "2010-03-04 07:30:26.307","eventZip": "91302","latitude": "34.12794","UpdateDateTime": "8/18/2010 10:16:26 AM","channel": ["Running", "Walking"]}},
|
233
|
-
{"escapedUrl": "http://www.active.com/10k-race/seattle-wa/fitness-for-vitality-5k10k-3race-series-919-2010","language": "en","title": "Fitness For Vitality 5k/\u003cb\u003e10k\u003c/b\u003e 3-Race Series (9/19, 10/17, 11/21) \u003cb\u003e...\u003c/b\u003e","url": "http://www.active.com/10k-race/seattle-wa/fitness-for-vitality-5k10k-3race-series-919-2010","summary": "\u003cb\u003e...\u003c/b\u003e Fitness For Vitality 5k/\u003cb\u003e10k\u003c/b\u003e 3-Race Series (9/19, 10/17, 11/21). Based on 0 reviews. \u003cb\u003e...\u003c/b\u003e\u003cbr\u003e Reviews of Fitness For Vitality 5k/\u003cb\u003e10k\u003c/b\u003e 3-Race Series (9/19, 10. \u003cb\u003e...\u003c/b\u003e ","meta": {"summary": "\u003cp style\u003dtext-align:left\u003e\u003cfont style\u003dfont-family:UniversEmbedded;font-size:12;color:#000000; LETTERSPACING\u003d0 KERNING\u003d0\u003eRace or walk on a flat, fast, and fun course! The entire event is along the Puget Sound. Do all 3 events in the series and watch your time and fitness improve! Oatmeal post-race. 10% proceeds sh","startDate": "2010-09-19","eventDate": "2010-09-19","location": "Alki Beach Park, Seattle","tag": ["event:10", "Running:10"],"state": "Washington","endDate": "2010-11-22","locationName": "1702 Alki Ave. SW","splitMediaType": ["5K", "difficulty:Beginner", "difficulty:Advanced", "Event", "difficulty:Intermediate", "10K"],"lastModifiedDateTime": "2010-08-19 23:35:50.117","endTime": "07:59:59","mediaType": ["5K", "difficulty:Beginner", "difficulty:Advanced", "Event", "difficulty:Intermediate", "10K"],"google-site-verification": "","city": "Seattle","startTime": "07:00:00","assetId": ["39e8177e-dd0e-42a2-8a2b-24055e5325f3", "39e8177e-dd0e-42a2-8a2b-24055e5325f3"],"eventId": "E-000NGFS9","participationCriteria": "Kids,Family","description": "","longitude": "-122.3912","substitutionUrl": "E-000NGFS9","assetName": ["Fitness For Vitality 5k/10k 3-Race Series (9/19, 10/17, 11/21)", "Fitness For Vitality 5k/10k 3-Race Series (9/19, 10/17, 11/21)"],"zip": "98136","contactPhone": "n/a","eventState": "WA","sortDate": "2000-09-19","keywords": "Event","eventAddress": "1702 Alki Ave. SW","contactEmail": "n/a","dma": "Seattle - Tacoma","trackbackurl": "http://www.active.com/10k-race/seattle-wa/fitness-for-vitality-5k10k-3race-series-919-2010","seourl": "http://www.active.com/10k-race/seattle-wa/fitness-for-vitality-5k10k-3race-series-919-2010","country": "United States","onlineRegistrationAvailable": "true","category": "Activities","image1": "http://photos-images.active.com/file/3/1/optimized/9015e50d-3a2e-4ce4-9ddc-80b05b973b01.jpg","allText": "\u003cp style\u003dtext-align:left\u003e\u003cfont style\u003dfont-family:UniversEmbedded;font-size:12;color:#000000; LETTERSPACING\u003d0 KERNING\u003d0\u003eRace or walk on a flat, fast, and fun course! The entire event is along the Puget Sound. Do all 3 events in the series and watch your time and fitness improve! Oatmeal post-race. 10% proceeds sh","address": "1702 Alki Ave. SW","assetTypeId": "DFAA997A-D591-44CA-9FB7-BF4A4C8984F1","lastModifiedDate": "2010-08-19","eventZip": "98136","latitude": "47.53782","UpdateDateTime": "8/18/2010 10:16:08 AM","channel": "Running"}},
|
234
|
-
{"escapedUrl": "http://www.active.com/running/calabasas-ca/calabasas-classic-5k-10k-runs-2010","language": "en","title": "Calabasas Classic 2010 - 5k \u003cb\u003e10k\u003c/b\u003e Runs | Calabasas, California 91302 \u003cb\u003e...\u003c/b\u003e","url": "http://www.active.com/running/calabasas-ca/calabasas-classic-5k-10k-runs-2010","summary": "\u003cb\u003e...\u003c/b\u003e Calabasas Classic 2010 - 5k \u003cb\u003e10k\u003c/b\u003e Runs. Based on 0 reviews. \u003cb\u003e...\u003c/b\u003e Recent Reviews Calabasas\u003cbr\u003e Classic 2010 - 5k \u003cb\u003e10k\u003c/b\u003e Runs reviews. Get Directions. Start Address. End Address \u003cb\u003e...\u003c/b\u003e ","meta": {"startDate": "2010-11-14","eventDate": "2010-11-14T08:00:00-08:00","location": "Calabasas Park Centre","tag": ["event:10", "Green:10", "Running:10"],"state": "California","eventLongitude": "-118.6789","endDate": "2010-11-14","locationName": "Calabasas Park Centre","splitMediaType": ["Event", "1 mile", "10K", "5K"],"endTime": "8:00:00","mediaType": ["Event", "Event\\1 mile", "Event\\10K", "Event\\5K"],"google-site-verification": "","city": "Calabasas","startTime": "8:00:00","assetId": ["11B01475-8C65-4F9C-A4AC-2A3FA55FE8CD", "11b01475-8c65-4f9c-a4ac-2a3fa55fe8cd"],"eventId": "1810531","participationCriteria": "All","description": "","longitude": "-118.6789","onlineDonationAvailable": "false","substitutionUrl": "1810531","assetName": ["Calabasas Classic 2010 - 5k 10k Runs", "Calabasas Classic 2010 - 5k 10k Runs"],"zip": "91302","contactPhone": "818-715-0428","sortDate": "2000-11-14","eventState": "California","eventLatitude": "34.12794","keywords": "Event","eventAddress": "23975 Park Sorrento","contactEmail": "rot10kd@yahoo.com","onlineMembershipAvailable": "false","trackbackurl": "http://www.active.com/running/calabasas-ca/calabasas-classic-5k-10k-runs-2010","country": "United States","onlineRegistrationAvailable": "true","category": "Activities","image1": "http://www.active.com/images/events/hotrace.gif","assetTypeId": "EA4E860A-9DCD-4DAA-A7CA-4A77AD194F65","lastModifiedDate": "2010-03-04 07:30:26.307","eventZip": "91302","latitude": "34.12794","UpdateDateTime": "8/18/2010 10:16:26 AM","channel": ["Running", "Walking"]}}]}',
|
235
|
-
:status => ["200", "Found"])
|
236
|
-
s = Search.search( {:location => "San Diego, CA, US"} )
|
237
|
-
s.should be_a_kind_of(Search)
|
238
|
-
s.should have(3).results
|
239
|
-
s.results.each do |a|
|
240
|
-
a.should be_an_instance_of(Activity)
|
241
|
-
a.title.should_not be_nil
|
242
|
-
a.start_date.should_not be_nil
|
243
|
-
a.end_date.should_not be_nil
|
244
|
-
a.categories.should_not be_nil
|
245
|
-
a.desc.should_not be_nil
|
246
|
-
a.start_time.should_not be_nil
|
247
|
-
a.end_time.should_not be_nil
|
248
|
-
a.address.should_not be_nil
|
249
|
-
a.address[:name].should_not be_nil
|
250
|
-
a.address[:city].should_not be_nil
|
251
|
-
a.address[:state].should_not be_nil
|
252
|
-
a.address[:zip].should_not be_nil
|
253
|
-
a.address[:country].should_not be_nil
|
254
|
-
a.address[:lat].should_not be_nil
|
255
|
-
a.address[:lng].should_not be_nil
|
42
|
+
it "should place lat and lng in the l param" do
|
43
|
+
location = {:latitude=>"37.785895", :longitude=>"-122.40638"}
|
44
|
+
uri = URI.parse( Search.new(location).end_point )
|
45
|
+
uri.query.should have_param("l=37.785895;-122.40638")
|
256
46
|
end
|
257
|
-
end
|
258
|
-
|
259
|
-
it "should handle this json error" do
|
260
|
-
# FakeWeb.register_uri(:get, "http://search.active.com/search?api_key=&num=10&page=1&l=San+Diego%2C+CA%2C+US&f=activities&v=json&r=50&s=date_asc&k=&m=meta:startDate:daterange:today..+",
|
261
|
-
# :body => '{"endIndex":10,"numberOfResults":2790,"pageSize":10,"searchTime":0.253913,"_results":[{"escapedUrl":"http://www.active.com/running/myrtle-beach-sc/myrtle-beach-mini-marathon-2010","language":"en","title":"Myrtle Beach Mini Marathon | Myrtle Beach, South Carolina \u003cb\u003e...\u003c/b\u003e","url":"http://www.active.com/running/myrtle-beach-sc/myrtle-beach-mini-marathon-2010","summary":"","meta":{"eventDate":"2010-10-24T07:00:00-07:00","location":"Myrtle Beach, South Carolina","tag":["event:10","Running:10"],"endDate":"2010-10-24","eventLongitude":"-78.92921","splitMediaType":["Event","5K","Half Marathon","Marathon","\u003ddifficulty:Advanced","\u003ddifficulty:Beginner","\u003ddifficulty:Intermediate"],"lastModifiedDateTime":"2010-09-13 18:15:04.753","locationName":"Myrtle Beach, South Carolina","endTime":"7:00:00","google-site-verification":"","city":"Myrtle Beach","startTime":"7:00:00","eventId":"1797753","description":"","longitude":"-78.92921","substitutionUrl":"1797753","eventLatitude":"33.75043","eventState":"South Carolina","sortDate":"2000-10-24","keywords":"Event","eventAddress":"Medieval Times","dma":"Florence - Myrtle Beach","seourl":"http://www.active.com/running/myrtle-beach-sc/myrtle-beach-mini-marathon-2010","country":"United States","category":"Activities","market":"Florence - Myrtle Beach","assetTypeId":"EA4E860A-9DCD-4DAA-A7CA-4A77AD194F65","contactName":"Robert Pozo","eventZip":"29579","latitude":"33.75043","UpdateDateTime":"9/1/2010 6:09:21 PM","startDate":"2010-10-24","state":"South Carolina","mediaType":["Event","Event\\5K","Event\\Half Marathon","Event\\Marathon","\u003ddifficulty:Advanced","\u003ddifficulty:Beginner","\u003ddifficulty:Intermediate"],"estParticipants":"6000","assetId":["008540A9-C2AB-4D7F-BE68-298758B324CD","008540a9-c2ab-4d7f-be68-298758b324cd"],"participationCriteria":"Adult,Men,Women","onlineDonationAvailable":"1","assetName":["Myrtle Beach Mini Marathon","Myrtle Beach Mini Marathon"],"eventURL":"http://runmyrtlebeach.com","zip":"29579","contactPhone":"1-800-733-7089","contactEmail":"info@runmyrtlebeach.com","onlineMembershipAvailable":"0","trackbackurl":"http://www.active.com/running/myrtle-beach-sc/myrtle-beach-mini-marathon-2010","onlineRegistrationAvailable":"1","image1":"http://www.active.com/images/events/hotrace.gif","lastModifiedDate":"2010-09-13","channel":"Running"}},{"escapedUrl":"http://www.active.com/running/denver-co/fans-on-the-field-denver-stadium-5k10k-2010","language":"en","title":"Fans on the Field 2010 - Denver Stadium 5K/10K | Denver \u003cb\u003e...\u003c/b\u003e","url":"http://www.active.com/running/denver-co/fans-on-the-field-denver-stadium-5k10k-2010","summary":"","meta":{"startDate":"2010-10-10","eventDate":"2010-10-10T00:00:00-07:00","location":"INVESCO Field at Mile High","tag":["event:10","Running:10"],"state":"Colorado","eventLongitude":"-105.0265","endDate":"2010-10-10","lastModifiedDateTime":"2010-08-05 16:15:18.14","splitMediaType":["Event","10K","5K"],"locationName":"INVESCO Field at Mile High","endTime":"0:00:00","mediaType":["Event","Event\\10K","Event\\5K"],"city":"Denver","google-site-verification":"","startTime":"0:00:00","assetId":["4850BB73-3701-493D-936C-C38CC0B3FD4C","4850bb73-3701-493d-936c-c38cc0b3fd4c"],"eventId":"1869635","participationCriteria":"All","description":"","longitude":"-105.0265","onlineDonationAvailable":"false","substitutionUrl":"1869635","assetName":["Fans on the Field 2010 - Denver Stadium 5K/10K","Fans on the Field 2010 - Denver Stadium 5K/10K"],"zip":"80204","contactPhone":"303-293-5315","eventLatitude":"39.73804","eventState":"Colorado","sortDate":"2000-10-10","keywords":"Event","eventAddress":"1801 Bryant Street","contactEmail":"ahinkle@nscd.org","onlineMembershipAvailable":"false","trackbackurl":"http://www.active.com/running/denver-co/fans-on-the-field-denver-stadium-5k10k-2010","country":"United States","onlineRegistrationAvailable":"true","category":"Activities","image1":"http://www.active.com/images/events/hotrace.gif","assetTypeId":"EA4E860A-9DCD-4DAA-A7CA-4A77AD194F65","lastModifiedDate":"2010-08-05","eventZip":"80204","UpdateDateTime":"9/1/2010 6:09:21 PM","latitude":"39.73804","channel":["Running","Walking"]}},{"escapedUrl":"http://www.active.com/triathlon/sedalia-mo/sedalia-duathlon-2010","language":"en","title":"Sedalia Duathlon | Sedalia, Missouri 65301 | Sunday \u003cb\u003e...\u003c/b\u003e","url":"http://www.active.com/triathlon/sedalia-mo/sedalia-duathlon-2010","summary":"","meta":{"startDate":"2010-09-26","eventDate":"2010-09-26T08:00:00-07:00","location":"Centennial Park/Parview School","state":"Missouri","endDate":"2010-09-26","eventLongitude":"-93.22826","lastModifiedDateTime":"2010-07-29 17:15:03.313","splitMediaType":["Event","Sprint"],"locationName":"Centennial Park/Parview School","endTime":"8:00:00","mediaType":["Event","Event\\Sprint"],"city":"Sedalia","google-site-verification":"","startTime":"8:00:00","assetId":["F11300A4-0A56-4321-AD4C-17502CEE8503","f11300a4-0a56-4321-ad4c-17502cee8503"],"eventId":"1879447","participationCriteria":"All","description":"","longitude":"-93.22826","onlineDonationAvailable":"false","substitutionUrl":"1879447","assetName":["Sedalia Duathlon","Sedalia Duathlon"],"zip":"65301","contactPhone":"660-827-6809","eventLatitude":"38.70446","eventState":"Missouri","sortDate":"2000-09-26","keywords":"Event","eventAddress":"1901 S. New York","contactEmail":"jamm@iland.net","onlineMembershipAvailable":"false","trackbackurl":"http://www.active.com/triathlon/sedalia-mo/sedalia-duathlon-2010","country":"United States","onlineRegistrationAvailable":"true","category":"Activities","image1":"http://www.active.com/images/events/hotrace.gif","assetTypeId":"EA4E860A-9DCD-4DAA-A7CA-4A77AD194F65","lastModifiedDate":"2010-07-29","eventZip":"65301","UpdateDateTime":"9/1/2010 6:09:21 PM","latitude":"38.70446","channel":["More Sports\\Duathlon","Triathlon"]}},{"escapedUrl":"http://www.active.com/triathlon/tempe-az/pbr-urban-dirt-duathlon-2010","language":"en","title":"PBR Urban Dirt Duathlon | Tempe, Arizona 85281 | Sunday \u003cb\u003e...\u003c/b\u003e","url":"http://www.active.com/triathlon/tempe-az/pbr-urban-dirt-duathlon-2010","summary":"","meta":{"eventDate":"2010-10-10T07:30:00-07:00","location":"North side of Tempe Town Lake near sand Volleyball courts, east of Mill Ave. Race thru Papago!","tag":["event:10","Triathlon:10"],"endDate":"2010-10-10","eventLongitude":"-111.9305","splitMediaType":["Event","Off-Road","Sprint","\u003ddifficulty:Advanced","\u003ddifficulty:Beginner","\u003ddifficulty:Intermediate"],"lastModifiedDateTime":"2010-09-08 15:15:42.507","locationName":"North side of Tempe Town Lake near sand Volleyball courts, east of Mill Ave. Race thru Papago!","endTime":"7:30:00","google-site-verification":"","city":"Tempe","startTime":"7:30:00","eventId":"1814945","description":"","longitude":"-111.9305","substitutionUrl":"1814945","eventLatitude":"33.42507","eventState":"Arizona","sortDate":"2000-10-10","keywords":"Event","eventAddress":"54 West Rio Salado Parkway","dma":"Phoenix","seourl":"http://www.active.com/triathlon/tempe-az/pbr-urban-dirt-duathlon-2010","country":"United States","category":"Activities","market":"Phoenix","assetTypeId":"EA4E860A-9DCD-4DAA-A7CA-4A77AD194F65","contactName":"Red Rock Co","eventZip":"85281","latitude":"33.42507","UpdateDateTime":"9/1/2010 6:09:21 PM","startDate":"2010-10-10","state":"Arizona","mediaType":["Event","Event\\Off-Road","Event\\Sprint","\u003ddifficulty:Advanced","\u003ddifficulty:Beginner","\u003ddifficulty:Intermediate"],"estParticipants":"400","assetId":["C47BA275-BFFF-41F1-8915-42F9159456B6","c47ba275-bfff-41f1-8915-42f9159456b6"],"participationCriteria":"Adult,Family,Kids,Men,Women","onlineDonationAvailable":"0","assetName":["PBR Urban Dirt Duathlon","PBR Urban Dirt Duathlon"],"eventURL":"http://www.redrockco.com","zip":"85281","contactPhone":"877-681-7223","contactEmail":"mike@redrockco.com","onlineMembershipAvailable":"0","trackbackurl":"http://www.active.com/triathlon/tempe-az/pbr-urban-dirt-duathlon-2010","onlineRegistrationAvailable":"1","image1":"http://www.active.com/images/events/hotrace.gif","lastModifiedDate":"2010-09-08","channel":["More Sports\\Duathlon","Triathlon"]}},{"escapedUrl":"http://www.active.com/triathlon/hayesville-nc/fall-chill-duathlon-2010","language":"en","title":"Fall Chill Duathlon 2010 | Hayesville, North Carolina 28904 \u003cb\u003e...\u003c/b\u003e","url":"http://www.active.com/triathlon/hayesville-nc/fall-chill-duathlon-2010","summary":"","meta":{"eventDate":"2010-10-24T10:00:00-07:00","location":"Clay County Recreation Park: 5 miles from Hiawassee Ga","tag":["event:10","Triathlon:10"],"endDate":"2010-10-24","eventLongitude":"-83.73081","splitMediaType":["Event","Sprint","\u003ddifficulty:Intermediate"],"lastModifiedDateTime":"2010-09-16 03:11:56.37","locationName":"Clay County Recreation Park: 5 miles from Hiawassee Ga","endTime":"10:00:00","google-site-verification":"","city":"Hayesville","startTime":"10:00:00","eventId":"1816551","description":"","longitude":"-83.73081","substitutionUrl":"1816551","eventLatitude":"35.04112","eventState":"North Carolina","sortDate":"2000-10-24","keywords":"Event","eventAddress":"Clay County Recreation Park Road, Hayesville, NC 28904","dma":"Atlanta","seourl":"http://www.active.com/triathlon/hayesville-nc/fall-chill-duathlon-2010","country":"United States","category":"Activities","market":"Atlanta","assetTypeId":"EA4E860A-9DCD-4DAA-A7CA-4A77AD194F65","contactName":"Scott Hanna","eventZip":"28904","latitude":"35.04112","UpdateDateTime":"9/1/2010 6:09:21 PM","startDate":"2010-10-24","state":"North Carolina","mediaType":["Event","Event\\Sprint","\u003ddifficulty:Intermediate"],"estParticipants":"150","assetId":["2B2DD142-23EA-42AE-A86A-C3BAAF8089F0","2b2dd142-23ea-42ae-a86a-c3baaf8089f0"],"participationCriteria":"Adult","onlineDonationAvailable":"0","assetName":["Fall Chill Duathlon 2010","Fall Chill Duathlon 2010"],"eventURL":"http://www.thebeastoftheeast.net","zip":"28904","contactPhone":"828-389-6982","contactEmail":"tri20001@msn.com","onlineMembershipAvailable":"0","trackbackurl":"http://www.active.com/triathlon/hayesville-nc/fall-chill-duathlon-2010","onlineRegistrationAvailable":"true","image1":"http://www.active.com/images/events/hotrace.gif","lastModifiedDate":"2010-09-16","channel":["More Sports\\Duathlon","Triathlon"]}},{"escapedUrl":"http://www.active.com/triathlon/congers-ny/fall-toga-duathlon-2010","language":"en","title":"2010 Fall Toga Duathlon | Congers, New York 10920 \u003cb\u003e...\u003c/b\u003e","url":"http://www.active.com/triathlon/congers-ny/fall-toga-duathlon-2010","summary":"","meta":{"startDate":"2010-10-17","eventDate":"2010-10-17T08:30:00-07:00","location":"Rockland Lake","tag":["event:10","Triathlon:10"],"state":"New York","endDate":"2010-10-17","eventLongitude":"-73.93904","splitMediaType":["Event","Sprint"],"locationName":"Rockland Lake","endTime":"8:30:00","mediaType":["Event","Event\\Sprint"],"city":"Congers","google-site-verification":"","startTime":"8:30:00","assetId":["096853C1-151A-4EED-9931-79275795AAA9","096853c1-151a-4eed-9931-79275795aaa9"],"eventId":"1821127","participationCriteria":"All","description":"","longitude":"-73.93904","onlineDonationAvailable":"false","substitutionUrl":"1821127","assetName":["2010 Fall Toga Duathlon","2010 Fall Toga Duathlon"],"zip":"10920","contactPhone":"8453538331","eventLatitude":"41.15644","eventState":"New York","sortDate":"2000-10-17","keywords":"Event","eventAddress":"Rt 9W","contactEmail":"Lonny@Togabikes.com","onlineMembershipAvailable":"false","trackbackurl":"http://www.active.com/triathlon/congers-ny/fall-toga-duathlon-2010","country":"United States","onlineRegistrationAvailable":"true","category":"Activities","image1":"http://www.active.com/images/events/hotrace.gif","assetTypeId":"EA4E860A-9DCD-4DAA-A7CA-4A77AD194F65","lastModifiedDate":"2010-03-02 15:22:22.54","eventZip":"10920","UpdateDateTime":"9/1/2010 6:09:21 PM","latitude":"41.15644","channel":["More Sports\\Duathlon","Triathlon"]}},{"escapedUrl":"http://www.active.com/triathlon/mendon-ny/rochester-autumn-classic-duathlon-2010","language":"en","title":"Rochester Autumn Classic Duathlon 2010 | Mendon, New \u003cb\u003e...\u003c/b\u003e","url":"http://www.active.com/triathlon/mendon-ny/rochester-autumn-classic-duathlon-2010","summary":"","meta":{"eventDate":"2010-10-03T08:30:00-07:00","location":"Stewart Lodge, Mendon Ponds Park","tag":["event:10","Triathlon:10"],"endDate":"2010-10-03","eventLongitude":"-77.49951","splitMediaType":["Event","Sprint"],"lastModifiedDateTime":"2010-08-30 13:15:51.837","locationName":"Stewart Lodge, Mendon Ponds Park","endTime":"8:30:00","google-site-verification":"","city":"Mendon","startTime":"8:30:00","eventId":"1821816","description":"","longitude":"-77.49951","substitutionUrl":"1821816","eventLatitude":"42.99441","eventState":"New York","sortDate":"2000-10-03","keywords":"Event","eventAddress":"Douglas Rd.","dma":"Rochester, NY","seourl":"http://www.active.com/triathlon/mendon-ny/rochester-autumn-classic-duathlon-2010","country":"United States","category":"Activities","market":"Rochester, NY","contactName":"Dave or Ellen Boutillier","assetTypeId":"EA4E860A-9DCD-4DAA-A7CA-4A77AD194F65","eventZip":"14506","latitude":"42.99441","UpdateDateTime":"9/1/2010 6:09:21 PM","startDate":"2010-10-03","state":"New York","mediaType":["Event","Event\\Sprint"],"estParticipants":"250","assetId":["39F96A49-A188-4592-A04C-755D12D5D8BB","39f96a49-a188-4592-a04c-755d12d5d8bb"],"participationCriteria":"All","onlineDonationAvailable":"0","assetName":["Rochester Autumn Classic Duathlon 2010","Rochester Autumn Classic Duathlon 2010"],"eventURL":"http://www.yellowjacketracing.com","zip":"14506","contactPhone":"585-697-3338","contactEmail":"elleneabrenner@aol.com","onlineMembershipAvailable":"0","trackbackurl":"http://www.active.com/triathlon/mendon-ny/rochester-autumn-classic-duathlon-2010","onlineRegistrationAvailable":"1","image1":"http://www.active.com/images/events/hotrace.gif","lastModifiedDate":"2010-08-30","channel":["More Sports\\Duathlon","Triathlon"]}},{"escapedUrl":"http://www.active.com/triathlon/miami-fl/ironman-703-miami-2010","language":"en","title":"IRONMAN 70.3 MIAMI | Miami, Florida 33132 | Saturday \u003cb\u003e...\u003c/b\u003e","url":"http://www.active.com/triathlon/miami-fl/ironman-703-miami-2010","summary":"","meta":{"startDate":"2010-10-30","eventDate":"2010-10-30T07:00:00-07:00","location":"Bayfront Park - Downtown Miami","tag":["event:10","Triathlon:10"],"state":"Florida","eventLongitude":"-80.18975","endDate":"2010-10-30","lastModifiedDateTime":"2010-05-10 11:16:04.46","splitMediaType":["Event","Ironman","Long Course","\u003ddifficulty:Advanced","\u003ddifficulty:Intermediate"],"locationName":"Bayfront Park - Downtown Miami","endTime":"7:00:00","mediaType":["Event","Event\\Ironman","Event\\Long Course","\u003ddifficulty:Advanced","\u003ddifficulty:Intermediate"],"city":"Miami","google-site-verification":"","startTime":"7:00:00","assetId":["72FAE9F7-5C68-4DF8-B01C-B63AC188A06A","72fae9f7-5c68-4df8-b01c-b63ac188a06a"],"eventId":"1800302","participationCriteria":"Adult,Family,Men,Women","description":"","longitude":"-80.18975","onlineDonationAvailable":"false","substitutionUrl":"1800302","assetName":["IRONMAN 70.3 MIAMI","IRONMAN 70.3 MIAMI"],"zip":"33132","contactPhone":"3053072285","eventLatitude":"25.78649","eventState":"Florida","sortDate":"2000-10-30","keywords":"Event","eventAddress":"301 N. Biscayne Blvd.","contactEmail":"jennifer@miamitrievents.com","onlineMembershipAvailable":"false","trackbackurl":"http://www.active.com/triathlon/miami-fl/ironman-703-miami-2010","country":"United States","onlineRegistrationAvailable":"true","category":"Activities","image1":"http://www.active.com/images/events/hotrace.gif","assetTypeId":"EA4E860A-9DCD-4DAA-A7CA-4A77AD194F65","lastModifiedDate":"2010-05-10","eventZip":"33132","UpdateDateTime":"9/1/2010 6:09:21 PM","latitude":"25.78649","channel":"Triathlon"}},{"escapedUrl":"http://www.active.com/triathlon/austin-tx/austin-oyster-urban-adventure-race-2010","language":"en","title":"Austin Oyster Urban Adventure Race | Austin, Texas 78704 \u003cb\u003e...\u003c/b\u003e","url":"http://www.active.com/triathlon/austin-tx/austin-oyster-urban-adventure-race-2010","summary":"","meta":{"eventDate":"2010-10-16T08:00:00-07:00","location":"Runtex","tag":["event:10","Triathlon:10"],"endDate":"2010-10-16","eventLongitude":"-97.76204","splitMediaType":"Event","lastModifiedDateTime":"2010-09-17 10:16:19.03","locationName":"Runtex","endTime":"8:00:00","google-site-verification":"","city":"Austin","startTime":"8:00:00","eventId":"1831863","description":"","longitude":"-97.76204","substitutionUrl":"1831863","eventLatitude":"30.24495","eventState":"Texas","sortDate":"2000-10-16","keywords":"Event","eventAddress":"422 W. Riverside","dma":"Austin","seourl":"http://www.active.com/triathlon/austin-tx/austin-oyster-urban-adventure-race-2010","country":"United States","category":"Activities","market":"Austin","assetTypeId":"EA4E860A-9DCD-4DAA-A7CA-4A77AD194F65","contactName":"Luann Morris","eventZip":"78704","latitude":"30.24495","UpdateDateTime":"9/1/2010 6:09:21 PM","startDate":"2010-10-16","state":"Texas","mediaType":"Event","estParticipants":"500","assetId":["5BCA2E67-05F8-49FA-911B-EA007A08A7ED","5bca2e67-05f8-49fa-911b-ea007a08a7ed"],"participationCriteria":"All","onlineDonationAvailable":"0","assetName":["Austin Oyster Urban Adventure Race","Austin Oyster Urban Adventure Race"],"eventURL":"http://OysterRacingSeries.com","zip":"78704","contactPhone":"3037776887","contactEmail":"luann@teamsage.com","onlineMembershipAvailable":"0","trackbackurl":"http://www.active.com/triathlon/austin-tx/austin-oyster-urban-adventure-race-2010","onlineRegistrationAvailable":"true","image1":"http://www.active.com/images/events/hotrace.gif","lastModifiedDate":"2010-09-17","channel":["More Sports\\Adventure Racing","Triathlon"]}},{"escapedUrl":"http://www.active.com/running/colorado-springs-co/fall-series-kids-2010-ov251","language":"en","title":"Fall Series 2010 (Kids) | Colorado Springs, Colorado 80903 \u003cb\u003e...\u003c/b\u003e","url":"http://www.active.com/running/colorado-springs-co/fall-series-kids-2010-ov251","summary":"","meta":{"startDate":"2010-10-03","eventDate":"2010-10-03T13:30:00-07:00","location":"Various sites","tag":["event:10","Running:10"],"state":"Colorado","eventLongitude":"-104.8163","endDate":"2010-10-03","lastModifiedDateTime":"2010-08-12 11:19:31.73","splitMediaType":["Event","1 mile","\u003ddifficulty:Advanced","\u003ddifficulty:Beginner","\u003ddifficulty:Intermediate"],"locationName":"Various sites","endTime":"13:30:00","mediaType":["Event","Event\\1 mile","\u003ddifficulty:Advanced","\u003ddifficulty:Beginner","\u003ddifficulty:Intermediate"],"city":"Colorado Springs","google-site-verification":"","estParticipants":"400","startTime":"13:30:00","assetId":["54A4A562-2A34-4345-8A20-7084EC435C57","54a4a562-2a34-4345-8a20-7084ec435c57"],"eventId":"1882757","participationCriteria":"Kids","description":"","longitude":"-104.8163","onlineDonationAvailable":"true","substitutionUrl":"1882757","assetName":["Fall Series 2010 (Kids)","Fall Series 2010 (Kids)"],"zip":"80903","eventURL":"http://pprrun.org","contactPhone":"719-590-7086","sortDate":"2000-10-03","eventState":"Colorado","eventLatitude":"38.84134","keywords":"Event","contactEmail":"fallseries@aol.com","onlineMembershipAvailable":"false","trackbackurl":"http://www.active.com/running/colorado-springs-co/fall-series-kids-2010-ov251","country":"United States","onlineRegistrationAvailable":"true","category":"Activities","image1":"http://www.active.com/images/events/hotrace.gif","market":"Colorado Springs - Pueblo","contactName":"Larry Miller","assetTypeId":"EA4E860A-9DCD-4DAA-A7CA-4A77AD194F65","lastModifiedDate":"2010-08-12","eventZip":"80903","UpdateDateTime":"9/1/2010 6:09:21 PM","latitude":"38.84134","channel":["Running","Walking"]}}]}',
|
262
|
-
# :status => ["200", "Found"])
|
263
|
-
# s = Search.search( {:zips=>["92198", "92199", "91901", "91902", "91903", "91905", "91906", "91908", "91909", "91910", "91911", "91912", "91913", "91914", "91915", "91916", "91917", "91921", "91931", "91932", "91933", "91934", "91935", "91941", "91942", "91943", "91944", "91945", "91946", "91947", "91948", "91950", "91951", "91962", "91963", "91976", "91977", "91978", "91979", "91980", "91987", "91990", "92003", "92004", "92007", "92008", "92009", "92013", "92014", "92018", "92019", "92020", "92021", "92022", "92023", "92024", "92025", "92026", "92027", "92028", "92029", "92030", "92033", "92036", "92037", "92038", "92039", "92040", "92046", "92049", "92051", "92052", "92054", "92055", "92056", "92057", "92058", "92059", "92060", "92061", "92064", "92065", "92066", "92067", "92068", "92069", "92070", "92071", "92072", "92074", "92075", "92078", "92079", "92082", "92083", "92084", "92085", "92086", "92088", "92090", "92091", "92092", "92093", "92096", "92101", "92102", "92103", "92104", "92105", "92106", "92107", "92108", "92109", "92110", "92111", "92112", "92113", "92114", "92115", "92116", "92117", "92118", "92119", "92120", "92121", "92122", "92123", "92124", "92126", "92127", "92128", "92129", "92130", "92131", "92132", "92133", "92134", "92135", "92136", "92137", "92138", "92139", "92140", "92142", "92143", "92145", "92147", "92149", "92150", "92152", "92153", "92154", "92155", "92158", "92159", "92160", "92161", "92162", "92163", "92164", "92165", "92166", "92167", "92168", "92169", "92170", "92171", "92172", "92173", "92174", "92175", "92176", "92177", "92178", "92179", "92182", "92184", "92186", "92187", "92190", "92191", "92192", "92193", "92194", "92195", "92196", "92197", "92081"]} )
|
264
|
-
s = Search.search( {:zips=>["92198", "92199", "91901"]} )
|
265
|
-
s.results.should have(10).items
|
266
|
-
s.results.should_not be_empty
|
267
|
-
end
|
268
|
-
|
269
|
-
it "should handle a JSON parse error" do
|
270
|
-
# /search?api_key=&num=10&page=1&l=0&f=activities&v=json&r=50&s=trending&k=&m=meta:startDate:daterange:today..+
|
271
|
-
# FakeWeb.register_uri(:get, "http://search.active.com/search?api_key=&num=10&page=1&l=San+Diego%2C+CA%2C+US&f=activities&v=json&r=50&s=date_asc&k=&m=meta:startDate:daterange:today..+",
|
272
|
-
# :body => '{"endIndex":10,"numberOfResults":2810,"pageSize":10,"searchTime":0.86581,"_results":[{"escapedUrl":"http://www.active.com/running/myrtle-beach-sc/myrtle-beach-mini-marathon-2010","language":"en","title":"Myrtle Beach Mini Marathon | Myrtle Beach, South Carolina \u003cb\u003e...\u003c/b\u003e","url":"http://www.active.com/running/myrtle-beach-sc/myrtle-beach-mini-marathon-2010","summary":"","meta":{"eventDate":"2010-10-24T07:00:00-07:00","location":"Myrtle Beach, South Carolina","tag":["event:10","Running:10"],"endDate":"2010-10-24","eventLongitude":"-78.92921","splitMediaType":["Event","5K","Half Marathon","Marathon","\u003ddifficulty:Advanced","\u003ddifficulty:Beginner","\u003ddifficulty:Intermediate"],"lastModifiedDateTime":"2010-09-13 18:15:04.753","locationName":"Myrtle Beach, South Carolina","endTime":"7:00:00","google-site-verification":"","city":"Myrtle Beach","startTime":"7:00:00","eventId":"1797753","description":"","longitude":"-78.92921","substitutionUrl":"1797753","eventLatitude":"33.75043","eventState":"South Carolina","sortDate":"2000-10-24","keywords":"Event","eventAddress":"Medieval Times","dma":"Florence - Myrtle Beach","seourl":"http://www.active.com/running/myrtle-beach-sc/myrtle-beach-mini-marathon-2010","country":"United States","category":"Activities","market":"Florence - Myrtle Beach","assetTypeId":"EA4E860A-9DCD-4DAA-A7CA-4A77AD194F65","contactName":"Robert Pozo","eventZip":"29579","latitude":"33.75043","UpdateDateTime":"9/1/2010 6:09:21 PM","startDate":"2010-10-24","state":"South Carolina","mediaType":["Event","Event\\5K","Event\\Half Marathon","Event\\Marathon","\u003ddifficulty:Advanced","\u003ddifficulty:Beginner","\u003ddifficulty:Intermediate"],"estParticipants":"6000","assetId":["008540A9-C2AB-4D7F-BE68-298758B324CD","008540a9-c2ab-4d7f-be68-298758b324cd"],"participationCriteria":"Adult,Men,Women","onlineDonationAvailable":"1","assetName":["Myrtle Beach Mini Marathon","Myrtle Beach Mini Marathon"],"eventURL":"http://runmyrtlebeach.com","zip":"29579","contactPhone":"1-800-733-7089","contactEmail":"info@runmyrtlebeach.com","onlineMembershipAvailable":"0","trackbackurl":"http://www.active.com/running/myrtle-beach-sc/myrtle-beach-mini-marathon-2010","onlineRegistrationAvailable":"1","image1":"http://www.active.com/images/events/hotrace.gif","lastModifiedDate":"2010-09-13","channel":"Running"}},{"escapedUrl":"http://www.active.com/running/denver-co/fans-on-the-field-denver-stadium-5k10k-2010","language":"en","title":"Fans on the Field 2010 - Denver Stadium 5K/10K | Denver \u003cb\u003e...\u003c/b\u003e","url":"http://www.active.com/running/denver-co/fans-on-the-field-denver-stadium-5k10k-2010","summary":"","meta":{"startDate":"2010-10-10","eventDate":"2010-10-10T00:00:00-07:00","location":"INVESCO Field at Mile High","tag":["event:10","Running:10"],"state":"Colorado","eventLongitude":"-105.0265","endDate":"2010-10-10","lastModifiedDateTime":"2010-08-05 16:15:18.14","splitMediaType":["Event","10K","5K"],"locationName":"INVESCO Field at Mile High","endTime":"0:00:00","mediaType":["Event","Event\\10K","Event\\5K"],"city":"Denver","google-site-verification":"","startTime":"0:00:00","assetId":["4850BB73-3701-493D-936C-C38CC0B3FD4C","4850bb73-3701-493d-936c-c38cc0b3fd4c"],"eventId":"1869635","participationCriteria":"All","description":"","longitude":"-105.0265","onlineDonationAvailable":"false","substitutionUrl":"1869635","assetName":["Fans on the Field 2010 - Denver Stadium 5K/10K","Fans on the Field 2010 - Denver Stadium 5K/10K"],"zip":"80204","contactPhone":"303-293-5315","eventLatitude":"39.73804","eventState":"Colorado","sortDate":"2000-10-10","keywords":"Event","eventAddress":"1801 Bryant Street","contactEmail":"ahinkle@nscd.org","onlineMembershipAvailable":"false","trackbackurl":"http://www.active.com/running/denver-co/fans-on-the-field-denver-stadium-5k10k-2010","country":"United States","onlineRegistrationAvailable":"true","category":"Activities","image1":"http://www.active.com/images/events/hotrace.gif","assetTypeId":"EA4E860A-9DCD-4DAA-A7CA-4A77AD194F65","lastModifiedDate":"2010-08-05","eventZip":"80204","UpdateDateTime":"9/1/2010 6:09:21 PM","latitude":"39.73804","channel":["Running","Walking"]}},{"escapedUrl":"http://www.active.com/running/west-palm-beach-fl/the-palm-beaches-marathon-festival-2010","language":"en","title":"The Palm Beaches Marathon Festival | West Palm Beach \u003cb\u003e...\u003c/b\u003e","url":"http://www.active.com/running/west-palm-beach-fl/the-palm-beaches-marathon-festival-2010","summary":"","meta":{"eventDate":"2010-12-05T06:00:00-08:00","location":"West Palm Beach, Florida","tag":["event:10","Running:10"],"endDate":"2010-12-05","eventLongitude":"-80.06707","splitMediaType":["Event","5K","Half Marathon","Marathon","Relay"],"lastModifiedDateTime":"2010-09-10 13:15:05.057","locationName":"West Palm Beach, Florida","endTime":"6:00:00","google-site-verification":"","city":"West Palm Beach","startTime":"6:00:00","eventId":"1815427","description":"","longitude":"-80.06707","substitutionUrl":"1815427","eventLatitude":"26.72339","eventState":"Florida","sortDate":"2000-12-05","keywords":"Event","eventAddress":"S. Flagler Drive and Evernia St.","dma":"West Palm Beach - Fort Pierce","seourl":"http://www.active.com/running/west-palm-beach-fl/the-palm-beaches-marathon-festival-2010","country":"United States","category":"Activities","market":"West Palm Beach - Fort Pierce","assetTypeId":"EA4E860A-9DCD-4DAA-A7CA-4A77AD194F65","contactName":"Iva Grady","eventZip":"33401","latitude":"26.72339","UpdateDateTime":"9/1/2010 6:09:21 PM","startDate":"2010-12-05","state":"Florida","mediaType":["Event","Event\\5K","Event\\Half Marathon","Event\\Marathon","Event\\Relay"],"estParticipants":"8000","assetId":["EA86AD3C-FBBA-403A-9DDB-1D211C210225","ea86ad3c-fbba-403a-9ddb-1d211c210225"],"participationCriteria":"All","onlineDonationAvailable":"0","assetName":["The Palm Beaches Marathon Festival","The Palm Beaches Marathon Festival"],"eventURL":"http://www.pbmarathon.com","zip":"33401","contactPhone":"561-833-3711 ex. 222","contactEmail":"info@marathonofthepalmbeaches.com","onlineMembershipAvailable":"0","trackbackurl":"http://www.active.com/running/west-palm-beach-fl/the-palm-beaches-marathon-festival-2010","onlineRegistrationAvailable":"1","image1":"http://www.active.com/images/events/hotrace.gif","lastModifiedDate":"2010-09-10","channel":"Running"}},{"escapedUrl":"http://www.active.com/running/encino-ca/2nd-annual-wespark-10k-run-and-5k-run-walk-2010","language":"en","title":"2nd Annual weSPARK 10K Run \u0026amp; 5K Run Walk | Encino \u003cb\u003e...\u003c/b\u003e","url":"http://www.active.com/running/encino-ca/2nd-annual-wespark-10k-run-and-5k-run-walk-2010","summary":"","meta":{"eventDate":"2010-11-14T08:00:00-08:00","location":"Balboa Park/Lake Balboa","tag":["event:10","Running:10"],"endDate":"2010-11-14","eventLongitude":"-118.4924","splitMediaType":["Event","10K","5K"],"lastModifiedDateTime":"2010-08-23 13:16:00.843","locationName":"Balboa Park/Lake Balboa","endTime":"8:00:00","google-site-verification":"","city":"Encino","startTime":"8:00:00","eventId":"1847738","description":"","longitude":"-118.4924","substitutionUrl":"1847738","eventLatitude":"34.19933","eventState":"California","sortDate":"2000-11-14","keywords":"Event","eventAddress":"6335 Woodley Avenue","dma":"Los Angeles","seourl":"http://www.active.com/running/encino-ca/2nd-annual-wespark-10k-run-and-5k-run-walk-2010","country":"United States","category":"Activities","market":"Los Angeles","contactName":"Lilliane Ballesteros","assetTypeId":"EA4E860A-9DCD-4DAA-A7CA-4A77AD194F65","eventZip":"91406","latitude":"34.19933","UpdateDateTime":"9/1/2010 6:09:21 PM","startDate":"2010-11-14","state":"California","mediaType":["Event","Event\\10K","Event\\5K"],"estParticipants":"1400","assetId":["D9A22F33-8A14-4175-8D5B-D11578212A98","d9a22f33-8a14-4175-8d5b-d11578212a98"],"participationCriteria":"All","onlineDonationAvailable":"0","assetName":["2nd Annual weSPARK 10K Run \u0026 5K Run Walk","2nd Annual weSPARK 10K Run \u0026 5K Run Walk"],"eventURL":"http://www.wespark.org","zip":"91406","contactPhone":"818-906-3022","contactEmail":"lilliane@wespark.org","onlineMembershipAvailable":"0","trackbackurl":"http://www.active.com/running/encino-ca/2nd-annual-wespark-10k-run-and-5k-run-walk-2010","onlineRegistrationAvailable":"1","image1":"http://www.active.com/images/events/hotrace.gif","lastModifiedDate":"2010-08-23","channel":["Running","Walking"]}},{"escapedUrl":"http://www.active.com/running/los-angeles-playa-del-rey-ca/heroes-of-hope-race-for-research-2010","language":"en","title":"Heroes of Hope Race for Research | Los Angeles, Playa Del \u003cb\u003e...\u003c/b\u003e","url":"http://www.active.com/running/los-angeles-playa-del-rey-ca/heroes-of-hope-race-for-research-2010","summary":"","meta":{"eventDate":"2010-11-07T08:00:00-08:00","location":"Dockweiler State Beach","tag":["event:10","Running:10"],"endDate":"2010-11-07","eventLongitude":"-118.4392","splitMediaType":["Event","10K","5K"],"lastModifiedDateTime":"2010-09-09 07:15:48.193","locationName":"Dockweiler State Beach","endTime":"8:00:00","google-site-verification":"","city":"Los Angeles, Playa Del Rey","startTime":"8:00:00","eventId":"1858905","description":"","longitude":"-118.4392","substitutionUrl":"1858905","eventLatitude":"33.9495","eventState":"California","sortDate":"2000-11-07","keywords":"Event","eventAddress":"8255 Vista Del Mar Blvd","dma":"Los Angeles","seourl":"http://www.active.com/running/los-angeles-playa-del-rey-ca/heroes-of-hope-race-for-research-2010","country":"United States","category":"Activities","market":"Los Angeles","assetTypeId":"EA4E860A-9DCD-4DAA-A7CA-4A77AD194F65","contactName":"Lisa Kaminsky-Millar","eventZip":"90293","latitude":"33.9495","UpdateDateTime":"9/1/2010 6:09:21 PM","startDate":"2010-11-07","state":"California","mediaType":["Event","Event\\10K","Event\\5K"],"estParticipants":"1000","assetId":["0D92AB40-ED0B-4657-B00B-480B38062F1C","0d92ab40-ed0b-4657-b00b-480b38062f1c"],"participationCriteria":"All","onlineDonationAvailable":"1","assetName":["Heroes of Hope Race for Research","Heroes of Hope Race for Research"],"eventURL":"http://www.heroesofhoperace.org","zip":"90293","contactPhone":"1-866-48-4CURE","contactEmail":"heroesofhoperace@gmail.com","onlineMembershipAvailable":"0","trackbackurl":"http://www.active.com/running/los-angeles-playa-del-rey-ca/heroes-of-hope-race-for-research-2010","onlineRegistrationAvailable":"1","image1":"http://www.active.com/images/events/hotrace.gif","lastModifiedDate":"2010-09-09","channel":"Running"}},{"escapedUrl":"http://www.active.com/running/calabasas-ca/calabasas-classic-5k-10k-runs-2010","language":"en","title":"Calabasas Classic 2010 - 5k 10k Runs | Calabasas, California \u003cb\u003e...\u003c/b\u003e","url":"http://www.active.com/running/calabasas-ca/calabasas-classic-5k-10k-runs-2010","summary":"","meta":{"eventDate":"2010-11-14T08:00:00-08:00","location":"Calabasas Park Centre","tag":["event:10","Green:10","Running:10"],"endDate":"2010-11-14","eventLongitude":"-118.6789","splitMediaType":["Event","1 mile","10K","5K"],"lastModifiedDateTime":"2010-09-14 21:02:55.007","locationName":"Calabasas Park Centre","endTime":"8:00:00","google-site-verification":"","city":"Calabasas","startTime":"8:00:00","eventId":"1810531","description":"","longitude":"-118.6789","substitutionUrl":"1810531","eventLatitude":"34.12794","eventState":"California","sortDate":"2000-11-14","keywords":"Event","eventAddress":"23975 Park Sorrento","dma":"Los Angeles","seourl":"http://www.active.com/running/calabasas-ca/calabasas-classic-5k-10k-runs-2010","country":"United States","category":"Activities","market":"Los Angeles","contactName":"Julie Talbert","assetTypeId":"EA4E860A-9DCD-4DAA-A7CA-4A77AD194F65","eventZip":"91302","latitude":"34.12794","UpdateDateTime":"9/1/2010 6:09:21 PM","startDate":"2010-11-14","state":"California","mediaType":["Event","Event\\1 mile","Event\\10K","Event\\5K"],"estParticipants":"2500","assetId":["11B01475-8C65-4F9C-A4AC-2A3FA55FE8CD","11b01475-8c65-4f9c-a4ac-2a3fa55fe8cd"],"participationCriteria":"All","onlineDonationAvailable":"0","assetName":["Calabasas Classic 2010 - 5k 10k Runs","Calabasas Classic 2010 - 5k 10k Runs"],"eventURL":"http://www.calabasasclassic.com","zip":"91302","contactPhone":"818-715-0428","contactEmail":"rot10kd@yahoo.com","onlineMembershipAvailable":"0","trackbackurl":"http://www.active.com/running/calabasas-ca/calabasas-classic-5k-10k-runs-2010","onlineRegistrationAvailable":"1","image1":"http://www.active.com/images/events/hotrace.gif","lastModifiedDate":"2010-09-14","channel":["Running","Walking"]}},{"escapedUrl":"http://www.active.com/triathlon/miami-fl/ironman-703-miami-2010","language":"en","title":"IRONMAN 70.3 MIAMI | Miami, Florida 33132 | Saturday \u003cb\u003e...\u003c/b\u003e","url":"http://www.active.com/triathlon/miami-fl/ironman-703-miami-2010","summary":"","meta":{"startDate":"2010-10-30","eventDate":"2010-10-30T07:00:00-07:00","location":"Bayfront Park - Downtown Miami","tag":["event:10","Triathlon:10"],"state":"Florida","eventLongitude":"-80.18975","endDate":"2010-10-30","lastModifiedDateTime":"2010-05-10 11:16:04.46","splitMediaType":["Event","Ironman","Long Course","\u003ddifficulty:Advanced","\u003ddifficulty:Intermediate"],"locationName":"Bayfront Park - Downtown Miami","endTime":"7:00:00","mediaType":["Event","Event\\Ironman","Event\\Long Course","\u003ddifficulty:Advanced","\u003ddifficulty:Intermediate"],"city":"Miami","google-site-verification":"","startTime":"7:00:00","assetId":["72FAE9F7-5C68-4DF8-B01C-B63AC188A06A","72fae9f7-5c68-4df8-b01c-b63ac188a06a"],"eventId":"1800302","participationCriteria":"Adult,Family,Men,Women","description":"","longitude":"-80.18975","onlineDonationAvailable":"false","substitutionUrl":"1800302","assetName":["IRONMAN 70.3 MIAMI","IRONMAN 70.3 MIAMI"],"zip":"33132","contactPhone":"3053072285","eventLatitude":"25.78649","eventState":"Florida","sortDate":"2000-10-30","keywords":"Event","eventAddress":"301 N. Biscayne Blvd.","contactEmail":"jennifer@miamitrievents.com","onlineMembershipAvailable":"false","trackbackurl":"http://www.active.com/triathlon/miami-fl/ironman-703-miami-2010","country":"United States","onlineRegistrationAvailable":"true","category":"Activities","image1":"http://www.active.com/images/events/hotrace.gif","assetTypeId":"EA4E860A-9DCD-4DAA-A7CA-4A77AD194F65","lastModifiedDate":"2010-05-10","eventZip":"33132","UpdateDateTime":"9/1/2010 6:09:21 PM","latitude":"25.78649","channel":"Triathlon"}},{"escapedUrl":"http://www.active.com/triathlon/san-juan-na/ironman-703-san-juan-2011-ig329","language":"en","title":"2011 Ironman 70.3 San Juan | San Juan, 00901 | Saturday \u003cb\u003e...\u003c/b\u003e","url":"http://www.active.com/triathlon/san-juan-na/ironman-703-san-juan-2011-ig329","summary":"","meta":{"startDate":"2011-03-19","eventDate":"2011-03-19T07:00:00-07:00","location":"Los Rosales Street, San Geronimo Grounds","tag":["event:10","Triathlon:10"],"state":"N/A","endDate":"2011-03-19","eventLongitude":"-66.10572","lastModifiedDateTime":"2010-06-15 14:15:08.557","splitMediaType":["Event","Ironman","\u003ddifficulty:Advanced"],"locationName":"Los Rosales Street, San Geronimo Grounds","endTime":"7:00:00","mediaType":["Event","Event\\Ironman","\u003ddifficulty:Advanced"],"city":"San Juan","google-site-verification":"","startTime":"7:00:00","assetId":["F6B819B9-9CC1-4E67-A87D-11518B05D4F3","f6b819b9-9cc1-4e67-a87d-11518b05d4f3"],"eventId":"1841595","participationCriteria":"Adult","description":"","longitude":"-66.10572","onlineDonationAvailable":"false","substitutionUrl":"1841595","assetName":["2011 Ironman 70.3 San Juan","2011 Ironman 70.3 San Juan"],"zip":"00901","contactPhone":"813-868-5940","eventLatitude":"18.46633","sortDate":"2001-03-19","keywords":"Event","contactEmail":"info@bnsportsllc.com","onlineMembershipAvailable":"false","trackbackurl":"http://www.active.com/triathlon/san-juan-na/ironman-703-san-juan-2011-ig329","country":"Puerto Rico","onlineRegistrationAvailable":"true","category":"Activities","image1":"http://www.active.com/images/events/hotrace.gif","assetTypeId":"EA4E860A-9DCD-4DAA-A7CA-4A77AD194F65","lastModifiedDate":"2010-06-15","eventZip":"00901","latitude":"18.46633","UpdateDateTime":"9/1/2010 6:09:21 PM","channel":"Triathlon"}},{"escapedUrl":"http://www.active.com/triathlon/st-george-ut/ford-ironman-st-george-2011","language":"en","title":"2011 Ford Ironman St. George | St. George, Utah 84737 \u003cb\u003e...\u003c/b\u003e","url":"http://www.active.com/triathlon/st-george-ut/ford-ironman-st-george-2011","summary":"","meta":{"startDate":"2011-05-07","eventDate":"2011-05-07T07:00:00-07:00","location":"Sand Hollow State Park,","tag":["event:10","Triathlon:10"],"state":"Utah","eventLongitude":"-113.1508","endDate":"2011-05-07","lastModifiedDateTime":"2010-07-22 11:15:08.46","splitMediaType":["Event","Ironman","Long Course"],"locationName":"Sand Hollow State Park,","endTime":"7:00:00","mediaType":["Event","Event\\Ironman","Event\\Long Course"],"city":"St. George","google-site-verification":"","startTime":"7:00:00","assetId":["A10B5BC1-BD95-4AFE-A1F6-35F6099E3636","a10b5bc1-bd95-4afe-a1f6-35f6099e3636"],"eventId":"1848350","participationCriteria":"All","description":"","longitude":"-113.1508","onlineDonationAvailable":"false","substitutionUrl":"1848350","assetName":["2011 Ford Ironman St. George","2011 Ford Ironman St. George"],"zip":"84737","contactPhone":"813-868-5940","eventLatitude":"37.15574","eventState":"Utah","sortDate":"2001-05-07","keywords":"Event","eventAddress":"4405 West 3600 South","contactEmail":"stgeorge@ironman.com","onlineMembershipAvailable":"false","trackbackurl":"http://www.active.com/triathlon/st-george-ut/ford-ironman-st-george-2011","country":"United States","onlineRegistrationAvailable":"true","category":"Activities","image1":"http://www.active.com/images/events/hotrace.gif","assetTypeId":"3BF82BBE-CF88-4E8C-A56F-78F5CE87E4C6","lastModifiedDate":"2010-07-22","eventZip":"84737","UpdateDateTime":"9/1/2010 6:09:21 PM","latitude":"37.15574","channel":"Triathlon"}},{"escapedUrl":"http://www.active.com/triathlon/galveston-tx/memorial-hermann-ironman-703-texas-and-lonestar-sprint-triathlon-2011","language":"en","title":"2011 Memorial Hermann Ironman 70.3 Texas \u0026amp; Lonestar \u003cb\u003e...\u003c/b\u003e","url":"http://www.active.com/triathlon/galveston-tx/memorial-hermann-ironman-703-texas-and-lonestar-sprint-triathlon-2011","summary":"","meta":{"startDate":"2011-04-09","eventDate":"2011-04-09T07:00:00-07:00","location":"Moody Gardens","state":"Texas","endDate":"2011-04-10","eventLongitude":"-94.90395","lastModifiedDateTime":"2010-05-12 09:16:41.91","splitMediaType":["Event","Ironman","Long Course","Sprint"],"locationName":"Moody Gardens","endTime":"7:00:00","mediaType":["Event","Event\\Ironman","Event\\Long Course","Event\\Sprint"],"city":"Galveston","google-site-verification":"","startTime":"7:00:00","assetId":["A40CC533-D502-4953-8157-DBB64D7FC4C2","a40cc533-d502-4953-8157-dbb64d7fc4c2"],"eventId":"1859810","participationCriteria":"All","description":"","longitude":"-94.90395","onlineDonationAvailable":"false","substitutionUrl":"1859810","assetName":["2011 Memorial Hermann Ironman 70.3 Texas \u0026 Lonestar Sprint Triathlon","2011 Memorial Hermann Ironman 70.3 Texas \u0026 Lonestar Sprint Triathlon"],"zip":"77554","contactPhone":"813-868-5940","eventLatitude":"29.24699","eventState":"Texas","sortDate":"2001-04-09","keywords":"Event","contactEmail":"texas70.3@ironman.com","onlineMembershipAvailable":"false","trackbackurl":"http://www.active.com/triathlon/galveston-tx/memorial-hermann-ironman-703-texas-and-lonestar-sprint-triathlon-2011","country":"United States","onlineRegistrationAvailable":"true","category":"Activities","image1":"http://www.active.com/images/events/hotrace.gif","assetTypeId":"3BF82BBE-CF88-4E8C-A56F-78F5CE87E4C6","lastModifiedDate":"2010-05-12","eventZip":"77554","latitude":"29.24699","UpdateDateTime":"9/1/2010 6:09:21 PM","channel":"Triathlon"}}]}',
|
273
|
-
# :status => ["200", "Found"])
|
274
|
-
# This query is throwing this error "source did not contain any JSON!" and we need to handle it
|
275
|
-
# s = Search.search( {:radius=>"50", :keywords=>"", :page=>1, :num_results=>10, :location=>"0"} )
|
276
|
-
pending
|
277
|
-
end
|
278
47
|
|
279
|
-
|
48
|
+
it "should escape the location" do
|
49
|
+
s = Search.new()
|
50
|
+
s.location.should be_nil
|
51
|
+
s = Search.new({:location => "San Diego"})
|
52
|
+
s.location.should eql("San+Diego")
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should have an array of keywords" do
|
56
|
+
s = Search.new()
|
57
|
+
s.should have(0).keywords
|
58
|
+
s = Search.new({:keywords => "Dog,Cat,Cow"})
|
59
|
+
s.should have(3).keywords
|
60
|
+
s = Search.new({:keywords => %w(Dog Cat Cow)})
|
61
|
+
s.should have(3).keywords
|
62
|
+
s = Search.new({:keywords => ["Dog","Cat","Cow"]})
|
63
|
+
s.should have(3).keywords
|
64
|
+
end
|
65
|
+
|
66
|
+
it "should have an array of channels" do
|
67
|
+
s = Search.new()
|
68
|
+
s.should have(0).channels
|
69
|
+
s = Search.new({:channels => "running,swimming,yoga"})
|
70
|
+
s.should have(3).channels
|
71
|
+
s = Search.new({:channels => %w(running swimming yoga)})
|
72
|
+
s.should have(3).channels
|
73
|
+
s = Search.new({:channels => ["running","swimming","yoga"]})
|
74
|
+
s.should have(3).channels
|
75
|
+
end
|
76
|
+
|
77
|
+
it "should have defaults set" do
|
78
|
+
s = Search.new()
|
79
|
+
uri = URI.parse( s.end_point )
|
80
|
+
uri.query.include?("f=#{Facet.ACTIVITIES}").should be_true
|
81
|
+
uri.query.include?("s=#{Sort.DATE_ASC}").should be_true
|
82
|
+
uri.query.include?("v=json").should be_true
|
83
|
+
uri.query.include?("page=1").should be_true
|
84
|
+
uri.query.should have_param("num=10")
|
85
|
+
uri.query.should have_param("daterange:today..+")
|
86
|
+
uri.query.should_not have_param("assetId=")
|
87
|
+
end
|
88
|
+
|
89
|
+
it "should construct a valid url with location" do
|
90
|
+
s = Search.new( {:location => "San Diego, CA, US"} )
|
91
|
+
uri = URI.parse(s.end_point)
|
92
|
+
uri.scheme.should eql("http")
|
93
|
+
uri.host.should eql("search.active.com")
|
94
|
+
uri.query.should have_param("l=#{CGI.escape("San Diego, CA, US")}")
|
95
|
+
end
|
96
|
+
|
97
|
+
it "should send an array of zips" do
|
98
|
+
uri = URI.parse( Search.new( {:zips => "92121, 92078, 92114"} ).end_point )
|
99
|
+
uri.query.should have_param("l=92121,92078,92114")
|
100
|
+
uri = URI.parse( Search.new( {:zips => [92121, 92078, 92114]} ).end_point )
|
101
|
+
uri.query.should have_param("l=92121,92078,92114")
|
102
|
+
end
|
103
|
+
|
104
|
+
# it "should construct a valid url from a zip code" do
|
105
|
+
# s = Search.new( {:zip => "92121"} )
|
106
|
+
# uri = URI.parse(s.end_point)
|
107
|
+
# uri.query.should have_param("l=#{CGI.escape("92121")}")
|
108
|
+
# end
|
109
|
+
|
110
|
+
it "should construct a valid url with CSV keywords" do
|
111
|
+
s = Search.new( {:keywords => "running, tri"} )
|
112
|
+
uri = URI.parse( s.end_point )
|
113
|
+
uri.query.should have_param("k=running+tri")
|
114
|
+
s = Search.new( {:keywords => ["running","tri","cycling"]} )
|
115
|
+
uri = URI.parse( s.end_point )
|
116
|
+
uri.query.should have_param("k=running+tri+cycling")
|
117
|
+
end
|
118
|
+
|
119
|
+
it "should construct a valid url with channels array" do
|
120
|
+
s = Search.new( {:channels => [:running, :tri,:cycling, :yoga]} )
|
121
|
+
uri = URI.parse( s.end_point )
|
122
|
+
uri.query.should have_param("m=meta:channel=Running+OR+meta:channel=Cycling+OR+meta:channel=Mind%2520%2526%2520Body%255CYoga")
|
123
|
+
end
|
124
|
+
|
125
|
+
it "should send valid channel info" do
|
126
|
+
uri = URI.parse( Search.new({:channels => [:running,:triathlon]}).end_point )
|
127
|
+
uri.query.include?("meta:channel=Running+OR+meta:channel=Triathlon").should be_true
|
128
|
+
end
|
129
|
+
|
130
|
+
it "should send the correct channel value for everything in Search.CHANNELS" do
|
131
|
+
Categories.CHANNELS.each do |key,value|
|
132
|
+
uri = URI.parse( Search.new({:channels => [key]}).end_point )
|
133
|
+
value = URI.escape(value, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))
|
134
|
+
value = URI.escape(value, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))
|
135
|
+
value.gsub!(/\-/,"%252D")
|
136
|
+
uri.query.should have_param("meta:channel=#{value}")
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
it "should send a valid start and end date" do
|
141
|
+
uri = URI.parse( Search.new().end_point )
|
142
|
+
uri.query.should have_param("daterange:today..+")
|
143
|
+
end
|
144
|
+
|
145
|
+
it "should send a valid start and end date" do
|
146
|
+
uri = URI.parse( Search.new({:start_date => Date.new(2010, 11, 1), :end_date => Date.new(2010, 11, 15)}).end_point )
|
147
|
+
uri.query.include?("meta:startDate:daterange:11%2F01%2F2010..11%2F15%2F2010").should be_true
|
148
|
+
end
|
149
|
+
|
150
|
+
it "should be valid with date range and channels" do
|
151
|
+
uri = URI.parse( Search.new({:channels => [:running, :triathlon],
|
152
|
+
:start_date => Date.new(2010, 11, 1),
|
153
|
+
:end_date => Date.new(2010, 11, 15)}).end_point )
|
154
|
+
uri.query.should have_param("meta:channel=Running+OR+meta:channel=Triathlon")
|
155
|
+
uri.query.should have_param("daterange:11%2F01%2F2010..11%2F15%2F2010")
|
156
|
+
end
|
157
|
+
|
158
|
+
it "should pass the search radius" do
|
159
|
+
uri = URI.parse( Search.new({:radius => '666'}).end_point )
|
160
|
+
uri.query.should have_param("r=666")
|
161
|
+
end
|
162
|
+
|
163
|
+
it "should pass the given asset_id" do
|
164
|
+
s = Search.new({:asset_id => "12-34" })
|
165
|
+
s.should have(1).asset_ids
|
166
|
+
end
|
167
|
+
|
168
|
+
it "should pass the given asset_id's" do
|
169
|
+
s = Search.new({:asset_ids => ["12-34","5-67","77-7"] })
|
170
|
+
s.should have(3).asset_ids
|
171
|
+
uri = URI.parse( s.end_point )
|
172
|
+
uri.query.should_not have_param("m=+AND+")
|
173
|
+
uri.query.should have_param("meta:assetId%3D12%252d34+OR+meta:assetId%3D5%252d67+OR+meta:assetId%3D77%252d7")
|
174
|
+
end
|
175
|
+
|
176
|
+
it "should pass a query" do
|
177
|
+
# uri = URI.parse( Search.search({:num_results => 50, :radius => "50", :query => "soccer"}).end_point )
|
178
|
+
# uri.query.should have_param("q=soccer")
|
179
|
+
pending
|
180
|
+
end
|
181
|
+
|
182
|
+
it "should probably encode the query value" do
|
183
|
+
pending
|
184
|
+
# uri = URI.parse( Search.search({:num_results => 50, :radius => "50", :query => "soccer balls"}).end_point )
|
185
|
+
# uri.query.should have_param("q=soccer+balls") What kind of encoding do we need
|
186
|
+
end
|
280
187
|
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
188
|
+
it "should decode this JSON" do
|
189
|
+
# if the location is not in the correct format there is a json error.
|
190
|
+
# s = Active::Services::Search.search({:location => "belvedere-tiburon-ca"})
|
191
|
+
# /search?api_key=&num=10&page=1&l=belvedere-tiburon-ca&f=activities&v=json&r=50&s=date_asc&k=&m=meta:startDate:daterange:today..+
|
192
|
+
# I think the JSON spec says that only arrays or objects can be at the top level.
|
193
|
+
# JSON::ParserError: A JSON text must at least contain two octets!
|
194
|
+
pending
|
195
|
+
end
|
196
|
+
|
197
|
+
it "should find 5 items when doing a DMA search" do
|
198
|
+
Search.search({:dma=>"San Francisco - Oakland - San Jose", :limit => 5}).should have(5).results
|
199
|
+
Search.search({:dma=>"San Francisco - Oakland - San Jose", :limit => 2}).should have(2).results
|
290
200
|
end
|
291
201
|
end
|
202
|
+
describe "Handle http server codes" do
|
203
|
+
after(:each) do
|
204
|
+
FakeWeb.clean_registry
|
205
|
+
end
|
292
206
|
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
}
|
207
|
+
it "should follow a 302" do
|
208
|
+
FakeWeb.register_uri(:get, "http://search.active.com/search?api_key=&num=10&page=1&l=San+Diego%2C+CA%2C+US&f=activities&v=json&s=date_asc&m=meta:startDate:daterange:today..+",
|
209
|
+
:body => '{"endIndex":3,"numberOfResults":3,"pageSize":3,"searchTime":0.600205,"_results":[{"escapedUrl": "http://www.active.com/running/calabasas-ca/calabasas-classic-5k-10k-runs-2010","language": "en","title": "Calabasas Classic 2010 - 5k \u003cb\u003e10k\u003c/b\u003e Runs | Calabasas, California 91302 \u003cb\u003e...\u003c/b\u003e","url": "http://www.active.com/running/calabasas-ca/calabasas-classic-5k-10k-runs-2010","summary": "\u003cb\u003e...\u003c/b\u003e Calabasas Classic 2010 - 5k \u003cb\u003e10k\u003c/b\u003e Runs. Based on 0 reviews. \u003cb\u003e...\u003c/b\u003e Recent Reviews Calabasas\u003cbr\u003e Classic 2010 - 5k \u003cb\u003e10k\u003c/b\u003e Runs reviews. Get Directions. Start Address. End Address \u003cb\u003e...\u003c/b\u003e ","meta": {"startDate": "2010-11-14","eventDate": "2010-11-14T08:00:00-08:00","location": "Calabasas Park Centre","tag": ["event:10", "Green:10", "Running:10"],"state": "California","eventLongitude": "-118.6789","endDate": "2010-11-14","locationName": "Calabasas Park Centre","splitMediaType": ["Event", "1 mile", "10K", "5K"],"endTime": "8:00:00","mediaType": ["Event", "Event\\1 mile", "Event\\10K", "Event\\5K"],"google-site-verification": "","city": "Calabasas","startTime": "8:00:00","assetId": ["11B01475-8C65-4F9C-A4AC-2A3FA55FE8CD", "11b01475-8c65-4f9c-a4ac-2a3fa55fe8cd"],"eventId": "1810531","participationCriteria": "All","description": "","longitude": "-118.6789","onlineDonationAvailable": "false","substitutionUrl": "1810531","assetName": ["Calabasas Classic 2010 - 5k 10k Runs", "Calabasas Classic 2010 - 5k 10k Runs"],"zip": "91302","contactPhone": "818-715-0428","sortDate": "2000-11-14","eventState": "California","eventLatitude": "34.12794","keywords": "Event","eventAddress": "23975 Park Sorrento","contactEmail": "rot10kd@yahoo.com","onlineMembershipAvailable": "false","trackbackurl": "http://www.active.com/running/calabasas-ca/calabasas-classic-5k-10k-runs-2010","country": "United States","onlineRegistrationAvailable": "true","category": "Activities","image1": "http://www.active.com/images/events/hotrace.gif","assetTypeId": "EA4E860A-9DCD-4DAA-A7CA-4A77AD194F65","lastModifiedDate": "2010-03-04 07:30:26.307","eventZip": "91302","latitude": "34.12794","UpdateDateTime": "8/18/2010 10:16:26 AM","channel": ["Running", "Walking"]}},
|
210
|
+
{"escapedUrl": "http://www.active.com/10k-race/seattle-wa/fitness-for-vitality-5k10k-3race-series-919-2010","language": "en","title": "Fitness For Vitality 5k/\u003cb\u003e10k\u003c/b\u003e 3-Race Series (9/19, 10/17, 11/21) \u003cb\u003e...\u003c/b\u003e","url": "http://www.active.com/10k-race/seattle-wa/fitness-for-vitality-5k10k-3race-series-919-2010","summary": "\u003cb\u003e...\u003c/b\u003e Fitness For Vitality 5k/\u003cb\u003e10k\u003c/b\u003e 3-Race Series (9/19, 10/17, 11/21). Based on 0 reviews. \u003cb\u003e...\u003c/b\u003e\u003cbr\u003e Reviews of Fitness For Vitality 5k/\u003cb\u003e10k\u003c/b\u003e 3-Race Series (9/19, 10. \u003cb\u003e...\u003c/b\u003e ","meta": {"summary": "\u003cp style\u003dtext-align:left\u003e\u003cfont style\u003dfont-family:UniversEmbedded;font-size:12;color:#000000; LETTERSPACING\u003d0 KERNING\u003d0\u003eRace or walk on a flat, fast, and fun course! The entire event is along the Puget Sound. Do all 3 events in the series and watch your time and fitness improve! Oatmeal post-race. 10% proceeds sh","startDate": "2010-09-19","eventDate": "2010-09-19","location": "Alki Beach Park, Seattle","tag": ["event:10", "Running:10"],"state": "Washington","endDate": "2010-11-22","locationName": "1702 Alki Ave. SW","splitMediaType": ["5K", "difficulty:Beginner", "difficulty:Advanced", "Event", "difficulty:Intermediate", "10K"],"lastModifiedDateTime": "2010-08-19 23:35:50.117","endTime": "07:59:59","mediaType": ["5K", "difficulty:Beginner", "difficulty:Advanced", "Event", "difficulty:Intermediate", "10K"],"google-site-verification": "","city": "Seattle","startTime": "07:00:00","assetId": ["39e8177e-dd0e-42a2-8a2b-24055e5325f3", "39e8177e-dd0e-42a2-8a2b-24055e5325f3"],"eventId": "E-000NGFS9","participationCriteria": "Kids,Family","description": "","longitude": "-122.3912","substitutionUrl": "E-000NGFS9","assetName": ["Fitness For Vitality 5k/10k 3-Race Series (9/19, 10/17, 11/21)", "Fitness For Vitality 5k/10k 3-Race Series (9/19, 10/17, 11/21)"],"zip": "98136","contactPhone": "n/a","eventState": "WA","sortDate": "2000-09-19","keywords": "Event","eventAddress": "1702 Alki Ave. SW","contactEmail": "n/a","dma": "Seattle - Tacoma","trackbackurl": "http://www.active.com/10k-race/seattle-wa/fitness-for-vitality-5k10k-3race-series-919-2010","seourl": "http://www.active.com/10k-race/seattle-wa/fitness-for-vitality-5k10k-3race-series-919-2010","country": "United States","onlineRegistrationAvailable": "true","category": "Activities","image1": "http://photos-images.active.com/file/3/1/optimized/9015e50d-3a2e-4ce4-9ddc-80b05b973b01.jpg","allText": "\u003cp style\u003dtext-align:left\u003e\u003cfont style\u003dfont-family:UniversEmbedded;font-size:12;color:#000000; LETTERSPACING\u003d0 KERNING\u003d0\u003eRace or walk on a flat, fast, and fun course! The entire event is along the Puget Sound. Do all 3 events in the series and watch your time and fitness improve! Oatmeal post-race. 10% proceeds sh","address": "1702 Alki Ave. SW","assetTypeId": "DFAA997A-D591-44CA-9FB7-BF4A4C8984F1","lastModifiedDate": "2010-08-19","eventZip": "98136","latitude": "47.53782","UpdateDateTime": "8/18/2010 10:16:08 AM","channel": "Running"}},
|
211
|
+
{"escapedUrl": "http://www.active.com/running/calabasas-ca/calabasas-classic-5k-10k-runs-2010","language": "en","title": "Calabasas Classic 2010 - 5k \u003cb\u003e10k\u003c/b\u003e Runs | Calabasas, California 91302 \u003cb\u003e...\u003c/b\u003e","url": "http://www.active.com/running/calabasas-ca/calabasas-classic-5k-10k-runs-2010","summary": "\u003cb\u003e...\u003c/b\u003e Calabasas Classic 2010 - 5k \u003cb\u003e10k\u003c/b\u003e Runs. Based on 0 reviews. \u003cb\u003e...\u003c/b\u003e Recent Reviews Calabasas\u003cbr\u003e Classic 2010 - 5k \u003cb\u003e10k\u003c/b\u003e Runs reviews. Get Directions. Start Address. End Address \u003cb\u003e...\u003c/b\u003e ","meta": {"startDate": "2010-11-14","eventDate": "2010-11-14T08:00:00-08:00","location": "Calabasas Park Centre","tag": ["event:10", "Green:10", "Running:10"],"state": "California","eventLongitude": "-118.6789","endDate": "2010-11-14","locationName": "Calabasas Park Centre","splitMediaType": ["Event", "1 mile", "10K", "5K"],"endTime": "8:00:00","mediaType": ["Event", "Event\\1 mile", "Event\\10K", "Event\\5K"],"google-site-verification": "","city": "Calabasas","startTime": "8:00:00","assetId": ["11B01475-8C65-4F9C-A4AC-2A3FA55FE8CD", "11b01475-8c65-4f9c-a4ac-2a3fa55fe8cd"],"eventId": "1810531","participationCriteria": "All","description": "","longitude": "-118.6789","onlineDonationAvailable": "false","substitutionUrl": "1810531","assetName": ["Calabasas Classic 2010 - 5k 10k Runs", "Calabasas Classic 2010 - 5k 10k Runs"],"zip": "91302","contactPhone": "818-715-0428","sortDate": "2000-11-14","eventState": "California","eventLatitude": "34.12794","keywords": "Event","eventAddress": "23975 Park Sorrento","contactEmail": "rot10kd@yahoo.com","onlineMembershipAvailable": "false","trackbackurl": "http://www.active.com/running/calabasas-ca/calabasas-classic-5k-10k-runs-2010","country": "United States","onlineRegistrationAvailable": "true","category": "Activities","image1": "http://www.active.com/images/events/hotrace.gif","assetTypeId": "EA4E860A-9DCD-4DAA-A7CA-4A77AD194F65","lastModifiedDate": "2010-03-04 07:30:26.307","eventZip": "91302","latitude": "34.12794","UpdateDateTime": "8/18/2010 10:16:26 AM","channel": ["Running", "Walking"]}}]}',
|
212
|
+
:status => ["302", "Found"])
|
213
|
+
s = Search.search( {:location => "San Diego, CA, US"} )
|
214
|
+
s.should have(3).results
|
300
215
|
end
|
216
|
+
|
301
217
|
end
|
218
|
+
describe "Calls with FakeWeb" do
|
219
|
+
after(:each) do
|
220
|
+
FakeWeb.clean_registry
|
221
|
+
end
|
302
222
|
|
303
|
-
|
304
|
-
|
305
|
-
s.should have(50).results
|
306
|
-
s.results.each do |a|
|
307
|
-
a.start_date.should satisfy { |d|
|
308
|
-
d >= Date.new(2010,1,1)
|
309
|
-
}
|
223
|
+
it "should have some channels" do
|
224
|
+
Categories.CHANNELS.should_not be_nil
|
310
225
|
end
|
311
|
-
|
312
|
-
|
226
|
+
|
227
|
+
it "should describe pagination info on search object" do
|
228
|
+
FakeWeb.register_uri(:get, "http://search.active.com/search?api_key=&num=10&page=1&l=San+Diego%2C+CA%2C+US&f=activities&v=json&s=date_asc&m=meta:startDate:daterange:today..+",
|
229
|
+
:body => '{"endIndex":3,"numberOfResults":3,"pageSize":5,"searchTime":0.600205,"_results":[{"escapedUrl": "http://www.active.com/running/calabasas-ca/calabasas-classic-5k-10k-runs-2010","language": "en","title": "Calabasas Classic 2010 - 5k \u003cb\u003e10k\u003c/b\u003e Runs | Calabasas, California 91302 \u003cb\u003e...\u003c/b\u003e","url": "http://www.active.com/running/calabasas-ca/calabasas-classic-5k-10k-runs-2010","summary": "\u003cb\u003e...\u003c/b\u003e Calabasas Classic 2010 - 5k \u003cb\u003e10k\u003c/b\u003e Runs. Based on 0 reviews. \u003cb\u003e...\u003c/b\u003e Recent Reviews Calabasas\u003cbr\u003e Classic 2010 - 5k \u003cb\u003e10k\u003c/b\u003e Runs reviews. Get Directions. Start Address. End Address \u003cb\u003e...\u003c/b\u003e ","meta": {"startDate": "2010-11-14","eventDate": "2010-11-14T08:00:00-08:00","location": "Calabasas Park Centre","tag": ["event:10", "Green:10", "Running:10"],"state": "California","eventLongitude": "-118.6789","endDate": "2010-11-14","locationName": "Calabasas Park Centre","splitMediaType": ["Event", "1 mile", "10K", "5K"],"endTime": "8:00:00","mediaType": ["Event", "Event\\1 mile", "Event\\10K", "Event\\5K"],"google-site-verification": "","city": "Calabasas","startTime": "8:00:00","assetId": ["11B01475-8C65-4F9C-A4AC-2A3FA55FE8CD", "11b01475-8c65-4f9c-a4ac-2a3fa55fe8cd"],"eventId": "1810531","participationCriteria": "All","description": "","longitude": "-118.6789","onlineDonationAvailable": "false","substitutionUrl": "1810531","assetName": ["Calabasas Classic 2010 - 5k 10k Runs", "Calabasas Classic 2010 - 5k 10k Runs"],"zip": "91302","contactPhone": "818-715-0428","sortDate": "2000-11-14","eventState": "California","eventLatitude": "34.12794","keywords": "Event","eventAddress": "23975 Park Sorrento","contactEmail": "rot10kd@yahoo.com","onlineMembershipAvailable": "false","trackbackurl": "http://www.active.com/running/calabasas-ca/calabasas-classic-5k-10k-runs-2010","country": "United States","onlineRegistrationAvailable": "true","category": "Activities","image1": "http://www.active.com/images/events/hotrace.gif","assetTypeId": "EA4E860A-9DCD-4DAA-A7CA-4A77AD194F65","lastModifiedDate": "2010-03-04 07:30:26.307","eventZip": "91302","latitude": "34.12794","UpdateDateTime": "8/18/2010 10:16:26 AM","channel": ["Running", "Walking"]}},
|
230
|
+
{"escapedUrl": "http://www.active.com/10k-race/seattle-wa/fitness-for-vitality-5k10k-3race-series-919-2010","language": "en","title": "Fitness For Vitality 5k/\u003cb\u003e10k\u003c/b\u003e 3-Race Series (9/19, 10/17, 11/21) \u003cb\u003e...\u003c/b\u003e","url": "http://www.active.com/10k-race/seattle-wa/fitness-for-vitality-5k10k-3race-series-919-2010","summary": "\u003cb\u003e...\u003c/b\u003e Fitness For Vitality 5k/\u003cb\u003e10k\u003c/b\u003e 3-Race Series (9/19, 10/17, 11/21). Based on 0 reviews. \u003cb\u003e...\u003c/b\u003e\u003cbr\u003e Reviews of Fitness For Vitality 5k/\u003cb\u003e10k\u003c/b\u003e 3-Race Series (9/19, 10. \u003cb\u003e...\u003c/b\u003e ","meta": {"summary": "\u003cp style\u003dtext-align:left\u003e\u003cfont style\u003dfont-family:UniversEmbedded;font-size:12;color:#000000; LETTERSPACING\u003d0 KERNING\u003d0\u003eRace or walk on a flat, fast, and fun course! The entire event is along the Puget Sound. Do all 3 events in the series and watch your time and fitness improve! Oatmeal post-race. 10% proceeds sh","startDate": "2010-09-19","eventDate": "2010-09-19","location": "Alki Beach Park, Seattle","tag": ["event:10", "Running:10"],"state": "Washington","endDate": "2010-11-22","locationName": "1702 Alki Ave. SW","splitMediaType": ["5K", "difficulty:Beginner", "difficulty:Advanced", "Event", "difficulty:Intermediate", "10K"],"lastModifiedDateTime": "2010-08-19 23:35:50.117","endTime": "07:59:59","mediaType": ["5K", "difficulty:Beginner", "difficulty:Advanced", "Event", "difficulty:Intermediate", "10K"],"google-site-verification": "","city": "Seattle","startTime": "07:00:00","assetId": ["39e8177e-dd0e-42a2-8a2b-24055e5325f3", "39e8177e-dd0e-42a2-8a2b-24055e5325f3"],"eventId": "E-000NGFS9","participationCriteria": "Kids,Family","description": "","longitude": "-122.3912","substitutionUrl": "E-000NGFS9","assetName": ["Fitness For Vitality 5k/10k 3-Race Series (9/19, 10/17, 11/21)", "Fitness For Vitality 5k/10k 3-Race Series (9/19, 10/17, 11/21)"],"zip": "98136","contactPhone": "n/a","eventState": "WA","sortDate": "2000-09-19","keywords": "Event","eventAddress": "1702 Alki Ave. SW","contactEmail": "n/a","dma": "Seattle - Tacoma","trackbackurl": "http://www.active.com/10k-race/seattle-wa/fitness-for-vitality-5k10k-3race-series-919-2010","seourl": "http://www.active.com/10k-race/seattle-wa/fitness-for-vitality-5k10k-3race-series-919-2010","country": "United States","onlineRegistrationAvailable": "true","category": "Activities","image1": "http://photos-images.active.com/file/3/1/optimized/9015e50d-3a2e-4ce4-9ddc-80b05b973b01.jpg","allText": "\u003cp style\u003dtext-align:left\u003e\u003cfont style\u003dfont-family:UniversEmbedded;font-size:12;color:#000000; LETTERSPACING\u003d0 KERNING\u003d0\u003eRace or walk on a flat, fast, and fun course! The entire event is along the Puget Sound. Do all 3 events in the series and watch your time and fitness improve! Oatmeal post-race. 10% proceeds sh","address": "1702 Alki Ave. SW","assetTypeId": "DFAA997A-D591-44CA-9FB7-BF4A4C8984F1","lastModifiedDate": "2010-08-19","eventZip": "98136","latitude": "47.53782","UpdateDateTime": "8/18/2010 10:16:08 AM","channel": "Running"}},
|
231
|
+
{"escapedUrl": "http://www.active.com/running/calabasas-ca/calabasas-classic-5k-10k-runs-2010","language": "en","title": "Calabasas Classic 2010 - 5k \u003cb\u003e10k\u003c/b\u003e Runs | Calabasas, California 91302 \u003cb\u003e...\u003c/b\u003e","url": "http://www.active.com/running/calabasas-ca/calabasas-classic-5k-10k-runs-2010","summary": "\u003cb\u003e...\u003c/b\u003e Calabasas Classic 2010 - 5k \u003cb\u003e10k\u003c/b\u003e Runs. Based on 0 reviews. \u003cb\u003e...\u003c/b\u003e Recent Reviews Calabasas\u003cbr\u003e Classic 2010 - 5k \u003cb\u003e10k\u003c/b\u003e Runs reviews. Get Directions. Start Address. End Address \u003cb\u003e...\u003c/b\u003e ","meta": {"startDate": "2010-11-14","eventDate": "2010-11-14T08:00:00-08:00","location": "Calabasas Park Centre","tag": ["event:10", "Green:10", "Running:10"],"state": "California","eventLongitude": "-118.6789","endDate": "2010-11-14","locationName": "Calabasas Park Centre","splitMediaType": ["Event", "1 mile", "10K", "5K"],"endTime": "8:00:00","mediaType": ["Event", "Event\\1 mile", "Event\\10K", "Event\\5K"],"google-site-verification": "","city": "Calabasas","startTime": "8:00:00","assetId": ["11B01475-8C65-4F9C-A4AC-2A3FA55FE8CD", "11b01475-8c65-4f9c-a4ac-2a3fa55fe8cd"],"eventId": "1810531","participationCriteria": "All","description": "","longitude": "-118.6789","onlineDonationAvailable": "false","substitutionUrl": "1810531","assetName": ["Calabasas Classic 2010 - 5k 10k Runs", "Calabasas Classic 2010 - 5k 10k Runs"],"zip": "91302","contactPhone": "818-715-0428","sortDate": "2000-11-14","eventState": "California","eventLatitude": "34.12794","keywords": "Event","eventAddress": "23975 Park Sorrento","contactEmail": "rot10kd@yahoo.com","onlineMembershipAvailable": "false","trackbackurl": "http://www.active.com/running/calabasas-ca/calabasas-classic-5k-10k-runs-2010","country": "United States","onlineRegistrationAvailable": "true","category": "Activities","image1": "http://www.active.com/images/events/hotrace.gif","assetTypeId": "EA4E860A-9DCD-4DAA-A7CA-4A77AD194F65","lastModifiedDate": "2010-03-04 07:30:26.307","eventZip": "91302","latitude": "34.12794","UpdateDateTime": "8/18/2010 10:16:26 AM","channel": ["Running", "Walking"]}}]}',
|
232
|
+
:status => ["200", "Found"])
|
233
|
+
s = Search.search( {:location => "San Diego, CA, US"} )
|
234
|
+
s.should be_a_kind_of(Search)
|
235
|
+
s.should have(3).results
|
236
|
+
s.endIndex.should == 3
|
237
|
+
s.numberOfResults.should == 3
|
238
|
+
s.pageSize.should == 5
|
239
|
+
s.searchTime.should == 0.600205
|
240
|
+
|
241
|
+
end
|
242
|
+
|
243
|
+
it "should raise and error during a 404" do
|
244
|
+
FakeWeb.register_uri(:get, "http://search.active.com/search?api_key=&num=10&page=1&l=San+Diego%2C+CA%2C+US&f=activities&v=json&s=date_asc&m=meta:startDate:daterange:today..+",
|
245
|
+
:body => "Nothing to be found 'round here", :status => ["404", "Not Found"])
|
246
|
+
lambda { Search.search( {:location => "San Diego, CA, US"} ) }.should raise_error(RuntimeError)
|
313
247
|
end
|
248
|
+
|
249
|
+
it "should search by location (san diego)" do
|
250
|
+
FakeWeb.register_uri(:get, "http://search.active.com/search?api_key=&num=10&page=1&l=San+Diego%2C+CA%2C+US&f=activities&v=json&s=date_asc&m=meta:startDate:daterange:today..+",
|
251
|
+
:body => '{"endIndex":3,"numberOfResults":3,"pageSize":5,"searchTime":0.600205,"_results":[{"escapedUrl": "http://www.active.com/running/calabasas-ca/calabasas-classic-5k-10k-runs-2010","language": "en","title": "Calabasas Classic 2010 - 5k \u003cb\u003e10k\u003c/b\u003e Runs | Calabasas, California 91302 \u003cb\u003e...\u003c/b\u003e","url": "http://www.active.com/running/calabasas-ca/calabasas-classic-5k-10k-runs-2010","summary": "\u003cb\u003e...\u003c/b\u003e Calabasas Classic 2010 - 5k \u003cb\u003e10k\u003c/b\u003e Runs. Based on 0 reviews. \u003cb\u003e...\u003c/b\u003e Recent Reviews Calabasas\u003cbr\u003e Classic 2010 - 5k \u003cb\u003e10k\u003c/b\u003e Runs reviews. Get Directions. Start Address. End Address \u003cb\u003e...\u003c/b\u003e ","meta": {"startDate": "2010-11-14","eventDate": "2010-11-14T08:00:00-08:00","location": "Calabasas Park Centre","tag": ["event:10", "Green:10", "Running:10"],"state": "California","eventLongitude": "-118.6789","endDate": "2010-11-14","locationName": "Calabasas Park Centre","splitMediaType": ["Event", "1 mile", "10K", "5K"],"endTime": "8:00:00","mediaType": ["Event", "Event\\1 mile", "Event\\10K", "Event\\5K"],"google-site-verification": "","city": "Calabasas","startTime": "8:00:00","assetId": ["11B01475-8C65-4F9C-A4AC-2A3FA55FE8CD", "11b01475-8c65-4f9c-a4ac-2a3fa55fe8cd"],"eventId": "1810531","participationCriteria": "All","description": "","longitude": "-118.6789","onlineDonationAvailable": "false","substitutionUrl": "1810531","assetName": ["Calabasas Classic 2010 - 5k 10k Runs", "Calabasas Classic 2010 - 5k 10k Runs"],"zip": "91302","contactPhone": "818-715-0428","sortDate": "2000-11-14","eventState": "California","eventLatitude": "34.12794","keywords": "Event","eventAddress": "23975 Park Sorrento","contactEmail": "rot10kd@yahoo.com","onlineMembershipAvailable": "false","trackbackurl": "http://www.active.com/running/calabasas-ca/calabasas-classic-5k-10k-runs-2010","country": "United States","onlineRegistrationAvailable": "true","category": "Activities","image1": "http://www.active.com/images/events/hotrace.gif","assetTypeId": "EA4E860A-9DCD-4DAA-A7CA-4A77AD194F65","lastModifiedDate": "2010-03-04 07:30:26.307","eventZip": "91302","latitude": "34.12794","UpdateDateTime": "8/18/2010 10:16:26 AM","channel": ["Running", "Walking"]}},
|
252
|
+
{"escapedUrl": "http://www.active.com/10k-race/seattle-wa/fitness-for-vitality-5k10k-3race-series-919-2010","language": "en","title": "Fitness For Vitality 5k/\u003cb\u003e10k\u003c/b\u003e 3-Race Series (9/19, 10/17, 11/21) \u003cb\u003e...\u003c/b\u003e","url": "http://www.active.com/10k-race/seattle-wa/fitness-for-vitality-5k10k-3race-series-919-2010","summary": "\u003cb\u003e...\u003c/b\u003e Fitness For Vitality 5k/\u003cb\u003e10k\u003c/b\u003e 3-Race Series (9/19, 10/17, 11/21). Based on 0 reviews. \u003cb\u003e...\u003c/b\u003e\u003cbr\u003e Reviews of Fitness For Vitality 5k/\u003cb\u003e10k\u003c/b\u003e 3-Race Series (9/19, 10. \u003cb\u003e...\u003c/b\u003e ","meta": {"summary": "\u003cp style\u003dtext-align:left\u003e\u003cfont style\u003dfont-family:UniversEmbedded;font-size:12;color:#000000; LETTERSPACING\u003d0 KERNING\u003d0\u003eRace or walk on a flat, fast, and fun course! The entire event is along the Puget Sound. Do all 3 events in the series and watch your time and fitness improve! Oatmeal post-race. 10% proceeds sh","startDate": "2010-09-19","eventDate": "2010-09-19","location": "Alki Beach Park, Seattle","tag": ["event:10", "Running:10"],"state": "Washington","endDate": "2010-11-22","locationName": "1702 Alki Ave. SW","splitMediaType": ["5K", "difficulty:Beginner", "difficulty:Advanced", "Event", "difficulty:Intermediate", "10K"],"lastModifiedDateTime": "2010-08-19 23:35:50.117","endTime": "07:59:59","mediaType": ["5K", "difficulty:Beginner", "difficulty:Advanced", "Event", "difficulty:Intermediate", "10K"],"google-site-verification": "","city": "Seattle","startTime": "07:00:00","assetId": ["39e8177e-dd0e-42a2-8a2b-24055e5325f3", "39e8177e-dd0e-42a2-8a2b-24055e5325f3"],"eventId": "E-000NGFS9","participationCriteria": "Kids,Family","description": "","longitude": "-122.3912","substitutionUrl": "E-000NGFS9","assetName": ["Fitness For Vitality 5k/10k 3-Race Series (9/19, 10/17, 11/21)", "Fitness For Vitality 5k/10k 3-Race Series (9/19, 10/17, 11/21)"],"zip": "98136","contactPhone": "n/a","eventState": "WA","sortDate": "2000-09-19","keywords": "Event","eventAddress": "1702 Alki Ave. SW","contactEmail": "n/a","dma": "Seattle - Tacoma","trackbackurl": "http://www.active.com/10k-race/seattle-wa/fitness-for-vitality-5k10k-3race-series-919-2010","seourl": "http://www.active.com/10k-race/seattle-wa/fitness-for-vitality-5k10k-3race-series-919-2010","country": "United States","onlineRegistrationAvailable": "true","category": "Activities","image1": "http://photos-images.active.com/file/3/1/optimized/9015e50d-3a2e-4ce4-9ddc-80b05b973b01.jpg","allText": "\u003cp style\u003dtext-align:left\u003e\u003cfont style\u003dfont-family:UniversEmbedded;font-size:12;color:#000000; LETTERSPACING\u003d0 KERNING\u003d0\u003eRace or walk on a flat, fast, and fun course! The entire event is along the Puget Sound. Do all 3 events in the series and watch your time and fitness improve! Oatmeal post-race. 10% proceeds sh","address": "1702 Alki Ave. SW","assetTypeId": "DFAA997A-D591-44CA-9FB7-BF4A4C8984F1","lastModifiedDate": "2010-08-19","eventZip": "98136","latitude": "47.53782","UpdateDateTime": "8/18/2010 10:16:08 AM","channel": "Running"}},
|
253
|
+
{"escapedUrl": "http://www.active.com/running/calabasas-ca/calabasas-classic-5k-10k-runs-2010","language": "en","title": "Calabasas Classic 2010 - 5k \u003cb\u003e10k\u003c/b\u003e Runs | Calabasas, California 91302 \u003cb\u003e...\u003c/b\u003e","url": "http://www.active.com/running/calabasas-ca/calabasas-classic-5k-10k-runs-2010","summary": "\u003cb\u003e...\u003c/b\u003e Calabasas Classic 2010 - 5k \u003cb\u003e10k\u003c/b\u003e Runs. Based on 0 reviews. \u003cb\u003e...\u003c/b\u003e Recent Reviews Calabasas\u003cbr\u003e Classic 2010 - 5k \u003cb\u003e10k\u003c/b\u003e Runs reviews. Get Directions. Start Address. End Address \u003cb\u003e...\u003c/b\u003e ","meta": {"startDate": "2010-11-14","eventDate": "2010-11-14T08:00:00-08:00","location": "Calabasas Park Centre","tag": ["event:10", "Green:10", "Running:10"],"state": "California","eventLongitude": "-118.6789","endDate": "2010-11-14","locationName": "Calabasas Park Centre","splitMediaType": ["Event", "1 mile", "10K", "5K"],"endTime": "8:00:00","mediaType": ["Event", "Event\\1 mile", "Event\\10K", "Event\\5K"],"google-site-verification": "","city": "Calabasas","startTime": "8:00:00","assetId": ["11B01475-8C65-4F9C-A4AC-2A3FA55FE8CD", "11b01475-8c65-4f9c-a4ac-2a3fa55fe8cd"],"eventId": "1810531","participationCriteria": "All","description": "","longitude": "-118.6789","onlineDonationAvailable": "false","substitutionUrl": "1810531","assetName": ["Calabasas Classic 2010 - 5k 10k Runs", "Calabasas Classic 2010 - 5k 10k Runs"],"zip": "91302","contactPhone": "818-715-0428","sortDate": "2000-11-14","eventState": "California","eventLatitude": "34.12794","keywords": "Event","eventAddress": "23975 Park Sorrento","contactEmail": "rot10kd@yahoo.com","onlineMembershipAvailable": "false","trackbackurl": "http://www.active.com/running/calabasas-ca/calabasas-classic-5k-10k-runs-2010","country": "United States","onlineRegistrationAvailable": "true","category": "Activities","image1": "http://www.active.com/images/events/hotrace.gif","assetTypeId": "EA4E860A-9DCD-4DAA-A7CA-4A77AD194F65","lastModifiedDate": "2010-03-04 07:30:26.307","eventZip": "91302","latitude": "34.12794","UpdateDateTime": "8/18/2010 10:16:26 AM","channel": ["Running", "Walking"]}}]}',
|
254
|
+
:status => ["200", "Found"])
|
255
|
+
s = Search.search( {:location => "San Diego, CA, US"} )
|
256
|
+
s.should be_a_kind_of(Search)
|
257
|
+
s.should have(3).results
|
258
|
+
s.results.each do |a|
|
259
|
+
a.should be_an_instance_of(Activity)
|
260
|
+
a.title.should_not be_nil
|
261
|
+
# a.start_date.should_not be_nil
|
262
|
+
# a.end_date.should_not be_nil
|
263
|
+
# a.categories.should_not be_nil
|
264
|
+
# a.desc.should_not be_nil
|
265
|
+
# a.start_time.should_not be_nil
|
266
|
+
# a.end_time.should_not be_nil
|
267
|
+
# a.address.should_not be_nil
|
268
|
+
# a.address[:name].should_not be_nil
|
269
|
+
# a.address[:city].should_not be_nil
|
270
|
+
# a.address[:state].should_not be_nil
|
271
|
+
# a.address[:zip].should_not be_nil
|
272
|
+
# a.address[:country].should_not be_nil
|
273
|
+
# a.address[:lat].should_not be_nil
|
274
|
+
# a.address[:lng].should_not be_nil
|
275
|
+
end
|
276
|
+
end
|
277
|
+
|
278
|
+
it "should handle this json error" do
|
279
|
+
# FakeWeb.register_uri(:get, "http://search.active.com/search?api_key=&num=10&page=1&l=San+Diego%2C+CA%2C+US&f=activities&v=json&r=50&s=date_asc&k=&m=meta:startDate:daterange:today..+",
|
280
|
+
# :body => '{"endIndex":10,"numberOfResults":2790,"pageSize":10,"searchTime":0.253913,"_results":[{"escapedUrl":"http://www.active.com/running/myrtle-beach-sc/myrtle-beach-mini-marathon-2010","language":"en","title":"Myrtle Beach Mini Marathon | Myrtle Beach, South Carolina \u003cb\u003e...\u003c/b\u003e","url":"http://www.active.com/running/myrtle-beach-sc/myrtle-beach-mini-marathon-2010","summary":"","meta":{"eventDate":"2010-10-24T07:00:00-07:00","location":"Myrtle Beach, South Carolina","tag":["event:10","Running:10"],"endDate":"2010-10-24","eventLongitude":"-78.92921","splitMediaType":["Event","5K","Half Marathon","Marathon","\u003ddifficulty:Advanced","\u003ddifficulty:Beginner","\u003ddifficulty:Intermediate"],"lastModifiedDateTime":"2010-09-13 18:15:04.753","locationName":"Myrtle Beach, South Carolina","endTime":"7:00:00","google-site-verification":"","city":"Myrtle Beach","startTime":"7:00:00","eventId":"1797753","description":"","longitude":"-78.92921","substitutionUrl":"1797753","eventLatitude":"33.75043","eventState":"South Carolina","sortDate":"2000-10-24","keywords":"Event","eventAddress":"Medieval Times","dma":"Florence - Myrtle Beach","seourl":"http://www.active.com/running/myrtle-beach-sc/myrtle-beach-mini-marathon-2010","country":"United States","category":"Activities","market":"Florence - Myrtle Beach","assetTypeId":"EA4E860A-9DCD-4DAA-A7CA-4A77AD194F65","contactName":"Robert Pozo","eventZip":"29579","latitude":"33.75043","UpdateDateTime":"9/1/2010 6:09:21 PM","startDate":"2010-10-24","state":"South Carolina","mediaType":["Event","Event\\5K","Event\\Half Marathon","Event\\Marathon","\u003ddifficulty:Advanced","\u003ddifficulty:Beginner","\u003ddifficulty:Intermediate"],"estParticipants":"6000","assetId":["008540A9-C2AB-4D7F-BE68-298758B324CD","008540a9-c2ab-4d7f-be68-298758b324cd"],"participationCriteria":"Adult,Men,Women","onlineDonationAvailable":"1","assetName":["Myrtle Beach Mini Marathon","Myrtle Beach Mini Marathon"],"eventURL":"http://runmyrtlebeach.com","zip":"29579","contactPhone":"1-800-733-7089","contactEmail":"info@runmyrtlebeach.com","onlineMembershipAvailable":"0","trackbackurl":"http://www.active.com/running/myrtle-beach-sc/myrtle-beach-mini-marathon-2010","onlineRegistrationAvailable":"1","image1":"http://www.active.com/images/events/hotrace.gif","lastModifiedDate":"2010-09-13","channel":"Running"}},{"escapedUrl":"http://www.active.com/running/denver-co/fans-on-the-field-denver-stadium-5k10k-2010","language":"en","title":"Fans on the Field 2010 - Denver Stadium 5K/10K | Denver \u003cb\u003e...\u003c/b\u003e","url":"http://www.active.com/running/denver-co/fans-on-the-field-denver-stadium-5k10k-2010","summary":"","meta":{"startDate":"2010-10-10","eventDate":"2010-10-10T00:00:00-07:00","location":"INVESCO Field at Mile High","tag":["event:10","Running:10"],"state":"Colorado","eventLongitude":"-105.0265","endDate":"2010-10-10","lastModifiedDateTime":"2010-08-05 16:15:18.14","splitMediaType":["Event","10K","5K"],"locationName":"INVESCO Field at Mile High","endTime":"0:00:00","mediaType":["Event","Event\\10K","Event\\5K"],"city":"Denver","google-site-verification":"","startTime":"0:00:00","assetId":["4850BB73-3701-493D-936C-C38CC0B3FD4C","4850bb73-3701-493d-936c-c38cc0b3fd4c"],"eventId":"1869635","participationCriteria":"All","description":"","longitude":"-105.0265","onlineDonationAvailable":"false","substitutionUrl":"1869635","assetName":["Fans on the Field 2010 - Denver Stadium 5K/10K","Fans on the Field 2010 - Denver Stadium 5K/10K"],"zip":"80204","contactPhone":"303-293-5315","eventLatitude":"39.73804","eventState":"Colorado","sortDate":"2000-10-10","keywords":"Event","eventAddress":"1801 Bryant Street","contactEmail":"ahinkle@nscd.org","onlineMembershipAvailable":"false","trackbackurl":"http://www.active.com/running/denver-co/fans-on-the-field-denver-stadium-5k10k-2010","country":"United States","onlineRegistrationAvailable":"true","category":"Activities","image1":"http://www.active.com/images/events/hotrace.gif","assetTypeId":"EA4E860A-9DCD-4DAA-A7CA-4A77AD194F65","lastModifiedDate":"2010-08-05","eventZip":"80204","UpdateDateTime":"9/1/2010 6:09:21 PM","latitude":"39.73804","channel":["Running","Walking"]}},{"escapedUrl":"http://www.active.com/triathlon/sedalia-mo/sedalia-duathlon-2010","language":"en","title":"Sedalia Duathlon | Sedalia, Missouri 65301 | Sunday \u003cb\u003e...\u003c/b\u003e","url":"http://www.active.com/triathlon/sedalia-mo/sedalia-duathlon-2010","summary":"","meta":{"startDate":"2010-09-26","eventDate":"2010-09-26T08:00:00-07:00","location":"Centennial Park/Parview School","state":"Missouri","endDate":"2010-09-26","eventLongitude":"-93.22826","lastModifiedDateTime":"2010-07-29 17:15:03.313","splitMediaType":["Event","Sprint"],"locationName":"Centennial Park/Parview School","endTime":"8:00:00","mediaType":["Event","Event\\Sprint"],"city":"Sedalia","google-site-verification":"","startTime":"8:00:00","assetId":["F11300A4-0A56-4321-AD4C-17502CEE8503","f11300a4-0a56-4321-ad4c-17502cee8503"],"eventId":"1879447","participationCriteria":"All","description":"","longitude":"-93.22826","onlineDonationAvailable":"false","substitutionUrl":"1879447","assetName":["Sedalia Duathlon","Sedalia Duathlon"],"zip":"65301","contactPhone":"660-827-6809","eventLatitude":"38.70446","eventState":"Missouri","sortDate":"2000-09-26","keywords":"Event","eventAddress":"1901 S. New York","contactEmail":"jamm@iland.net","onlineMembershipAvailable":"false","trackbackurl":"http://www.active.com/triathlon/sedalia-mo/sedalia-duathlon-2010","country":"United States","onlineRegistrationAvailable":"true","category":"Activities","image1":"http://www.active.com/images/events/hotrace.gif","assetTypeId":"EA4E860A-9DCD-4DAA-A7CA-4A77AD194F65","lastModifiedDate":"2010-07-29","eventZip":"65301","UpdateDateTime":"9/1/2010 6:09:21 PM","latitude":"38.70446","channel":["More Sports\\Duathlon","Triathlon"]}},{"escapedUrl":"http://www.active.com/triathlon/tempe-az/pbr-urban-dirt-duathlon-2010","language":"en","title":"PBR Urban Dirt Duathlon | Tempe, Arizona 85281 | Sunday \u003cb\u003e...\u003c/b\u003e","url":"http://www.active.com/triathlon/tempe-az/pbr-urban-dirt-duathlon-2010","summary":"","meta":{"eventDate":"2010-10-10T07:30:00-07:00","location":"North side of Tempe Town Lake near sand Volleyball courts, east of Mill Ave. Race thru Papago!","tag":["event:10","Triathlon:10"],"endDate":"2010-10-10","eventLongitude":"-111.9305","splitMediaType":["Event","Off-Road","Sprint","\u003ddifficulty:Advanced","\u003ddifficulty:Beginner","\u003ddifficulty:Intermediate"],"lastModifiedDateTime":"2010-09-08 15:15:42.507","locationName":"North side of Tempe Town Lake near sand Volleyball courts, east of Mill Ave. Race thru Papago!","endTime":"7:30:00","google-site-verification":"","city":"Tempe","startTime":"7:30:00","eventId":"1814945","description":"","longitude":"-111.9305","substitutionUrl":"1814945","eventLatitude":"33.42507","eventState":"Arizona","sortDate":"2000-10-10","keywords":"Event","eventAddress":"54 West Rio Salado Parkway","dma":"Phoenix","seourl":"http://www.active.com/triathlon/tempe-az/pbr-urban-dirt-duathlon-2010","country":"United States","category":"Activities","market":"Phoenix","assetTypeId":"EA4E860A-9DCD-4DAA-A7CA-4A77AD194F65","contactName":"Red Rock Co","eventZip":"85281","latitude":"33.42507","UpdateDateTime":"9/1/2010 6:09:21 PM","startDate":"2010-10-10","state":"Arizona","mediaType":["Event","Event\\Off-Road","Event\\Sprint","\u003ddifficulty:Advanced","\u003ddifficulty:Beginner","\u003ddifficulty:Intermediate"],"estParticipants":"400","assetId":["C47BA275-BFFF-41F1-8915-42F9159456B6","c47ba275-bfff-41f1-8915-42f9159456b6"],"participationCriteria":"Adult,Family,Kids,Men,Women","onlineDonationAvailable":"0","assetName":["PBR Urban Dirt Duathlon","PBR Urban Dirt Duathlon"],"eventURL":"http://www.redrockco.com","zip":"85281","contactPhone":"877-681-7223","contactEmail":"mike@redrockco.com","onlineMembershipAvailable":"0","trackbackurl":"http://www.active.com/triathlon/tempe-az/pbr-urban-dirt-duathlon-2010","onlineRegistrationAvailable":"1","image1":"http://www.active.com/images/events/hotrace.gif","lastModifiedDate":"2010-09-08","channel":["More Sports\\Duathlon","Triathlon"]}},{"escapedUrl":"http://www.active.com/triathlon/hayesville-nc/fall-chill-duathlon-2010","language":"en","title":"Fall Chill Duathlon 2010 | Hayesville, North Carolina 28904 \u003cb\u003e...\u003c/b\u003e","url":"http://www.active.com/triathlon/hayesville-nc/fall-chill-duathlon-2010","summary":"","meta":{"eventDate":"2010-10-24T10:00:00-07:00","location":"Clay County Recreation Park: 5 miles from Hiawassee Ga","tag":["event:10","Triathlon:10"],"endDate":"2010-10-24","eventLongitude":"-83.73081","splitMediaType":["Event","Sprint","\u003ddifficulty:Intermediate"],"lastModifiedDateTime":"2010-09-16 03:11:56.37","locationName":"Clay County Recreation Park: 5 miles from Hiawassee Ga","endTime":"10:00:00","google-site-verification":"","city":"Hayesville","startTime":"10:00:00","eventId":"1816551","description":"","longitude":"-83.73081","substitutionUrl":"1816551","eventLatitude":"35.04112","eventState":"North Carolina","sortDate":"2000-10-24","keywords":"Event","eventAddress":"Clay County Recreation Park Road, Hayesville, NC 28904","dma":"Atlanta","seourl":"http://www.active.com/triathlon/hayesville-nc/fall-chill-duathlon-2010","country":"United States","category":"Activities","market":"Atlanta","assetTypeId":"EA4E860A-9DCD-4DAA-A7CA-4A77AD194F65","contactName":"Scott Hanna","eventZip":"28904","latitude":"35.04112","UpdateDateTime":"9/1/2010 6:09:21 PM","startDate":"2010-10-24","state":"North Carolina","mediaType":["Event","Event\\Sprint","\u003ddifficulty:Intermediate"],"estParticipants":"150","assetId":["2B2DD142-23EA-42AE-A86A-C3BAAF8089F0","2b2dd142-23ea-42ae-a86a-c3baaf8089f0"],"participationCriteria":"Adult","onlineDonationAvailable":"0","assetName":["Fall Chill Duathlon 2010","Fall Chill Duathlon 2010"],"eventURL":"http://www.thebeastoftheeast.net","zip":"28904","contactPhone":"828-389-6982","contactEmail":"tri20001@msn.com","onlineMembershipAvailable":"0","trackbackurl":"http://www.active.com/triathlon/hayesville-nc/fall-chill-duathlon-2010","onlineRegistrationAvailable":"true","image1":"http://www.active.com/images/events/hotrace.gif","lastModifiedDate":"2010-09-16","channel":["More Sports\\Duathlon","Triathlon"]}},{"escapedUrl":"http://www.active.com/triathlon/congers-ny/fall-toga-duathlon-2010","language":"en","title":"2010 Fall Toga Duathlon | Congers, New York 10920 \u003cb\u003e...\u003c/b\u003e","url":"http://www.active.com/triathlon/congers-ny/fall-toga-duathlon-2010","summary":"","meta":{"startDate":"2010-10-17","eventDate":"2010-10-17T08:30:00-07:00","location":"Rockland Lake","tag":["event:10","Triathlon:10"],"state":"New York","endDate":"2010-10-17","eventLongitude":"-73.93904","splitMediaType":["Event","Sprint"],"locationName":"Rockland Lake","endTime":"8:30:00","mediaType":["Event","Event\\Sprint"],"city":"Congers","google-site-verification":"","startTime":"8:30:00","assetId":["096853C1-151A-4EED-9931-79275795AAA9","096853c1-151a-4eed-9931-79275795aaa9"],"eventId":"1821127","participationCriteria":"All","description":"","longitude":"-73.93904","onlineDonationAvailable":"false","substitutionUrl":"1821127","assetName":["2010 Fall Toga Duathlon","2010 Fall Toga Duathlon"],"zip":"10920","contactPhone":"8453538331","eventLatitude":"41.15644","eventState":"New York","sortDate":"2000-10-17","keywords":"Event","eventAddress":"Rt 9W","contactEmail":"Lonny@Togabikes.com","onlineMembershipAvailable":"false","trackbackurl":"http://www.active.com/triathlon/congers-ny/fall-toga-duathlon-2010","country":"United States","onlineRegistrationAvailable":"true","category":"Activities","image1":"http://www.active.com/images/events/hotrace.gif","assetTypeId":"EA4E860A-9DCD-4DAA-A7CA-4A77AD194F65","lastModifiedDate":"2010-03-02 15:22:22.54","eventZip":"10920","UpdateDateTime":"9/1/2010 6:09:21 PM","latitude":"41.15644","channel":["More Sports\\Duathlon","Triathlon"]}},{"escapedUrl":"http://www.active.com/triathlon/mendon-ny/rochester-autumn-classic-duathlon-2010","language":"en","title":"Rochester Autumn Classic Duathlon 2010 | Mendon, New \u003cb\u003e...\u003c/b\u003e","url":"http://www.active.com/triathlon/mendon-ny/rochester-autumn-classic-duathlon-2010","summary":"","meta":{"eventDate":"2010-10-03T08:30:00-07:00","location":"Stewart Lodge, Mendon Ponds Park","tag":["event:10","Triathlon:10"],"endDate":"2010-10-03","eventLongitude":"-77.49951","splitMediaType":["Event","Sprint"],"lastModifiedDateTime":"2010-08-30 13:15:51.837","locationName":"Stewart Lodge, Mendon Ponds Park","endTime":"8:30:00","google-site-verification":"","city":"Mendon","startTime":"8:30:00","eventId":"1821816","description":"","longitude":"-77.49951","substitutionUrl":"1821816","eventLatitude":"42.99441","eventState":"New York","sortDate":"2000-10-03","keywords":"Event","eventAddress":"Douglas Rd.","dma":"Rochester, NY","seourl":"http://www.active.com/triathlon/mendon-ny/rochester-autumn-classic-duathlon-2010","country":"United States","category":"Activities","market":"Rochester, NY","contactName":"Dave or Ellen Boutillier","assetTypeId":"EA4E860A-9DCD-4DAA-A7CA-4A77AD194F65","eventZip":"14506","latitude":"42.99441","UpdateDateTime":"9/1/2010 6:09:21 PM","startDate":"2010-10-03","state":"New York","mediaType":["Event","Event\\Sprint"],"estParticipants":"250","assetId":["39F96A49-A188-4592-A04C-755D12D5D8BB","39f96a49-a188-4592-a04c-755d12d5d8bb"],"participationCriteria":"All","onlineDonationAvailable":"0","assetName":["Rochester Autumn Classic Duathlon 2010","Rochester Autumn Classic Duathlon 2010"],"eventURL":"http://www.yellowjacketracing.com","zip":"14506","contactPhone":"585-697-3338","contactEmail":"elleneabrenner@aol.com","onlineMembershipAvailable":"0","trackbackurl":"http://www.active.com/triathlon/mendon-ny/rochester-autumn-classic-duathlon-2010","onlineRegistrationAvailable":"1","image1":"http://www.active.com/images/events/hotrace.gif","lastModifiedDate":"2010-08-30","channel":["More Sports\\Duathlon","Triathlon"]}},{"escapedUrl":"http://www.active.com/triathlon/miami-fl/ironman-703-miami-2010","language":"en","title":"IRONMAN 70.3 MIAMI | Miami, Florida 33132 | Saturday \u003cb\u003e...\u003c/b\u003e","url":"http://www.active.com/triathlon/miami-fl/ironman-703-miami-2010","summary":"","meta":{"startDate":"2010-10-30","eventDate":"2010-10-30T07:00:00-07:00","location":"Bayfront Park - Downtown Miami","tag":["event:10","Triathlon:10"],"state":"Florida","eventLongitude":"-80.18975","endDate":"2010-10-30","lastModifiedDateTime":"2010-05-10 11:16:04.46","splitMediaType":["Event","Ironman","Long Course","\u003ddifficulty:Advanced","\u003ddifficulty:Intermediate"],"locationName":"Bayfront Park - Downtown Miami","endTime":"7:00:00","mediaType":["Event","Event\\Ironman","Event\\Long Course","\u003ddifficulty:Advanced","\u003ddifficulty:Intermediate"],"city":"Miami","google-site-verification":"","startTime":"7:00:00","assetId":["72FAE9F7-5C68-4DF8-B01C-B63AC188A06A","72fae9f7-5c68-4df8-b01c-b63ac188a06a"],"eventId":"1800302","participationCriteria":"Adult,Family,Men,Women","description":"","longitude":"-80.18975","onlineDonationAvailable":"false","substitutionUrl":"1800302","assetName":["IRONMAN 70.3 MIAMI","IRONMAN 70.3 MIAMI"],"zip":"33132","contactPhone":"3053072285","eventLatitude":"25.78649","eventState":"Florida","sortDate":"2000-10-30","keywords":"Event","eventAddress":"301 N. Biscayne Blvd.","contactEmail":"jennifer@miamitrievents.com","onlineMembershipAvailable":"false","trackbackurl":"http://www.active.com/triathlon/miami-fl/ironman-703-miami-2010","country":"United States","onlineRegistrationAvailable":"true","category":"Activities","image1":"http://www.active.com/images/events/hotrace.gif","assetTypeId":"EA4E860A-9DCD-4DAA-A7CA-4A77AD194F65","lastModifiedDate":"2010-05-10","eventZip":"33132","UpdateDateTime":"9/1/2010 6:09:21 PM","latitude":"25.78649","channel":"Triathlon"}},{"escapedUrl":"http://www.active.com/triathlon/austin-tx/austin-oyster-urban-adventure-race-2010","language":"en","title":"Austin Oyster Urban Adventure Race | Austin, Texas 78704 \u003cb\u003e...\u003c/b\u003e","url":"http://www.active.com/triathlon/austin-tx/austin-oyster-urban-adventure-race-2010","summary":"","meta":{"eventDate":"2010-10-16T08:00:00-07:00","location":"Runtex","tag":["event:10","Triathlon:10"],"endDate":"2010-10-16","eventLongitude":"-97.76204","splitMediaType":"Event","lastModifiedDateTime":"2010-09-17 10:16:19.03","locationName":"Runtex","endTime":"8:00:00","google-site-verification":"","city":"Austin","startTime":"8:00:00","eventId":"1831863","description":"","longitude":"-97.76204","substitutionUrl":"1831863","eventLatitude":"30.24495","eventState":"Texas","sortDate":"2000-10-16","keywords":"Event","eventAddress":"422 W. Riverside","dma":"Austin","seourl":"http://www.active.com/triathlon/austin-tx/austin-oyster-urban-adventure-race-2010","country":"United States","category":"Activities","market":"Austin","assetTypeId":"EA4E860A-9DCD-4DAA-A7CA-4A77AD194F65","contactName":"Luann Morris","eventZip":"78704","latitude":"30.24495","UpdateDateTime":"9/1/2010 6:09:21 PM","startDate":"2010-10-16","state":"Texas","mediaType":"Event","estParticipants":"500","assetId":["5BCA2E67-05F8-49FA-911B-EA007A08A7ED","5bca2e67-05f8-49fa-911b-ea007a08a7ed"],"participationCriteria":"All","onlineDonationAvailable":"0","assetName":["Austin Oyster Urban Adventure Race","Austin Oyster Urban Adventure Race"],"eventURL":"http://OysterRacingSeries.com","zip":"78704","contactPhone":"3037776887","contactEmail":"luann@teamsage.com","onlineMembershipAvailable":"0","trackbackurl":"http://www.active.com/triathlon/austin-tx/austin-oyster-urban-adventure-race-2010","onlineRegistrationAvailable":"true","image1":"http://www.active.com/images/events/hotrace.gif","lastModifiedDate":"2010-09-17","channel":["More Sports\\Adventure Racing","Triathlon"]}},{"escapedUrl":"http://www.active.com/running/colorado-springs-co/fall-series-kids-2010-ov251","language":"en","title":"Fall Series 2010 (Kids) | Colorado Springs, Colorado 80903 \u003cb\u003e...\u003c/b\u003e","url":"http://www.active.com/running/colorado-springs-co/fall-series-kids-2010-ov251","summary":"","meta":{"startDate":"2010-10-03","eventDate":"2010-10-03T13:30:00-07:00","location":"Various sites","tag":["event:10","Running:10"],"state":"Colorado","eventLongitude":"-104.8163","endDate":"2010-10-03","lastModifiedDateTime":"2010-08-12 11:19:31.73","splitMediaType":["Event","1 mile","\u003ddifficulty:Advanced","\u003ddifficulty:Beginner","\u003ddifficulty:Intermediate"],"locationName":"Various sites","endTime":"13:30:00","mediaType":["Event","Event\\1 mile","\u003ddifficulty:Advanced","\u003ddifficulty:Beginner","\u003ddifficulty:Intermediate"],"city":"Colorado Springs","google-site-verification":"","estParticipants":"400","startTime":"13:30:00","assetId":["54A4A562-2A34-4345-8A20-7084EC435C57","54a4a562-2a34-4345-8a20-7084ec435c57"],"eventId":"1882757","participationCriteria":"Kids","description":"","longitude":"-104.8163","onlineDonationAvailable":"true","substitutionUrl":"1882757","assetName":["Fall Series 2010 (Kids)","Fall Series 2010 (Kids)"],"zip":"80903","eventURL":"http://pprrun.org","contactPhone":"719-590-7086","sortDate":"2000-10-03","eventState":"Colorado","eventLatitude":"38.84134","keywords":"Event","contactEmail":"fallseries@aol.com","onlineMembershipAvailable":"false","trackbackurl":"http://www.active.com/running/colorado-springs-co/fall-series-kids-2010-ov251","country":"United States","onlineRegistrationAvailable":"true","category":"Activities","image1":"http://www.active.com/images/events/hotrace.gif","market":"Colorado Springs - Pueblo","contactName":"Larry Miller","assetTypeId":"EA4E860A-9DCD-4DAA-A7CA-4A77AD194F65","lastModifiedDate":"2010-08-12","eventZip":"80903","UpdateDateTime":"9/1/2010 6:09:21 PM","latitude":"38.84134","channel":["Running","Walking"]}}]}',
|
281
|
+
# :status => ["200", "Found"])
|
282
|
+
# s = Search.search( {:zips=>["92198", "92199", "91901", "91902", "91903", "91905", "91906", "91908", "91909", "91910", "91911", "91912", "91913", "91914", "91915", "91916", "91917", "91921", "91931", "91932", "91933", "91934", "91935", "91941", "91942", "91943", "91944", "91945", "91946", "91947", "91948", "91950", "91951", "91962", "91963", "91976", "91977", "91978", "91979", "91980", "91987", "91990", "92003", "92004", "92007", "92008", "92009", "92013", "92014", "92018", "92019", "92020", "92021", "92022", "92023", "92024", "92025", "92026", "92027", "92028", "92029", "92030", "92033", "92036", "92037", "92038", "92039", "92040", "92046", "92049", "92051", "92052", "92054", "92055", "92056", "92057", "92058", "92059", "92060", "92061", "92064", "92065", "92066", "92067", "92068", "92069", "92070", "92071", "92072", "92074", "92075", "92078", "92079", "92082", "92083", "92084", "92085", "92086", "92088", "92090", "92091", "92092", "92093", "92096", "92101", "92102", "92103", "92104", "92105", "92106", "92107", "92108", "92109", "92110", "92111", "92112", "92113", "92114", "92115", "92116", "92117", "92118", "92119", "92120", "92121", "92122", "92123", "92124", "92126", "92127", "92128", "92129", "92130", "92131", "92132", "92133", "92134", "92135", "92136", "92137", "92138", "92139", "92140", "92142", "92143", "92145", "92147", "92149", "92150", "92152", "92153", "92154", "92155", "92158", "92159", "92160", "92161", "92162", "92163", "92164", "92165", "92166", "92167", "92168", "92169", "92170", "92171", "92172", "92173", "92174", "92175", "92176", "92177", "92178", "92179", "92182", "92184", "92186", "92187", "92190", "92191", "92192", "92193", "92194", "92195", "92196", "92197", "92081"]} )
|
283
|
+
s = Search.search( {:zips=>["92198", "92199", "91901"]} )
|
284
|
+
s.results.should have(10).items
|
285
|
+
s.results.should_not be_empty
|
286
|
+
end
|
287
|
+
|
288
|
+
it "should handle a JSON parse error" do
|
289
|
+
# /search?api_key=&num=10&page=1&l=0&f=activities&v=json&r=50&s=trending&k=&m=meta:startDate:daterange:today..+
|
290
|
+
# FakeWeb.register_uri(:get, "http://search.active.com/search?api_key=&num=10&page=1&l=San+Diego%2C+CA%2C+US&f=activities&v=json&r=50&s=date_asc&k=&m=meta:startDate:daterange:today..+",
|
291
|
+
# :body => '{"endIndex":10,"numberOfResults":2810,"pageSize":10,"searchTime":0.86581,"_results":[{"escapedUrl":"http://www.active.com/running/myrtle-beach-sc/myrtle-beach-mini-marathon-2010","language":"en","title":"Myrtle Beach Mini Marathon | Myrtle Beach, South Carolina \u003cb\u003e...\u003c/b\u003e","url":"http://www.active.com/running/myrtle-beach-sc/myrtle-beach-mini-marathon-2010","summary":"","meta":{"eventDate":"2010-10-24T07:00:00-07:00","location":"Myrtle Beach, South Carolina","tag":["event:10","Running:10"],"endDate":"2010-10-24","eventLongitude":"-78.92921","splitMediaType":["Event","5K","Half Marathon","Marathon","\u003ddifficulty:Advanced","\u003ddifficulty:Beginner","\u003ddifficulty:Intermediate"],"lastModifiedDateTime":"2010-09-13 18:15:04.753","locationName":"Myrtle Beach, South Carolina","endTime":"7:00:00","google-site-verification":"","city":"Myrtle Beach","startTime":"7:00:00","eventId":"1797753","description":"","longitude":"-78.92921","substitutionUrl":"1797753","eventLatitude":"33.75043","eventState":"South Carolina","sortDate":"2000-10-24","keywords":"Event","eventAddress":"Medieval Times","dma":"Florence - Myrtle Beach","seourl":"http://www.active.com/running/myrtle-beach-sc/myrtle-beach-mini-marathon-2010","country":"United States","category":"Activities","market":"Florence - Myrtle Beach","assetTypeId":"EA4E860A-9DCD-4DAA-A7CA-4A77AD194F65","contactName":"Robert Pozo","eventZip":"29579","latitude":"33.75043","UpdateDateTime":"9/1/2010 6:09:21 PM","startDate":"2010-10-24","state":"South Carolina","mediaType":["Event","Event\\5K","Event\\Half Marathon","Event\\Marathon","\u003ddifficulty:Advanced","\u003ddifficulty:Beginner","\u003ddifficulty:Intermediate"],"estParticipants":"6000","assetId":["008540A9-C2AB-4D7F-BE68-298758B324CD","008540a9-c2ab-4d7f-be68-298758b324cd"],"participationCriteria":"Adult,Men,Women","onlineDonationAvailable":"1","assetName":["Myrtle Beach Mini Marathon","Myrtle Beach Mini Marathon"],"eventURL":"http://runmyrtlebeach.com","zip":"29579","contactPhone":"1-800-733-7089","contactEmail":"info@runmyrtlebeach.com","onlineMembershipAvailable":"0","trackbackurl":"http://www.active.com/running/myrtle-beach-sc/myrtle-beach-mini-marathon-2010","onlineRegistrationAvailable":"1","image1":"http://www.active.com/images/events/hotrace.gif","lastModifiedDate":"2010-09-13","channel":"Running"}},{"escapedUrl":"http://www.active.com/running/denver-co/fans-on-the-field-denver-stadium-5k10k-2010","language":"en","title":"Fans on the Field 2010 - Denver Stadium 5K/10K | Denver \u003cb\u003e...\u003c/b\u003e","url":"http://www.active.com/running/denver-co/fans-on-the-field-denver-stadium-5k10k-2010","summary":"","meta":{"startDate":"2010-10-10","eventDate":"2010-10-10T00:00:00-07:00","location":"INVESCO Field at Mile High","tag":["event:10","Running:10"],"state":"Colorado","eventLongitude":"-105.0265","endDate":"2010-10-10","lastModifiedDateTime":"2010-08-05 16:15:18.14","splitMediaType":["Event","10K","5K"],"locationName":"INVESCO Field at Mile High","endTime":"0:00:00","mediaType":["Event","Event\\10K","Event\\5K"],"city":"Denver","google-site-verification":"","startTime":"0:00:00","assetId":["4850BB73-3701-493D-936C-C38CC0B3FD4C","4850bb73-3701-493d-936c-c38cc0b3fd4c"],"eventId":"1869635","participationCriteria":"All","description":"","longitude":"-105.0265","onlineDonationAvailable":"false","substitutionUrl":"1869635","assetName":["Fans on the Field 2010 - Denver Stadium 5K/10K","Fans on the Field 2010 - Denver Stadium 5K/10K"],"zip":"80204","contactPhone":"303-293-5315","eventLatitude":"39.73804","eventState":"Colorado","sortDate":"2000-10-10","keywords":"Event","eventAddress":"1801 Bryant Street","contactEmail":"ahinkle@nscd.org","onlineMembershipAvailable":"false","trackbackurl":"http://www.active.com/running/denver-co/fans-on-the-field-denver-stadium-5k10k-2010","country":"United States","onlineRegistrationAvailable":"true","category":"Activities","image1":"http://www.active.com/images/events/hotrace.gif","assetTypeId":"EA4E860A-9DCD-4DAA-A7CA-4A77AD194F65","lastModifiedDate":"2010-08-05","eventZip":"80204","UpdateDateTime":"9/1/2010 6:09:21 PM","latitude":"39.73804","channel":["Running","Walking"]}},{"escapedUrl":"http://www.active.com/running/west-palm-beach-fl/the-palm-beaches-marathon-festival-2010","language":"en","title":"The Palm Beaches Marathon Festival | West Palm Beach \u003cb\u003e...\u003c/b\u003e","url":"http://www.active.com/running/west-palm-beach-fl/the-palm-beaches-marathon-festival-2010","summary":"","meta":{"eventDate":"2010-12-05T06:00:00-08:00","location":"West Palm Beach, Florida","tag":["event:10","Running:10"],"endDate":"2010-12-05","eventLongitude":"-80.06707","splitMediaType":["Event","5K","Half Marathon","Marathon","Relay"],"lastModifiedDateTime":"2010-09-10 13:15:05.057","locationName":"West Palm Beach, Florida","endTime":"6:00:00","google-site-verification":"","city":"West Palm Beach","startTime":"6:00:00","eventId":"1815427","description":"","longitude":"-80.06707","substitutionUrl":"1815427","eventLatitude":"26.72339","eventState":"Florida","sortDate":"2000-12-05","keywords":"Event","eventAddress":"S. Flagler Drive and Evernia St.","dma":"West Palm Beach - Fort Pierce","seourl":"http://www.active.com/running/west-palm-beach-fl/the-palm-beaches-marathon-festival-2010","country":"United States","category":"Activities","market":"West Palm Beach - Fort Pierce","assetTypeId":"EA4E860A-9DCD-4DAA-A7CA-4A77AD194F65","contactName":"Iva Grady","eventZip":"33401","latitude":"26.72339","UpdateDateTime":"9/1/2010 6:09:21 PM","startDate":"2010-12-05","state":"Florida","mediaType":["Event","Event\\5K","Event\\Half Marathon","Event\\Marathon","Event\\Relay"],"estParticipants":"8000","assetId":["EA86AD3C-FBBA-403A-9DDB-1D211C210225","ea86ad3c-fbba-403a-9ddb-1d211c210225"],"participationCriteria":"All","onlineDonationAvailable":"0","assetName":["The Palm Beaches Marathon Festival","The Palm Beaches Marathon Festival"],"eventURL":"http://www.pbmarathon.com","zip":"33401","contactPhone":"561-833-3711 ex. 222","contactEmail":"info@marathonofthepalmbeaches.com","onlineMembershipAvailable":"0","trackbackurl":"http://www.active.com/running/west-palm-beach-fl/the-palm-beaches-marathon-festival-2010","onlineRegistrationAvailable":"1","image1":"http://www.active.com/images/events/hotrace.gif","lastModifiedDate":"2010-09-10","channel":"Running"}},{"escapedUrl":"http://www.active.com/running/encino-ca/2nd-annual-wespark-10k-run-and-5k-run-walk-2010","language":"en","title":"2nd Annual weSPARK 10K Run \u0026amp; 5K Run Walk | Encino \u003cb\u003e...\u003c/b\u003e","url":"http://www.active.com/running/encino-ca/2nd-annual-wespark-10k-run-and-5k-run-walk-2010","summary":"","meta":{"eventDate":"2010-11-14T08:00:00-08:00","location":"Balboa Park/Lake Balboa","tag":["event:10","Running:10"],"endDate":"2010-11-14","eventLongitude":"-118.4924","splitMediaType":["Event","10K","5K"],"lastModifiedDateTime":"2010-08-23 13:16:00.843","locationName":"Balboa Park/Lake Balboa","endTime":"8:00:00","google-site-verification":"","city":"Encino","startTime":"8:00:00","eventId":"1847738","description":"","longitude":"-118.4924","substitutionUrl":"1847738","eventLatitude":"34.19933","eventState":"California","sortDate":"2000-11-14","keywords":"Event","eventAddress":"6335 Woodley Avenue","dma":"Los Angeles","seourl":"http://www.active.com/running/encino-ca/2nd-annual-wespark-10k-run-and-5k-run-walk-2010","country":"United States","category":"Activities","market":"Los Angeles","contactName":"Lilliane Ballesteros","assetTypeId":"EA4E860A-9DCD-4DAA-A7CA-4A77AD194F65","eventZip":"91406","latitude":"34.19933","UpdateDateTime":"9/1/2010 6:09:21 PM","startDate":"2010-11-14","state":"California","mediaType":["Event","Event\\10K","Event\\5K"],"estParticipants":"1400","assetId":["D9A22F33-8A14-4175-8D5B-D11578212A98","d9a22f33-8a14-4175-8d5b-d11578212a98"],"participationCriteria":"All","onlineDonationAvailable":"0","assetName":["2nd Annual weSPARK 10K Run \u0026 5K Run Walk","2nd Annual weSPARK 10K Run \u0026 5K Run Walk"],"eventURL":"http://www.wespark.org","zip":"91406","contactPhone":"818-906-3022","contactEmail":"lilliane@wespark.org","onlineMembershipAvailable":"0","trackbackurl":"http://www.active.com/running/encino-ca/2nd-annual-wespark-10k-run-and-5k-run-walk-2010","onlineRegistrationAvailable":"1","image1":"http://www.active.com/images/events/hotrace.gif","lastModifiedDate":"2010-08-23","channel":["Running","Walking"]}},{"escapedUrl":"http://www.active.com/running/los-angeles-playa-del-rey-ca/heroes-of-hope-race-for-research-2010","language":"en","title":"Heroes of Hope Race for Research | Los Angeles, Playa Del \u003cb\u003e...\u003c/b\u003e","url":"http://www.active.com/running/los-angeles-playa-del-rey-ca/heroes-of-hope-race-for-research-2010","summary":"","meta":{"eventDate":"2010-11-07T08:00:00-08:00","location":"Dockweiler State Beach","tag":["event:10","Running:10"],"endDate":"2010-11-07","eventLongitude":"-118.4392","splitMediaType":["Event","10K","5K"],"lastModifiedDateTime":"2010-09-09 07:15:48.193","locationName":"Dockweiler State Beach","endTime":"8:00:00","google-site-verification":"","city":"Los Angeles, Playa Del Rey","startTime":"8:00:00","eventId":"1858905","description":"","longitude":"-118.4392","substitutionUrl":"1858905","eventLatitude":"33.9495","eventState":"California","sortDate":"2000-11-07","keywords":"Event","eventAddress":"8255 Vista Del Mar Blvd","dma":"Los Angeles","seourl":"http://www.active.com/running/los-angeles-playa-del-rey-ca/heroes-of-hope-race-for-research-2010","country":"United States","category":"Activities","market":"Los Angeles","assetTypeId":"EA4E860A-9DCD-4DAA-A7CA-4A77AD194F65","contactName":"Lisa Kaminsky-Millar","eventZip":"90293","latitude":"33.9495","UpdateDateTime":"9/1/2010 6:09:21 PM","startDate":"2010-11-07","state":"California","mediaType":["Event","Event\\10K","Event\\5K"],"estParticipants":"1000","assetId":["0D92AB40-ED0B-4657-B00B-480B38062F1C","0d92ab40-ed0b-4657-b00b-480b38062f1c"],"participationCriteria":"All","onlineDonationAvailable":"1","assetName":["Heroes of Hope Race for Research","Heroes of Hope Race for Research"],"eventURL":"http://www.heroesofhoperace.org","zip":"90293","contactPhone":"1-866-48-4CURE","contactEmail":"heroesofhoperace@gmail.com","onlineMembershipAvailable":"0","trackbackurl":"http://www.active.com/running/los-angeles-playa-del-rey-ca/heroes-of-hope-race-for-research-2010","onlineRegistrationAvailable":"1","image1":"http://www.active.com/images/events/hotrace.gif","lastModifiedDate":"2010-09-09","channel":"Running"}},{"escapedUrl":"http://www.active.com/running/calabasas-ca/calabasas-classic-5k-10k-runs-2010","language":"en","title":"Calabasas Classic 2010 - 5k 10k Runs | Calabasas, California \u003cb\u003e...\u003c/b\u003e","url":"http://www.active.com/running/calabasas-ca/calabasas-classic-5k-10k-runs-2010","summary":"","meta":{"eventDate":"2010-11-14T08:00:00-08:00","location":"Calabasas Park Centre","tag":["event:10","Green:10","Running:10"],"endDate":"2010-11-14","eventLongitude":"-118.6789","splitMediaType":["Event","1 mile","10K","5K"],"lastModifiedDateTime":"2010-09-14 21:02:55.007","locationName":"Calabasas Park Centre","endTime":"8:00:00","google-site-verification":"","city":"Calabasas","startTime":"8:00:00","eventId":"1810531","description":"","longitude":"-118.6789","substitutionUrl":"1810531","eventLatitude":"34.12794","eventState":"California","sortDate":"2000-11-14","keywords":"Event","eventAddress":"23975 Park Sorrento","dma":"Los Angeles","seourl":"http://www.active.com/running/calabasas-ca/calabasas-classic-5k-10k-runs-2010","country":"United States","category":"Activities","market":"Los Angeles","contactName":"Julie Talbert","assetTypeId":"EA4E860A-9DCD-4DAA-A7CA-4A77AD194F65","eventZip":"91302","latitude":"34.12794","UpdateDateTime":"9/1/2010 6:09:21 PM","startDate":"2010-11-14","state":"California","mediaType":["Event","Event\\1 mile","Event\\10K","Event\\5K"],"estParticipants":"2500","assetId":["11B01475-8C65-4F9C-A4AC-2A3FA55FE8CD","11b01475-8c65-4f9c-a4ac-2a3fa55fe8cd"],"participationCriteria":"All","onlineDonationAvailable":"0","assetName":["Calabasas Classic 2010 - 5k 10k Runs","Calabasas Classic 2010 - 5k 10k Runs"],"eventURL":"http://www.calabasasclassic.com","zip":"91302","contactPhone":"818-715-0428","contactEmail":"rot10kd@yahoo.com","onlineMembershipAvailable":"0","trackbackurl":"http://www.active.com/running/calabasas-ca/calabasas-classic-5k-10k-runs-2010","onlineRegistrationAvailable":"1","image1":"http://www.active.com/images/events/hotrace.gif","lastModifiedDate":"2010-09-14","channel":["Running","Walking"]}},{"escapedUrl":"http://www.active.com/triathlon/miami-fl/ironman-703-miami-2010","language":"en","title":"IRONMAN 70.3 MIAMI | Miami, Florida 33132 | Saturday \u003cb\u003e...\u003c/b\u003e","url":"http://www.active.com/triathlon/miami-fl/ironman-703-miami-2010","summary":"","meta":{"startDate":"2010-10-30","eventDate":"2010-10-30T07:00:00-07:00","location":"Bayfront Park - Downtown Miami","tag":["event:10","Triathlon:10"],"state":"Florida","eventLongitude":"-80.18975","endDate":"2010-10-30","lastModifiedDateTime":"2010-05-10 11:16:04.46","splitMediaType":["Event","Ironman","Long Course","\u003ddifficulty:Advanced","\u003ddifficulty:Intermediate"],"locationName":"Bayfront Park - Downtown Miami","endTime":"7:00:00","mediaType":["Event","Event\\Ironman","Event\\Long Course","\u003ddifficulty:Advanced","\u003ddifficulty:Intermediate"],"city":"Miami","google-site-verification":"","startTime":"7:00:00","assetId":["72FAE9F7-5C68-4DF8-B01C-B63AC188A06A","72fae9f7-5c68-4df8-b01c-b63ac188a06a"],"eventId":"1800302","participationCriteria":"Adult,Family,Men,Women","description":"","longitude":"-80.18975","onlineDonationAvailable":"false","substitutionUrl":"1800302","assetName":["IRONMAN 70.3 MIAMI","IRONMAN 70.3 MIAMI"],"zip":"33132","contactPhone":"3053072285","eventLatitude":"25.78649","eventState":"Florida","sortDate":"2000-10-30","keywords":"Event","eventAddress":"301 N. Biscayne Blvd.","contactEmail":"jennifer@miamitrievents.com","onlineMembershipAvailable":"false","trackbackurl":"http://www.active.com/triathlon/miami-fl/ironman-703-miami-2010","country":"United States","onlineRegistrationAvailable":"true","category":"Activities","image1":"http://www.active.com/images/events/hotrace.gif","assetTypeId":"EA4E860A-9DCD-4DAA-A7CA-4A77AD194F65","lastModifiedDate":"2010-05-10","eventZip":"33132","UpdateDateTime":"9/1/2010 6:09:21 PM","latitude":"25.78649","channel":"Triathlon"}},{"escapedUrl":"http://www.active.com/triathlon/san-juan-na/ironman-703-san-juan-2011-ig329","language":"en","title":"2011 Ironman 70.3 San Juan | San Juan, 00901 | Saturday \u003cb\u003e...\u003c/b\u003e","url":"http://www.active.com/triathlon/san-juan-na/ironman-703-san-juan-2011-ig329","summary":"","meta":{"startDate":"2011-03-19","eventDate":"2011-03-19T07:00:00-07:00","location":"Los Rosales Street, San Geronimo Grounds","tag":["event:10","Triathlon:10"],"state":"N/A","endDate":"2011-03-19","eventLongitude":"-66.10572","lastModifiedDateTime":"2010-06-15 14:15:08.557","splitMediaType":["Event","Ironman","\u003ddifficulty:Advanced"],"locationName":"Los Rosales Street, San Geronimo Grounds","endTime":"7:00:00","mediaType":["Event","Event\\Ironman","\u003ddifficulty:Advanced"],"city":"San Juan","google-site-verification":"","startTime":"7:00:00","assetId":["F6B819B9-9CC1-4E67-A87D-11518B05D4F3","f6b819b9-9cc1-4e67-a87d-11518b05d4f3"],"eventId":"1841595","participationCriteria":"Adult","description":"","longitude":"-66.10572","onlineDonationAvailable":"false","substitutionUrl":"1841595","assetName":["2011 Ironman 70.3 San Juan","2011 Ironman 70.3 San Juan"],"zip":"00901","contactPhone":"813-868-5940","eventLatitude":"18.46633","sortDate":"2001-03-19","keywords":"Event","contactEmail":"info@bnsportsllc.com","onlineMembershipAvailable":"false","trackbackurl":"http://www.active.com/triathlon/san-juan-na/ironman-703-san-juan-2011-ig329","country":"Puerto Rico","onlineRegistrationAvailable":"true","category":"Activities","image1":"http://www.active.com/images/events/hotrace.gif","assetTypeId":"EA4E860A-9DCD-4DAA-A7CA-4A77AD194F65","lastModifiedDate":"2010-06-15","eventZip":"00901","latitude":"18.46633","UpdateDateTime":"9/1/2010 6:09:21 PM","channel":"Triathlon"}},{"escapedUrl":"http://www.active.com/triathlon/st-george-ut/ford-ironman-st-george-2011","language":"en","title":"2011 Ford Ironman St. George | St. George, Utah 84737 \u003cb\u003e...\u003c/b\u003e","url":"http://www.active.com/triathlon/st-george-ut/ford-ironman-st-george-2011","summary":"","meta":{"startDate":"2011-05-07","eventDate":"2011-05-07T07:00:00-07:00","location":"Sand Hollow State Park,","tag":["event:10","Triathlon:10"],"state":"Utah","eventLongitude":"-113.1508","endDate":"2011-05-07","lastModifiedDateTime":"2010-07-22 11:15:08.46","splitMediaType":["Event","Ironman","Long Course"],"locationName":"Sand Hollow State Park,","endTime":"7:00:00","mediaType":["Event","Event\\Ironman","Event\\Long Course"],"city":"St. George","google-site-verification":"","startTime":"7:00:00","assetId":["A10B5BC1-BD95-4AFE-A1F6-35F6099E3636","a10b5bc1-bd95-4afe-a1f6-35f6099e3636"],"eventId":"1848350","participationCriteria":"All","description":"","longitude":"-113.1508","onlineDonationAvailable":"false","substitutionUrl":"1848350","assetName":["2011 Ford Ironman St. George","2011 Ford Ironman St. George"],"zip":"84737","contactPhone":"813-868-5940","eventLatitude":"37.15574","eventState":"Utah","sortDate":"2001-05-07","keywords":"Event","eventAddress":"4405 West 3600 South","contactEmail":"stgeorge@ironman.com","onlineMembershipAvailable":"false","trackbackurl":"http://www.active.com/triathlon/st-george-ut/ford-ironman-st-george-2011","country":"United States","onlineRegistrationAvailable":"true","category":"Activities","image1":"http://www.active.com/images/events/hotrace.gif","assetTypeId":"3BF82BBE-CF88-4E8C-A56F-78F5CE87E4C6","lastModifiedDate":"2010-07-22","eventZip":"84737","UpdateDateTime":"9/1/2010 6:09:21 PM","latitude":"37.15574","channel":"Triathlon"}},{"escapedUrl":"http://www.active.com/triathlon/galveston-tx/memorial-hermann-ironman-703-texas-and-lonestar-sprint-triathlon-2011","language":"en","title":"2011 Memorial Hermann Ironman 70.3 Texas \u0026amp; Lonestar \u003cb\u003e...\u003c/b\u003e","url":"http://www.active.com/triathlon/galveston-tx/memorial-hermann-ironman-703-texas-and-lonestar-sprint-triathlon-2011","summary":"","meta":{"startDate":"2011-04-09","eventDate":"2011-04-09T07:00:00-07:00","location":"Moody Gardens","state":"Texas","endDate":"2011-04-10","eventLongitude":"-94.90395","lastModifiedDateTime":"2010-05-12 09:16:41.91","splitMediaType":["Event","Ironman","Long Course","Sprint"],"locationName":"Moody Gardens","endTime":"7:00:00","mediaType":["Event","Event\\Ironman","Event\\Long Course","Event\\Sprint"],"city":"Galveston","google-site-verification":"","startTime":"7:00:00","assetId":["A40CC533-D502-4953-8157-DBB64D7FC4C2","a40cc533-d502-4953-8157-dbb64d7fc4c2"],"eventId":"1859810","participationCriteria":"All","description":"","longitude":"-94.90395","onlineDonationAvailable":"false","substitutionUrl":"1859810","assetName":["2011 Memorial Hermann Ironman 70.3 Texas \u0026 Lonestar Sprint Triathlon","2011 Memorial Hermann Ironman 70.3 Texas \u0026 Lonestar Sprint Triathlon"],"zip":"77554","contactPhone":"813-868-5940","eventLatitude":"29.24699","eventState":"Texas","sortDate":"2001-04-09","keywords":"Event","contactEmail":"texas70.3@ironman.com","onlineMembershipAvailable":"false","trackbackurl":"http://www.active.com/triathlon/galveston-tx/memorial-hermann-ironman-703-texas-and-lonestar-sprint-triathlon-2011","country":"United States","onlineRegistrationAvailable":"true","category":"Activities","image1":"http://www.active.com/images/events/hotrace.gif","assetTypeId":"3BF82BBE-CF88-4E8C-A56F-78F5CE87E4C6","lastModifiedDate":"2010-05-12","eventZip":"77554","latitude":"29.24699","UpdateDateTime":"9/1/2010 6:09:21 PM","channel":"Triathlon"}}]}',
|
292
|
+
# :status => ["200", "Found"])
|
293
|
+
# This query is throwing this error "source did not contain any JSON!" and we need to handle it
|
294
|
+
# s = Search.search( {:radius=>"50", :keywords=>"", :page=>1, :num_results=>10, :location=>"0"} )
|
295
|
+
pending
|
296
|
+
end
|
297
|
+
|
314
298
|
end
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
299
|
+
describe "Call Live Data" do
|
300
|
+
|
301
|
+
it "should find only events in the future" do
|
302
|
+
s = Search.search( { :keywords => ["running"] } )
|
303
|
+
s.should have(10).results
|
304
|
+
s.results.each do |a|
|
305
|
+
a.start_date.should satisfy { |d|
|
306
|
+
d >= Date.today
|
307
|
+
}
|
308
|
+
end
|
309
|
+
end
|
310
|
+
|
311
|
+
it "should find only events with in a range" do
|
312
|
+
s = Search.search( {:start_date => Date.new(2010,1,1), :end_date => Date.new(2010,2,1)} )
|
313
|
+
s.should have(10).results
|
314
|
+
s.results.each do |a|
|
315
|
+
a.start_date.should satisfy { |d|
|
316
|
+
d >= Date.new(2010,1,1) and d <= Date.new(2010,2,1)
|
317
|
+
}
|
318
|
+
end
|
319
|
+
end
|
320
|
+
|
321
|
+
it "should find events after the start date" do
|
322
|
+
s = Search.search( {:start_date => Date.new(2010,1,1), :num_results => 50} )
|
323
|
+
s.should have(50).results
|
324
|
+
s.results.each do |a|
|
325
|
+
a.start_date.should satisfy { |d|
|
326
|
+
d >= Date.new(2010,1,1)
|
327
|
+
}
|
328
|
+
end
|
329
|
+
s.results.each do |a|
|
330
|
+
a.asset_id.should_not be_nil
|
331
|
+
end
|
332
|
+
end
|
333
|
+
|
334
|
+
it "should search by keyword" do
|
335
|
+
s = Search.search( {:keywords => "Running Race"} )
|
336
|
+
s.results.should have_at_least(1).items
|
337
|
+
end
|
338
|
+
|
339
|
+
it "shouls search by city" do
|
340
|
+
s = Search.search({:city=>"Oceanside"})
|
341
|
+
s.results.should have_at_least(1).items
|
342
|
+
end
|
343
|
+
# our model should be updated to handle multiple categories
|
344
|
+
# I'm sure running is with in all of these events but we're only storing 1.
|
345
|
+
# it "should find only running activities" do
|
346
|
+
# s = Search.search( {:channels => [:running],
|
347
|
+
# :start_date => Date.new(2010,1,1), :num_results => 20} )
|
348
|
+
# s.should have(20).results
|
349
|
+
# s.results.each do |a|
|
350
|
+
# puts "-#{a.category}-"
|
351
|
+
# a.category.should satisfy { |d|
|
352
|
+
# d.include?('Running' )
|
353
|
+
# }
|
354
|
+
# end
|
355
|
+
# end
|
356
|
+
|
357
|
+
it "should find yoga activities by channel" do
|
358
|
+
s = Search.search( {:channels => [:yoga]} )
|
359
|
+
s.should have_at_least(1).results
|
360
|
+
end
|
361
|
+
|
362
|
+
it "should not set sort to an empty string" do
|
363
|
+
# s = Search.search( {:sort => ""} )
|
364
|
+
# s.sort.should_not be_empty
|
365
|
+
pending
|
366
|
+
end
|
367
|
+
|
368
|
+
it "should get results given these area codes" do
|
369
|
+
s = Search.search( {:zips => "92121, 92078, 92114"} )
|
370
|
+
s.should be_an_instance_of Search
|
371
|
+
s.results.should_not be_empty
|
372
|
+
end
|
373
|
+
|
374
|
+
it "should find activities that have been recently added" do
|
375
|
+
s = Search.search( {:sort=>Sort.DATE_DESC})
|
376
|
+
s.should be_an_instance_of Search
|
377
|
+
s.results.should_not be_empty
|
378
|
+
s.results.each do |a|
|
379
|
+
DateTime.parse(a.gsa.last_modified).should satisfy { |d|
|
380
|
+
d >= DateTime.now-2
|
381
|
+
}
|
382
|
+
end
|
383
|
+
end
|
384
|
+
|
385
|
+
it "should find upcoming events"
|
386
|
+
|
387
|
+
it "should find popular events"
|
388
|
+
|
389
|
+
it "should order by trending with params"
|
390
|
+
# results = Search.search( {:channels => ['Running'], :sort => 'trending'} )
|
391
|
+
# end
|
392
|
+
|
393
|
+
it "should order by RELEVANCE"
|
394
|
+
|
395
|
+
it "should order by date DATE_ASC"
|
396
|
+
|
397
|
+
it "should order by date DATE_DESC"
|
398
|
+
|
399
|
+
it "should order by the date created" do
|
400
|
+
# results = Search.search( {:channels => ['Running'], :sort => 'created_at_asc'} )
|
401
|
+
pending
|
402
|
+
end
|
403
|
+
|
319
404
|
end
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
# puts "-#{a.category}-"
|
329
|
-
# a.category.should satisfy { |d|
|
330
|
-
# d.include?('Running' )
|
331
|
-
# }
|
332
|
-
# end
|
333
|
-
# end
|
334
|
-
|
335
|
-
it "should find yoga activities by channel" do
|
336
|
-
s = Search.search( {:channels => [:yoga]} )
|
337
|
-
s.should have(10).results
|
405
|
+
describe "Parametric search" do
|
406
|
+
describe "Parametric search for running channel" do
|
407
|
+
it "should find by splitMediaType for the Running channel" do
|
408
|
+
# http://developer.active.com/docs/Activecom_Search_API_Reference
|
409
|
+
end
|
410
|
+
end
|
411
|
+
describe "Parametric search for triathlon channel" do
|
412
|
+
end
|
338
413
|
end
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
414
|
+
|
415
|
+
describe "Find things within X miles to me" do
|
416
|
+
it "should find activities within 20 miles of me" do
|
417
|
+
location = {:latitude=>"37.785895", :longitude=>"-122.40638"}
|
418
|
+
Search.search(location).results.should_not be_empty
|
419
|
+
pending
|
420
|
+
end
|
421
|
+
it "shoule be near this location"
|
344
422
|
end
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
423
|
+
|
424
|
+
describe "Address" do
|
425
|
+
it "should have a valid address, city, state, zip, lat, lng if the event was from ?___ATS__"
|
426
|
+
it "should have a valid address, city, state, zip, lat, lng if the event was from ?___Works__"
|
427
|
+
it "should have a valid address, city, state, zip, lat, lng if the event was from ?___NET__"
|
350
428
|
end
|
351
429
|
|
352
|
-
it "should find activities that have been recently added"
|
353
|
-
|
354
|
-
it "should find upcoming events"
|
355
|
-
|
356
|
-
it "should find popular events"
|
357
|
-
|
358
|
-
it "should order by trending with params"
|
359
|
-
# results = Search.search( {:channels => ['Running'], :sort => 'trending'} )
|
360
|
-
# end
|
361
|
-
|
362
|
-
it "should order by RELEVANCE"
|
363
|
-
|
364
|
-
it "should order by date DATE_ASC"
|
365
|
-
|
366
|
-
it "should order by date DATE_DESC"
|
367
|
-
|
368
|
-
it "should order by the date created" do
|
369
|
-
# results = Search.search( {:channels => ['Running'], :sort => 'created_at_asc'} )
|
370
|
-
pending
|
371
|
-
end
|
372
|
-
|
373
430
|
end
|
374
431
|
|
375
432
|
|
376
|
-
describe "Parametric search" do
|
377
|
-
describe "Parametric search for running channel" do
|
378
|
-
it "should find by splitMediaType for the Running channel" do
|
379
|
-
# http://developer.active.com/docs/Activecom_Search_API_Reference
|
380
|
-
end
|
381
|
-
end
|
382
|
-
describe "Parametric search for triathlon channel" do
|
383
|
-
end
|
384
|
-
end
|
385
433
|
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
434
|
+
|
435
|
+
|
436
|
+
|
437
|
+
|
438
|
+
|
439
|
+
|
440
|
+
|
393
441
|
|
394
442
|
|
395
443
|
|