Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

rename to StravaApi

  • Loading branch information...
commit fc551b9a1bcc0dd5680102d6f75de2953fef82bd 1 parent e7296ad
Steven Chanin authored

Showing 30 changed files with 286 additions and 202 deletions. Show diff stats Hide diff stats

  1. +33 33 README.rdoc
  2. +4 4 Rakefile
  3. +22 0 lib/strava-api.rb
  4. +5 5 lib/{strava → strava-api}/base.rb
  5. +1 1  lib/{strava → strava-api}/bike.rb
  6. +1 1  lib/{strava → strava-api}/club.rb
  7. +3 3 lib/{strava → strava-api}/clubs.rb
  8. +1 1  lib/{strava → strava-api}/effort.rb
  9. +1 1  lib/{strava → strava-api}/efforts.rb
  10. +1 1  lib/{strava → strava-api}/exceptions.rb
  11. +2 2 lib/{strava → strava-api}/hash_based_store.rb
  12. +1 1  lib/{strava → strava-api}/member.rb
  13. +1 1  lib/{strava → strava-api}/ride.rb
  14. +2 2 lib/{strava → strava-api}/rides.rb
  15. +1 1  lib/{strava → strava-api}/segment.rb
  16. +1 1  lib/{strava → strava-api}/segments.rb
  17. +0 22 lib/strava.rb
  18. +84 0 strava-api.gemspec
  19. +13 13 strava.gemspec
  20. +1 1  test/helper.rb
  21. +7 7 test/test_base.rb
  22. +6 6 test/test_club.rb
  23. +13 13 test/test_clubs.rb
  24. +4 4 test/test_effort.rb
  25. +11 11 test/test_hash_based_store.rb
  26. +6 6 test/test_ride.rb
  27. +26 26 test/test_rides.rb
  28. +8 8 test/test_segment.rb
  29. +20 20 test/test_segments.rb
  30. +7 7 test/test_strava.rb
66 README.rdoc
Source Rendered
... ... @@ -1,10 +1,10 @@
1   -= strava
  1 += strava-api
2 2
3 3 Strava (http://www.strava.com/) allows access to it's data via a JSON api. This gem wraps that API an allows you to interact with Ruby classes instead.
4 4
5 5 = Installation
6 6
7   - gem install strava
  7 + gem install strava-api
8 8
9 9 depending on your installation, you may need to use sudo
10 10
@@ -15,40 +15,40 @@ httparty [http://github.com/jnunemaker/httparty]
15 15 mocha (only if you want to run the tests) [http://github.com/floehopper/mocha]
16 16
17 17 = Usage
18   -Strava is a Ruby wrapper for working with Strava API.
  18 +StravaApi is a Ruby wrapper for working with Strava API.
19 19
20   -== Loading the Strava gem classes
  20 +== Loading the StravaApi gem classes
21 21 Before you can use the gem's classes and methods, you have to load them
22 22
23 23 in a Rails app
24   - require 'strava'
  24 + require 'strava-api'
25 25
26 26 in a plain irb session
27 27 require 'rubygems'
28   - require 'strava'
  28 + require 'strava-api'
29 29
30   -== Creating a Strava::Base object
31   -In order to interact with the Strava API, you need a Strava::Base object
  30 +== Creating a StravaApi::Base object
  31 +In order to interact with the Strava API, you need a StravaApi::Base object
32 32
33   - s = Strava::Base.new
  33 + s = StravaApi::Base.new
34 34
35 35 == Clubs
36 36 The Strava API allows you to search for clubs by name,
37 37
38   - #returns an array of Strava::Club objects (each object only has minimal attributes)
  38 + #returns an array of StravaApi::Club objects (each object only has minimal attributes)
39 39 s.clubs("part of club name")
40 40
41 41 get full details on a club,
42 42
43   - #returns a Strava::Club with full attributes
  43 + #returns a StravaApi::Club with full attributes
44 44 s.club_show(club_id)
45 45
46 46 and see the members of a club
47 47
48   - #returns an array of Strava::Member objects
  48 + #returns an array of StravaApi::Member objects
49 49 s.club_members(club_id)
50 50
51   -Alternatively, you can work in a more object oriented way. The .clubs("part of club name") method returns an array of Strava::Club objects. The Strava::Club object makes club_show and club_members available as instance methods
  51 +Alternatively, you can work in a more object oriented way. The .clubs("part of club name") method returns an array of StravaApi::Club objects. The StravaApi::Club object makes club_show and club_members available as instance methods
52 52
53 53 my_club = s.clubs("Fred's Riders").first
54 54 my_club.show
@@ -67,7 +67,7 @@ Using the API, you can search for rides using any combination of criteria
67 67
68 68 To get set of rides (by club),
69 69
70   - #returns an array of up to 50 Strava::Ride objects (each object has minimal attributes)
  70 + #returns an array of up to 50 StravaApi::Ride objects (each object has minimal attributes)
71 71 s.rides(:club_id => club_id)
72 72
73 73 by athlete and start date
@@ -78,15 +78,15 @@ etc
78 78
79 79 To see details on a particular ride
80 80
81   - #returns a Strava::Ride with full attributes
  81 + #returns a StravaApi::Ride with full attributes
82 82 s.ride_show(ride_id)
83 83
84 84 A ride is composed of a list of efforts (time, etc spent on each segment which makes up part of the ride). To see the efforts for a particular ride,
85 85
86   - #returns an array of Strava::Effort objects (each object has minimal attributes)
  86 + #returns an array of StravaApi::Effort objects (each object has minimal attributes)
87 87 s.ride_efforts(ride_id)
88 88
89   -Alternatively, you can work in a more object oriented way. The .rides(:filter => value) method returns an array of Strava::Ride objects. The Strava::Ride object makes ride_show and ride_efforts available as instance methods
  89 +Alternatively, you can work in a more object oriented way. The .rides(:filter => value) method returns an array of StravaApi::Ride objects. The StravaApi::Ride object makes ride_show and ride_efforts available as instance methods
90 90
91 91 my_ride = s.rides(:club_id => my_club.id).first
92 92 my_ride.show
@@ -111,17 +111,17 @@ Rides can be thought of as a sequence of segments (e.g. my "trip to the kitchen"
111 111
112 112 To find a segment by name,
113 113
114   - #returns an array of Strava::Segment objects (each object has minimal attributes)
  114 + #returns an array of StravaApi::Segment objects (each object has minimal attributes)
115 115 s.segments("part of segment name")
116 116
117 117 to see measurements / details on a segment,
118 118
119   - #returns a Strava::Segment with full attributes
  119 + #returns a StravaApi::Segment with full attributes
120 120 s.segment_show(segment_id)
121 121
122 122 to see who rode a segment and how they did,
123 123
124   - #returns an array of up to 50 Strava::Effort objects (each object has minimal attributes)
  124 + #returns an array of up to 50 StravaApi::Effort objects (each object has minimal attributes)
125 125 s.segment_efforts(segment_id, {:param => value})
126 126
127 127 To refine the data returned by segment_efforts, you can pass any combination of optional parameters:
@@ -141,9 +141,9 @@ Example
141 141 #only shows each riders best time
142 142 s.segment_efforts(segment_id, :club_id => club_id, :start_date => Date.civil(2010,7,1), :best => true)
143 143
144   -Alternatively, you can work in a more object oriented way. Given a Strava::Segment object returned by another method call, you can get it's full details and the efforts made on that segment using the .show and .efforts instance methods
  144 +Alternatively, you can work in a more object oriented way. Given a StravaApi::Segment object returned by another method call, you can get it's full details and the efforts made on that segment using the .show and .efforts instance methods
145 145
146   - #my_segment is a Strava::Segment
  146 + #my_segment is a StravaApi::Segment
147 147
148 148 my_segment.show
149 149
@@ -157,31 +157,31 @@ See the instructions above for an example of how this works with .rides.
157 157 == Efforts
158 158 To get full details on an effort (i.e. specifics on how a rider did on a specific stretch of a ride), you
159 159
160   - ##returns a Strava::Effort with full attributes
  160 + ##returns a StravaApi::Effort with full attributes
161 161 s.effort_show(effort_id)
162 162
163   -If you have an efforts object (Strava::Effort) that has been returned by another call (for example my_ride.efforts), you can use the .show method to fill out the missing details on that effort
  163 +If you have an efforts object (StravaApi::Effort) that has been returned by another call (for example my_ride.efforts), you can use the .show method to fill out the missing details on that effort
164 164
165 165 my_ride.efforts.first.show
166 166
167 167 == Error Handling
168   -The Strava gem raises errors under various conditions.
  168 +The StravaApi gem raises errors under various conditions.
169 169
170   -If an error is raised, check .errors on your Strava::Base object to see more details
  170 +If an error is raised, check .errors on your StravaApi::Base object to see more details
171 171
172 172 s.errors
173 173
174   -=== Strava::NetworkError
  174 +=== StravaApi::NetworkError
175 175 This is raised when the attempt to connect to Strava via httparty raises any of the following:
176 176 * HTTParty::UnsupportedFormat
177 177 * HTTParty::UnsupportedURIScheme
178 178 * HTTParty::ResponseError
179 179 * HTTParty::RedirectionTooDeep
180 180
181   -=== Strava::InvalidResponseError
  181 +=== StravaApi::InvalidResponseError
182 182 This is raised is the call to Strava returns a result describing an error rather than the data you requested.
183 183
184   -=== Strava::CommandError
  184 +=== StravaApi::CommandError
185 185 This is raised if your request causes Strava to return a 500 Error.
186 186 This is also raised if you attempt to run a command that lacks required parameters. For example, trying to call
187 187 .clubs("")
@@ -189,22 +189,22 @@ with an empty string or
189 189 .rides()
190 190 with no options will raise this error.
191 191
192   -=== Strava::InternalError
  192 +=== StravaApi::InternalErrorInternalError
193 193 This is raised if you attempt to access an invalid property of a result. For example,
194 194
195 195 my_seg = s.segment_show(segment_id)
196   - # => returns a <Strava::Segment>
  196 + # => returns a <StravaApi::Segment>
197 197
198 198 my_seg.bogus_property
199 199
200   -will raise a Strava::InternalError
  200 +will raise a StravaApi::InternalErrorInternalError
201 201
202 202
203 203 this returns distance, maximum speed, average speed, etc, etc for that part of the ride.
204 204
205 205 = Contributors
206 206
207   -Strava is maintained by {Steve Chanin}[http://devleverage.com].
  207 +StravaApi is maintained by {Steve Chanin}[http://devleverage.com].
208 208
209 209 == Note on Patches/Pull Requests
210 210
8 Rakefile
@@ -4,11 +4,11 @@ require 'rake'
4 4 begin
5 5 require 'jeweler'
6 6 Jeweler::Tasks.new do |gem|
7   - gem.name = "strava"
  7 + gem.name = "strava-api"
8 8 gem.summary = %Q{Provides a Ruby interface to the Strava api}
9 9 gem.description = %Q{Strava (http://www.strava.com/) allows access to it's data via a JSON api. This gem wraps that API an allows you to interact with Ruby classes instead.}
10   - gem.email = "steven_chanin@alum.mit.edu"
11   - gem.homepage = "http://github.com/stevenchanin/strava"
  10 + gem.email = "schanin@devleverage.com"
  11 + gem.homepage = "http://github.com/stevenchanin/strava-api"
12 12 gem.authors = ["Steven Chanin"]
13 13 #not sure why files wasn't picking up subdirectors of lib when it seems to do so for hominid...
14 14 gem.files = FileList['{lib,test}/**/*'] + %w(CHANGELOG.rdoc init.rb LICENSE Rakefile README.rdoc) - FileList['test/*.log']
@@ -50,7 +50,7 @@ Rake::RDocTask.new do |rdoc|
50 50 version = File.exist?('VERSION') ? File.read('VERSION') : ""
51 51
52 52 rdoc.rdoc_dir = 'rdoc'
53   - rdoc.title = "strava #{version}"
  53 + rdoc.title = "strava-api #{version}"
54 54 rdoc.rdoc_files.include('README*')
55 55 rdoc.rdoc_files.include('lib/**/*.rb')
56 56 end
22 lib/strava-api.rb
... ... @@ -0,0 +1,22 @@
  1 +require 'httparty'
  2 +require 'strava-api/exceptions'
  3 +
  4 +#classes used to hold results from Strava
  5 +require 'strava-api/hash_based_store'
  6 +require 'strava-api/club'
  7 +require 'strava-api/member'
  8 +require 'strava-api/bike'
  9 +require 'strava-api/ride'
  10 +require 'strava-api/segment'
  11 +require 'strava-api/effort'
  12 +
  13 +module StravaApi
  14 + #everything now in independent class files
  15 +end
  16 +
  17 +#classes to perform network access to Strava
  18 +require 'strava-api/clubs'
  19 +require 'strava-api/rides'
  20 +require 'strava-api/segments'
  21 +require 'strava-api/efforts'
  22 +require 'strava-api/base'
10 lib/strava/base.rb → lib/strava-api/base.rb
... ... @@ -1,11 +1,11 @@
1   -module Strava
  1 +module StravaApi
2 2 class Base
3 3 include HTTParty
4 4
5   - include Strava::Clubs
6   - include Strava::Rides
7   - include Strava::Segments
8   - include Strava::Efforts
  5 + include StravaApi::Clubs
  6 + include StravaApi::Rides
  7 + include StravaApi::Segments
  8 + include StravaApi::Efforts
9 9
10 10 format :json
11 11 base_uri 'www.strava.com/api/v1'
2  lib/strava/bike.rb → lib/strava-api/bike.rb
... ... @@ -1,4 +1,4 @@
1   -module Strava
  1 +module StravaApi
2 2 class Bike < HashBasedStore
3 3 ATTRIBUTE_MAP = {'name' => :name, 'id' => :id }
4 4 def initialize(connection, options = {})
2  lib/strava/club.rb → lib/strava-api/club.rb
... ... @@ -1,4 +1,4 @@
1   -module Strava
  1 +module StravaApi
2 2 class Club < HashBasedStore
3 3 ATTRIBUTE_MAP = {'name' => :name, 'id' => :id, 'description' => :description, 'location' => :location }
4 4 def initialize(connection, options = {})
6 lib/strava/clubs.rb → lib/strava-api/clubs.rb
... ... @@ -1,11 +1,11 @@
1   -module Strava
  1 +module StravaApi
2 2 module Clubs
3 3 #returns all clubs, don't need an offset
4 4 def clubs(name)
5   - raise Strava::CommandError if name.blank?
  5 + raise StravaApi::CommandError if name.blank?
6 6
7 7 name = name.strip
8   - raise Strava::CommandError if name.empty?
  8 + raise StravaApi::CommandError if name.empty?
9 9
10 10 result = call("clubs", "clubs", {:name => name})
11 11
2  lib/strava/effort.rb → lib/strava-api/effort.rb
... ... @@ -1,4 +1,4 @@
1   -module Strava
  1 +module StravaApi
2 2 # {
3 3 # "id"=>688432,
4 4 # "elapsedTime"=>598,
2  lib/strava/efforts.rb → lib/strava-api/efforts.rb
... ... @@ -1,4 +1,4 @@
1   -module Strava
  1 +module StravaApi
2 2 module Efforts
3 3 def effort_show(id)
4 4 result = call("efforts/#{id}", "effort", {})
2  lib/strava/exceptions.rb → lib/strava-api/exceptions.rb
... ... @@ -1,4 +1,4 @@
1   -module Strava
  1 +module StravaApi
2 2 class InvalidResponseError < StandardError; end
3 3
4 4 class CommandError < StandardError; end
4 lib/strava/hash_based_store.rb → lib/strava-api/hash_based_store.rb
... ... @@ -1,4 +1,4 @@
1   -module Strava
  1 +module StravaApi
2 2 class HashBasedStore
3 3 def initialize(connection, attribute_map, nested_class_map, options)
4 4 @connection = connection
@@ -31,7 +31,7 @@ def to_s
31 31 "#<#{self.class} [#{result.join(', ')}]>"
32 32 end
33 33
34   - #cleanup how Strava objects are displayed in irb
  34 + #cleanup how StravaApi objects are displayed in irb
35 35 alias_method :original_inspect, :inspect
36 36 alias_method :inspect, :to_s
37 37
2  lib/strava/member.rb → lib/strava-api/member.rb
... ... @@ -1,4 +1,4 @@
1   -module Strava
  1 +module StravaApi
2 2 class Member < HashBasedStore
3 3 ATTRIBUTE_MAP = {'name' => :name, 'id' => :id, 'username' => :username }
4 4 def initialize(connection, options = {})
2  lib/strava/ride.rb → lib/strava-api/ride.rb
... ... @@ -1,4 +1,4 @@
1   -module Strava
  1 +module StravaApi
2 2 # {"ride":{
3 3 # "timeZoneOffset":-8.0,
4 4 # "elevationGain":1441.02,
4 lib/strava/rides.rb → lib/strava-api/rides.rb
... ... @@ -1,4 +1,4 @@
1   -module Strava
  1 +module StravaApi
2 2 module Rides
3 3 def rides(options = {})
4 4 options_map = {
@@ -17,7 +17,7 @@ def rides(options = {})
17 17 filtered_options[converted] = options[key] if options[key]
18 18 end
19 19
20   - raise Strava::CommandError if filtered_options.empty?
  20 + raise StravaApi::CommandError if filtered_options.empty?
21 21
22 22 result = call("rides", "rides", filtered_options)
23 23 result["rides"].collect {|item| Ride.new(self, item)}
2  lib/strava/segment.rb → lib/strava-api/segment.rb
... ... @@ -1,4 +1,4 @@
1   -module Strava
  1 +module StravaApi
2 2 # {
3 3 # "name":"Panoramic to Pan Toll",
4 4 # "id":156,
2  lib/strava/segments.rb → lib/strava-api/segments.rb
... ... @@ -1,4 +1,4 @@
1   -module Strava
  1 +module StravaApi
2 2 module Segments
3 3 #returns all segments, don't need an offset
4 4 def segments(name)
22 lib/strava.rb
... ... @@ -1,22 +0,0 @@
1   -require 'httparty'
2   -require 'strava/exceptions'
3   -
4   -#classes used to hold results from Strava
5   -require 'strava/hash_based_store'
6   -require 'strava/club'
7   -require 'strava/member'
8   -require 'strava/bike'
9   -require 'strava/ride'
10   -require 'strava/segment'
11   -require 'strava/effort'
12   -
13   -module Strava
14   - #everything now in independent class files
15   -end
16   -
17   -#classes to perform network access to Strava
18   -require 'strava/clubs'
19   -require 'strava/rides'
20   -require 'strava/segments'
21   -require 'strava/efforts'
22   -require 'strava/base'
84 strava-api.gemspec
... ... @@ -0,0 +1,84 @@
  1 +# Generated by jeweler
  2 +# DO NOT EDIT THIS FILE DIRECTLY
  3 +# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
  4 +# -*- encoding: utf-8 -*-
  5 +
  6 +Gem::Specification.new do |s|
  7 + s.name = %q{strava-api}
  8 + s.version = "0.13.0"
  9 +
  10 + s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
  11 + s.authors = ["Steven Chanin"]
  12 + s.date = %q{2010-10-04}
  13 + s.description = %q{Strava (http://www.strava.com/) allows access to it's data via a JSON api. This gem wraps that API an allows you to interact with Ruby classes instead.}
  14 + s.email = %q{schanin@devleverage.com}
  15 + s.extra_rdoc_files = [
  16 + "LICENSE",
  17 + "README.rdoc"
  18 + ]
  19 + s.files = [
  20 + "LICENSE",
  21 + "README.rdoc",
  22 + "Rakefile",
  23 + "lib/strava-api.rb",
  24 + "lib/strava-api/base.rb",
  25 + "lib/strava-api/bike.rb",
  26 + "lib/strava-api/club.rb",
  27 + "lib/strava-api/clubs.rb",
  28 + "lib/strava-api/effort.rb",
  29 + "lib/strava-api/efforts.rb",
  30 + "lib/strava-api/exceptions.rb",
  31 + "lib/strava-api/hash_based_store.rb",
  32 + "lib/strava-api/member.rb",
  33 + "lib/strava-api/ride.rb",
  34 + "lib/strava-api/rides.rb",
  35 + "lib/strava-api/segment.rb",
  36 + "lib/strava-api/segments.rb",
  37 + "test/helper.rb",
  38 + "test/test_base.rb",
  39 + "test/test_club.rb",
  40 + "test/test_clubs.rb",
  41 + "test/test_effort.rb",
  42 + "test/test_hash_based_store.rb",
  43 + "test/test_ride.rb",
  44 + "test/test_rides.rb",
  45 + "test/test_segment.rb",
  46 + "test/test_segments.rb",
  47 + "test/test_strava.rb"
  48 + ]
  49 + s.homepage = %q{http://github.com/stevenchanin/strava-api}
  50 + s.rdoc_options = ["--charset=UTF-8"]
  51 + s.require_paths = ["lib"]
  52 + s.rubygems_version = %q{1.3.7}
  53 + s.summary = %q{Provides a Ruby interface to the Strava api}
  54 + s.test_files = [
  55 + "test/helper.rb",
  56 + "test/test_base.rb",
  57 + "test/test_club.rb",
  58 + "test/test_clubs.rb",
  59 + "test/test_effort.rb",
  60 + "test/test_hash_based_store.rb",
  61 + "test/test_ride.rb",
  62 + "test/test_rides.rb",
  63 + "test/test_segment.rb",
  64 + "test/test_segments.rb",
  65 + "test/test_strava.rb"
  66 + ]
  67 +
  68 + if s.respond_to? :specification_version then
  69 + current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
  70 + s.specification_version = 3
  71 +
  72 + if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
  73 + s.add_runtime_dependency(%q<httparty>, ["~> 0.6.1"])
  74 + s.add_runtime_dependency(%q<mocha>, ["~> 0.9.8"])
  75 + else
  76 + s.add_dependency(%q<httparty>, ["~> 0.6.1"])
  77 + s.add_dependency(%q<mocha>, ["~> 0.9.8"])
  78 + end
  79 + else
  80 + s.add_dependency(%q<httparty>, ["~> 0.6.1"])
  81 + s.add_dependency(%q<mocha>, ["~> 0.9.8"])
  82 + end
  83 +end
  84 +
26 strava.gemspec
@@ -21,19 +21,19 @@ Gem::Specification.new do |s|
21 21 "README.rdoc",
22 22 "Rakefile",
23 23 "lib/strava.rb",
24   - "lib/strava/base.rb",
25   - "lib/strava/bike.rb",
26   - "lib/strava/club.rb",
27   - "lib/strava/clubs.rb",
28   - "lib/strava/effort.rb",
29   - "lib/strava/efforts.rb",
30   - "lib/strava/exceptions.rb",
31   - "lib/strava/hash_based_store.rb",
32   - "lib/strava/member.rb",
33   - "lib/strava/ride.rb",
34   - "lib/strava/rides.rb",
35   - "lib/strava/segment.rb",
36   - "lib/strava/segments.rb",
  24 + "lib/strava-api/base.rb",
  25 + "lib/strava-api/bike.rb",
  26 + "lib/strava-api/club.rb",
  27 + "lib/strava-api/clubs.rb",
  28 + "lib/strava-api/effort.rb",
  29 + "lib/strava-api/efforts.rb",
  30 + "lib/strava-api/exceptions.rb",
  31 + "lib/strava-api/hash_based_store.rb",
  32 + "lib/strava-api/member.rb",
  33 + "lib/strava-api/ride.rb",
  34 + "lib/strava-api/rides.rb",
  35 + "lib/strava-api/segment.rb",
  36 + "lib/strava-api/segments.rb",
37 37 "test/helper.rb",
38 38 "test/test_base.rb",
39 39 "test/test_club.rb",
2  test/helper.rb
@@ -3,7 +3,7 @@
3 3
4 4 $LOAD_PATH.unshift(File.dirname(__FILE__))
5 5 $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6   -require 'strava'
  6 +require 'strava-api'
7 7
8 8 class Test::Unit::TestCase
9 9 def expect_error(error, &block)
14 test/test_base.rb
@@ -3,28 +3,28 @@
3 3 require 'json'
4 4
5 5 class TestBase < Test::Unit::TestCase
6   - ###### Testing Strava::Base
  6 + ###### Testing StravaApi::Base
7 7 def setup
8   - @s = Strava::Base.new
  8 + @s = StravaApi::Base.new
9 9 end
10 10
11 11 def test_create
12   - assert @s.is_a?(Strava::Base)
  12 + assert @s.is_a?(StravaApi::Base)
13 13 end
14 14
15 15 def test_bad_command
16   - Strava::Base.stubs(:get).with('/clubsx', {:query => {}}).raises(Strava::NetworkError)
  16 + StravaApi::Base.stubs(:get).with('/clubsx', {:query => {}}).raises(StravaApi::NetworkError)
17 17
18   - expect_error(Strava::NetworkError) { @s.call('clubsx', 'club', {}) }
  18 + expect_error(StravaApi::NetworkError) { @s.call('clubsx', 'club', {}) }
19 19
20 20 assert @s.errors.include?("NetworkError from httparty")
21 21 end
22 22
23 23 def test_bad_command
24 24 @response = mock('HTTParty::Response', :parsed_response => '<html><body><h1>500 Internal Server Error</h1></body></html>')
25   - Strava::Base.stubs(:get).with('/clubs', {:query => {}}).returns(@response)
  25 + StravaApi::Base.stubs(:get).with('/clubs', {:query => {}}).returns(@response)
26 26
27   - expect_error(Strava::CommandError) { @s.call('clubs', 'club', {}) }
  27 + expect_error(StravaApi::CommandError) { @s.call('clubs', 'club', {}) }
28 28
29 29 assert @s.errors.include?("Strava returned a 500 error")
30 30 end
12 test/test_club.rb
@@ -4,11 +4,11 @@
4 4
5 5 class TestClub < Test::Unit::TestCase
6 6 def setup
7   - @s = Strava::Base.new
  7 + @s = StravaApi::Base.new
8 8
9 9 api_result = JSON.parse clubs_index_json
10 10 api_result.stubs(:parsed_response).returns("")
11   - Strava::Base.stubs(:get).with('/clubs', {:query => {:name => 'X'}}).returns(api_result)
  11 + StravaApi::Base.stubs(:get).with('/clubs', {:query => {:name => 'X'}}).returns(api_result)
12 12
13 13 @club = @s.clubs("X").first
14 14 end
@@ -16,14 +16,14 @@ def setup
16 16 def test_show
17 17 api_result = JSON.parse club_show_json
18 18 api_result.stubs(:parsed_response).returns("")
19   - Strava::Base.stubs(:get).with('/clubs/23', { :query => {} }).returns(api_result)
  19 + StravaApi::Base.stubs(:get).with('/clubs/23', { :query => {} }).returns(api_result)
20 20
21 21 assert @club.description.nil?
22 22 assert @club.location.nil?
23 23
24 24 result = @club.show
25 25
26   - assert result.is_a?(Strava::Club)
  26 + assert result.is_a?(StravaApi::Club)
27 27
28 28 assert @club.description == "SLO Nexus brings together people who love to ride bikes, race bikes, and promote bike riding in our community. Our fresh outlook on the local bike scene incorporates support, fun, education, and fitness and is designed to bring together the growing number"
29 29 assert @club.location == "San Luis Obispo, CA"
@@ -32,14 +32,14 @@ def test_show
32 32 def test_members
33 33 api_result = JSON.parse club_members_json
34 34 api_result.stubs(:parsed_response).returns("")
35   - Strava::Base.stubs(:get).with('/clubs/23/members', { :query => {} }).returns(api_result)
  35 + StravaApi::Base.stubs(:get).with('/clubs/23/members', { :query => {} }).returns(api_result)
36 36
37 37 members = @club.members
38 38
39 39 assert members.is_a?(Array)
40 40 assert members.size == 6
41 41 members.each do |member|
42   - assert member.is_a?(Strava::Member)
  42 + assert member.is_a?(StravaApi::Member)
43 43 end
44 44 end
45 45 end
26 test/test_clubs.rb
@@ -3,31 +3,31 @@
3 3 require 'json'
4 4
5 5 class TestClubs < Test::Unit::TestCase
6   - ###### Testing Strava::Base
  6 + ###### Testing StravaApi::Base
7 7 def setup
8   - @s = Strava::Base.new
  8 + @s = StravaApi::Base.new
9 9 end
10 10
11 11 def test_clubs_no_search_string
12   - expect_error(Strava::CommandError) { @s.clubs('') }
  12 + expect_error(StravaApi::CommandError) { @s.clubs('') }
13 13 end
14 14
15 15 def test_clubs_all_spaces_search_string
16   - expect_error(Strava::CommandError) { @s.clubs(' ') }
  16 + expect_error(StravaApi::CommandError) { @s.clubs(' ') }
17 17 end
18 18
19 19 def test_clubs_index
20 20 #curl http://www.strava.com/api/v1/clubs?name=X
21 21 api_result = JSON.parse clubs_index_json
22 22 api_result.stubs(:parsed_response).returns("")
23   - Strava::Base.stubs(:get).with('/clubs', {:query => {:name => 'X'}}).returns(api_result)
  23 + StravaApi::Base.stubs(:get).with('/clubs', {:query => {:name => 'X'}}).returns(api_result)
24 24
25 25 result = @s.clubs('X')
26 26
27 27 assert result.is_a?(Array)
28 28
29 29 result.each do |club|
30   - assert club.is_a?(Strava::Club)
  30 + assert club.is_a?(StravaApi::Club)
31 31 end
32 32 end
33 33
@@ -35,7 +35,7 @@ def test_clubs_index_that_returns_nothing
35 35 #curl http://www.strava.com/api/v1/clubs?name=X5678i9o90
36 36 api_result = JSON.parse '{"clubs":[]}'
37 37 api_result.stubs(:parsed_response).returns("")
38   - Strava::Base.stubs(:get).with('/clubs', {:query => {:name => 'X93afadf80833'}}).returns(api_result)
  38 + StravaApi::Base.stubs(:get).with('/clubs', {:query => {:name => 'X93afadf80833'}}).returns(api_result)
39 39
40 40 result = @s.clubs('X93afadf80833')
41 41
@@ -47,11 +47,11 @@ def test_clubs_index_that_returns_nothing
47 47 def test_club_show
48 48 api_result = JSON.parse club_show_json
49 49 api_result.stubs(:parsed_response).returns("")
50   - Strava::Base.stubs(:get).with('/clubs/23', { :query => {} }).returns(api_result)
  50 + StravaApi::Base.stubs(:get).with('/clubs/23', { :query => {} }).returns(api_result)
51 51
52 52 result = @s.club_show(23)
53 53
54   - assert result.is_a?(Strava::Club)
  54 + assert result.is_a?(StravaApi::Club)
55 55 assert result.name == "SLO Nexus"
56 56 assert result.id == 23
57 57 assert result.location == "San Luis Obispo, CA"
@@ -62,9 +62,9 @@ def test_club_show_bad_id
62 62 #curl http://www.strava.com/api/v1/clubs/0
63 63 api_result = JSON.parse '{"error":"Invalid clubs/0"}'
64 64 api_result.stubs(:parsed_response).returns("")
65   - Strava::Base.stubs(:get).with('/clubs/0', { :query => {} }).returns(api_result)
  65 + StravaApi::Base.stubs(:get).with('/clubs/0', { :query => {} }).returns(api_result)
66 66
67   - expect_error(Strava::InvalidResponseError) { @s.club_show(0) }
  67 + expect_error(StravaApi::InvalidResponseError) { @s.club_show(0) }
68 68
69 69 assert @s.errors.include?("Invalid clubs/0")
70 70 end
@@ -73,13 +73,13 @@ def test_club_members
73 73 #curl http://www.strava.com/api/v1/clubs/23/members
74 74 api_result = JSON.parse club_members_json
75 75 api_result.stubs(:parsed_response).returns("")
76   - Strava::Base.stubs(:get).with('/clubs/23/members', { :query => {} }).returns(api_result)
  76 + StravaApi::Base.stubs(:get).with('/clubs/23/members', { :query => {} }).returns(api_result)
77 77
78 78 result = @s.club_members(23)
79 79
80 80 assert result.is_a?(Array)
81 81 result.each do |member|
82   - assert member.is_a?(Strava::Member)
  82 + assert member.is_a?(StravaApi::Member)
83 83 end
84 84
85 85 assert result.first.name == "Dan Speirs"
8 test/test_effort.rb
@@ -4,11 +4,11 @@
4 4
5 5 class TestEffort < Test::Unit::TestCase
6 6 def setup
7   - @s = Strava::Base.new
  7 + @s = StravaApi::Base.new
8 8
9 9 api_result = JSON.parse ride_efforts_json
10 10 api_result.stubs(:parsed_response).returns("")
11   - Strava::Base.stubs(:get).with('/rides/77563/efforts', {:query => {}}).returns(api_result)
  11 + StravaApi::Base.stubs(:get).with('/rides/77563/efforts', {:query => {}}).returns(api_result)
12 12
13 13 @effort = @s.ride_efforts(77563).first
14 14 end
@@ -16,14 +16,14 @@ def setup
16 16 def test_show
17 17 api_result = JSON.parse effort_show_method
18 18 api_result.stubs(:parsed_response).returns("")
19   - Strava::Base.stubs(:get).with('/efforts/2231990', { :query => {} }).returns(api_result)
  19 + StravaApi::Base.stubs(:get).with('/efforts/2231990', { :query => {} }).returns(api_result)
20 20
21 21 assert @effort.athlete.nil?
22 22 assert @effort.average_speed.nil?
23 23
24 24 result = @effort.show
25 25
26   - assert result.is_a?(Strava::Effort)
  26 + assert result.is_a?(StravaApi::Effort)
27 27
28 28 assert @effort.athlete.name == "Julian Bill"
29 29 assert @effort.average_speed == 20149.3205741627
22 test/test_hash_based_store.rb
@@ -9,49 +9,49 @@ def setup
9 9 @attribute_map = {'name' => :name, 'id' => :id }
10 10 @initial_values = {'id' => 3, 'name' => 'Fred'}
11 11
12   - @nested_class_map = { :bike => Strava::Bike }
  12 + @nested_class_map = { :bike => StravaApi::Bike }
13 13 @complex_attribute_map = {'name' => :name, 'id' => :id, 'bike' => :bike }
14 14 @complex_initial_values = {'id' => 3, 'name' => 'Fred', 'bike' => {'id' => 7, 'name' => 'Cruiser'}}
15 15 end
16 16
17 17 def test_creating
18   - obj = Strava::HashBasedStore.new(@connection, @attribute_map, {}, {})
  18 + obj = StravaApi::HashBasedStore.new(@connection, @attribute_map, {}, {})
19 19
20   - assert obj.is_a?(Strava::HashBasedStore)
  20 + assert obj.is_a?(StravaApi::HashBasedStore)
21 21 end
22 22
23 23 def test_storing_values
24   - obj = Strava::HashBasedStore.new(@connection, @attribute_map, {}, @initial_values)
  24 + obj = StravaApi::HashBasedStore.new(@connection, @attribute_map, {}, @initial_values)
25 25
26 26 assert obj[:id] == @initial_values['id']
27 27 assert obj[:name] == @initial_values['name']
28 28 end
29 29
30 30 def test_getting_values_via_methods
31   - obj = Strava::HashBasedStore.new(@connection, @attribute_map, {}, @initial_values)
  31 + obj = StravaApi::HashBasedStore.new(@connection, @attribute_map, {}, @initial_values)
32 32
33 33 assert obj.id == @initial_values['id']
34 34 assert obj.name == @initial_values['name']
35 35 end
36 36
37 37 def test_create_with_nested_object
38   - obj = Strava::HashBasedStore.new(@connection, @complex_attribute_map, @nested_class_map, @complex_initial_values)
  38 + obj = StravaApi::HashBasedStore.new(@connection, @complex_attribute_map, @nested_class_map, @complex_initial_values)
39 39
40 40 assert obj[:id] == @complex_initial_values['id']
41 41 assert obj[:name] == @complex_initial_values['name']
42 42
43   - assert obj[:bike].is_a?(Strava::Bike)
  43 + assert obj[:bike].is_a?(StravaApi::Bike)
44 44 assert obj[:bike][:id] == @complex_initial_values['bike']['id']
45 45 assert obj[:bike][:name] == @complex_initial_values['bike']['name']
46 46 end
47 47
48 48 def test_create_with_nested_object_via_methods
49   - obj = Strava::HashBasedStore.new(@connection, @complex_attribute_map, @nested_class_map, @complex_initial_values)
  49 + obj = StravaApi::HashBasedStore.new(@connection, @complex_attribute_map, @nested_class_map, @complex_initial_values)
50 50
51 51 assert obj.id == @complex_initial_values['id']
52 52 assert obj.name == @complex_initial_values['name']
53 53
54   - assert obj.bike.is_a?(Strava::Bike)
  54 + assert obj.bike.is_a?(StravaApi::Bike)
55 55 assert obj.bike.id == @complex_initial_values['bike']['id']
56 56 assert obj.bike.name == @complex_initial_values['bike']['name']
57 57 end
@@ -59,11 +59,11 @@ def test_create_with_nested_object_via_methods
59 59 def test_merge
60 60 @big_attribute_map = {'name' => :name, 'id' => :id, "extra1" => :extra1, "extra2" => :extra2 }
61 61
62   - obj1 = Strava::HashBasedStore.new(@connection, @big_attribute_map, {}, {'id' => 13, 'name' => 'Fred'})
  62 + obj1 = StravaApi::HashBasedStore.new(@connection, @big_attribute_map, {}, {'id' => 13, 'name' => 'Fred'})
63 63 assert obj1.name == 'Fred'
64 64 assert obj1.id == 13
65 65
66   - obj2 = Strava::HashBasedStore.new(@connection, @big_attribute_map, {},
  66 + obj2 = StravaApi::HashBasedStore.new(@connection, @big_attribute_map, {},
67 67 {'id' => 13, 'name' => 'Fred', 'extra1' => 'red', 'extra2' => 'sneaker'})
68 68 assert obj2.name == 'Fred'
69 69 assert obj2.id == 13
12 test/test_ride.rb
@@ -4,11 +4,11 @@
4 4
5 5 class TestRide < Test::Unit::TestCase
6 6 def setup
7   - @s = Strava::Base.new
  7 + @s = StravaApi::Base.new
8 8
9 9 api_result = JSON.parse rides_index_by_club_json
10 10 api_result.stubs(:parsed_response).returns("")
11   - Strava::Base.stubs(:get).with('/rides', { :query => {'clubId' => 23} }).returns(api_result)
  11 + StravaApi::Base.stubs(:get).with('/rides', { :query => {'clubId' => 23} }).returns(api_result)
12 12
13 13 @ride = @s.rides(:club_id => 23).first
14 14 end
@@ -16,7 +16,7 @@ def setup
16 16 def test_show
17 17 api_result = JSON.parse ride_show_method_json
18 18 api_result.stubs(:parsed_response).returns("")
19   - Strava::Base.stubs(:get).with('/rides/191846', { :query => {} }).returns(api_result)
  19 + StravaApi::Base.stubs(:get).with('/rides/191846', { :query => {} }).returns(api_result)
20 20
21 21 assert @ride.id == 191846
22 22 assert @ride.name == "from SVRMC"
@@ -24,7 +24,7 @@ def test_show
24 24 assert @ride.location.nil?
25 25
26 26 result = @ride.show
27   - assert result.is_a?(Strava::Ride)
  27 + assert result.is_a?(StravaApi::Ride)
28 28
29 29 assert @ride.id == 191846
30 30 assert @ride.name == "from SVRMC"
@@ -35,14 +35,14 @@ def test_show
35 35 def test_efforts
36 36 api_result = JSON.parse ride_effort_method_json
37 37 api_result.stubs(:parsed_response).returns("")
38   - Strava::Base.stubs(:get).with('/rides/191846/efforts', { :query => {} }).returns(api_result)
  38 + StravaApi::Base.stubs(:get).with('/rides/191846/efforts', { :query => {} }).returns(api_result)
39 39
40 40 efforts = @ride.efforts
41 41
42 42 assert efforts.is_a?(Array)
43 43 assert efforts.size == 1
44 44 efforts.each do |effort|
45   - assert effort.is_a?(Strava::Effort)
  45 + assert effort.is_a?(StravaApi::Effort)
46 46 end
47 47 end
48 48
52 test/test_rides.rb
@@ -4,28 +4,28 @@
4 4
5 5 class TestRides < Test::Unit::TestCase
6 6 def setup
7   - @s = Strava::Base.new
  7 + @s = StravaApi::Base.new
8 8 end
9 9
10 10 def test_rides_index_no_arguments
11   - expect_error(Strava::CommandError) { @s.rides }
  11 + expect_error(StravaApi::CommandError) { @s.rides }
12 12 end
13 13
14 14 def test_rides_index_invalid_argument
15   - expect_error(Strava::CommandError) { @s.rides(:invalid => true) }
  15 + expect_error(StravaApi::CommandError) { @s.rides(:invalid => true) }
16 16 end
17 17
18 18 def test_rides_index_by_club
19 19 api_result = JSON.parse rides_index_by_club_json
20 20 api_result.stubs(:parsed_response).returns("")
21   - Strava::Base.stubs(:get).with('/rides', { :query => {'clubId' => 23} }).returns(api_result)
  21 + StravaApi::Base.stubs(:get).with('/rides', { :query => {'clubId' => 23} }).returns(api_result)
22 22
23 23 result = @s.rides(:club_id => 23)
24 24
25 25 assert result.is_a?(Array)
26 26
27 27 result.each do |ride|
28   - assert ride.is_a?(Strava::Ride)
  28 + assert ride.is_a?(StravaApi::Ride)
29 29 end
30 30 end
31 31
@@ -33,14 +33,14 @@ def test_rides_index_by_athlete
33 33 #curl http://www.strava.com/api/v1/rides?athleteId=779
34 34 api_result = JSON.parse rides_index_by_athlete_json
35 35 api_result.stubs(:parsed_response).returns("")
36   - Strava::Base.stubs(:get).with('/rides', { :query => {'athleteId' => 779} }).returns(api_result)
  36 + StravaApi::Base.stubs(:get).with('/rides', { :query => {'athleteId' => 779} }).returns(api_result)
37 37
38 38 result = @s.rides(:athlete_id => 779)
39 39
40 40 assert result.is_a?(Array)
41 41
42 42 result.each do |ride|
43   - assert ride.is_a?(Strava::Ride)
  43 + assert ride.is_a?(StravaApi::Ride)
44 44 end
45 45 end
46 46
@@ -48,14 +48,14 @@ def test_rides_index_by_club_and_athlete
48 48 #curl "http://www.strava.com/api/v1/rides?clubId=23&athleteId=779"
49 49 api_result = JSON.parse rides_index_by_club_and_athlete_json
50 50 api_result.stubs(:parsed_response).returns("")
51   - Strava::Base.stubs(:get).with('/rides', { :query => {'clubId' => 23, 'athleteId' => 779} }).returns(api_result)
  51 + StravaApi::Base.stubs(:get).with('/rides', { :query => {'clubId' => 23, 'athleteId' => 779} }).returns(api_result)
52 52
53 53 result = @s.rides(:club_id => 23, :athlete_id => 779)
54 54
55 55 assert result.is_a?(Array)
56 56
57 57 result.each do |ride|
58   - assert ride.is_a?(Strava::Ride)
  58 + assert ride.is_a?(StravaApi::Ride)
59 59 end
60 60 end
61 61
@@ -63,9 +63,9 @@ def test_rides_index_with_mismatched_club_and_athlete
63 63 #curl "http://www.strava.com/api/v1/rides?clubId=24&athleteId=779"
64 64 api_result = JSON.parse '{"error":"Invalid clubId"}'
65 65 api_result.stubs(:parsed_response).returns("")
66   - Strava::Base.stubs(:get).with('/rides', { :query => {'clubId' => 24, 'athleteId' => 779} }).returns(api_result)
  66 + StravaApi::Base.stubs(:get).with('/rides', { :query => {'clubId' => 24, 'athleteId' => 779} }).returns(api_result)
67 67
68   - expect_error(Strava::InvalidResponseError) { @s.rides(:club_id => 24, :athlete_id => 779) }
  68 + expect_error(StravaApi::InvalidResponseError) { @s.rides(:club_id => 24, :athlete_id => 779) }
69 69
70 70 assert @s.errors.include?("Invalid clubId")
71 71 end
@@ -74,14 +74,14 @@ def test_rides_index_ignores_invalid_parameter
74 74 #curl http://www.strava.com/api/v1/rides?athleteId=779
75 75 api_result = JSON.parse rides_index_ignores_invalid_parameter_json
76 76 api_result.stubs(:parsed_response).returns("")
77   - Strava::Base.stubs(:get).with('/rides', { :query => {'athleteId' => 779} }).returns(api_result)
  77 + StravaApi::Base.stubs(:get).with('/rides', { :query => {'athleteId' => 779} }).returns(api_result)
78 78
79 79 result = @s.rides(:athlete_id => 779, :xclub_id => 24)
80 80
81 81 assert result.is_a?(Array)
82 82
83 83 result.each do |ride|
84   - assert ride.is_a?(Strava::Ride)
  84 + assert ride.is_a?(StravaApi::Ride)
85 85 end
86 86 end
87 87
@@ -89,14 +89,14 @@ def test_rides_after_start_date
89 89 #curl "http://www.strava.com/api/v1/rides?athleteId=779&startDate=2010-09-21"
90 90 api_result = JSON.parse rides_after_start_date_json
91 91 api_result.stubs(:parsed_response).returns("")
92   - Strava::Base.stubs(:get).with('/rides', { :query => {'athleteId' => 779, 'startDate' => Date.civil(2010,9,21)} }).returns(api_result)
  92 + StravaApi::Base.stubs(:get).with('/rides', { :query => {'athleteId' => 779, 'startDate' => Date.civil(2010,9,21)} }).returns(api_result)
93 93
94 94 result = @s.rides(:athlete_id => 779, :start_date => Date.civil(2010,9,21))
95 95
96 96 assert result.is_a?(Array)
97 97
98 98 result.each do |ride|
99   - assert ride.is_a?(Strava::Ride)
  99 + assert ride.is_a?(StravaApi::Ride)
100 100 #TODO check that each ride is after 9/21/2010
101 101 end
102 102 end
@@ -105,12 +105,12 @@ def test_rides_using_offset
105 105 #curl "http://www.strava.com/api/v1/rides?athleteId=779&startDate=2010-07-1&endDate=2010_09_01"
106 106 api_result = JSON.parse rides_using_offset_json
107 107 api_result.stubs(:parsed_response).returns("")
108   - Strava::Base.stubs(:get).with('/rides', { :query => {'startDate' => Date.civil(2010,7,1),
  108 + StravaApi::Base.stubs(:get).with('/rides', { :query => {'startDate' => Date.civil(2010,7,1),
109 109 'endDate' => Date.civil(2010,7,5)} }).returns(api_result)
110 110
111 111 api_result2 = JSON.parse rides_using_offset_50_json
112 112 api_result2.stubs(:parsed_response).returns("")
113   - Strava::Base.stubs(:get).with('/rides', { :query => {'startDate' => Date.civil(2010,7,1),
  113 + StravaApi::Base.stubs(:get).with('/rides', { :query => {'startDate' => Date.civil(2010,7,1),
114 114 'endDate' => Date.civil(2010,7,5), 'offset' => 50} }).returns(api_result2)
115 115
116 116 set_1 = @s.rides(:start_date => Date.civil(2010,7,1), :end_date => Date.civil(2010,7,5))
@@ -119,8 +119,8 @@ def test_rides_using_offset
119 119 assert set_1.is_a?(Array)
120 120 assert set_2.is_a?(Array)
121 121
122   - set_1.each {|ride| assert ride.is_a?(Strava::Ride)}
123   - set_2.each {|ride| assert ride.is_a?(Strava::Ride)}
  122 + set_1.each {|ride| assert ride.is_a?(StravaApi::Ride)}
  123 + set_2.each {|ride| assert ride.is_a?(StravaApi::Ride)}
124 124
125 125 #but there shouldn't be any overlap
126 126 set_1_ids = set_1.collect(&:id)
@@ -135,11 +135,11 @@ def test_ride_show
135 135 #curl "http://www.strava.com/api/v1/rides/77563"
136 136 api_result = JSON.parse ride_show_json
137 137 api_result.stubs(:parsed_response).returns("")
138   - Strava::Base.stubs(:get).with('/rides/77563', { :query => {} }).returns(api_result)
  138 + StravaApi::Base.stubs(:get).with('/rides/77563', { :query => {} }).returns(api_result)
139 139
140 140 result = @s.ride_show(77563)
141 141
142   - assert result.is_a?(Strava::Ride)
  142 + assert result.is_a?(StravaApi::Ride)
143 143
144 144 {
145 145 :time_zone_offset => -8.0,
@@ -160,10 +160,10 @@ def test_ride_show
160 160 assert result[property] == value, "mismatch on #{property}: #{result[property]} != #{value}"
161 161 end
162 162
163   - assert result[:athlete].is_a?(Strava::Member)
  163 + assert result[:athlete].is_a?(StravaApi::Member)
164 164 assert result[:athlete].username == "julianbill"
165 165
166   - assert result[:bike].is_a?(Strava::Bike)
  166 + assert result[:bike].is_a?(StravaApi::Bike)
167 167 assert result[:bike].name == "Serotta Legend Ti"
168 168 end
169 169
@@ -171,16 +171,16 @@ def test_ride_efforts
171 171 #curl "http://www.strava.com/api/v1/rides/77563/efforts"
172 172 api_result = JSON.parse ride_efforts_json
173 173 api_result.stubs(:parsed_response).returns("")
174   - Strava::Base.stubs(:get).with('/rides/77563/efforts', { :query => {} }).returns(api_result)
  174 + StravaApi::Base.stubs(:get).with('/rides/77563/efforts', { :query => {} }).returns(api_result)
175 175
176 176 result = @s.ride_efforts(77563)
177 177
178 178 assert result.is_a?(Array)
179 179 result.each do |effort|
180   - assert effort.is_a?(Strava::Effort)
  180 + assert effort.is_a?(StravaApi::Effort)
181 181 end
182 182
183   - assert result.first.segment.is_a?(Strava::Segment)
  183 + assert result.first.segment.is_a?(StravaApi::Segment)
184 184 assert result.first.segment.name == "Panhandle to GGP"
185 185 end
186 186 end
16 test/test_segment.rb
@@ -4,11 +4,11 @@
4 4
5 5 class TestSegment < Test::Unit::TestCase
6 6 def setup
7   - @s = Strava::Base.new
  7 + @s = StravaApi::Base.new
8 8
9 9 api_result = JSON.parse segments_index_json
10 10 api_result.stubs(:parsed_response).returns("")
11   - Strava::Base.stubs(:get).with('/segments', {:query => {:name => 'Hawk Hill'}}).returns(api_result)
  11 + StravaApi::Base.stubs(:get).with('/segments', {:query => {:name => 'Hawk Hill'}}).returns(api_result)
12 12
13 13 @segment = @s.segments("Hawk Hill").first
14 14 end
@@ -16,7 +16,7 @@ def setup
16 16 def test_show
17 17 api_result = JSON.parse segment_show_json
18 18 api_result.stubs(:parsed_response).returns("")
19   - Strava::Base.stubs(:get).with('/segments/99243', { :query => {} }).returns(api_result)
  19 + StravaApi::Base.stubs(:get).with('/segments/99243', { :query => {} }).returns(api_result)
20 20
21 21 assert @segment.id == 99243
22 22 assert @segment.name == "Hawk Hill Saddle"
@@ -24,7 +24,7 @@ def test_show
24 24 assert @segment.elevation_high.nil?
25 25
26 26 result = @segment.show
27   - assert result.is_a?(Strava::Segment)
  27 + assert result.is_a?(StravaApi::Segment)
28 28
29 29 assert @segment.id == 99243
30 30 assert @segment.name == "Hawk Hill Saddle"
@@ -35,21 +35,21 @@ def test_show
35 35 def test_efforts
36 36 api_result = JSON.parse segment_efforts_index_json
37 37 api_result.stubs(:parsed_response).returns("")
38   - Strava::Base.stubs(:get).with('/segments/99243/efforts', { :query => {} }).returns(api_result)
  38 + StravaApi::Base.stubs(:get).with('/segments/99243/efforts', { :query => {} }).returns(api_result)
39 39
40 40 efforts = @segment.efforts
41 41
42 42 assert efforts.is_a?(Array)
43 43 assert efforts.size == 3
44 44 efforts.each do |effort|
45   - assert effort.is_a?(Strava::Effort)
  45 + assert effort.is_a?(StravaApi::Effort)
46 46 end
47 47 end
48 48
49 49 def test_efforts_with_athlete_id
50 50 api_result = JSON.parse segment_efforts_index_by_athlete_id_json
51 51 api_result.stubs(:parsed_response).returns("")
52   - Strava::Base.stubs(:get).with('/segments/99243/efforts', { :query => {'athleteId' => 1377} }).returns(api_result)
  52 + StravaApi::Base.stubs(:get).with('/segments/99243/efforts', { :query => {'athleteId' => 1377} }).returns(api_result)
53 53
54 54 efforts = @segment.efforts(:athlete_id => 1377)
55 55
@@ -57,7 +57,7 @@ def test_efforts_with_athlete_id
57 57
58 58 assert efforts.size == 17
59 59 efforts.each do |effort|
60   - assert effort.is_a?(Strava::Effort)
  60 + assert effort.is_a?(StravaApi::Effort)
61 61 end
62 62 end
63 63 end
40 test/test_segments.rb
@@ -4,20 +4,20 @@
4 4
5 5 class TestSegments < Test::Unit::TestCase
6 6 def setup
7   - @s = Strava::Base.new
  7 + @s = StravaApi::Base.new
8 8 end
9 9 def test_segments_index
10 10 #curl http://www.strava.com/api/v1/segments?name=hawk%20hill
11 11 api_result = JSON.parse segments_index_json
12 12 api_result.stubs(:parsed_response).returns("")
13   - Strava::Base.stubs(:get).with('/segments', {:query => {:name => 'Hawk Hill'}}).returns(api_result)
  13 + StravaApi::Base.stubs(:get).with('/segments', {:query => {:name => 'Hawk Hill'}}).returns(api_result)
14 14
15 15 result = @s.segments('Hawk Hill')
16 16
17 17 assert result.is_a?(Array)
18 18
19 19 result.each do |segment|
20   - assert segment.is_a?(Strava::Segment)
  20 + assert segment.is_a?(StravaApi::Segment)
21 21 end
22 22 end
23 23
@@ -25,7 +25,7 @@ def test_segments_index_that_returns_nothing
25 25 #curl http://www.strava.com/api/v1/segments?name=hawk%20hillxxxy
26 26 api_result = JSON.parse '{"segments":[]}'
27