fitgem 0.12.0 → 0.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/fitgem.gemspec +1 -47
- data/lib/fitgem/locales.rb +69 -0
- data/lib/fitgem/version.rb +1 -1
- metadata +3 -19
- data/.gitignore +0 -12
- data/.travis.yml +0 -3
- data/.yardopts +0 -7
- data/Gemfile +0 -13
- data/Guardfile +0 -15
- data/Rakefile +0 -13
- data/changelog.md +0 -166
- data/spec/fitgem_constructor_spec.rb +0 -19
- data/spec/fitgem_helper_spec.rb +0 -244
- data/spec/fitgem_notifications_spec.rb +0 -173
- data/spec/fitgem_spec.rb +0 -69
- data/spec/spec_helper.rb +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 526686b046dd456463dcd774bd631ef2d31ff0e8
|
4
|
+
data.tar.gz: d05e4df2c5744761cc928d74a66218faf4acda4c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ad678e020cad7b396ee91eaf12be483142226d746b04ea0c877c6feda74b5690920692cc63032c889f931a5bf3f22f803331f84afb4269a6356207bfeb4e3d01
|
7
|
+
data.tar.gz: 84860dde2891a70d144998d47a3dfa2c14f717cddebc972bcefa4b7e96ff0cb7667d391d6dcf2b7a5f6cfc0542eb3e47a98c1e5e4c092d5e72a52dfaff0a5b4b
|
data/fitgem.gemspec
CHANGED
@@ -22,52 +22,6 @@ Gem::Specification.new do |s|
|
|
22
22
|
s.add_development_dependency 'yard'
|
23
23
|
s.add_development_dependency 'rdiscount'
|
24
24
|
|
25
|
-
s.files
|
26
|
-
'.gitignore',
|
27
|
-
# '.rvmrc',
|
28
|
-
'.yardopts',
|
29
|
-
'.travis.yml',
|
30
|
-
'Gemfile',
|
31
|
-
'Guardfile',
|
32
|
-
'LICENSE',
|
33
|
-
'README.md',
|
34
|
-
'Rakefile',
|
35
|
-
'changelog.md',
|
36
|
-
'fitgem.gemspec',
|
37
|
-
'lib/fitgem.rb',
|
38
|
-
'lib/fitgem/version.rb',
|
39
|
-
'lib/fitgem/activities.rb',
|
40
|
-
'lib/fitgem/alarms.rb',
|
41
|
-
'lib/fitgem/badges.rb',
|
42
|
-
'lib/fitgem/body_measurements.rb',
|
43
|
-
'lib/fitgem/client.rb',
|
44
|
-
'lib/fitgem/devices.rb',
|
45
|
-
'lib/fitgem/errors.rb',
|
46
|
-
'lib/fitgem/food_form.rb',
|
47
|
-
'lib/fitgem/foods.rb',
|
48
|
-
'lib/fitgem/friends.rb',
|
49
|
-
'lib/fitgem/helpers.rb',
|
50
|
-
'lib/fitgem/notifications.rb',
|
51
|
-
'lib/fitgem/sleep.rb',
|
52
|
-
'lib/fitgem/time_range.rb',
|
53
|
-
'lib/fitgem/units.rb',
|
54
|
-
'lib/fitgem/users.rb',
|
55
|
-
'lib/fitgem/water.rb',
|
56
|
-
'lib/fitgem/blood_pressure.rb',
|
57
|
-
'lib/fitgem/glucose.rb',
|
58
|
-
'lib/fitgem/heart_rate.rb',
|
59
|
-
'spec/fitgem_spec.rb',
|
60
|
-
'spec/spec_helper.rb',
|
61
|
-
'spec/fitgem_notifications_spec.rb',
|
62
|
-
'spec/fitgem_helper_spec.rb',
|
63
|
-
'spec/fitgem_constructor_spec.rb'
|
64
|
-
]
|
65
|
-
s.test_files = [
|
66
|
-
'spec/fitgem_spec.rb',
|
67
|
-
'spec/spec_helper.rb',
|
68
|
-
'spec/fitgem_notifications_spec.rb',
|
69
|
-
'spec/fitgem_helper_spec.rb',
|
70
|
-
'spec/fitgem_constructor_spec.rb'
|
71
|
-
]
|
25
|
+
s.files = %w(LICENSE README.md fitgem.gemspec) + `git ls-files -z`.split("\x0").select { |f| f.start_with?("lib/") }
|
72
26
|
s.require_paths = ['lib']
|
73
27
|
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
module Fitgem
|
2
|
+
# Enumeration of valid locales that can be sent to fitbit
|
3
|
+
#
|
4
|
+
# Set the {Fitgem::Client#api_locale} property to one of
|
5
|
+
# these values to set the locale used for all subsequent
|
6
|
+
# API calls.
|
7
|
+
#
|
8
|
+
# See {https://wiki.fitbit.com/display/API/API+Localization} for
|
9
|
+
# more information on how the various locales are used.
|
10
|
+
class ApiLocale
|
11
|
+
# US Locale
|
12
|
+
#
|
13
|
+
# Used by default in fitgem
|
14
|
+
#
|
15
|
+
# @return [String]
|
16
|
+
def self.US
|
17
|
+
"en_US"
|
18
|
+
end
|
19
|
+
|
20
|
+
# Australia Locale
|
21
|
+
#
|
22
|
+
# @return [String]
|
23
|
+
def self.AU
|
24
|
+
"en_AU"
|
25
|
+
end
|
26
|
+
|
27
|
+
# France Locale
|
28
|
+
#
|
29
|
+
# @return [String]
|
30
|
+
def self.FR
|
31
|
+
"fr_FR"
|
32
|
+
end
|
33
|
+
|
34
|
+
# Germany Locale
|
35
|
+
#
|
36
|
+
# @return [String]
|
37
|
+
def self.DE
|
38
|
+
"de_DE"
|
39
|
+
end
|
40
|
+
|
41
|
+
# Japan Locale
|
42
|
+
#
|
43
|
+
# @return [String]
|
44
|
+
def self.JP
|
45
|
+
"ja_JP"
|
46
|
+
end
|
47
|
+
|
48
|
+
# New Zealand Locale
|
49
|
+
#
|
50
|
+
# @return [String]
|
51
|
+
def self.NZ
|
52
|
+
"en_NZ"
|
53
|
+
end
|
54
|
+
|
55
|
+
# Spain Locale
|
56
|
+
#
|
57
|
+
# @return [String]
|
58
|
+
def self.ES
|
59
|
+
"es_ES"
|
60
|
+
end
|
61
|
+
|
62
|
+
# UK Locale
|
63
|
+
#
|
64
|
+
# @return [String]
|
65
|
+
def self.UK
|
66
|
+
"en_GB"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
data/lib/fitgem/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fitgem
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.12.
|
4
|
+
version: 0.12.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zachery Moneypenny
|
@@ -88,15 +88,8 @@ executables: []
|
|
88
88
|
extensions: []
|
89
89
|
extra_rdoc_files: []
|
90
90
|
files:
|
91
|
-
- ".gitignore"
|
92
|
-
- ".travis.yml"
|
93
|
-
- ".yardopts"
|
94
|
-
- Gemfile
|
95
|
-
- Guardfile
|
96
91
|
- LICENSE
|
97
92
|
- README.md
|
98
|
-
- Rakefile
|
99
|
-
- changelog.md
|
100
93
|
- fitgem.gemspec
|
101
94
|
- lib/fitgem.rb
|
102
95
|
- lib/fitgem/activities.rb
|
@@ -113,6 +106,7 @@ files:
|
|
113
106
|
- lib/fitgem/glucose.rb
|
114
107
|
- lib/fitgem/heart_rate.rb
|
115
108
|
- lib/fitgem/helpers.rb
|
109
|
+
- lib/fitgem/locales.rb
|
116
110
|
- lib/fitgem/notifications.rb
|
117
111
|
- lib/fitgem/sleep.rb
|
118
112
|
- lib/fitgem/time_range.rb
|
@@ -120,11 +114,6 @@ files:
|
|
120
114
|
- lib/fitgem/users.rb
|
121
115
|
- lib/fitgem/version.rb
|
122
116
|
- lib/fitgem/water.rb
|
123
|
-
- spec/fitgem_constructor_spec.rb
|
124
|
-
- spec/fitgem_helper_spec.rb
|
125
|
-
- spec/fitgem_notifications_spec.rb
|
126
|
-
- spec/fitgem_spec.rb
|
127
|
-
- spec/spec_helper.rb
|
128
117
|
homepage: http://github.com/whazzmaster/fitgem
|
129
118
|
licenses: []
|
130
119
|
metadata: {}
|
@@ -148,10 +137,5 @@ rubygems_version: 2.4.5
|
|
148
137
|
signing_key:
|
149
138
|
specification_version: 4
|
150
139
|
summary: OAuth client library to the data on fitbit.com
|
151
|
-
test_files:
|
152
|
-
- spec/fitgem_spec.rb
|
153
|
-
- spec/spec_helper.rb
|
154
|
-
- spec/fitgem_notifications_spec.rb
|
155
|
-
- spec/fitgem_helper_spec.rb
|
156
|
-
- spec/fitgem_constructor_spec.rb
|
140
|
+
test_files: []
|
157
141
|
has_rdoc:
|
data/.gitignore
DELETED
data/.travis.yml
DELETED
data/.yardopts
DELETED
data/Gemfile
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
source "http://rubygems.org"
|
2
|
-
|
3
|
-
# Specify your gem's dependencies in fitgem.gemspec
|
4
|
-
gemspec
|
5
|
-
|
6
|
-
group :test do
|
7
|
-
gem 'guard-rspec'
|
8
|
-
gem 'fuubar'
|
9
|
-
gem 'rb-inotify', :require => false
|
10
|
-
gem 'rb-fsevent', :require => false
|
11
|
-
gem 'rb-fchange', :require => false
|
12
|
-
gem 'terminal-notifier-guard'
|
13
|
-
end
|
data/Guardfile
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
# A sample Guardfile
|
2
|
-
# More info at https://github.com/guard/guard#readme
|
3
|
-
|
4
|
-
guard 'rspec', :cli => "--color --format Fuubar --fail-fast", :version => 2 do
|
5
|
-
watch(%r{^spec/.+_spec\.rb$})
|
6
|
-
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
7
|
-
watch('spec/spec_helper.rb') { "spec" }
|
8
|
-
|
9
|
-
# Rails example
|
10
|
-
watch(%r{^spec/.+_spec\.rb$})
|
11
|
-
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
12
|
-
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
13
|
-
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
|
14
|
-
watch('spec/spec_helper.rb') { "spec" }
|
15
|
-
end
|
data/Rakefile
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
require 'bundler'
|
2
|
-
require 'rspec/core/rake_task'
|
3
|
-
|
4
|
-
Bundler::GemHelper.install_tasks
|
5
|
-
|
6
|
-
desc 'Default: run specs.'
|
7
|
-
task :default => :spec
|
8
|
-
|
9
|
-
desc "Run specs"
|
10
|
-
RSpec::Core::RakeTask.new do |t|
|
11
|
-
t.pattern = "./spec/**/*_spec.rb" # don't need this, it's default.
|
12
|
-
# Put spec opts in a file named .rspec in root
|
13
|
-
end
|
data/changelog.md
DELETED
@@ -1,166 +0,0 @@
|
|
1
|
-
# @markup markdown
|
2
|
-
# @author Zachery Moneypenny
|
3
|
-
|
4
|
-
# fitgem changelog
|
5
|
-
|
6
|
-
## v0.10.0
|
7
|
-
|
8
|
-
#### 2014-08-08 Zachery Moneypenny <fitgem@whazzmaster.com>
|
9
|
-
|
10
|
-
* Updates default test framework to RSpec 3
|
11
|
-
* Updates library to use SSL exclusively when hitting the Fitbit REST API. Fitbit is restricting access to its API via https only on November 3rd, 2014. See [issue #30](https://github.com/whazzmaster/fitgem/issues/30) for more information. This should be transparent to end users of fitgem, as the library simply ignores the :ssl option in the Client constructor and defaults to https everywhere.
|
12
|
-
* The previously-deprecated `weekly_leaderboard` and `monthly_leaderboard` methods have now been updated to throw a `DeprecatedApiError` rather than warning about deprecation. These methods will be removed in v1.0.
|
13
|
-
|
14
|
-
## v0.9.0
|
15
|
-
|
16
|
-
#### 2014-02-11 Zachery Moneypenny <fitgem@whazzmaster.com>
|
17
|
-
|
18
|
-
The v0.9.0 release adds a number of new methods to match new functionality available through the Fitbit REST API. It
|
19
|
-
also removes support for concepts (monthly leaderboards) that have been removed from the Fitbit REST API.
|
20
|
-
|
21
|
-
There's a big change to **leaderboard support** in this update; please read the notes below if you're currently using
|
22
|
-
`monthly_leaderboard` or `weekly_leaderboard` -- you should update your code to use the new method before v1.0 is
|
23
|
-
released.
|
24
|
-
|
25
|
-
* Add ability to target SSL Fitbit REST endpoints
|
26
|
-
* Add `activity_on_date_range` method
|
27
|
-
* Condense existing `weekly_leaderboard` and (no longer available) `monthly_leaderboard` into a simple `leaderboard`
|
28
|
-
method. There is now only one leaderboard (weekly) so no need to differentiate in the API. The previous leaderboard
|
29
|
-
methods are now deprecated and **will be removed** in v1.0.
|
30
|
-
* Add `create_or_update_weekly_goal` method and specs
|
31
|
-
* Add `create_or_update_daily_goal` method and specs
|
32
|
-
* Add `daily_goals` method and update documentation
|
33
|
-
* Add `delete_body_fat_log` method
|
34
|
-
* Add `delete_body_weight_log` method
|
35
|
-
* Add `create_or_update_body_fat_goal` method
|
36
|
-
* Add `create_or_update_body_weight_goal` method
|
37
|
-
* Add `log_body_fat` method to push a body fat measurement to Fitbit
|
38
|
-
* Add `body_fat_goal` method to fetch the current body fat goal
|
39
|
-
* Add `body_fat` method to fetch body fat measurements
|
40
|
-
* Add `body_weight` method to fetch body fat measurements
|
41
|
-
* For the `body_weight` and `body_fat` methods, determine a URI based on the base URI and provided options
|
42
|
-
|
43
|
-
## v0.8.0
|
44
|
-
|
45
|
-
#### 2013-08-03 Zachery Moneypenny <fitgem@whazzmaster.com>
|
46
|
-
|
47
|
-
* Add support for weekly goals
|
48
|
-
* Add support for silent alarms (including updates)
|
49
|
-
* Add support for intraday distance
|
50
|
-
* Add time zone support for usage of times
|
51
|
-
* Add support for badges
|
52
|
-
|
53
|
-
## v0.7.0
|
54
|
-
|
55
|
-
#### 2013-05-17 Zachery Moneypenny <fitgem@whazzmaster.com>
|
56
|
-
|
57
|
-
* Add support for intraday time series retrieval of various resources
|
58
|
-
* Removed rvmrc from project- use whatever ruby you want!
|
59
|
-
* Updated Travis CI configuration
|
60
|
-
|
61
|
-
## v0.6.1
|
62
|
-
|
63
|
-
#### 2013-02-28 Zachery Moneypenny <fitgem@whazzmaster.com>
|
64
|
-
|
65
|
-
* More unit tests
|
66
|
-
* Fix an issue where we weren't applying the `format_date` helper when constructing a date range fragment
|
67
|
-
|
68
|
-
## v0.6.0
|
69
|
-
|
70
|
-
* Streamline the README; add contributors link
|
71
|
-
* Removed FAQs from README
|
72
|
-
* Added support for daily activity goals
|
73
|
-
* Moved testing-focused gemspec dependencies to the Gemfile
|
74
|
-
|
75
|
-
#### 2013-02-13 Zachery Moneypenny <fitgem@whazzmaster.com>
|
76
|
-
|
77
|
-
## v0.5.2
|
78
|
-
|
79
|
-
#### 2012-03-04 Zachery Moneypenny <fitgem@whazzmaster.com>
|
80
|
-
|
81
|
-
* Added new <tt>symbolize_keys</tt> helper method for turning the string-key based return hashes into symbol-key based ones
|
82
|
-
* Added new <tt>label_for_measurement</tt> helper method to get the correct unit measurement label given a measurement type and the current user's ApiUnitSystem setting
|
83
|
-
* Added specs
|
84
|
-
* Added new <tt>connected?</tt> method on Fitgem::Client that will report whether API calls may be made
|
85
|
-
* Added <tt>InvalidUnitSystem</tt> error and <tt>InvalidMeasurementType</tt> error
|
86
|
-
* Fixed a small issue where date values were not being formatted correctly in calls to <tt>log_body_measurements</tt>
|
87
|
-
|
88
|
-
## v0.5.1
|
89
|
-
|
90
|
-
#### 2012-01-24 Zachery Moneypenny <fitgem@whazzmaster.com>
|
91
|
-
|
92
|
-
* Fix for creating and removing data subscriptions
|
93
|
-
* Updated specs
|
94
|
-
|
95
|
-
## v0.5.0
|
96
|
-
|
97
|
-
#### 2012-01-22 Zachery Moneypenny <fitgem@whazzmaster.com>
|
98
|
-
|
99
|
-
* Added view/log/delete access for blood pressure data
|
100
|
-
* Added view/log/delete access for glucose data
|
101
|
-
* Added view/log/delete access for heart rate data
|
102
|
-
* Added updated time series documentation for new endpoints
|
103
|
-
* Updated temporal information in the readme
|
104
|
-
* Added unit tests for <tt>format_time</tt> method
|
105
|
-
* Updated copyright date
|
106
|
-
|
107
|
-
## v0.4.0
|
108
|
-
|
109
|
-
#### 2011-11-29 Zachery Moneypenny <fitgem@whazzmaster.com>
|
110
|
-
|
111
|
-
* Added YARD documentation to thoroughly document code
|
112
|
-
* DEPRECATED: <tt>Fitgem::Client#log_weight</tt> method, use <tt>Fitgem::Client#log_body_measurements</tt> instead.
|
113
|
-
The new method allows you to log more than weight (bicep size, body fat %, etc.)
|
114
|
-
* Added <tt>Fitgem::FoodFormType</tt> to be used in calls to <tt>Fitgem::Client#create_food</tt>
|
115
|
-
* Added <tt>Fitgem::Client#log_sleep</tt> to log sleep data to fitbit
|
116
|
-
* Added <tt>Fitgem::Client#delete_sleep_log</tt> to delete previously logged sleep data
|
117
|
-
* Added <tt>Fitgem::Client#activities</tt> method to get a list of all activities
|
118
|
-
* Added <tt>Fitgem::Client#activity_statistics</tt> method to get statistics for all logged activities
|
119
|
-
* Added to documentation of supported endpoints for <tt>Fitgem::Client#data_by_time_range</tt>
|
120
|
-
* Added unit tests for parameter validation for many methods
|
121
|
-
* Overhauled notifications methods, including extensive documentation,
|
122
|
-
unit tests, refactoring, and a couple of bug fixes. These methods now
|
123
|
-
return both the HTTP status code and the JSON response body. See https://wiki.fitbit.com/display/API/Subscriptions-API
|
124
|
-
for information on how to interpret each of the error codes.
|
125
|
-
* Added fitgem to travis-ci for continuous integration (http://travis-ci.org/#!/whazzmaster/fitgem)
|
126
|
-
* Added fitgem to rubydoc.info (http://rubydoc.info/github/whazzmaster/fitgem/master/frames)
|
127
|
-
* Updated README
|
128
|
-
* Moved OAuth documentation from the README to the [fitgem wiki](https://github.com/whazzmaster/fitgem/wiki/The-OAuth-Process)
|
129
|
-
|
130
|
-
## v0.3.6
|
131
|
-
|
132
|
-
#### 2011-07-12 Zachery Moneypenny <fitgem@whazzmaster.com>
|
133
|
-
|
134
|
-
* Added friends support (get friends, friend leaderboard, create invites, accept/reject invites)
|
135
|
-
* Added water support (get water data per date)
|
136
|
-
* Added sleep support (get sleep data per date)
|
137
|
-
* Added ability to update user profile information
|
138
|
-
|
139
|
-
## Previous Releases
|
140
|
-
|
141
|
-
#### 2011-05-11 Zachery Moneypenny <fitgem@whazzmaster.com>
|
142
|
-
|
143
|
-
* Changed name and all references of this project from 'fitbit' to 'fitgem'
|
144
|
-
|
145
|
-
#### 2011-04-11 Zachery Moneypenny <fitgem@whazzmaster.com>
|
146
|
-
|
147
|
-
* Fixed an issue where blank user id's are used and an error is thrown.
|
148
|
-
* Added support for creating/removing subscriptions (this support is experimental for now, more tests coming)
|
149
|
-
|
150
|
-
#### 2011-03-24 Zachery Moneypenny <fitgem@whazzmaster.com>
|
151
|
-
|
152
|
-
* Added logging of activities and foods
|
153
|
-
* Added ability to add favorite activities and foods
|
154
|
-
* Added ability to delete logged activities and foods, and remove favorite activities and foods
|
155
|
-
* Refactored data_by_time_range for more testability
|
156
|
-
* Added ability to query devices
|
157
|
-
|
158
|
-
#### 2011-03-19 Zachery Moneypenny <fitgem@whazzmaster.com>
|
159
|
-
|
160
|
-
* Updated auth client to support first-time auth and reconnections (if you have previously been authorized and received token/secret).
|
161
|
-
* Added 'named' retrieval of activities and foods (recent_, favorite_, frequent_)
|
162
|
-
* Added ability to log weight back to the site using the API
|
163
|
-
|
164
|
-
#### 2011-03-18 Zachery Moneypenny <fitgem@whazzmaster.com>
|
165
|
-
|
166
|
-
* First revision. Supports the auth process via oauth, and retrieval of user info and activities.
|
@@ -1,19 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Fitgem::Client do
|
4
|
-
describe "constructor" do
|
5
|
-
it "requires consumer_key" do
|
6
|
-
expect {
|
7
|
-
opts = { :consumer_secret => "12345" }
|
8
|
-
client = Fitgem::Client.new(opts)
|
9
|
-
}.to raise_error(Fitgem::InvalidArgumentError, "Missing required options: consumer_key")
|
10
|
-
end
|
11
|
-
|
12
|
-
it "requires consumer_secret" do
|
13
|
-
expect {
|
14
|
-
opts = { :consumer_key => "12345" }
|
15
|
-
client = Fitgem::Client.new(opts)
|
16
|
-
}.to raise_error(Fitgem::InvalidArgumentError, "Missing required options: consumer_secret")
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
data/spec/fitgem_helper_spec.rb
DELETED
@@ -1,244 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Fitgem::Client do
|
4
|
-
before(:each) do
|
5
|
-
@client = Fitgem::Client.new({
|
6
|
-
:consumer_key => '12345',
|
7
|
-
:consumer_secret => '67890'
|
8
|
-
})
|
9
|
-
end
|
10
|
-
|
11
|
-
describe "#construct_date_range_fragment" do
|
12
|
-
it 'should format the correct URI fragment based on a base date and end date' do
|
13
|
-
frag = @client.construct_date_range_fragment({:base_date => '2011-03-07', :end_date => '2011-03-14'})
|
14
|
-
expect(frag).to eq 'date/2011-03-07/2011-03-14'
|
15
|
-
end
|
16
|
-
|
17
|
-
it 'should format the correct URI fragment based on a base date and period' do
|
18
|
-
frag = @client.construct_date_range_fragment({:base_date => '2011-03-07', :period => '7d'})
|
19
|
-
expect(frag).to eq 'date/2011-03-07/7d'
|
20
|
-
end
|
21
|
-
|
22
|
-
it 'should raise an error unless there is a base date AND either a period or an end date' do
|
23
|
-
expect {
|
24
|
-
@client.construct_date_range_fragment({:base_date => '2011-03-07'})
|
25
|
-
}.to raise_error(Fitgem::InvalidTimeRange)
|
26
|
-
|
27
|
-
expect {
|
28
|
-
@client.construct_date_range_fragment({:period => '1y'})
|
29
|
-
}.to raise_error(Fitgem::InvalidTimeRange)
|
30
|
-
|
31
|
-
expect {
|
32
|
-
@client.construct_date_range_fragment({:end_date => '2011-03-07', :period => '7d'})
|
33
|
-
}.to raise_error(Fitgem::InvalidTimeRange)
|
34
|
-
end
|
35
|
-
|
36
|
-
it 'formats DateTime objects to the required date format' do
|
37
|
-
span_start = DateTime.new(1997, 4, 18, 9, 30, 30)
|
38
|
-
span_end = DateTime.new(1999, 10, 3, 15, 30, 30)
|
39
|
-
frag = @client.construct_date_range_fragment base_date: span_start, end_date: span_end
|
40
|
-
expect(frag).to eq 'date/1997-04-18/1999-10-03'
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
describe "#format_date" do
|
45
|
-
it "accepts DateTime objects" do
|
46
|
-
date = DateTime.strptime('2011-03-19','%Y-%m-%d')
|
47
|
-
expect(@client.format_date(date)).to eq '2011-03-19'
|
48
|
-
end
|
49
|
-
|
50
|
-
it "accepts strings in YYYY-MM-DD format" do
|
51
|
-
expect(@client.format_date('2011-03-19')).to eq '2011-03-19'
|
52
|
-
end
|
53
|
-
|
54
|
-
it "accepts the string 'today' to denote the current date" do
|
55
|
-
today = Date.today.strftime("%Y-%m-%d")
|
56
|
-
expect(@client.format_date('today')).to eq today
|
57
|
-
end
|
58
|
-
|
59
|
-
it "accepts the string 'yesterday' to denote the day previous to today" do
|
60
|
-
yesterday = (Date.today-1).strftime("%Y-%m-%d")
|
61
|
-
expect(@client.format_date('yesterday')).to eq yesterday
|
62
|
-
end
|
63
|
-
|
64
|
-
it "rejects strings that are not in YYY-MM-DD format" do
|
65
|
-
date = "2011-3-2"
|
66
|
-
expect {
|
67
|
-
@client.format_date(date)
|
68
|
-
}.to raise_error Fitgem::InvalidDateArgument, "Invalid date (2011-3-2), must be in yyyy-MM-dd format"
|
69
|
-
end
|
70
|
-
|
71
|
-
it "rejects strings are formatted correctly but include non-numeric elements" do
|
72
|
-
date = "2011-aa-20"
|
73
|
-
expect {
|
74
|
-
@client.format_date(date)
|
75
|
-
}.to raise_error Fitgem::InvalidDateArgument, "Invalid date (2011-aa-20), must be in yyyy-MM-dd format"
|
76
|
-
end
|
77
|
-
|
78
|
-
it "rejects arguments that are not a Date, Time, DateTime, or String" do
|
79
|
-
date = 200
|
80
|
-
expect {
|
81
|
-
@client.format_date(date)
|
82
|
-
}.to raise_error Fitgem::InvalidDateArgument, "Date used must be a date/time object or a string in the format YYYY-MM-DD; supplied argument is a Fixnum"
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
describe "#format_time" do
|
87
|
-
context "without a timezone" do
|
88
|
-
it "accepts DateTime objects" do
|
89
|
-
time = DateTime.parse("3rd Feb 2001 04:05:06 PM")
|
90
|
-
expect(@client.format_time(time)).to eq "16:05"
|
91
|
-
end
|
92
|
-
|
93
|
-
it "accepts Time objects" do
|
94
|
-
time = Time.mktime 2012, 1, 20, 13, 33, 30
|
95
|
-
expect(@client.format_time(time)).to eq "13:33"
|
96
|
-
end
|
97
|
-
|
98
|
-
it "accepts the string 'now' to denote the current localtime" do
|
99
|
-
now = DateTime.now
|
100
|
-
expect(@client.format_time('now')).to eq now.strftime("%H:%M")
|
101
|
-
end
|
102
|
-
|
103
|
-
it "accepts strings in HH:mm format" do
|
104
|
-
time = "04:20"
|
105
|
-
expect(@client.format_time(time)).to eq "04:20"
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
context "with a timezone" do
|
110
|
-
it "accepts DateTime objects" do
|
111
|
-
time = DateTime.parse("3rd Feb 2001 04:05:06 PM UTC")
|
112
|
-
expect(@client.format_time(time, include_timezone: true)).to eq "16:05+00:00"
|
113
|
-
end
|
114
|
-
|
115
|
-
it "accepts Time objects" do
|
116
|
-
time = Time.new 2012, 1, 20, 13, 33, 30, "+00:00"
|
117
|
-
expect(@client.format_time(time, include_timezone: true)).to eq "13:33+00:00"
|
118
|
-
end
|
119
|
-
|
120
|
-
it "accepts the string 'now' to denote the current localtime" do
|
121
|
-
now = DateTime.now
|
122
|
-
expect(@client.format_time('now', include_timezone: true)).to eq now.strftime("%H:%M%:z")
|
123
|
-
end
|
124
|
-
|
125
|
-
it "accepts strings in HH:mm format" do
|
126
|
-
datetime = DateTime.parse("26th Apr 2000 09:27:00 +08:00")
|
127
|
-
allow(DateTime).to receive(:now).and_return datetime
|
128
|
-
|
129
|
-
time = "04:20"
|
130
|
-
expect(@client.format_time(time, include_timezone: true)).to eq "04:20+08:00"
|
131
|
-
end
|
132
|
-
end
|
133
|
-
|
134
|
-
it "rejects Date objects" do
|
135
|
-
date = Date.today
|
136
|
-
expect {
|
137
|
-
@client.format_time(date)
|
138
|
-
}.to raise_error Fitgem::InvalidTimeArgument
|
139
|
-
end
|
140
|
-
|
141
|
-
it "rejects strings that are not in HH:mm format" do
|
142
|
-
time = "4:20pm"
|
143
|
-
expect {
|
144
|
-
@client.format_time(time)
|
145
|
-
}.to raise_error Fitgem::InvalidTimeArgument
|
146
|
-
end
|
147
|
-
|
148
|
-
it "rejects strings that are formatted correctly but include non-numeric elements" do
|
149
|
-
time = "4a:33"
|
150
|
-
expect {
|
151
|
-
@client.format_time(time)
|
152
|
-
}.to raise_error Fitgem::InvalidTimeArgument
|
153
|
-
end
|
154
|
-
|
155
|
-
it "rejects arguments that do not conform to accepted types" do
|
156
|
-
expect {
|
157
|
-
@client.format_time(200)
|
158
|
-
}.to raise_error Fitgem::InvalidTimeArgument
|
159
|
-
end
|
160
|
-
end
|
161
|
-
|
162
|
-
describe "#label_for_measurement" do
|
163
|
-
it "accepts the supported Fitgem::ApiUnitSystem values" do
|
164
|
-
@client.api_unit_system = Fitgem::ApiUnitSystem.US
|
165
|
-
@client.label_for_measurement :duration, false
|
166
|
-
@client.api_unit_system = Fitgem::ApiUnitSystem.UK
|
167
|
-
@client.label_for_measurement :duration, false
|
168
|
-
@client.api_unit_system = Fitgem::ApiUnitSystem.METRIC
|
169
|
-
@client.label_for_measurement :duration, false
|
170
|
-
end
|
171
|
-
|
172
|
-
it "raises an InvalidUnitSystem error if the Fitgem::Client.api_unit_system value is invalid" do
|
173
|
-
expect {
|
174
|
-
@client.api_unit_system = "something else entirely"
|
175
|
-
@client.label_for_measurement :duration, false
|
176
|
-
}.to raise_error Fitgem::InvalidUnitSystem
|
177
|
-
end
|
178
|
-
|
179
|
-
it "accepts the supported values for the measurement_type parameter" do
|
180
|
-
@client.label_for_measurement :duration, false
|
181
|
-
@client.label_for_measurement :distance, false
|
182
|
-
@client.label_for_measurement :elevation, false
|
183
|
-
@client.label_for_measurement :height, false
|
184
|
-
@client.label_for_measurement :weight, false
|
185
|
-
@client.label_for_measurement :measurements, false
|
186
|
-
@client.label_for_measurement :liquids, false
|
187
|
-
@client.label_for_measurement :blood_glucose, false
|
188
|
-
end
|
189
|
-
|
190
|
-
it "raises an InvalidMeasurementType error if the measurement_type parameter is invalid" do
|
191
|
-
expect {
|
192
|
-
@client.label_for_measurement :homina, false
|
193
|
-
}.to raise_error Fitgem::InvalidMeasurementType
|
194
|
-
end
|
195
|
-
|
196
|
-
it "returns the correct values when the unit system is Fitgem::ApiUnitSystem.US" do
|
197
|
-
@client.api_unit_system = Fitgem::ApiUnitSystem.US
|
198
|
-
expect(@client.label_for_measurement(:duration, false)).to eq "milliseconds"
|
199
|
-
expect(@client.label_for_measurement(:distance, false)).to eq "miles"
|
200
|
-
expect(@client.label_for_measurement(:elevation, false)).to eq "feet"
|
201
|
-
expect(@client.label_for_measurement(:height, false)).to eq "inches"
|
202
|
-
expect(@client.label_for_measurement(:weight, false)).to eq "pounds"
|
203
|
-
expect(@client.label_for_measurement(:measurements, false)).to eq "inches"
|
204
|
-
expect(@client.label_for_measurement(:liquids, false)).to eq "fl oz"
|
205
|
-
expect(@client.label_for_measurement(:blood_glucose, false)).to eq "mg/dL"
|
206
|
-
end
|
207
|
-
|
208
|
-
it "returns the correct values when the unit system is Fitgem::ApiUnitSystem.UK" do
|
209
|
-
@client.api_unit_system = Fitgem::ApiUnitSystem.UK
|
210
|
-
expect(@client.label_for_measurement(:duration, false)).to eq "milliseconds"
|
211
|
-
expect(@client.label_for_measurement(:distance, false)).to eq "kilometers"
|
212
|
-
expect(@client.label_for_measurement(:elevation, false)).to eq "meters"
|
213
|
-
expect(@client.label_for_measurement(:height, false)).to eq "centimeters"
|
214
|
-
expect(@client.label_for_measurement(:weight, false)).to eq "stone"
|
215
|
-
expect(@client.label_for_measurement(:measurements, false)).to eq "centimeters"
|
216
|
-
expect(@client.label_for_measurement(:liquids, false)).to eq "mL"
|
217
|
-
expect(@client.label_for_measurement(:blood_glucose, false)).to eq "mmol/l"
|
218
|
-
end
|
219
|
-
|
220
|
-
it "returns the correct values when the unit system is Fitgem::ApiUnitSystem.METRIC" do
|
221
|
-
@client.api_unit_system = Fitgem::ApiUnitSystem.METRIC
|
222
|
-
expect(@client.label_for_measurement(:duration, false)).to eq "milliseconds"
|
223
|
-
expect(@client.label_for_measurement(:distance, false)).to eq "kilometers"
|
224
|
-
expect(@client.label_for_measurement(:elevation, false)).to eq "meters"
|
225
|
-
expect(@client.label_for_measurement(:height, false)).to eq "centimeters"
|
226
|
-
expect(@client.label_for_measurement(:weight, false)).to eq "kilograms"
|
227
|
-
expect(@client.label_for_measurement(:measurements, false)).to eq "centimeters"
|
228
|
-
expect(@client.label_for_measurement(:liquids, false)).to eq "mL"
|
229
|
-
expect(@client.label_for_measurement(:blood_glucose, false)).to eq "mmol/l"
|
230
|
-
end
|
231
|
-
|
232
|
-
context "when respecting the user's unit measurement preferences" do
|
233
|
-
before(:each) do
|
234
|
-
allow(@client).to receive(:connected?).and_return(true)
|
235
|
-
allow(@client).to receive(:user_info).and_return({"user" => {"distanceUnit"=>"en_GB", "glucoseUnit"=>"en_GB", "heightUnit"=>"en_GB", "waterUnit"=>"METRIC", "weightUnit"=>"en_GB"}})
|
236
|
-
end
|
237
|
-
|
238
|
-
it "returns the correct overridden measurement label" do
|
239
|
-
@client.api_unit_system = Fitgem::ApiUnitSystem.US
|
240
|
-
expect(@client.label_for_measurement(:distance)).to eq "kilometers"
|
241
|
-
end
|
242
|
-
end
|
243
|
-
end
|
244
|
-
end
|
@@ -1,173 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'ostruct'
|
3
|
-
|
4
|
-
describe Fitgem::Client do
|
5
|
-
before(:each) do
|
6
|
-
@client = Fitgem::Client.new({:consumer_key => '12345', :consumer_secret => '56789'})
|
7
|
-
end
|
8
|
-
|
9
|
-
describe "#subscriptions" do
|
10
|
-
before(:each) do
|
11
|
-
allow(@client).to receive(:get)
|
12
|
-
end
|
13
|
-
|
14
|
-
it "calls #make_headers to create the headers for the API call" do
|
15
|
-
opts = { :subscriber_id => "5555", :type => :all }
|
16
|
-
expect(@client).to receive(:make_headers).with({:type=>:all, :subscriber_id=>"5555"})
|
17
|
-
@client.subscriptions(opts)
|
18
|
-
end
|
19
|
-
|
20
|
-
it "calls #get with the correct url and headers" do
|
21
|
-
opts = { :subscriber_id => "5555", :type => :all }
|
22
|
-
expect(@client).to receive(:get).with("/user/-/apiSubscriptions.json", {"X-Fitbit-Subscriber-Id"=>"5555"})
|
23
|
-
@client.subscriptions(opts)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
describe "#create_subscription" do
|
28
|
-
before(:each) do
|
29
|
-
@resp = OpenStruct.new
|
30
|
-
allow(@client).to receive(:raw_post).and_return(@resp)
|
31
|
-
end
|
32
|
-
|
33
|
-
it "adds the :use_subscription_id flag and calls #make_headers" do
|
34
|
-
opts = { :subscriber_id => "5555", :type => :all, :subscription_id => "320" }
|
35
|
-
expect(@client).to receive(:make_headers).with({ :subscriber_id => "5555", :type => :all, :subscription_id => "320"})
|
36
|
-
@client.create_subscription(opts)
|
37
|
-
end
|
38
|
-
|
39
|
-
it "calls #raw_post with the correct url and headers for :all collection type" do
|
40
|
-
opts = { :subscriber_id => "5555", :type => :all, :subscription_id => "320", :use_subscription_id => true }
|
41
|
-
expect(@client).to receive(:raw_post).once.with("/user/-/apiSubscriptions/320.json", "", {"X-Fitbit-Subscriber-Id"=>"5555"})
|
42
|
-
@client.create_subscription(opts)
|
43
|
-
end
|
44
|
-
|
45
|
-
it "calls #raw_post with the correct url and headers for :sleep collection type" do
|
46
|
-
opts = { :subscriber_id => "5555", :type => :sleep, :subscription_id => "320", :use_subscription_id => true }
|
47
|
-
expect(@client).to receive(:raw_post).once.with("/user/-/sleep/apiSubscriptions/320.json", "", {"X-Fitbit-Subscriber-Id"=>"5555"})
|
48
|
-
@client.create_subscription(opts)
|
49
|
-
end
|
50
|
-
|
51
|
-
it "calls #extract_response_body to get the JSON body" do
|
52
|
-
opts = { :subscriber_id => "5555", :type => :all, :subscription_id => "320", :use_subscription_id => true }
|
53
|
-
expect(@client).to receive(:extract_response_body)
|
54
|
-
@client.create_subscription(opts)
|
55
|
-
end
|
56
|
-
|
57
|
-
it "returns the code and the JSON body in an array" do
|
58
|
-
opts = { :subscriber_id => "5555", :type => :all, :subscription_id => "320", :use_subscription_id => true }
|
59
|
-
expect(@resp).to receive(:code).twice
|
60
|
-
expect(@client.create_subscription(opts)).to be_a(Array)
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
describe "#remove_subscription" do
|
65
|
-
before(:each) do
|
66
|
-
@resp = OpenStruct.new
|
67
|
-
allow(@client).to receive(:raw_delete).and_return(@resp)
|
68
|
-
end
|
69
|
-
|
70
|
-
it "adds the :use_subscription_id flag and calls #make_headers" do
|
71
|
-
opts = { :subscriber_id => "5555", :type => :all, :subscription_id => "320" }
|
72
|
-
expect(@client).to receive(:make_headers).with({ :subscriber_id => "5555", :type => :all, :subscription_id => "320" })
|
73
|
-
@client.remove_subscription(opts)
|
74
|
-
end
|
75
|
-
|
76
|
-
it "calls #raw_delete with the correct url and headers for :all collection type" do
|
77
|
-
opts = { :subscriber_id => "5555", :type => :all, :subscription_id => "320", :use_subscription_id => true }
|
78
|
-
expect(@client).to receive(:raw_delete).once.with("/user/-/apiSubscriptions/320.json", {"X-Fitbit-Subscriber-Id"=>"5555"})
|
79
|
-
@client.remove_subscription(opts)
|
80
|
-
end
|
81
|
-
|
82
|
-
it "calls #extract_response_body to get the JSON body" do
|
83
|
-
opts = { :subscriber_id => "5555", :type => :all, :subscription_id => "320", :use_subscription_id => true }
|
84
|
-
expect(@client).to receive(:extract_response_body)
|
85
|
-
@client.remove_subscription(opts)
|
86
|
-
end
|
87
|
-
|
88
|
-
it "returns the code and the JSON body in an array" do
|
89
|
-
opts = { :subscriber_id => "5555", :type => :all, :subscription_id => "320", :use_subscription_id => true }
|
90
|
-
expect(@resp).to receive(:code).twice
|
91
|
-
expect(@client.remove_subscription(opts)).to be_a(Array)
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
describe "#validate_subscription_types" do
|
96
|
-
it "raises an exception if an invalid type is passed in" do
|
97
|
-
expect {
|
98
|
-
@client.send(:validate_subscription_type, :every_single_thing)
|
99
|
-
}.to raise_error Fitgem::InvalidArgumentError, "Invalid subscription type (valid values are sleep, body, activities, foods, all)"
|
100
|
-
end
|
101
|
-
|
102
|
-
it "raises an exception if no type is supplied" do
|
103
|
-
opts = { :opt1 => 'hello!' }
|
104
|
-
expect {
|
105
|
-
@client.send(:validate_subscription_type, opts[:type])
|
106
|
-
}.to raise_error Fitgem::InvalidArgumentError
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
describe "#make_headers" do
|
111
|
-
it "adds the subscriber id header" do
|
112
|
-
opts = { :subscriber_id => '5555', :subscription_id => '320-activity' }
|
113
|
-
headers = @client.send(:make_headers, opts)
|
114
|
-
expect(headers.size).to eq 1
|
115
|
-
expect(headers['X-Fitbit-Subscriber-Id']).to eq "5555"
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
describe "#make_subscription_url" do
|
120
|
-
it "creates the correct URL when no specific subscription id is used" do
|
121
|
-
opts = { :subscription_id => "320", :type => :all }
|
122
|
-
expect(@client.send(:make_subscription_url, opts)).to eq "/user/-/apiSubscriptions.json"
|
123
|
-
end
|
124
|
-
|
125
|
-
it "creates the correct URL for :all collection types" do
|
126
|
-
opts = { :subscription_id => "320", :type => :all, :use_subscription_id => true }
|
127
|
-
expect(@client.send(:make_subscription_url, opts)).to eq "/user/-/apiSubscriptions/320.json"
|
128
|
-
end
|
129
|
-
|
130
|
-
it "creates the correct URL for the :sleep collection type" do
|
131
|
-
opts = { :subscription_id => "320", :type => :sleep, :use_subscription_id => true }
|
132
|
-
expect(@client.send(:make_subscription_url, opts)).to eq "/user/-/sleep/apiSubscriptions/320.json"
|
133
|
-
end
|
134
|
-
|
135
|
-
it "creates the correct URL for the :body collection type" do
|
136
|
-
opts = { :subscription_id => "320", :type => :body, :use_subscription_id => true }
|
137
|
-
expect(@client.send(:make_subscription_url, opts)).to eq "/user/-/body/apiSubscriptions/320.json"
|
138
|
-
end
|
139
|
-
|
140
|
-
it "creates the correct URL for the :activities collection type" do
|
141
|
-
opts = { :subscription_id => "320", :type => :activities, :use_subscription_id => true }
|
142
|
-
expect(@client.send(:make_subscription_url, opts)).to eq "/user/-/activities/apiSubscriptions/320.json"
|
143
|
-
end
|
144
|
-
|
145
|
-
it "creates the correct URL for the :foods collection type" do
|
146
|
-
opts = { :subscription_id => "320", :type => :foods, :use_subscription_id => true }
|
147
|
-
expect(@client.send(:make_subscription_url, opts)).to eq "/user/-/foods/apiSubscriptions/320.json"
|
148
|
-
end
|
149
|
-
|
150
|
-
it "validates the supplied subscription type" do
|
151
|
-
opts = { :subscription_id => "320" }
|
152
|
-
expect { @client.send(:make_subscription_url, opts) }.to raise_error Fitgem::InvalidArgumentError
|
153
|
-
|
154
|
-
opts[:type] = nil
|
155
|
-
expect { @client.send(:make_subscription_url, opts) }.to raise_error Fitgem::InvalidArgumentError
|
156
|
-
|
157
|
-
opts[:type] = :all
|
158
|
-
expect { @client.send(:make_subscription_url, opts) }.not_to raise_error
|
159
|
-
|
160
|
-
opts[:type] = :activities
|
161
|
-
expect { @client.send(:make_subscription_url, opts) }.not_to raise_error
|
162
|
-
|
163
|
-
opts[:type] = :sleep
|
164
|
-
expect { @client.send(:make_subscription_url, opts) }.not_to raise_error
|
165
|
-
|
166
|
-
opts[:type] = :foods
|
167
|
-
expect { @client.send(:make_subscription_url, opts) }.not_to raise_error
|
168
|
-
|
169
|
-
opts[:type] = :body
|
170
|
-
expect { @client.send(:make_subscription_url, opts) }.not_to raise_error
|
171
|
-
end
|
172
|
-
end
|
173
|
-
end
|
data/spec/fitgem_spec.rb
DELETED
@@ -1,69 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Fitgem do
|
4
|
-
before do
|
5
|
-
@client = Fitgem::Client.new({
|
6
|
-
:consumer_key => '12345',
|
7
|
-
:consumer_secret => '67890'
|
8
|
-
})
|
9
|
-
end
|
10
|
-
|
11
|
-
describe 'global settings' do
|
12
|
-
it 'should expose the api_version' do
|
13
|
-
expect(@client.api_version).to eq "1"
|
14
|
-
end
|
15
|
-
|
16
|
-
it 'should all clients to set a new api version' do
|
17
|
-
@client.api_version = "2"
|
18
|
-
expect(@client.api_version).to eq "2"
|
19
|
-
end
|
20
|
-
|
21
|
-
it 'should default to the US unit system' do
|
22
|
-
expect(@client.api_unit_system).to eq Fitgem::ApiUnitSystem.US
|
23
|
-
end
|
24
|
-
|
25
|
-
it 'should allow the unit system to be set to other types' do
|
26
|
-
@client.api_unit_system = Fitgem::ApiUnitSystem.UK
|
27
|
-
expect(@client.api_unit_system).to eq Fitgem::ApiUnitSystem.UK
|
28
|
-
@client.api_unit_system = Fitgem::ApiUnitSystem.METRIC
|
29
|
-
expect(@client.api_unit_system).to eq Fitgem::ApiUnitSystem.METRIC
|
30
|
-
end
|
31
|
-
|
32
|
-
it 'should default to a user id of \'-\', the currently-logged in user' do
|
33
|
-
expect(@client.user_id).to eq '-'
|
34
|
-
end
|
35
|
-
|
36
|
-
it 'should default to the US locale' do
|
37
|
-
expect(@client.api_locale).to eq Fitgem::ApiLocale.US
|
38
|
-
end
|
39
|
-
|
40
|
-
it 'should allow the locale to be set to other types' do
|
41
|
-
@client.api_locale = Fitgem::ApiLocale.AU
|
42
|
-
expect(@client.api_locale).to eq Fitgem::ApiLocale.AU
|
43
|
-
@client.api_locale = Fitgem::ApiLocale.FR
|
44
|
-
expect(@client.api_locale).to eq Fitgem::ApiLocale.FR
|
45
|
-
@client.api_locale = Fitgem::ApiLocale.DE
|
46
|
-
expect(@client.api_locale).to eq Fitgem::ApiLocale.DE
|
47
|
-
@client.api_locale = Fitgem::ApiLocale.JP
|
48
|
-
expect(@client.api_locale).to eq Fitgem::ApiLocale.JP
|
49
|
-
@client.api_locale = Fitgem::ApiLocale.NZ
|
50
|
-
expect(@client.api_locale).to eq Fitgem::ApiLocale.NZ
|
51
|
-
@client.api_locale = Fitgem::ApiLocale.ES
|
52
|
-
expect(@client.api_locale).to eq Fitgem::ApiLocale.ES
|
53
|
-
@client.api_locale = Fitgem::ApiLocale.UK
|
54
|
-
expect(@client.api_locale).to eq Fitgem::ApiLocale.UK
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
describe '#reconnect' do
|
59
|
-
it 'resets the access token' do
|
60
|
-
access_token = @client.reconnect('abc', '123')
|
61
|
-
expect(access_token.token).to eq('abc')
|
62
|
-
expect(access_token.secret).to eq('123')
|
63
|
-
|
64
|
-
access_token = @client.reconnect('def', '456')
|
65
|
-
expect(access_token.token).to eq('def')
|
66
|
-
expect(access_token.secret).to eq('456')
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|