mini_strava 0.1.0 → 0.2.0
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/README.md +1 -1
- data/lib/mini_strava/client.rb +3 -0
- data/lib/mini_strava/version.rb +1 -1
- data/spec/client_spec.rb +13 -4
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 17f57c2f43ce57a2adc6204a120300911952ec8b
|
4
|
+
data.tar.gz: b0695afa11997d750f50a17f3641c3e7d89a7988
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6a609b02a84cfc78ef00ace1776ab9d796ce0b1213a9ca642d487835cafcd307022827adbbd91d3443452fa56067af1d51c6a348d3fafdaba8b9eccfb3384c19
|
7
|
+
data.tar.gz: 02e2b65c27f97cd57c5554265da73c00577863fb3380c27aabf5f22098ccb08573981c384503f8136cd7ca43f5c2bf2bb7d587c8bdb8dac246872d9a2162e2ee
|
data/README.md
CHANGED
data/lib/mini_strava/client.rb
CHANGED
@@ -6,6 +6,7 @@ module MiniStrava
|
|
6
6
|
class Client
|
7
7
|
class AuthorizationError < Exception; end
|
8
8
|
class BlankAccessTokenError < Exception; end
|
9
|
+
class ResourceNotFound < Exception; end
|
9
10
|
|
10
11
|
BaseUrl = 'https://www.strava.com/api/v3'
|
11
12
|
|
@@ -46,6 +47,8 @@ module MiniStrava
|
|
46
47
|
case response.code
|
47
48
|
when 401
|
48
49
|
raise AuthorizationError.new
|
50
|
+
when 404
|
51
|
+
raise ResourceNotFound.new
|
49
52
|
else
|
50
53
|
response
|
51
54
|
end
|
data/lib/mini_strava/version.rb
CHANGED
data/spec/client_spec.rb
CHANGED
@@ -4,9 +4,8 @@ module MiniStrava
|
|
4
4
|
describe Client do
|
5
5
|
subject { Client.new 'test_token' }
|
6
6
|
|
7
|
-
|
7
|
+
describe '#build_uri' do
|
8
8
|
it 'should build uri with params' do
|
9
|
-
require 'pry'; binding.pry;
|
10
9
|
params = { foo: :bar, baz: :qux }
|
11
10
|
uri = subject.send(:build_uri, '/test', params)
|
12
11
|
|
@@ -15,7 +14,7 @@ module MiniStrava
|
|
15
14
|
end
|
16
15
|
end
|
17
16
|
|
18
|
-
|
17
|
+
describe 'parse_response' do
|
19
18
|
it 'should parse response and return an athlete model' do
|
20
19
|
body = double('body')
|
21
20
|
parsed_body = double('parsed_body')
|
@@ -28,6 +27,16 @@ module MiniStrava
|
|
28
27
|
end
|
29
28
|
end
|
30
29
|
|
30
|
+
describe 'perform_request' do
|
31
|
+
context 'not found' do
|
32
|
+
it 'raises a ResourceNotFound exception' do
|
33
|
+
not_found_response = double('response', code: 404)
|
34
|
+
allow(Net::HTTP).to receive(:start).and_return not_found_response
|
35
|
+
expect{ subject.send(:perform_request, nil, URI('http://localhost')) }.to raise_error(Client::ResourceNotFound)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
31
40
|
describe '#athlete' do
|
32
41
|
it 'should retrieve current athlete' do
|
33
42
|
body = fixture 'athlete'
|
@@ -40,7 +49,7 @@ module MiniStrava
|
|
40
49
|
end
|
41
50
|
end
|
42
51
|
|
43
|
-
|
52
|
+
describe '#activity' do
|
44
53
|
it 'should retrieve activity' do
|
45
54
|
body = fixture 'activity'
|
46
55
|
response = double('response', body: body)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mini_strava
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrea Franz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-01-
|
11
|
+
date: 2016-01-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ripl
|
@@ -124,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
124
124
|
version: '0'
|
125
125
|
requirements: []
|
126
126
|
rubyforge_project:
|
127
|
-
rubygems_version: 2.
|
127
|
+
rubygems_version: 2.5.1
|
128
128
|
signing_key:
|
129
129
|
specification_version: 4
|
130
130
|
summary: A simple client for the strava API
|