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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3fe815926d04faf11099a80f03e0b8a600aeec83
4
- data.tar.gz: 4ea64770e09e52df2c0992f501fd1d6f62f46445
3
+ metadata.gz: 17f57c2f43ce57a2adc6204a120300911952ec8b
4
+ data.tar.gz: b0695afa11997d750f50a17f3641c3e7d89a7988
5
5
  SHA512:
6
- metadata.gz: e1ab20bf97b537d815007926b2844e9a9ce0d258d67166c77bed2878a120ac6adbac6a5cca393e2e56dce6261b7dbf12a62e0e4e49bfe00e083855fece1bf36c
7
- data.tar.gz: 6f53c3fca48c184efd6e3d6afc0f087ef5dce56b085f7a1faaa85d15c37ad66674d8d2faa8f7a46d675776cfd44904b50442f355b67f419bfa222d5272e206f1
6
+ metadata.gz: 6a609b02a84cfc78ef00ace1776ab9d796ce0b1213a9ca642d487835cafcd307022827adbbd91d3443452fa56067af1d51c6a348d3fafdaba8b9eccfb3384c19
7
+ data.tar.gz: 02e2b65c27f97cd57c5554265da73c00577863fb3380c27aabf5f22098ccb08573981c384503f8136cd7ca43f5c2bf2bb7d587c8bdb8dac246872d9a2162e2ee
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # MiniStrava
2
2
 
3
- TODO: Write a gem description
3
+ A simple Ruby client and CLI for the Strava API.
4
4
 
5
5
  ## Installation
6
6
 
@@ -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
@@ -1,3 +1,3 @@
1
1
  module MiniStrava
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
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
- context '#build_uri' do
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
- context 'parse_response' do
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
- context '#activity' do
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.1.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-07 00:00:00.000000000 Z
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.4.5.1
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