instagram-continued 1.3.0 → 1.3.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.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +11 -0
  3. data/.travis.yml +1 -0
  4. data/README.md +1 -1
  5. data/Rakefile +12 -11
  6. data/instagram-continued.gemspec +6 -5
  7. data/lib/faraday/loud_logger.rb +47 -48
  8. data/lib/faraday/oauth2.rb +16 -18
  9. data/lib/faraday/raise_http_exception.rb +9 -9
  10. data/lib/instagram.rb +8 -8
  11. data/lib/instagram/api.rb +4 -4
  12. data/lib/instagram/client.rb +1 -1
  13. data/lib/instagram/client/comments.rb +5 -5
  14. data/lib/instagram/client/embedding.rb +9 -9
  15. data/lib/instagram/client/likes.rb +5 -5
  16. data/lib/instagram/client/locations.rb +4 -4
  17. data/lib/instagram/client/media.rb +3 -3
  18. data/lib/instagram/client/subscriptions.rb +27 -27
  19. data/lib/instagram/client/tags.rb +3 -3
  20. data/lib/instagram/client/users.rb +19 -19
  21. data/lib/instagram/client/utils.rb +5 -5
  22. data/lib/instagram/configuration.rb +7 -6
  23. data/lib/instagram/connection.rb +7 -7
  24. data/lib/instagram/oauth.rb +8 -8
  25. data/lib/instagram/request.rb +23 -26
  26. data/lib/instagram/response.rb +8 -4
  27. data/lib/instagram/version.rb +1 -1
  28. data/spec/faraday/response_spec.rb +23 -25
  29. data/spec/instagram/api_spec.rb +90 -94
  30. data/spec/instagram/client/comments_spec.rb +21 -25
  31. data/spec/instagram/client/embedding_spec.rb +8 -8
  32. data/spec/instagram/client/geography_spec.rb +10 -13
  33. data/spec/instagram/client/likes_spec.rb +21 -25
  34. data/spec/instagram/client/locations_spec.rb +42 -48
  35. data/spec/instagram/client/media_spec.rb +33 -37
  36. data/spec/instagram/client/subscriptions_spec.rb +34 -46
  37. data/spec/instagram/client/tags_spec.rb +29 -33
  38. data/spec/instagram/client/users_spec.rb +155 -180
  39. data/spec/instagram/client/utils_spec.rb +8 -9
  40. data/spec/instagram/client_spec.rb +9 -9
  41. data/spec/instagram/request_spec.rb +27 -27
  42. data/spec/instagram_spec.rb +20 -24
  43. data/spec/spec_helper.rb +10 -10
  44. metadata +24 -9
@@ -1,26 +1,24 @@
1
- require File.expand_path('../../../spec_helper', __FILE__)
1
+ require File.expand_path("../../../spec_helper", __FILE__)
2
2
 
3
3
  describe Instagram::Client do
4
4
  Instagram::Configuration::VALID_FORMATS.each do |format|
5
5
  context ".new(:format => '#{format}')" do
6
-
7
6
  before do
8
- @client = Instagram::Client.new(:format => format, :client_id => 'CID', :client_secret => 'CS', :access_token => 'AT')
7
+ @client = Instagram::Client.new(format: format, client_id: "CID", client_secret: "CS", access_token: "AT")
9
8
  end
10
9
 
11
10
  describe ".subscriptions" do
12
-
13
11
  before do
14
- stub_get("subscriptions.#{format}").
15
- with(:query => {:client_id => @client.client_id, :client_secret => @client.client_secret}).
16
- to_return(:body => fixture("subscriptions.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
12
+ stub_get("subscriptions.#{format}")
13
+ .with(query: { client_id: @client.client_id, client_secret: @client.client_secret })
14
+ .to_return(body: fixture("subscriptions.#{format}"), headers: { content_type: "application/#{format}; charset=utf-8" })
17
15
  end
18
16
 
19
17
  it "should get the correct resource" do
20
18
  @client.subscriptions
21
- expect(a_get("subscriptions.#{format}").
22
- with(:query => {:client_id => @client.client_id, :client_secret => @client.client_secret})).
23
- to have_been_made
19
+ expect(a_get("subscriptions.#{format}")
20
+ .with(query: { client_id: @client.client_id, client_secret: @client.client_secret }))
21
+ .to have_been_made
24
22
  end
25
23
 
26
24
  it "should return an array of subscriptions" do
@@ -31,67 +29,61 @@ describe Instagram::Client do
31
29
  end
32
30
 
33
31
  describe ".create_subscription" do
34
-
35
32
  before do
36
- stub_post("subscriptions.#{format}").
37
- with(:body => {:object => "user", :callback_url => "http://example.com/instagram/callback", :aspect => "media", :client_id => @client.client_id, :client_secret => @client.client_secret}).
38
- to_return(:body => fixture("subscription.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
33
+ stub_post("subscriptions.#{format}")
34
+ .with(body: { object: "user", callback_url: "http://example.com/instagram/callback", aspect: "media", client_id: @client.client_id, client_secret: @client.client_secret })
35
+ .to_return(body: fixture("subscription.#{format}"), headers: { content_type: "application/#{format}; charset=utf-8" })
39
36
  end
40
37
 
41
38
  it "should get the correct resource" do
42
- @client.create_subscription("user", :callback_url => "http://example.com/instagram/callback")
43
- expect(a_post("subscriptions.#{format}").
44
- with(:body => {:object => "user", :callback_url => "http://example.com/instagram/callback", :aspect => "media", :client_id => @client.client_id, :client_secret => @client.client_secret})).
45
- to have_been_made
39
+ @client.create_subscription("user", callback_url: "http://example.com/instagram/callback")
40
+ expect(a_post("subscriptions.#{format}")
41
+ .with(body: { object: "user", callback_url: "http://example.com/instagram/callback", aspect: "media", client_id: @client.client_id, client_secret: @client.client_secret }))
42
+ .to have_been_made
46
43
  end
47
44
 
48
45
  it "should return the new subscription when successful" do
49
- subscription = @client.create_subscription("user", :callback_url => "http://example.com/instagram/callback")
46
+ subscription = @client.create_subscription("user", callback_url: "http://example.com/instagram/callback")
50
47
  expect(subscription.object).to eq("user")
51
48
  end
52
49
  end
53
50
 
54
51
  describe ".delete_media_comment" do
55
-
56
52
  before do
57
- stub_delete("subscriptions.#{format}").
58
- with(:query => {:object => "user", :client_id => @client.client_id, :client_secret => @client.client_secret}).
59
- to_return(:body => fixture("subscription_deleted.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
53
+ stub_delete("subscriptions.#{format}")
54
+ .with(query: { object: "user", client_id: @client.client_id, client_secret: @client.client_secret })
55
+ .to_return(body: fixture("subscription_deleted.#{format}"), headers: { content_type: "application/#{format}; charset=utf-8" })
60
56
  end
61
57
 
62
58
  it "should get the correct resource" do
63
- @client.delete_subscription(:object => "user")
64
- expect(a_delete("subscriptions.#{format}").
65
- with(:query => {:object => "user", :client_id => @client.client_id, :client_secret => @client.client_secret})).
66
- to have_been_made
59
+ @client.delete_subscription(object: "user")
60
+ expect(a_delete("subscriptions.#{format}")
61
+ .with(query: { object: "user", client_id: @client.client_id, client_secret: @client.client_secret }))
62
+ .to have_been_made
67
63
  end
68
64
  end
69
65
 
70
66
  describe ".validate_update" do
71
-
72
67
  subject { @client.validate_update(body, headers) }
73
68
 
74
69
  context "when calculated signature matches request signature" do
75
-
76
- let(:body) { {foo: "bar"}.to_json }
77
- let(:request_signature) { OpenSSL::HMAC.hexdigest('sha1', @client.client_secret, body) }
78
- let(:headers) { {"X-Hub-Signature" => request_signature} }
70
+ let(:body) { { foo: "bar" }.to_json }
71
+ let(:request_signature) { OpenSSL::HMAC.hexdigest("sha1", @client.client_secret, body) }
72
+ let(:headers) { { "X-Hub-Signature" => request_signature } }
79
73
 
80
74
  it { expect(subject).to be_truthy }
81
75
  end
82
76
 
83
77
  context "when calculated signature does not match request signature" do
84
-
85
- let(:body) { {foo: "bar"}.to_json }
78
+ let(:body) { { foo: "bar" }.to_json }
86
79
  let(:request_signature) { "going to fail" }
87
- let(:headers) { {"X-Hub-Signature" => request_signature} }
80
+ let(:headers) { { "X-Hub-Signature" => request_signature } }
88
81
 
89
82
  it { expect(subject).to be_falsey }
90
83
  end
91
84
  end
92
85
 
93
86
  describe ".process_subscriptions" do
94
-
95
87
  context "without a callbacks block" do
96
88
  it "should raise an ArgumentError" do
97
89
  expect do
@@ -101,14 +93,13 @@ describe Instagram::Client do
101
93
  end
102
94
 
103
95
  context "with a callbacks block and valid JSON" do
104
-
105
96
  before do
106
97
  @json = fixture("subscription_payload.json").read
107
98
  end
108
99
 
109
100
  it "should issue a callback to on_user_changed" do
110
101
  @client.process_subscription(@json) do |handler|
111
- handler.on_user_changed do |user_id, payload|
102
+ handler.on_user_changed do |user_id, _payload|
112
103
  expect(user_id).to eq("1234")
113
104
  end
114
105
  end
@@ -116,7 +107,7 @@ describe Instagram::Client do
116
107
 
117
108
  it "should issue a callback to on_tag_changed" do
118
109
  @client.process_subscription(@json) do |handler|
119
- handler.on_tag_changed do |tag_name, payload|
110
+ handler.on_tag_changed do |tag_name, _payload|
120
111
  expect(tag_name).to eq("nofilter")
121
112
  end
122
113
  end
@@ -124,12 +115,11 @@ describe Instagram::Client do
124
115
 
125
116
  it "should issue both callbacks in one block" do
126
117
  @client.process_subscription(@json) do |handler|
127
-
128
- handler.on_user_changed do |user_id, payload|
118
+ handler.on_user_changed do |user_id, _payload|
129
119
  expect(user_id).to eq("1234")
130
120
  end
131
121
 
132
- handler.on_tag_changed do |tag_name, payload|
122
+ handler.on_tag_changed do |tag_name, _payload|
133
123
  expect(tag_name).to eq("nofilter")
134
124
  end
135
125
  end
@@ -138,14 +128,13 @@ describe Instagram::Client do
138
128
  end
139
129
 
140
130
  context "with a valid signature" do
141
-
142
131
  before do
143
132
  @json = fixture("subscription_payload.json").read
144
133
  end
145
134
 
146
135
  it "should not raise an Instagram::InvalidSignature error" do
147
136
  expect do
148
- @client.process_subscription(@json, :signature => "f1dbe2b6184ac2131209c87bba8e0382d089a8a2") do |handler|
137
+ @client.process_subscription(@json, signature: "f1dbe2b6184ac2131209c87bba8e0382d089a8a2") do |handler|
149
138
  # hi
150
139
  end
151
140
  end.not_to raise_error
@@ -153,7 +142,6 @@ describe Instagram::Client do
153
142
  end
154
143
 
155
144
  context "with an invalid signature" do
156
-
157
145
  before do
158
146
  @json = fixture("subscription_payload.json").read
159
147
  end
@@ -162,7 +150,7 @@ describe Instagram::Client do
162
150
  invalid_signatures = ["31337H4X0R", nil]
163
151
  invalid_signatures.each do |signature|
164
152
  expect do
165
- @client.process_subscription(@json, :signature => signature ) do |handler|
153
+ @client.process_subscription(@json, signature: signature) do |handler|
166
154
  # hi
167
155
  end
168
156
  end.to raise_error(Instagram::InvalidSignature)
@@ -1,75 +1,71 @@
1
- require File.expand_path('../../../spec_helper', __FILE__)
1
+ require File.expand_path("../../../spec_helper", __FILE__)
2
2
 
3
3
  describe Instagram::Client do
4
4
  Instagram::Configuration::VALID_FORMATS.each do |format|
5
5
  context ".new(:format => '#{format}')" do
6
6
  before do
7
- @client = Instagram::Client.new(:format => format, :client_id => 'CID', :client_secret => 'CS', :access_token => 'AT')
7
+ @client = Instagram::Client.new(format: format, client_id: "CID", client_secret: "CS", access_token: "AT")
8
8
  end
9
9
 
10
10
  describe ".tag" do
11
-
12
11
  before do
13
- stub_get("tags/cat.#{format}").
14
- with(:query => {:access_token => @client.access_token}).
15
- to_return(:body => fixture("tag.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
12
+ stub_get("tags/cat.#{format}")
13
+ .with(query: { access_token: @client.access_token })
14
+ .to_return(body: fixture("tag.#{format}"), headers: { content_type: "application/#{format}; charset=utf-8" })
16
15
  end
17
16
 
18
17
  it "should get the correct resource" do
19
- @client.tag('cat')
20
- expect(a_get("tags/cat.#{format}").
21
- with(:query => {:access_token => @client.access_token})).
22
- to have_been_made
18
+ @client.tag("cat")
19
+ expect(a_get("tags/cat.#{format}")
20
+ .with(query: { access_token: @client.access_token }))
21
+ .to have_been_made
23
22
  end
24
23
 
25
24
  it "should return extended information of a given media item" do
26
- tag = @client.tag('cat')
27
- expect(tag.name).to eq('cat')
25
+ tag = @client.tag("cat")
26
+ expect(tag.name).to eq("cat")
28
27
  end
29
28
  end
30
29
 
31
30
  describe ".tag_recent_media" do
32
-
33
31
  before do
34
- stub_get("tags/cat/media/recent.#{format}").
35
- with(:query => {:access_token => @client.access_token}).
36
- to_return(:body => fixture("tag_recent_media.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
32
+ stub_get("tags/cat/media/recent.#{format}")
33
+ .with(query: { access_token: @client.access_token })
34
+ .to_return(body: fixture("tag_recent_media.#{format}"), headers: { content_type: "application/#{format}; charset=utf-8" })
37
35
  end
38
36
 
39
37
  it "should get the correct resource" do
40
- @client.tag_recent_media('cat')
41
- expect(a_get("tags/cat/media/recent.#{format}").
42
- with(:query => {:access_token => @client.access_token})).
43
- to have_been_made
38
+ @client.tag_recent_media("cat")
39
+ expect(a_get("tags/cat/media/recent.#{format}")
40
+ .with(query: { access_token: @client.access_token }))
41
+ .to have_been_made
44
42
  end
45
43
 
46
44
  it "should return a list of media taken at a given location" do
47
- media = @client.tag_recent_media('cat')
45
+ media = @client.tag_recent_media("cat")
48
46
  expect(media).to be_a Array
49
47
  expect(media.first.user.username).to eq("amandavan")
50
48
  end
51
-
52
49
  end
53
50
 
54
51
  describe ".tag_search" do
55
-
56
52
  before do
57
- stub_get("tags/search.#{format}").
58
- with(:query => {:access_token => @client.access_token}).
59
- with(:query => {:q => 'cat'}).
60
- to_return(:body => fixture("tag_search.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
53
+ stub_get("tags/search.#{format}")
54
+ .with(query: { access_token: @client.access_token })
55
+ .with(query: { q: "cat" })
56
+ .to_return(body: fixture("tag_search.#{format}"), headers: { content_type: "application/#{format}; charset=utf-8" })
61
57
  end
62
58
 
63
59
  it "should get the correct resource" do
64
- @client.tag_search('cat')
65
- expect(a_get("tags/search.#{format}").
66
- with(:query => {:access_token => @client.access_token}).
67
- with(:query => {:q => 'cat'})).
68
- to have_been_made
60
+ @client.tag_search("cat")
61
+ expect(a_get("tags/search.#{format}")
62
+ .with(query: { access_token: @client.access_token })
63
+ .with(query: { q: "cat" }))
64
+ .to have_been_made
69
65
  end
70
66
 
71
67
  it "should return an array of user search results" do
72
- tags = @client.tag_search('cat')
68
+ tags = @client.tag_search("cat")
73
69
  expect(tags).to be_a Array
74
70
  expect(tags.first.name).to eq("cats")
75
71
  end
@@ -1,68 +1,63 @@
1
- require File.expand_path('../../../spec_helper', __FILE__)
1
+ require File.expand_path("../../../spec_helper", __FILE__)
2
2
 
3
3
  describe Instagram::Client do
4
4
  Instagram::Configuration::VALID_FORMATS.each do |format|
5
5
  context ".new(:format => '#{format}')" do
6
6
  before do
7
- @client = Instagram::Client.new(:format => format, :client_id => 'CID', :client_secret => 'CS', :access_token => 'AT')
7
+ @client = Instagram::Client.new(format: format, client_id: "CID", client_secret: "CS", access_token: "AT")
8
8
  end
9
9
 
10
10
  describe ".user" do
11
-
12
11
  context "with user ID passed" do
13
-
14
12
  before do
15
- stub_get("users/4.#{format}").
16
- with(:query => {:access_token => @client.access_token}).
17
- to_return(:body => fixture("mikeyk.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
13
+ stub_get("users/4.#{format}")
14
+ .with(query: { access_token: @client.access_token })
15
+ .to_return(body: fixture("mikeyk.#{format}"), headers: { content_type: "application/#{format}; charset=utf-8" })
18
16
  end
19
17
 
20
18
  it "should get the correct resource" do
21
19
  @client.user(4)
22
- expect(a_get("users/4.#{format}").
23
- with(:query => {:access_token => @client.access_token})).
24
- to have_been_made
20
+ expect(a_get("users/4.#{format}")
21
+ .with(query: { access_token: @client.access_token }))
22
+ .to have_been_made
25
23
  end
26
24
 
27
25
  it "should return extended information of a given user" do
28
26
  user = @client.user(4)
29
27
  expect(user.full_name).to eq("Mike Krieger")
30
28
  end
31
-
32
29
  end
33
30
 
34
31
  context "without user ID passed" do
35
-
36
32
  before do
37
- stub_get("users/self.#{format}").
38
- with(:query => {:access_token => @client.access_token}).
39
- to_return(:body => fixture("shayne.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
33
+ stub_get("users/self.#{format}")
34
+ .with(query: { access_token: @client.access_token })
35
+ .to_return(body: fixture("shayne.#{format}"), headers: { content_type: "application/#{format}; charset=utf-8" })
40
36
  end
41
37
 
42
38
  it "should get the correct resource" do
43
- @client.user()
44
- expect(a_get("users/self.#{format}").
45
- with(:query => {:access_token => @client.access_token})).
46
- to have_been_made
39
+ @client.user
40
+ expect(a_get("users/self.#{format}")
41
+ .with(query: { access_token: @client.access_token }))
42
+ .to have_been_made
47
43
  end
48
44
  end
49
45
  end
50
46
 
51
47
  describe ".user_search" do
52
-
53
48
  before do
54
- stub_get("users/search.#{format}").
55
- with(:query => {:access_token => @client.access_token}).
56
- with(:query => {:q => "Shayne Sweeney"}).
57
- to_return(:body => fixture("user_search.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
49
+ stub_get("users/search.#{format}")
50
+ .with(query: { access_token: @client.access_token })
51
+ .with(query: { q: "Shayne Sweeney" })
52
+ .to_return(body: fixture("user_search.#{format}"), headers: { content_type: "application/#{format}; charset=utf-8" })
58
53
  end
59
54
 
60
55
  it "should get the correct resource" do
61
56
  @client.user_search("Shayne Sweeney")
62
- expect(a_get("users/search.#{format}").
63
- with(:query => {:access_token => @client.access_token}).
64
- with(:query => {:q => "Shayne Sweeney"})).
65
- to have_been_made
57
+ expect(a_get("users/search.#{format}")
58
+ .with(query: { access_token: @client.access_token })
59
+ .with(query: { q: "Shayne Sweeney" }))
60
+ .to have_been_made
66
61
  end
67
62
 
68
63
  it "should return an array of user search results" do
@@ -73,20 +68,18 @@ describe Instagram::Client do
73
68
  end
74
69
 
75
70
  describe ".user_follows" do
76
-
77
71
  context "with user ID passed" do
78
-
79
72
  before do
80
- stub_get("users/4/follows.#{format}").
81
- with(:query => {:access_token => @client.access_token}).
82
- to_return(:body => fixture("follows.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
73
+ stub_get("users/4/follows.#{format}")
74
+ .with(query: { access_token: @client.access_token })
75
+ .to_return(body: fixture("follows.#{format}"), headers: { content_type: "application/#{format}; charset=utf-8" })
83
76
  end
84
77
 
85
78
  it "should get the correct resource" do
86
79
  @client.user_follows(4)
87
- expect(a_get("users/4/follows.#{format}").
88
- with(:query => {:access_token => @client.access_token})).
89
- to have_been_made
80
+ expect(a_get("users/4/follows.#{format}")
81
+ .with(query: { access_token: @client.access_token }))
82
+ .to have_been_made
90
83
  end
91
84
 
92
85
  it "should return a list of users whom a given user follows" do
@@ -97,37 +90,34 @@ describe Instagram::Client do
97
90
  end
98
91
 
99
92
  context "without user ID passed" do
100
-
101
93
  before do
102
- stub_get("users/self/follows.#{format}").
103
- with(:query => {:access_token => @client.access_token}).
104
- to_return(:body => fixture("follows.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
94
+ stub_get("users/self/follows.#{format}")
95
+ .with(query: { access_token: @client.access_token })
96
+ .to_return(body: fixture("follows.#{format}"), headers: { content_type: "application/#{format}; charset=utf-8" })
105
97
  end
106
98
 
107
99
  it "should get the correct resource" do
108
100
  @client.user_follows
109
- expect(a_get("users/self/follows.#{format}").
110
- with(:query => {:access_token => @client.access_token})).
111
- to have_been_made
101
+ expect(a_get("users/self/follows.#{format}")
102
+ .with(query: { access_token: @client.access_token }))
103
+ .to have_been_made
112
104
  end
113
105
  end
114
106
  end
115
107
 
116
108
  describe ".user_followed_by" do
117
-
118
109
  context "with user ID passed" do
119
-
120
110
  before do
121
- stub_get("users/4/followed-by.#{format}").
122
- with(:query => {:access_token => @client.access_token}).
123
- to_return(:body => fixture("followed_by.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
111
+ stub_get("users/4/followed-by.#{format}")
112
+ .with(query: { access_token: @client.access_token })
113
+ .to_return(body: fixture("followed_by.#{format}"), headers: { content_type: "application/#{format}; charset=utf-8" })
124
114
  end
125
115
 
126
116
  it "should get the correct resource" do
127
117
  @client.user_followed_by(4)
128
- expect(a_get("users/4/followed-by.#{format}").
129
- with(:query => {:access_token => @client.access_token})).
130
- to have_been_made
118
+ expect(a_get("users/4/followed-by.#{format}")
119
+ .with(query: { access_token: @client.access_token }))
120
+ .to have_been_made
131
121
  end
132
122
 
133
123
  it "should return a list of users whom a given user is followed by" do
@@ -138,63 +128,60 @@ describe Instagram::Client do
138
128
  end
139
129
 
140
130
  context "without user ID passed" do
141
-
142
131
  before do
143
- stub_get("users/self/followed-by.#{format}").
144
- with(:query => {:access_token => @client.access_token}).
145
- to_return(:body => fixture("followed_by.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
132
+ stub_get("users/self/followed-by.#{format}")
133
+ .with(query: { access_token: @client.access_token })
134
+ .to_return(body: fixture("followed_by.#{format}"), headers: { content_type: "application/#{format}; charset=utf-8" })
146
135
  end
147
136
 
148
137
  it "should get the correct resource" do
149
138
  @client.user_followed_by
150
- expect(a_get("users/self/followed-by.#{format}").
151
- with(:query => {:access_token => @client.access_token})).
152
- to have_been_made
139
+ expect(a_get("users/self/followed-by.#{format}")
140
+ .with(query: { access_token: @client.access_token }))
141
+ .to have_been_made
153
142
  end
154
143
  end
155
144
  end
156
145
 
157
146
  describe ".user_media_feed" do
158
-
159
147
  before do
160
- stub_get("users/self/feed.#{format}").
161
- with(:query => {:access_token => @client.access_token}).
162
- to_return(:body => fixture("user_media_feed.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
148
+ stub_get("users/self/feed.#{format}")
149
+ .with(query: { access_token: @client.access_token })
150
+ .to_return(body: fixture("user_media_feed.#{format}"), headers: { content_type: "application/#{format}; charset=utf-8" })
163
151
  end
164
152
 
165
153
  it "should get the correct resource" do
166
154
  @client.user_media_feed
167
- expect(a_get("users/self/feed.#{format}").
168
- with(:query => {:access_token => @client.access_token})).
169
- to have_been_made
155
+ expect(a_get("users/self/feed.#{format}")
156
+ .with(query: { access_token: @client.access_token }))
157
+ .to have_been_made
170
158
  end
171
159
 
172
160
  context Instagram::Response do
173
- let(:user_media_feed_response){ @client.user_media_feed }
174
- subject{ user_media_feed_response }
161
+ let(:user_media_feed_response) { @client.user_media_feed }
162
+ subject { user_media_feed_response }
175
163
 
176
- it{ is_expected.to be_an_instance_of(Array) }
177
- it{ is_expected.to be_a_kind_of(Instagram::Response) }
178
- it{ is_expected.to respond_to(:pagination) }
179
- it{ is_expected.to respond_to(:meta) }
164
+ it { is_expected.to be_a_kind_of(Instagram::Response) }
165
+ it { is_expected.to respond_to(:pagination) }
166
+ it { is_expected.to respond_to(:meta) }
180
167
 
181
- context '.pagination' do
182
- subject{ user_media_feed_response.pagination }
168
+ context ".pagination" do
169
+ subject { user_media_feed_response.pagination }
183
170
 
184
- it{ is_expected.to be_an_instance_of(Hashie::Mash) }
171
+ it { is_expected.to be_an_instance_of(Hashie::Mash) }
185
172
 
186
- describe '#next_max_id' do
173
+ describe "#next_max_id" do
187
174
  subject { super().next_max_id }
188
- it { is_expected.to eq('22063131') }
175
+ it { is_expected.to eq("22063131") }
189
176
  end
190
177
  end
191
178
 
192
- context '.meta' do
193
- subject{ user_media_feed_response.meta }
179
+ context ".meta" do
180
+ subject { user_media_feed_response.meta }
194
181
 
195
- it{ is_expected.to be_an_instance_of(Hashie::Mash) }
182
+ it { is_expected.to be_an_instance_of(Hashie::Mash) }
196
183
 
197
- describe '#code' do
184
+ describe "#code" do
198
185
  subject { super().code }
199
186
  it { is_expected.to eq(200) }
200
187
  end
@@ -203,36 +190,33 @@ describe Instagram::Client do
203
190
  end
204
191
 
205
192
  describe ".user_liked_media" do
206
-
207
193
  before do
208
- stub_get("users/self/media/liked.#{format}").
209
- with(:query => {:access_token => @client.access_token}).
210
- to_return(:body => fixture("liked_media.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
194
+ stub_get("users/self/media/liked.#{format}")
195
+ .with(query: { access_token: @client.access_token })
196
+ .to_return(body: fixture("liked_media.#{format}"), headers: { content_type: "application/#{format}; charset=utf-8" })
211
197
  end
212
198
 
213
199
  it "should get the correct resource" do
214
200
  @client.user_liked_media
215
- expect(a_get("users/self/media/liked.#{format}").
216
- with(:query => {:access_token => @client.access_token})).
217
- to have_been_made
201
+ expect(a_get("users/self/media/liked.#{format}")
202
+ .with(query: { access_token: @client.access_token }))
203
+ .to have_been_made
218
204
  end
219
205
  end
220
-
221
- describe ".user_recent_media" do
222
206
 
207
+ describe ".user_recent_media" do
223
208
  context "with user ID passed" do
224
-
225
209
  before do
226
- stub_get("users/4/media/recent.#{format}").
227
- with(:query => {:access_token => @client.access_token}).
228
- to_return(:body => fixture("recent_media.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
210
+ stub_get("users/4/media/recent.#{format}")
211
+ .with(query: { access_token: @client.access_token })
212
+ .to_return(body: fixture("recent_media.#{format}"), headers: { content_type: "application/#{format}; charset=utf-8" })
229
213
  end
230
214
 
231
215
  it "should get the correct resource" do
232
216
  @client.user_recent_media(4)
233
- expect(a_get("users/4/media/recent.#{format}").
234
- with(:query => {:access_token => @client.access_token})).
235
- to have_been_made
217
+ expect(a_get("users/4/media/recent.#{format}")
218
+ .with(query: { access_token: @client.access_token }))
219
+ .to have_been_made
236
220
  end
237
221
 
238
222
  it "should return a list of recent media items for the given user" do
@@ -243,35 +227,33 @@ describe Instagram::Client do
243
227
  end
244
228
 
245
229
  context "without user ID passed" do
246
-
247
230
  before do
248
- stub_get("users/self/media/recent.#{format}").
249
- with(:query => {:access_token => @client.access_token}).
250
- to_return(:body => fixture("recent_media.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
231
+ stub_get("users/self/media/recent.#{format}")
232
+ .with(query: { access_token: @client.access_token })
233
+ .to_return(body: fixture("recent_media.#{format}"), headers: { content_type: "application/#{format}; charset=utf-8" })
251
234
  end
252
235
 
253
236
  it "should get the correct resource" do
254
237
  @client.user_recent_media
255
- expect(a_get("users/self/media/recent.#{format}").
256
- with(:query => {:access_token => @client.access_token})).
257
- to have_been_made
238
+ expect(a_get("users/self/media/recent.#{format}")
239
+ .with(query: { access_token: @client.access_token }))
240
+ .to have_been_made
258
241
  end
259
242
  end
260
243
  end
261
244
 
262
245
  describe ".user_requested_by" do
263
-
264
246
  before do
265
- stub_get("users/self/requested-by.#{format}").
266
- with(:query => {:access_token => @client.access_token}).
267
- to_return(:body => fixture("requested_by.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
247
+ stub_get("users/self/requested-by.#{format}")
248
+ .with(query: { access_token: @client.access_token })
249
+ .to_return(body: fixture("requested_by.#{format}"), headers: { content_type: "application/#{format}; charset=utf-8" })
268
250
  end
269
251
 
270
252
  it "should get the correct resource" do
271
253
  @client.user_requested_by
272
- expect(a_get("users/self/requested-by.#{format}").
273
- with(:query => {:access_token => @client.access_token})).
274
- to have_been_made
254
+ expect(a_get("users/self/requested-by.#{format}")
255
+ .with(query: { access_token: @client.access_token }))
256
+ .to have_been_made
275
257
  end
276
258
 
277
259
  it "should return a list of users awaiting approval" do
@@ -280,148 +262,141 @@ describe Instagram::Client do
280
262
  expect(users.first.username).to eq("shayne")
281
263
  end
282
264
  end
283
-
265
+
284
266
  describe ".user_relationship" do
285
-
286
267
  before do
287
- stub_get("users/4/relationship.#{format}").
288
- with(:query => {:access_token => @client.access_token}).
289
- to_return(:body => fixture("relationship.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
268
+ stub_get("users/4/relationship.#{format}")
269
+ .with(query: { access_token: @client.access_token })
270
+ .to_return(body: fixture("relationship.#{format}"), headers: { content_type: "application/#{format}; charset=utf-8" })
290
271
  end
291
-
272
+
292
273
  it "should get the correct resource" do
293
274
  @client.user_relationship(4)
294
- expect(a_get("users/4/relationship.#{format}").
295
- with(:query => {:access_token => @client.access_token})).
296
- to have_been_made
275
+ expect(a_get("users/4/relationship.#{format}")
276
+ .with(query: { access_token: @client.access_token }))
277
+ .to have_been_made
297
278
  end
298
-
279
+
299
280
  it "should return a relationship status response" do
300
281
  status = @client.user_relationship(4)
301
282
  expect(status.incoming_status).to eq("requested_by")
302
283
  end
303
284
  end
304
-
285
+
305
286
  describe ".follow_user" do
306
-
307
287
  before do
308
- stub_post("users/4/relationship.#{format}").
309
- with(:body => {:action => "follow", :access_token => @client.access_token}).
310
- to_return(:body => fixture("follow_user.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
288
+ stub_post("users/4/relationship.#{format}")
289
+ .with(body: { action: "follow", access_token: @client.access_token })
290
+ .to_return(body: fixture("follow_user.#{format}"), headers: { content_type: "application/#{format}; charset=utf-8" })
311
291
  end
312
-
292
+
313
293
  it "should get the correct resource" do
314
294
  @client.follow_user(4)
315
- expect(a_post("users/4/relationship.#{format}").
316
- with(:body => {:action => "follow", :access_token => @client.access_token})).
317
- to have_been_made
295
+ expect(a_post("users/4/relationship.#{format}")
296
+ .with(body: { action: "follow", access_token: @client.access_token }))
297
+ .to have_been_made
318
298
  end
319
-
299
+
320
300
  it "should return a relationship status response" do
321
301
  status = @client.follow_user(4)
322
302
  expect(status.outgoing_status).to eq("requested")
323
303
  end
324
304
  end
325
-
305
+
326
306
  describe ".unfollow_user" do
327
-
328
307
  before do
329
- stub_post("users/4/relationship.#{format}").
330
- with(:body => {:action => "unfollow", :access_token => @client.access_token}).
331
- to_return(:body => fixture("unfollow_user.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
308
+ stub_post("users/4/relationship.#{format}")
309
+ .with(body: { action: "unfollow", access_token: @client.access_token })
310
+ .to_return(body: fixture("unfollow_user.#{format}"), headers: { content_type: "application/#{format}; charset=utf-8" })
332
311
  end
333
-
312
+
334
313
  it "should get the correct resource" do
335
314
  @client.unfollow_user(4)
336
- expect(a_post("users/4/relationship.#{format}").
337
- with(:body => {:action => "unfollow", :access_token => @client.access_token})).
338
- to have_been_made
315
+ expect(a_post("users/4/relationship.#{format}")
316
+ .with(body: { action: "unfollow", access_token: @client.access_token }))
317
+ .to have_been_made
339
318
  end
340
-
319
+
341
320
  it "should return a relationship status response" do
342
321
  status = @client.unfollow_user(4)
343
322
  expect(status.outgoing_status).to eq("none")
344
323
  end
345
324
  end
346
-
325
+
347
326
  describe ".block_user" do
348
-
349
327
  before do
350
- stub_post("users/4/relationship.#{format}").
351
- with(:body => {:action => "block", :access_token => @client.access_token}).
352
- to_return(:body => fixture("block_user.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
328
+ stub_post("users/4/relationship.#{format}")
329
+ .with(body: { action: "block", access_token: @client.access_token })
330
+ .to_return(body: fixture("block_user.#{format}"), headers: { content_type: "application/#{format}; charset=utf-8" })
353
331
  end
354
-
332
+
355
333
  it "should get the correct resource" do
356
334
  @client.block_user(4)
357
- expect(a_post("users/4/relationship.#{format}").
358
- with(:body => {:action => "block", :access_token => @client.access_token})).
359
- to have_been_made
335
+ expect(a_post("users/4/relationship.#{format}")
336
+ .with(body: { action: "block", access_token: @client.access_token }))
337
+ .to have_been_made
360
338
  end
361
-
339
+
362
340
  it "should return a relationship status response" do
363
341
  status = @client.block_user(4)
364
342
  expect(status.outgoing_status).to eq("none")
365
343
  end
366
344
  end
367
-
345
+
368
346
  describe ".unblock_user" do
369
-
370
347
  before do
371
- stub_post("users/4/relationship.#{format}").
372
- with(:body => {:action => "unblock", :access_token => @client.access_token}).
373
- to_return(:body => fixture("unblock_user.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
348
+ stub_post("users/4/relationship.#{format}")
349
+ .with(body: { action: "unblock", access_token: @client.access_token })
350
+ .to_return(body: fixture("unblock_user.#{format}"), headers: { content_type: "application/#{format}; charset=utf-8" })
374
351
  end
375
-
352
+
376
353
  it "should get the correct resource" do
377
354
  @client.unblock_user(4)
378
- expect(a_post("users/4/relationship.#{format}").
379
- with(:body => {:action => "unblock", :access_token => @client.access_token})).
380
- to have_been_made
355
+ expect(a_post("users/4/relationship.#{format}")
356
+ .with(body: { action: "unblock", access_token: @client.access_token }))
357
+ .to have_been_made
381
358
  end
382
-
359
+
383
360
  it "should return a relationship status response" do
384
361
  status = @client.unblock_user(4)
385
362
  expect(status.outgoing_status).to eq("none")
386
363
  end
387
364
  end
388
-
365
+
389
366
  describe ".approve_user" do
390
-
391
367
  before do
392
- stub_post("users/4/relationship.#{format}").
393
- with(:body => {:action => "approve", :access_token => @client.access_token}).
394
- to_return(:body => fixture("approve_user.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
368
+ stub_post("users/4/relationship.#{format}")
369
+ .with(body: { action: "approve", access_token: @client.access_token })
370
+ .to_return(body: fixture("approve_user.#{format}"), headers: { content_type: "application/#{format}; charset=utf-8" })
395
371
  end
396
-
372
+
397
373
  it "should get the correct resource" do
398
374
  @client.approve_user(4)
399
- expect(a_post("users/4/relationship.#{format}").
400
- with(:body => {:action => "approve", :access_token => @client.access_token})).
401
- to have_been_made
375
+ expect(a_post("users/4/relationship.#{format}")
376
+ .with(body: { action: "approve", access_token: @client.access_token }))
377
+ .to have_been_made
402
378
  end
403
-
379
+
404
380
  it "should return a relationship status response" do
405
381
  status = @client.approve_user(4)
406
382
  expect(status.outgoing_status).to eq("follows")
407
383
  end
408
384
  end
409
-
385
+
410
386
  describe ".deny_user" do
411
-
412
387
  before do
413
- stub_post("users/4/relationship.#{format}").
414
- with(:body => {:action => "deny", :access_token => @client.access_token}).
415
- to_return(:body => fixture("deny_user.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
388
+ stub_post("users/4/relationship.#{format}")
389
+ .with(body: { action: "deny", access_token: @client.access_token })
390
+ .to_return(body: fixture("deny_user.#{format}"), headers: { content_type: "application/#{format}; charset=utf-8" })
416
391
  end
417
-
392
+
418
393
  it "should get the correct resource" do
419
394
  @client.deny_user(4)
420
- expect(a_post("users/4/relationship.#{format}").
421
- with(:body => {:action => "deny", :access_token => @client.access_token})).
422
- to have_been_made
395
+ expect(a_post("users/4/relationship.#{format}")
396
+ .with(body: { action: "deny", access_token: @client.access_token }))
397
+ .to have_been_made
423
398
  end
424
-
399
+
425
400
  it "should return a relationship status response" do
426
401
  status = @client.deny_user(4)
427
402
  expect(status.outgoing_status).to eq("none")