Skip to content

Commit

Permalink
Adding tests and some test data for ride streams.
Browse files Browse the repository at this point in the history
  • Loading branch information
anolson committed Mar 27, 2011
1 parent d6e8222 commit 6ece846
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
5 changes: 5 additions & 0 deletions test/helper.rb
Expand Up @@ -76,6 +76,11 @@ def ride_efforts_json
'{"ride":{"name":"02/28/10 San Francisco, CA","id":77563},"efforts":[{"elapsed_time":209,"segment":{"name":"Panhandle to GGP","id":623323},"id":2231990},{"elapsed_time":63,"segment":{"name":"Conservatory of Flowers Hill","id":626358},"id":2543643},{"elapsed_time":409,"segment":{"name":"GGB Northbound","id":616515},"id":1523485},{"elapsed_time":470,"segment":{"name":"Bridgeway Vigilance Northbound","id":623072},"id":2201113},{"elapsed_time":126,"segment":{"name":"Mike\'s Bikes Sprint","id":626575},"id":2605695},{"elapsed_time":317,"segment":{"name":"Miller Ave TT","id":613995},"id":1324431},{"elapsed_time":776,"segment":{"name":"Brad\'s Climb (formerly Jim\'s Climb) (MV to 4Cs)","id":361375},"id":688442},{"elapsed_time":1185,"segment":{"name":"Mill Valley to Panoramic via Marion Ave","id":718},"id":688443},{"elapsed_time":2148,"segment":{"name":"Mill Valley to Pantoll","id":622149},"id":2078609},{"elapsed_time":1268,"segment":{"name":"4 Corners to Bootjack","id":609323},"id":840745},{"elapsed_time":1498,"segment":{"name":"4 Corners to Pantoll Station","id":625065},"id":2419895},{"elapsed_time":598,"segment":{"name":"Panoramic to Pan Toll","id":156},"id":688432},{"elapsed_time":547,"segment":{"name":"Stinson Beach Descent","id":617195},"id":1594150},{"elapsed_time":471,"segment":{"name":"Stinson Climb 1, south ","id":157},"id":688433},{"elapsed_time":1582,"segment":{"name":"Stinson Beach to Muir Beach","id":615929},"id":1469576},{"elapsed_time":1237,"segment":{"name":"Steep Ravine to Pelican Inn","id":618085},"id":1670144},{"elapsed_time":369,"segment":{"name":"Highway 1 South from Cold Stream","id":719},"id":688439},{"elapsed_time":656,"segment":{"name":"Muir Beach East","id":158},"id":688434},{"elapsed_time":240,"segment":{"name":"Panoramic to Mill Valley descent","id":611080},"id":1011931},{"elapsed_time":125,"segment":{"name":"Thread the Needle","id":616316},"id":1499338},{"elapsed_time":574,"segment":{"name":"Bridgeway Vigilance","id":614103},"id":1332656},{"elapsed_time":512,"segment":{"name":"Sausalito to GGB Climb","id":612804},"id":1214916},{"elapsed_time":407,"segment":{"name":"Sausalito to GGB","id":132513},"id":688436},{"elapsed_time":399,"segment":{"name":"GGB Southbound","id":597755},"id":771451},{"elapsed_time":342,"segment":{"name":"Presidio Wiggle","id":609096},"id":819402},{"elapsed_time":283,"segment":{"name":"Extended Presidio Sprint ","id":623484},"id":2259387},{"elapsed_time":164,"segment":{"name":"Presidio Sprint","id":318917},"id":688440},{"elapsed_time":86,"segment":{"name":"Oak Street (Schrader to Baker)","id":611238},"id":1032310}]}'
end

def ride_streams_json
#curl "http://www.strava.com/api/v1/streams/77563"
File.new('streams.json').gets
end

def segments_index_json
#curl http://www.strava.com/api/v1/segments?name=hawk%20hill
'{"segments":[{"name":"Hawk Hill Saddle","id":99243},{"name":"Hawk Hill","id":229781},{"name":"Hawk Hill from Bunker Road","id":229783},{"name":"Ham Hawk Hill | PD","id":243831},{"name":"Hawk Hill from Fort Baker","id":461025},{"name":"Hawk Hill from Sausalito","id":522551},{"name":"Hawk Hill Backside Descent","id":589138},{"name":"Backside Hawk Hill Climb","id":615706},{"name":"Hawk Hill Saddle from Sausalito","id":617665},{"name":"Hawk Hill Saddle from Ft Baker","id":619494}]}'
Expand Down
1 change: 1 addition & 0 deletions test/streams.json

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions test/test_rides.rb
Expand Up @@ -183,4 +183,21 @@ def test_ride_efforts
assert result.first.segment.is_a?(StravaApi::Segment)
assert result.first.segment.name == "Panhandle to GGP"
end

def test_ride_streams
#curl "http://www.strava.com/api/v1/streams/77563"
api_result = JSON.parse ride_streams_json
api_result.stubs(:parsed_response).returns("")
StravaApi::Base.stubs(:get).with('/streams/77563', { :query => {} }).returns(api_result)

result = @s.ride_streams(77563)

assert result.is_a?(StravaApi::Streams)
assert !result.altitude.empty?
assert !result.distance.empty?
assert !result.heartrate.empty?
assert !result.latlng.empty?
assert !result.time.empty?
assert !result.watts_calc.empty?
end
end

0 comments on commit 6ece846

Please sign in to comment.