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.
- checksums.yaml +4 -4
- data/.rubocop.yml +11 -0
- data/.travis.yml +1 -0
- data/README.md +1 -1
- data/Rakefile +12 -11
- data/instagram-continued.gemspec +6 -5
- data/lib/faraday/loud_logger.rb +47 -48
- data/lib/faraday/oauth2.rb +16 -18
- data/lib/faraday/raise_http_exception.rb +9 -9
- data/lib/instagram.rb +8 -8
- data/lib/instagram/api.rb +4 -4
- data/lib/instagram/client.rb +1 -1
- data/lib/instagram/client/comments.rb +5 -5
- data/lib/instagram/client/embedding.rb +9 -9
- data/lib/instagram/client/likes.rb +5 -5
- data/lib/instagram/client/locations.rb +4 -4
- data/lib/instagram/client/media.rb +3 -3
- data/lib/instagram/client/subscriptions.rb +27 -27
- data/lib/instagram/client/tags.rb +3 -3
- data/lib/instagram/client/users.rb +19 -19
- data/lib/instagram/client/utils.rb +5 -5
- data/lib/instagram/configuration.rb +7 -6
- data/lib/instagram/connection.rb +7 -7
- data/lib/instagram/oauth.rb +8 -8
- data/lib/instagram/request.rb +23 -26
- data/lib/instagram/response.rb +8 -4
- data/lib/instagram/version.rb +1 -1
- data/spec/faraday/response_spec.rb +23 -25
- data/spec/instagram/api_spec.rb +90 -94
- data/spec/instagram/client/comments_spec.rb +21 -25
- data/spec/instagram/client/embedding_spec.rb +8 -8
- data/spec/instagram/client/geography_spec.rb +10 -13
- data/spec/instagram/client/likes_spec.rb +21 -25
- data/spec/instagram/client/locations_spec.rb +42 -48
- data/spec/instagram/client/media_spec.rb +33 -37
- data/spec/instagram/client/subscriptions_spec.rb +34 -46
- data/spec/instagram/client/tags_spec.rb +29 -33
- data/spec/instagram/client/users_spec.rb +155 -180
- data/spec/instagram/client/utils_spec.rb +8 -9
- data/spec/instagram/client_spec.rb +9 -9
- data/spec/instagram/request_spec.rb +27 -27
- data/spec/instagram_spec.rb +20 -24
- data/spec/spec_helper.rb +10 -10
- metadata +24 -9
@@ -1,29 +1,28 @@
|
|
1
|
-
require File.expand_path(
|
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(:
|
7
|
+
@client = Instagram::Client.new(format: format, client_id: "CID", client_secret: "CS", client_ips: "1.2.3.4", access_token: "AT")
|
9
8
|
end
|
10
9
|
|
11
|
-
describe
|
10
|
+
describe ".utils_raw_response" do
|
12
11
|
before do
|
13
|
-
stub_get("users/self/feed.#{format}")
|
14
|
-
|
15
|
-
|
12
|
+
stub_get("users/self/feed.#{format}")
|
13
|
+
.with(query: { access_token: @client.access_token })
|
14
|
+
.to_return(body: fixture("user_media_feed.#{format}"), headers: { content_type: "application/#{format}; charset=utf-8" })
|
16
15
|
end
|
17
16
|
|
18
17
|
before(:each) do
|
19
18
|
@response = @client.utils_raw_response
|
20
19
|
end
|
21
20
|
|
22
|
-
it
|
21
|
+
it "return raw data" do
|
23
22
|
expect(@response).to be_instance_of(Faraday::Response)
|
24
23
|
end
|
25
24
|
|
26
|
-
it
|
25
|
+
it "response content headers" do
|
27
26
|
expect(@response).to be_respond_to(:headers)
|
28
27
|
end
|
29
28
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.expand_path(
|
1
|
+
require File.expand_path("../../spec_helper", __FILE__)
|
2
2
|
|
3
3
|
describe Instagram::Client do
|
4
4
|
it "should connect using the endpoint configuration" do
|
@@ -9,15 +9,15 @@ describe Instagram::Client do
|
|
9
9
|
end
|
10
10
|
|
11
11
|
it "should not cache the user account across clients" do
|
12
|
-
stub_get("users/self.json")
|
13
|
-
with(:
|
14
|
-
to_return(:
|
15
|
-
client1 = Instagram::Client.new(:
|
12
|
+
stub_get("users/self.json")
|
13
|
+
.with(query: { access_token: "at1" })
|
14
|
+
.to_return(body: fixture("shayne.json"), headers: { content_type: "application/json; charset=utf-8" })
|
15
|
+
client1 = Instagram::Client.new(access_token: "at1")
|
16
16
|
expect(client1.send(:get_username)).to eq("shayne")
|
17
|
-
stub_get("users/self.json")
|
18
|
-
with(:
|
19
|
-
to_return(:
|
20
|
-
client2 = Instagram::Client.new(:
|
17
|
+
stub_get("users/self.json")
|
18
|
+
.with(query: { access_token: "at2" })
|
19
|
+
.to_return(body: fixture("mikeyk.json"), headers: { content_type: "application/json; charset=utf-8" })
|
20
|
+
client2 = Instagram::Client.new(access_token: "at2")
|
21
21
|
expect(client2.send(:get_username)).to eq("mikeyk")
|
22
22
|
end
|
23
23
|
end
|
@@ -1,55 +1,55 @@
|
|
1
|
-
require File.expand_path(
|
1
|
+
require File.expand_path("../../spec_helper", __FILE__)
|
2
2
|
|
3
3
|
describe Instagram::Request do
|
4
4
|
describe "#post" do
|
5
5
|
before do
|
6
6
|
@ips = "1.2.3.4"
|
7
7
|
@secret = "CS"
|
8
|
-
digest = OpenSSL::Digest.new(
|
8
|
+
digest = OpenSSL::Digest.new("sha256")
|
9
9
|
signature = OpenSSL::HMAC.hexdigest(digest, @secret, @ips)
|
10
|
-
@signed_header = [@ips, signature].join(
|
10
|
+
@signed_header = [@ips, signature].join("|")
|
11
11
|
end
|
12
12
|
|
13
13
|
context "with signature=true" do
|
14
14
|
it "should set X-Insta-Forwarded-For header" do
|
15
|
-
client = Instagram::Client.new(:
|
15
|
+
client = Instagram::Client.new(client_id: "CID", client_secret: @secret, client_ips: @ips, access_token: "AT")
|
16
16
|
url = client.send(:connection).build_url("/media/123/likes.json").to_s
|
17
|
-
stub_request(:post, url)
|
18
|
-
with(:
|
19
|
-
to_return(:
|
17
|
+
stub_request(:post, url)
|
18
|
+
.with(body: { "access_token" => "AT" })
|
19
|
+
.to_return(status: 200, body: "", headers: {})
|
20
20
|
|
21
|
-
client.post("/media/123/likes", {}, signature=true)
|
22
|
-
expect(a_request(:post, url)
|
23
|
-
with(:
|
24
|
-
to have_been_made
|
21
|
+
client.post("/media/123/likes", {}, signature = true)
|
22
|
+
expect(a_request(:post, url)
|
23
|
+
.with(headers: { "X-Insta-Forwarded-For" => @signed_header }))
|
24
|
+
.to have_been_made
|
25
25
|
end
|
26
26
|
|
27
27
|
it "should not set X-Insta-Fowarded-For header if client_ips is not provided" do
|
28
|
-
client = Instagram::Client.new(:
|
28
|
+
client = Instagram::Client.new(client_id: "CID", client_secret: @secret, access_token: "AT")
|
29
29
|
url = client.send(:connection).build_url("/media/123/likes.json").to_s
|
30
|
-
stub_request(:post, url)
|
31
|
-
with(:
|
32
|
-
to_return(:
|
30
|
+
stub_request(:post, url)
|
31
|
+
.with(body: { "access_token" => "AT" })
|
32
|
+
.to_return(status: 200, body: "", headers: {})
|
33
33
|
|
34
|
-
client.post("/media/123/likes", {}, signature=true)
|
35
|
-
expect(a_request(:post, url)
|
36
|
-
with(:
|
37
|
-
not_to have_been_made
|
34
|
+
client.post("/media/123/likes", {}, signature = true)
|
35
|
+
expect(a_request(:post, url)
|
36
|
+
.with(headers: { "X-Insta-Forwarded-For" => @signed_header }))
|
37
|
+
.not_to have_been_made
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
41
|
context "with signature=false" do
|
42
42
|
it "should set X-Insta-Forwarded-For header" do
|
43
|
-
client = Instagram::Client.new(:
|
43
|
+
client = Instagram::Client.new(client_id: "CID", client_secret: @secret, client_ips: @ips, access_token: "AT")
|
44
44
|
url = client.send(:connection).build_url("/media/123/likes.json").to_s
|
45
|
-
stub_request(:post, url)
|
46
|
-
with(:
|
47
|
-
to_return(:
|
45
|
+
stub_request(:post, url)
|
46
|
+
.with(body: { "access_token" => "AT" })
|
47
|
+
.to_return(status: 200, body: "", headers: {})
|
48
48
|
|
49
|
-
client.post("/media/123/likes", {}, signature=false)
|
50
|
-
expect(a_request(:post, url)
|
51
|
-
with(:
|
52
|
-
not_to have_been_made
|
49
|
+
client.post("/media/123/likes", {}, signature = false)
|
50
|
+
expect(a_request(:post, url)
|
51
|
+
.with(headers: { "X-Insta-Forwarded-For" => @signed_header }))
|
52
|
+
.not_to have_been_made
|
53
53
|
end
|
54
54
|
end
|
55
55
|
end
|
data/spec/instagram_spec.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.expand_path(
|
1
|
+
require File.expand_path("../spec_helper", __FILE__)
|
2
2
|
|
3
3
|
describe Instagram do
|
4
4
|
after do
|
@@ -6,22 +6,20 @@ describe Instagram do
|
|
6
6
|
end
|
7
7
|
|
8
8
|
context "when delegating to a client" do
|
9
|
+
before do
|
10
|
+
stub_get("users/self/feed.json")
|
11
|
+
.to_return(body: fixture("user_media_feed.json"), headers: { content_type: "application/json; charset=utf-8" })
|
12
|
+
end
|
9
13
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
it "should get the correct resource" do
|
16
|
-
Instagram.user_media_feed()
|
17
|
-
expect(a_get("users/self/feed.json")).to have_been_made
|
18
|
-
end
|
19
|
-
|
20
|
-
it "should return the same results as a client" do
|
21
|
-
expect(Instagram.user_media_feed()).to eq(Instagram::Client.new.user_media_feed())
|
22
|
-
end
|
14
|
+
it "should get the correct resource" do
|
15
|
+
Instagram.user_media_feed
|
16
|
+
expect(a_get("users/self/feed.json")).to have_been_made
|
17
|
+
end
|
23
18
|
|
24
|
-
|
19
|
+
it "should return the same results as a client" do
|
20
|
+
expect(Instagram.user_media_feed).to eq(Instagram::Client.new.user_media_feed)
|
21
|
+
end
|
22
|
+
end
|
25
23
|
|
26
24
|
describe ".client" do
|
27
25
|
it "should be a Instagram::Client" do
|
@@ -50,8 +48,8 @@ describe Instagram do
|
|
50
48
|
|
51
49
|
describe ".endpoint=" do
|
52
50
|
it "should set the endpoint" do
|
53
|
-
Instagram.endpoint =
|
54
|
-
expect(Instagram.endpoint).to eq(
|
51
|
+
Instagram.endpoint = "http://tumblr.com"
|
52
|
+
expect(Instagram.endpoint).to eq("http://tumblr.com")
|
55
53
|
end
|
56
54
|
end
|
57
55
|
|
@@ -63,8 +61,8 @@ describe Instagram do
|
|
63
61
|
|
64
62
|
describe ".format=" do
|
65
63
|
it "should set the format" do
|
66
|
-
Instagram.format =
|
67
|
-
expect(Instagram.format).to eq(
|
64
|
+
Instagram.format = "xml"
|
65
|
+
expect(Instagram.format).to eq("xml")
|
68
66
|
end
|
69
67
|
end
|
70
68
|
|
@@ -76,12 +74,12 @@ describe Instagram do
|
|
76
74
|
|
77
75
|
describe ".user_agent=" do
|
78
76
|
it "should set the user_agent" do
|
79
|
-
Instagram.user_agent =
|
80
|
-
expect(Instagram.user_agent).to eq(
|
77
|
+
Instagram.user_agent = "Custom User Agent"
|
78
|
+
expect(Instagram.user_agent).to eq("Custom User Agent")
|
81
79
|
end
|
82
80
|
end
|
83
81
|
|
84
|
-
|
82
|
+
describe ".loud_logger" do
|
85
83
|
it "should return the loud_logger status" do
|
86
84
|
expect(Instagram.loud_logger).to eq(nil)
|
87
85
|
end
|
@@ -95,9 +93,7 @@ describe Instagram do
|
|
95
93
|
end
|
96
94
|
|
97
95
|
describe ".configure" do
|
98
|
-
|
99
96
|
Instagram::Configuration::VALID_OPTIONS_KEYS.each do |key|
|
100
|
-
|
101
97
|
it "should set the #{key}" do
|
102
98
|
Instagram.configure do |config|
|
103
99
|
config.send("#{key}=", key)
|
data/spec/spec_helper.rb
CHANGED
@@ -1,28 +1,28 @@
|
|
1
1
|
begin
|
2
|
-
require
|
2
|
+
require "simplecov"
|
3
3
|
rescue LoadError
|
4
4
|
# ignore
|
5
5
|
else
|
6
6
|
SimpleCov.start do
|
7
|
-
add_group
|
8
|
-
add_group
|
9
|
-
add_group
|
7
|
+
add_group "Instagram", "lib/instagram"
|
8
|
+
add_group "Faraday Middleware", "lib/faraday"
|
9
|
+
add_group "Specs", "spec"
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
|
-
require File.expand_path(
|
13
|
+
require File.expand_path("../../lib/instagram", __FILE__)
|
14
14
|
|
15
|
-
require
|
16
|
-
require
|
15
|
+
require "rspec"
|
16
|
+
require "webmock/rspec"
|
17
17
|
RSpec.configure do |config|
|
18
18
|
config.include WebMock::API
|
19
19
|
end
|
20
20
|
|
21
|
-
def capture_output
|
21
|
+
def capture_output
|
22
22
|
begin
|
23
23
|
old_stdout = $stdout
|
24
24
|
$stdout = StringIO.new
|
25
|
-
|
25
|
+
yield
|
26
26
|
result = $stdout.string
|
27
27
|
ensure
|
28
28
|
$stdout = old_stdout
|
@@ -67,5 +67,5 @@ def fixture_path
|
|
67
67
|
end
|
68
68
|
|
69
69
|
def fixture(file)
|
70
|
-
File.new(fixture_path +
|
70
|
+
File.new(fixture_path + "/" + file)
|
71
71
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: instagram-continued
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shayne Sweeney
|
@@ -67,6 +67,20 @@ dependencies:
|
|
67
67
|
- - "~>"
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: '2.2'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: rubocop
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
70
84
|
- !ruby/object:Gem::Dependency
|
71
85
|
name: faraday
|
72
86
|
requirement: !ruby/object:Gem::Requirement
|
@@ -99,30 +113,30 @@ dependencies:
|
|
99
113
|
name: multi_json
|
100
114
|
requirement: !ruby/object:Gem::Requirement
|
101
115
|
requirements:
|
102
|
-
- - "
|
116
|
+
- - ">="
|
103
117
|
- !ruby/object:Gem::Version
|
104
|
-
version: '
|
118
|
+
version: '0'
|
105
119
|
type: :runtime
|
106
120
|
prerelease: false
|
107
121
|
version_requirements: !ruby/object:Gem::Requirement
|
108
122
|
requirements:
|
109
|
-
- - "
|
123
|
+
- - ">="
|
110
124
|
- !ruby/object:Gem::Version
|
111
|
-
version: '
|
125
|
+
version: '0'
|
112
126
|
- !ruby/object:Gem::Dependency
|
113
127
|
name: hashie
|
114
128
|
requirement: !ruby/object:Gem::Requirement
|
115
129
|
requirements:
|
116
|
-
- - "
|
130
|
+
- - ">="
|
117
131
|
- !ruby/object:Gem::Version
|
118
|
-
version: '
|
132
|
+
version: '0'
|
119
133
|
type: :runtime
|
120
134
|
prerelease: false
|
121
135
|
version_requirements: !ruby/object:Gem::Requirement
|
122
136
|
requirements:
|
123
|
-
- - "
|
137
|
+
- - ">="
|
124
138
|
- !ruby/object:Gem::Version
|
125
|
-
version: '
|
139
|
+
version: '0'
|
126
140
|
description: A Ruby wrapper for the Instagram REST and Search APIs
|
127
141
|
email:
|
128
142
|
- shayne@instagr.am
|
@@ -133,6 +147,7 @@ extra_rdoc_files: []
|
|
133
147
|
files:
|
134
148
|
- ".gitignore"
|
135
149
|
- ".rspec"
|
150
|
+
- ".rubocop.yml"
|
136
151
|
- ".travis.yml"
|
137
152
|
- ".yardopts"
|
138
153
|
- Gemfile
|