passety 0.0.11 → 0.0.12

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.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +1 -0
  3. data/.travis.yml +1 -1
  4. data/Gemfile.lock +1 -1
  5. data/lib/passety/collection.rb +0 -4
  6. data/lib/passety/collections/thing.rb +3 -1
  7. data/lib/passety/nested_item.rb +0 -4
  8. data/lib/passety/property.rb +1 -1
  9. data/lib/passety/response.rb +0 -12
  10. data/lib/passety/version.rb +1 -1
  11. data/lib/passety/wrapper.rb +0 -4
  12. data/spec/collections_spec.rb +126 -0
  13. data/spec/properties_spec.rb +75 -0
  14. data/spec/things_spec.rb +100 -0
  15. data/spec/vcr/collections/all.yml +53 -0
  16. data/spec/vcr/collections/create.yml +54 -0
  17. data/spec/vcr/collections/delete.yml +46 -0
  18. data/spec/vcr/collections/find.yml +52 -0
  19. data/spec/vcr/collections/things/all.yml +52 -0
  20. data/spec/vcr/collections/things/create.yml +52 -0
  21. data/spec/vcr/collections/things/delete.yml +46 -0
  22. data/spec/vcr/collections/things/remove.yml +46 -0
  23. data/spec/vcr/collections/update.yml +52 -0
  24. data/spec/vcr/common/info.yml +52 -0
  25. data/spec/vcr/common/search.yml +52 -0
  26. data/spec/vcr/common/uploads.yml +56 -0
  27. data/spec/vcr/things/all.yml +55 -0
  28. data/spec/vcr/things/create.yml +54 -0
  29. data/spec/vcr/things/delete.yml +46 -0
  30. data/spec/vcr/things/find.yml +52 -0
  31. data/spec/vcr/things/photos/all.yml +52 -0
  32. data/spec/vcr/things/photos/create.yml +54 -0
  33. data/spec/vcr/things/properties/all.yml +52 -0
  34. data/spec/vcr/things/properties/create.yml +54 -0
  35. data/spec/vcr/things/properties/delete.yml +46 -0
  36. data/spec/vcr/things/properties/find.yml +52 -0
  37. data/spec/vcr/things/update.yml +52 -0
  38. data/spec/wrapper_spec.rb +41 -15
  39. metadata +55 -6
  40. data/spec/item_spec.rb +0 -14
  41. data/spec/property_spec.rb +0 -13
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3148f5a1198bda1d522cbb634bb38d0c098bfce8
4
- data.tar.gz: c6b6f96fecd4a3545fc59d8d9129c8475badbe41
3
+ metadata.gz: c3c3be3543f76e3ff12d2755f4be2b91c3cee3d5
4
+ data.tar.gz: c5b01e67e6769612abc079d9416228d640bcc754
5
5
  SHA512:
6
- metadata.gz: bba21159f3b08a73f9aba3c4881780ecfd76d933029fb4ceb7d8d6fcb8b67086a6c6a7195dfd327e922ff0234709415ef5ccb991ad2c46e4d26507881672f164
7
- data.tar.gz: 065569bedd8ba5fada62da3d0e267888bd3a041dd31a1d1dd8ceb34ed0be640f19140cc8b1a55fc6ea8b48c17ae6260479e206ff3c07e9e5f617ce410f95a0bb
6
+ metadata.gz: 11bc6963ad7dfadba4fba4466d26dcb8241fa9bbccd49b22652b75471465691a74448583a974215128c85de2cb37d520e8b05a909c29f0e704cf12ca9efd469d
7
+ data.tar.gz: e2535dc37169e8c32d44f893a21523e3476abd43e91fbe928de4cdc73ab19aaaeffce30b88c335c2e39cba7bc6fdee8b31ad42a9e7bc1e13cc2bc7844a9db3fe
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color --format doc
@@ -10,7 +10,7 @@ cache: bundler
10
10
 
11
11
  addons:
12
12
  code_climate:
13
- repo_token: e4f82da41220f9ee84cf1970a74e36a7616effac3d862dfa0486cf97d96ecbd0
13
+ repo_token: f023f5d7f53df0708ba3f0d41367da44d227eee536bd27ed2ede7a3a287e62e6
14
14
 
15
15
  notifications:
16
16
  email:
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- passety (0.0.11)
4
+ passety (0.0.12)
5
5
  faraday
6
6
  json
7
7
 
@@ -7,9 +7,5 @@ module Passety
7
7
  def things
8
8
  @things ||= Collections::Thing.new(@wrapper)
9
9
  end
10
-
11
- def update
12
- raise NotImplementedError
13
- end
14
10
  end
15
11
  end
@@ -6,7 +6,9 @@ module Passety
6
6
  end
7
7
 
8
8
  def remove(cid, params = {})
9
- @wrapper.perform_request { |c| c.delete(url(cid), JSON.generate(params)) }
9
+ @wrapper.perform_request do |c|
10
+ c.delete(url(cid)) { |req| req.body = JSON.generate(params) }
11
+ end
10
12
  end
11
13
  end
12
14
  end
@@ -14,10 +14,6 @@ module Passety
14
14
  @wrapper.perform_request { |c| c.get(url(pid, id), params) }
15
15
  end
16
16
 
17
- def update(pid, id, params)
18
- @wrapper.perform_request { |c| c.put(url(pid, id), JSON.generate(params)) }
19
- end
20
-
21
17
  def create(pid, params)
22
18
  @wrapper.perform_request { |c| c.post(url(pid), JSON.generate(params)) }
23
19
  end
@@ -4,7 +4,7 @@ module Passety
4
4
  super(wrapper, parent, 'properties')
5
5
  end
6
6
 
7
- def update
7
+ def update(pid, id, params)
8
8
  raise NotImplementedError
9
9
  end
10
10
  end
@@ -6,26 +6,14 @@ module Passety
6
6
  @response = response
7
7
  end
8
8
 
9
- def content_type
10
- ((response.headers.values_at('content-type', 'Content-Type').compact.first || '').split(';').first || '').strip
11
- end
12
-
13
9
  def parsed
14
10
  parse_body(response)
15
11
  end
16
12
 
17
- def headers
18
- response.headers
19
- end
20
-
21
13
  def status
22
14
  response.status
23
15
  end
24
16
 
25
- def body
26
- response.body || ''
27
- end
28
-
29
17
  private
30
18
  def parse_body(response)
31
19
  body = response.env[:body].strip
@@ -1,3 +1,3 @@
1
1
  module Passety
2
- VERSION = "0.0.11"
2
+ VERSION = "0.0.12"
3
3
  end
@@ -5,10 +5,6 @@ module Passety
5
5
  @raise_errors = options.fetch(:raise_errors, true)
6
6
  end
7
7
 
8
- def authorized?
9
- !!@token
10
- end
11
-
12
8
  def collections
13
9
  @collections ||= Collection.new(self)
14
10
  end
@@ -0,0 +1,126 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Collections API -> /collections' do
4
+ let(:token) { 'thVEvafigsp9nCMGiA5XlOSQ2lzNCBLl' }
5
+ let(:wrapper) { Passety::Wrapper.new(token) }
6
+ let(:collection_id) { 1 }
7
+ let(:tid) { 'AABAM' }
8
+
9
+ context 'Getting Collection List', vcr: { cassette_name: 'collections/all' } do
10
+ subject(:result) { wrapper.collections.all }
11
+
12
+ it 'has 200 (OK) status' do
13
+ expect(result.status).to eq(200)
14
+ end
15
+
16
+ it 'is paginated' do
17
+ expect(result.parsed).to include('meta')
18
+ end
19
+
20
+ it 'returns list of collections' do
21
+ expect(result.parsed).to include('collections')
22
+ end
23
+ end
24
+
25
+ context 'Getting Collection\'s profile', vcr: { cassette_name: 'collections/find' } do
26
+ subject(:result) { wrapper.collections.find(collection_id) }
27
+
28
+ it 'has 200 (OK) status' do
29
+ expect(result.status).to eq(200)
30
+ end
31
+
32
+ it 'contains information of collection' do
33
+ expect(result.parsed['id']).to eq(collection_id)
34
+ end
35
+ end
36
+
37
+ context 'Creating Collection', vcr: { cassette_name: 'collections/create' } do
38
+ let(:name) { 'My suppa-duppa collection' }
39
+ subject(:result) { wrapper.collections.create(name: name) }
40
+
41
+ it 'has 201 (Created) status' do
42
+ expect(result.status).to eq(201)
43
+ end
44
+
45
+ it 'has information about created collection' do
46
+ expect(result.parsed['name']).to eq(name)
47
+ end
48
+ end
49
+
50
+ context 'Updating Collection', vcr: { cassette_name: 'collections/update' } do
51
+ let(:new_name) { 'Brand new name' }
52
+ subject(:result) { wrapper.collections.update(collection_id, name: new_name) }
53
+
54
+ it 'has 200 (OK) status' do
55
+ expect(result.status).to eq(200)
56
+ end
57
+
58
+ it 'has information about updated collection' do
59
+ expect(result.parsed['name']).to eq(new_name)
60
+ end
61
+ end
62
+
63
+ context 'Deleting Collection', vcr: { cassette_name: 'collections/delete' } do
64
+ subject(:result) { wrapper.collections.destroy(collection_id) }
65
+
66
+ it 'has 204 (No Content) status' do
67
+ expect(result.status).to eq(204)
68
+ end
69
+
70
+ it 'has blank body' do
71
+ expect(result.parsed).to be_nil
72
+ end
73
+ end
74
+
75
+ context 'Getting Thing List out of the collection', vcr: { cassette_name: 'collections/things/all' } do
76
+ subject(:result) { wrapper.collections.things.all(collection_id) }
77
+
78
+ it 'has 200 (OK) status' do
79
+ expect(result.status).to eq(200)
80
+ end
81
+
82
+ it 'is paginated' do
83
+ expect(result.parsed).to include('meta')
84
+ end
85
+
86
+ it 'returns list of collections list' do
87
+ expect(result.parsed).to include('things')
88
+ end
89
+ end
90
+
91
+ context 'Adding Thing(s) to collection', vcr: { cassette_name: 'collections/things/create' } do
92
+ subject(:result) { wrapper.collections.things.create(collection_id, ids: [ tid ]) }
93
+
94
+ it 'has 200 (OK) status' do
95
+ expect(result.status).to eq(200)
96
+ end
97
+
98
+ it 'has blank body' do
99
+ expect(result.parsed).to eq(nil)
100
+ end
101
+ end
102
+
103
+ context 'Removing Thing(s) to collection', vcr: { cassette_name: 'collections/things/remove' } do
104
+ subject(:result) { wrapper.collections.things.remove(collection_id, ids: [ tid ]) }
105
+
106
+ it 'has 204 (No Content) status' do
107
+ expect(result.status).to eq(204)
108
+ end
109
+
110
+ it 'has blank body' do
111
+ expect(result.parsed).to eq(nil)
112
+ end
113
+ end
114
+
115
+ context 'Removing one specific Thing from the collection', vcr: { cassette_name: 'collections/things/delete' } do
116
+ subject(:result) { wrapper.collections.things.destroy(collection_id, tid) }
117
+
118
+ it 'has 204 (No Content) status' do
119
+ expect(result.status).to eq(204)
120
+ end
121
+
122
+ it 'has blank body' do
123
+ expect(result.parsed).to eq(nil)
124
+ end
125
+ end
126
+ end
@@ -0,0 +1,75 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Property API -> /thigns/:tid/properties' do
4
+ let(:token) { 'thVEvafigsp9nCMGiA5XlOSQ2lzNCBLl' }
5
+ let(:wrapper) { Passety::Wrapper.new(token) }
6
+ let(:tid) { 'AABAM' }
7
+
8
+ context 'Getting properties list', vcr: { cassette_name: 'things/properties/all' } do
9
+ subject(:result) { wrapper.things.properties.all(tid) }
10
+
11
+ it 'has 200 (OK) status' do
12
+ expect(result.status).to eq(200)
13
+ end
14
+
15
+ it 'is paginated' do
16
+ expect(result.parsed).to include('meta')
17
+ end
18
+
19
+ it 'returns list of properties' do
20
+ expect(result.parsed).to include('properties')
21
+ end
22
+ end
23
+
24
+ context 'Getting Property with Key', vcr: { cassette_name: 'things/properties/find' } do
25
+ let(:key) { 'description' }
26
+ subject(:result) { wrapper.things.properties.find(tid, key) }
27
+
28
+ it 'has 200 (OK) status' do
29
+ expect(result.status).to eq(200)
30
+ end
31
+
32
+ it 'contains information about property' do
33
+ expect(result.parsed['key']).to eq(key)
34
+ end
35
+ end
36
+
37
+ context 'Creating Property', vcr: { cassette_name: 'things/properties/create' } do
38
+ let(:key) { 'description' }
39
+ let(:value) { 'Thing Description' }
40
+ subject(:result) { wrapper.things.properties.create(tid, key: key, value: value) }
41
+
42
+ it 'has 201 (Created) status' do
43
+ expect(result.status).to eq(201)
44
+ end
45
+
46
+ it 'contains information about created property' do
47
+ expect(result.parsed['key']).to eq(key)
48
+ expect(result.parsed['value']).to eq(value)
49
+ end
50
+ end
51
+
52
+ context 'Updating Property' do
53
+ let(:key) { 'description' }
54
+ let(:value) { 'New value' }
55
+ subject(:result) { wrapper.things.properties.update(tid, key, value: value) }
56
+
57
+ it 'raises NotImplementedError' do
58
+ expect { result }.to raise_error(NotImplementedError)
59
+ end
60
+ end
61
+
62
+ context 'Delete Property', vcr: { cassette_name: 'things/properties/delete' } do
63
+ let(:key) { 'description' }
64
+ subject(:result) { wrapper.things.properties.destroy(tid, key: key) }
65
+
66
+ it 'has 204 (No Content) status' do
67
+ expect(result.status).to eq(204)
68
+ end
69
+
70
+ it 'has empty body' do
71
+ expect(result.parsed).to eq(nil)
72
+ end
73
+ end
74
+ end
75
+
@@ -0,0 +1,100 @@
1
+ require 'spec_helper'
2
+
3
+ describe'Things api -> /things' do
4
+ let(:token) { 'thVEvafigsp9nCMGiA5XlOSQ2lzNCBLl' }
5
+ let(:wrapper) { Passety::Wrapper.new(token) }
6
+ let(:tid) { 'AABAM' }
7
+
8
+ context 'List all things', vcr: { cassette_name: 'things/all' } do
9
+ subject(:result) { wrapper.things.all }
10
+
11
+ it 'has 200 (OK) status' do
12
+ expect(result.status).to eq(200)
13
+ end
14
+
15
+ it 'is paginated' do
16
+ expect(result.parsed).to include('meta')
17
+ end
18
+
19
+ it 'returns list of things' do
20
+ expect(result.parsed).to include("things")
21
+ end
22
+ end
23
+
24
+ context 'Getting Thing', vcr: { cassette_name: 'things/find' } do
25
+ subject(:result) { wrapper.things.find(tid) }
26
+
27
+ it 'has 200 (OK) status' do
28
+ expect(result.status).to eq(200)
29
+ end
30
+
31
+ it 'has thing info' do
32
+ expect(result.parsed['id']).to eq(tid)
33
+ end
34
+ end
35
+
36
+ context 'Creating Thing', vcr: { cassette_name: 'things/create' } do
37
+ let(:name) { 'Nikon D3100' }
38
+ subject(:result) { wrapper.things.create(name: name) }
39
+
40
+ it 'has 201 (Created) status' do
41
+ expect(result.status).to eq(201)
42
+ end
43
+
44
+ it 'contains information about created thing' do
45
+ expect(result.parsed['name']).to eq(name)
46
+ end
47
+ end
48
+
49
+ context 'Updating Thing', vcr: { cassette_name: 'things/update' } do
50
+ let(:new_name) { 'Canon 600D' }
51
+ subject(:result) { wrapper.things.update(tid, name: new_name) }
52
+
53
+ it 'has 200 (OK) status' do
54
+ expect(result.status).to eq(200)
55
+ end
56
+
57
+ it 'contains information about updated thing' do
58
+ expect(result.parsed['name']).to eq(new_name)
59
+ end
60
+ end
61
+
62
+ context 'Deleting Thing', vcr: { cassette_name: 'things/delete' } do
63
+ subject(:result) { wrapper.things.destroy(tid) }
64
+
65
+ it 'has 204 (No Content) status' do
66
+ expect(result.status).to eq(204)
67
+ end
68
+
69
+ it 'has empty body' do
70
+ expect(result.parsed).to be_nil
71
+ end
72
+ end
73
+
74
+ context 'Photo Thing' do
75
+ context 'Getting photos list', vcr: { cassette_name: 'things/photos/all' } do
76
+ subject(:result) { wrapper.things.photos.all(tid) }
77
+
78
+ it 'has 200 (OK) status' do
79
+ expect(result.status).to eq(200)
80
+ end
81
+
82
+ it 'is paginated' do
83
+ expect(result.parsed).to include('meta')
84
+ end
85
+
86
+ it 'returns list of photos' do
87
+ expect(result.parsed).to include('photos')
88
+ end
89
+ end
90
+
91
+ context 'Adding Photo to Thing', vcr: { cassette_name: 'things/photos/create' } do
92
+ let(:photo_id) { 1 }
93
+ subject(:result) { wrapper.things.photos.create(tid, photo: photo_id) }
94
+
95
+ it 'has 201 (Created) status' do
96
+ expect(result.status).to eq(201)
97
+ end
98
+ end
99
+ end
100
+ end
@@ -0,0 +1,53 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.passety.com/collections
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept:
11
+ - application/json; version=1
12
+ Authorization:
13
+ - Bearer thVEvafigsp9nCMGiA5XlOSQ2lzNCBLl
14
+ User-Agent:
15
+ - Faraday v0.9.0
16
+ Accept-Encoding:
17
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Server:
24
+ - nginx/1.6.0
25
+ Date:
26
+ - Fri, 06 Jun 2014 11:49:59 GMT
27
+ Content-Type:
28
+ - application/json; charset=utf-8
29
+ Transfer-Encoding:
30
+ - chunked
31
+ Connection:
32
+ - keep-alive
33
+ X-Frame-Options:
34
+ - SAMEORIGIN
35
+ X-Xss-Protection:
36
+ - 1; mode=block
37
+ X-Content-Type-Options:
38
+ - nosniff
39
+ Etag:
40
+ - '"0fc77b3586b893b71fe7e0d0b366ac62"'
41
+ Cache-Control:
42
+ - max-age=0, private, must-revalidate
43
+ X-Request-Id:
44
+ - fa17ad03-6f46-4866-8043-ebe92d9d0430
45
+ X-Runtime:
46
+ - '0.075925'
47
+ body:
48
+ encoding: UTF-8
49
+ string: '{"collections":[{"id":1,"name":"Lexi Colle","description":"","private":false,"things_count":0},{"id":2,"name":"My
50
+ Photo Kit","description":null,"private":true,"things_count":1},{"id":3,"name":"Wishlist","description":null,"private":true,"things_count":1}],"meta":{"total_count":3,"page_count":1,"per_page":24,"page":1}}'
51
+ http_version:
52
+ recorded_at: Fri, 06 Jun 2014 11:49:59 GMT
53
+ recorded_with: VCR 2.9.0