social_net 0.2.5 → 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c4fb1ec63c5ce47d9ff040eb09b8cc6f2fb3ddbd
4
- data.tar.gz: fa53574cd10a0c6cce4eec7f23dca92edbcbcfc6
3
+ metadata.gz: 73b6da8b92cf24696015cda1d38891a6fb043297
4
+ data.tar.gz: 28c123c06bd4e0262576075b85d67c45dbcf2425
5
5
  SHA512:
6
- metadata.gz: 6a8219b4539a81d7f18e51569bc21315c993e661d913b6e80748b3a3daa920e593cf2298950623dad8071318475d62160af1b8aa306a6455440f3a7a5737cc89
7
- data.tar.gz: ea0716f10d023237fc8cdc150d8686361a0d5d5648779a9caa99eaddad018f83a11e4284756e59ff330f394a48135d6016ef6f54d43f314368751ac2fd66fbb3
6
+ metadata.gz: 1ec0e9c88456a8a6919f45bce23005ac44a1b14d542cdb4372613f8b218a898c310e535d2cd5ce8b80fefa212515de1b386e370036f5dff76830b4f2abff354d
7
+ data.tar.gz: 355ef7c86b0b08e2348f397ae0c0dc458b59882ad395e6e7c536cfa501c386dc2545185286f38dfb0f199a761b048e6c0101f421391889e84de11c1774d508e4
data/CHANGELOG.md CHANGED
@@ -21,3 +21,7 @@ For more information about changelogs, check
21
21
  ## 0.2.5 - 2017-5-31
22
22
 
23
23
  * [BUGFIX] Return nil for an Instagram video's caption if it doesn't exist.
24
+
25
+ ## 0.2.6 - 2017-5-31
26
+
27
+ * [BUGFIX] Add missing tests and errors for a private Instagram user.
@@ -0,0 +1,11 @@
1
+ module SocialNet
2
+ module Instagram
3
+ module Errors
4
+ class PrivateUser < StandardError
5
+ def message
6
+ 'Private user'
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
@@ -1,2 +1,3 @@
1
1
  require 'social_net/instagram/errors/response_error'
2
2
  require 'social_net/instagram/errors/unknown_user'
3
+ require 'social_net/instagram/errors/private_user'
@@ -36,7 +36,7 @@ module SocialNet
36
36
  # (case-insensitive).
37
37
  def self.find_by(params = {})
38
38
  find_by! params
39
- rescue Errors::UnknownUser
39
+ rescue Errors::UnknownUser, Errors::PrivateUser
40
40
  nil
41
41
  end
42
42
 
@@ -1,3 +1,3 @@
1
1
  module SocialNet
2
- VERSION = "0.2.5"
2
+ VERSION = "0.2.6"
3
3
  end
@@ -12,6 +12,7 @@ describe SocialNet::Instagram::User, :vcr do
12
12
 
13
13
  let(:existing_username) { 'Collab' }
14
14
  let(:unknown_username) { '01LjqweoojkjR' }
15
+ let(:private_username) { '4ever_kelz' }
15
16
 
16
17
  describe '.find_by' do
17
18
  subject(:user) { SocialNet::Instagram::User.find_by username: username }
@@ -33,11 +34,11 @@ describe SocialNet::Instagram::User, :vcr do
33
34
 
34
35
  describe '.find_by!' do
35
36
  subject(:user) { SocialNet::Instagram::User.find_by! username: username }
37
+
36
38
  context 'given an existing (case-insensitive) username' do
37
39
  let(:username) { existing_username }
38
40
 
39
41
  it 'returns an object representing that user' do
40
-
41
42
  expect(user.username).to eq 'collab'
42
43
  expect(user.follower_count).to be_an Integer
43
44
  end
@@ -47,6 +48,11 @@ describe SocialNet::Instagram::User, :vcr do
47
48
  let(:username) { unknown_username }
48
49
  it { expect{user}.to raise_error SocialNet::Instagram::UnknownUser }
49
50
  end
51
+
52
+ context 'given a private username' do
53
+ let(:username) { private_username }
54
+ it { expect{user}.to raise_error SocialNet::Instagram::PrivateUser }
55
+ end
50
56
  end
51
57
 
52
58
  describe '.videos' do
@@ -0,0 +1,124 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.instagram.com/v1/users/search?access_token=INSTAGRAM_ACCESS_TOKEN&q=4ever_kelz
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - "*/*"
14
+ User-Agent:
15
+ - Ruby
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Content-Type:
22
+ - application/json; charset=utf-8
23
+ X-Ratelimit-Limit:
24
+ - '5000'
25
+ X-Ratelimit-Remaining:
26
+ - '4946'
27
+ Cache-Control:
28
+ - private, no-cache, no-store, must-revalidate
29
+ Pragma:
30
+ - no-cache
31
+ Expires:
32
+ - Sat, 01 Jan 2000 00:00:00 GMT
33
+ Vary:
34
+ - Cookie, Accept-Language, Accept-Encoding
35
+ Content-Language:
36
+ - en
37
+ Date:
38
+ - Wed, 31 May 2017 22:55:49 GMT
39
+ Set-Cookie:
40
+ - csrftoken=pXysynA51YFlvBD9OvK8gbzWVbLoMrV0; expires=Wed, 30-May-2018 22:55:49
41
+ GMT; Max-Age=31449600; Path=/; Secure
42
+ - rur=FRC; Path=/
43
+ Connection:
44
+ - keep-alive
45
+ Content-Length:
46
+ - '655'
47
+ body:
48
+ encoding: ASCII-8BIT
49
+ string: '{"data": [{"id": "317274250", "username": "4ever_kelz", "full_name":
50
+ "", "profile_picture": "https://scontent.cdninstagram.com/t51.2885-19/s150x150/18723017_261505297650578_2491961998191886336_n.jpg"},
51
+ {"id": "1430579128", "username": "kelz_5ever", "full_name": "@4ever_kelz 5Evaaaaaaa\ud83d\ude1d",
52
+ "profile_picture": "https://scontent.cdninstagram.com/t51.2885-19/10525518_321491474693063_518369360_a.jpg"},
53
+ {"id": "2909283868", "username": "4everkelz", "full_name": "", "profile_picture":
54
+ "https://scontent.cdninstagram.com/t51.2885-19/s150x150/18160804_1368392969893306_8482577202922127360_a.jpg"},
55
+ {"id": "1427099354", "username": "4ever_kelz_", "full_name": "Rider Gang 4
56
+ Life\u2764\ufe0f", "profile_picture": "https://scontent.cdninstagram.com/t51.2885-19/917194_810340968999864_779480532_a.jpg"},
57
+ {"id": "1412026177", "username": "4ever_kelzz", "full_name": "", "profile_picture":
58
+ "https://scontent.cdninstagram.com/t51.2885-19/924109_1398262387143189_745772866_a.jpg"},
59
+ {"id": "1924152124", "username": "yung.poppy.and.4everkelz", "full_name":
60
+ "yungpoppy and 4everkelz", "profile_picture": "https://scontent.cdninstagram.com/t51.2885-19/11350990_1597356853851108_1827961176_a.jpg"},
61
+ {"id": "1428011485", "username": "4everkelz_main", "full_name": "Da Kelz \ud83d\udc81\ud83c\udffd",
62
+ "profile_picture": "https://scontent.cdninstagram.com/t51.2885-19/10598644_1447639975513072_435174271_a.jpg"},
63
+ {"id": "733524793", "username": "_4everkelz", "full_name": "", "profile_picture":
64
+ "https://scontent.cdninstagram.com/t51.2885-19/s150x150/17882334_282034328914418_7861258025472884736_a.jpg"},
65
+ {"id": "1958247453", "username": "4everkelz.fanpage", "full_name": "", "profile_picture":
66
+ "https://scontent.cdninstagram.com/t51.2885-19/11906329_960233084022564_1448528159_a.jpg"},
67
+ {"id": "433445008", "username": "4ever_kelzfannpage", "full_name": "rider
68
+ gang", "profile_picture": "https://scontent.cdninstagram.com/t51.2885-19/10990658_1533148803611995_425548866_a.jpg"},
69
+ {"id": "826502883", "username": "4everkelzz", "full_name": "kelzz.", "profile_picture":
70
+ "https://scontent.cdninstagram.com/t51.2885-19/s150x150/18645993_130880437475430_1421491375903342592_a.jpg"}],
71
+ "meta": {"code": 200}}'
72
+ http_version:
73
+ recorded_at: Wed, 31 May 2017 22:55:49 GMT
74
+ - request:
75
+ method: get
76
+ uri: https://api.instagram.com/v1/users/317274250?access_token=INSTAGRAM_ACCESS_TOKEN
77
+ body:
78
+ encoding: US-ASCII
79
+ string: ''
80
+ headers:
81
+ Accept-Encoding:
82
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
83
+ Accept:
84
+ - "*/*"
85
+ User-Agent:
86
+ - Ruby
87
+ response:
88
+ status:
89
+ code: 400
90
+ message: Bad Request
91
+ headers:
92
+ Content-Type:
93
+ - application/json; charset=utf-8
94
+ X-Ratelimit-Limit:
95
+ - '5000'
96
+ X-Ratelimit-Remaining:
97
+ - '4945'
98
+ Cache-Control:
99
+ - private, no-cache, no-store, must-revalidate
100
+ Pragma:
101
+ - no-cache
102
+ Expires:
103
+ - Sat, 01 Jan 2000 00:00:00 GMT
104
+ Vary:
105
+ - Cookie, Accept-Language
106
+ Content-Language:
107
+ - en
108
+ Date:
109
+ - Wed, 31 May 2017 22:55:49 GMT
110
+ Set-Cookie:
111
+ - csrftoken=4VRiHEmCyB4Ukk5XSSZLXMmfsUBxgsbL; expires=Wed, 30-May-2018 22:55:49
112
+ GMT; Max-Age=31449600; Path=/; Secure
113
+ - rur=FRC; Path=/
114
+ Connection:
115
+ - keep-alive
116
+ Content-Length:
117
+ - '109'
118
+ body:
119
+ encoding: UTF-8
120
+ string: '{"meta": {"code": 400, "error_type": "APINotAllowedError", "error_message":
121
+ "you cannot view this resource"}}'
122
+ http_version:
123
+ recorded_at: Wed, 31 May 2017 22:55:49 GMT
124
+ recorded_with: VCR 2.9.3
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: social_net
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Cohen Hoffing
@@ -151,6 +151,7 @@ files:
151
151
  - lib/social_net/instagram/api/request.rb
152
152
  - lib/social_net/instagram/config.rb
153
153
  - lib/social_net/instagram/errors.rb
154
+ - lib/social_net/instagram/errors/private_user.rb
154
155
  - lib/social_net/instagram/errors/response_error.rb
155
156
  - lib/social_net/instagram/errors/unknown_user.rb
156
157
  - lib/social_net/instagram/models.rb
@@ -178,6 +179,7 @@ files:
178
179
  - spec/support/cassettes/Posts/_posts/given_an_unknown_username/.yml
179
180
  - spec/support/cassettes/SocialNet_Instagram_Models_User/_find_by/given_an_existing_case-insensitive_username/returns_an_object_representing_that_user.yml
180
181
  - spec/support/cassettes/SocialNet_Instagram_Models_User/_find_by/given_an_unknown_username/.yml
182
+ - spec/support/cassettes/SocialNet_Instagram_Models_User/_find_by_/given_a_private_username/.yml
181
183
  - spec/support/cassettes/SocialNet_Instagram_Models_User/_find_by_/given_an_existing_case-insensitive_username/returns_an_object_representing_that_user.yml
182
184
  - spec/support/cassettes/SocialNet_Instagram_Models_User/_find_by_/given_an_unknown_username/.yml
183
185
  - spec/support/cassettes/SocialNet_Instagram_Models_User/_videos/given_an_existing_user/returns_an_array_of_video_posts_from_the_user.yml
@@ -216,6 +218,7 @@ test_files:
216
218
  - spec/support/cassettes/Posts/_posts/given_an_unknown_username/.yml
217
219
  - spec/support/cassettes/SocialNet_Instagram_Models_User/_find_by/given_an_existing_case-insensitive_username/returns_an_object_representing_that_user.yml
218
220
  - spec/support/cassettes/SocialNet_Instagram_Models_User/_find_by/given_an_unknown_username/.yml
221
+ - spec/support/cassettes/SocialNet_Instagram_Models_User/_find_by_/given_a_private_username/.yml
219
222
  - spec/support/cassettes/SocialNet_Instagram_Models_User/_find_by_/given_an_existing_case-insensitive_username/returns_an_object_representing_that_user.yml
220
223
  - spec/support/cassettes/SocialNet_Instagram_Models_User/_find_by_/given_an_unknown_username/.yml
221
224
  - spec/support/cassettes/SocialNet_Instagram_Models_User/_videos/given_an_existing_user/returns_an_array_of_video_posts_from_the_user.yml