instagram 0.3.2 → 0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +12 -0
- data/.rspec +3 -0
- data/.yardopts +9 -0
- data/Gemfile +3 -0
- data/LICENSE.md +20 -0
- data/README.md +144 -55
- data/Rakefile +21 -9
- data/instagram.gemspec +41 -0
- data/lib/faraday/oauth2.rb +36 -0
- data/lib/faraday/raise_http_4xx.rb +37 -0
- data/lib/faraday/raise_http_5xx.rb +29 -0
- data/lib/instagram.rb +21 -55
- data/lib/instagram/api.rb +23 -0
- data/lib/instagram/client.rb +19 -0
- data/lib/instagram/client/comments.rb +62 -0
- data/lib/instagram/client/likes.rb +58 -0
- data/lib/instagram/client/locations.rb +59 -0
- data/lib/instagram/client/media.rb +63 -0
- data/lib/instagram/client/real_time.rb +8 -0
- data/lib/instagram/client/subscriptions.rb +141 -0
- data/lib/instagram/client/tags.rb +59 -0
- data/lib/instagram/client/users.rb +165 -0
- data/lib/instagram/client/utils.rb +15 -0
- data/lib/instagram/configuration.rb +90 -0
- data/lib/instagram/connection.rb +31 -0
- data/lib/instagram/error.rb +16 -0
- data/lib/instagram/oauth.rb +27 -0
- data/lib/instagram/request.rb +45 -0
- data/lib/instagram/version.rb +3 -0
- data/spec/faraday/response_spec.rb +28 -0
- data/spec/fixtures/access_token.json +9 -0
- data/spec/fixtures/followed_by.json +1 -0
- data/spec/fixtures/follows.json +1 -0
- data/spec/fixtures/location.json +1 -0
- data/spec/fixtures/location_recent_media.json +1 -0
- data/spec/fixtures/location_search.json +1 -0
- data/spec/fixtures/media.json +1 -0
- data/spec/fixtures/media_comment.json +1 -0
- data/spec/fixtures/media_comment_deleted.json +1 -0
- data/spec/fixtures/media_comments.json +1 -0
- data/spec/fixtures/media_liked.json +1 -0
- data/spec/fixtures/media_likes.json +1 -0
- data/spec/fixtures/media_popular.json +1 -0
- data/spec/fixtures/media_search.json +1 -0
- data/spec/fixtures/media_unliked.json +1 -0
- data/spec/fixtures/mikeyk.json +1 -0
- data/spec/fixtures/recent_media.json +1 -0
- data/spec/fixtures/requested_by.json +12 -0
- data/spec/fixtures/shayne.json +1 -0
- data/spec/fixtures/subscription.json +12 -0
- data/spec/fixtures/subscription_deleted.json +1 -0
- data/spec/fixtures/subscription_payload.json +14 -0
- data/spec/fixtures/subscriptions.json +22 -0
- data/spec/fixtures/tag.json +1 -0
- data/spec/fixtures/tag_recent_media.json +1 -0
- data/spec/fixtures/tag_search.json +1 -0
- data/spec/fixtures/user_media_feed.json +1 -0
- data/spec/fixtures/user_search.json +1 -0
- data/spec/instagram/api_spec.rb +110 -0
- data/spec/instagram/client/comments_spec.rb +71 -0
- data/spec/instagram/client/likes_spec.rb +66 -0
- data/spec/instagram/client/locations_spec.rb +78 -0
- data/spec/instagram/client/media_spec.rb +78 -0
- data/spec/instagram/client/real_time_spec.rb +13 -0
- data/spec/instagram/client/subscriptions_spec.rb +118 -0
- data/spec/instagram/client/tags_spec.rb +78 -0
- data/spec/instagram/client/users_spec.rb +237 -0
- data/spec/instagram/client_spec.rb +23 -0
- data/spec/instagram_spec.rb +97 -0
- data/spec/spec_helper.rb +54 -0
- metadata +265 -33
- data/MIT-LICENSE +0 -18
- data/lib/instagram/cached.rb +0 -25
- data/lib/instagram/failsafe_store.rb +0 -52
- data/lib/instagram/models.rb +0 -163
@@ -0,0 +1,78 @@
|
|
1
|
+
require File.expand_path('../../../spec_helper', __FILE__)
|
2
|
+
|
3
|
+
describe Instagram::Client do
|
4
|
+
Instagram::Configuration::VALID_FORMATS.each do |format|
|
5
|
+
context ".new(:format => '#{format}')" do
|
6
|
+
before do
|
7
|
+
@client = Instagram::Client.new(:format => format, :client_id => 'CID', :client_secret => 'CS', :access_token => 'AT')
|
8
|
+
end
|
9
|
+
|
10
|
+
describe ".media_item" do
|
11
|
+
|
12
|
+
before do
|
13
|
+
stub_get("media/18600493.#{format}").
|
14
|
+
with(:query => {:access_token => @client.access_token}).
|
15
|
+
to_return(:body => fixture("media.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should get the correct resource" do
|
19
|
+
@client.media_item(18600493)
|
20
|
+
a_get("media/18600493.#{format}").
|
21
|
+
with(:query => {:access_token => @client.access_token}).
|
22
|
+
should have_been_made
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should return extended information of a given media item" do
|
26
|
+
media = @client.media_item(18600493)
|
27
|
+
media.user.username.should == "mikeyk"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe ".media_popular" do
|
32
|
+
|
33
|
+
before do
|
34
|
+
stub_get("media/popular.#{format}").
|
35
|
+
with(:query => {:access_token => @client.access_token}).
|
36
|
+
to_return(:body => fixture("media_popular.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should get the correct resource" do
|
40
|
+
@client.media_popular
|
41
|
+
a_get("media/popular.#{format}").
|
42
|
+
with(:query => {:access_token => @client.access_token}).
|
43
|
+
should have_been_made
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should return popular media items" do
|
47
|
+
media_popular = @client.media_popular
|
48
|
+
media_popular.should be_a Array
|
49
|
+
media_popular.first.user.username == "babycamera"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe ".media_search" do
|
54
|
+
|
55
|
+
before do
|
56
|
+
stub_get("media/search.#{format}").
|
57
|
+
with(:query => {:access_token => @client.access_token}).
|
58
|
+
with(:query => {:lat => "37.7808851", :lng => "-122.3948632"}).
|
59
|
+
to_return(:body => fixture("media_search.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should get the correct resource" do
|
63
|
+
@client.media_search("37.7808851", "-122.3948632")
|
64
|
+
a_get("media/search.#{format}").
|
65
|
+
with(:query => {:access_token => @client.access_token}).
|
66
|
+
with(:query => {:lat => "37.7808851", :lng => "-122.3948632"}).
|
67
|
+
should have_been_made
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should return an array of user search results" do
|
71
|
+
user_search = @client.media_search("37.7808851", "-122.3948632")
|
72
|
+
user_search.should be_a Array
|
73
|
+
user_search.first.user.username.should == "mikeyk"
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require File.expand_path('../../../spec_helper', __FILE__)
|
2
|
+
|
3
|
+
describe Instagram::Client do
|
4
|
+
Instagram::Configuration::VALID_FORMATS.each do |format|
|
5
|
+
context ".new(:format => '#{format}')" do
|
6
|
+
|
7
|
+
before do
|
8
|
+
@client = Instagram::Client.new(:format => format, :client_id => 'CID', :access_token => 'AT')
|
9
|
+
end
|
10
|
+
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,118 @@
|
|
1
|
+
require File.expand_path('../../../spec_helper', __FILE__)
|
2
|
+
|
3
|
+
describe Instagram::Client do
|
4
|
+
Instagram::Configuration::VALID_FORMATS.each do |format|
|
5
|
+
context ".new(:format => '#{format}')" do
|
6
|
+
|
7
|
+
before do
|
8
|
+
@client = Instagram::Client.new(:format => format, :client_id => 'CID', :client_secret => 'CS', :access_token => 'AT')
|
9
|
+
end
|
10
|
+
|
11
|
+
describe ".subscriptions" do
|
12
|
+
|
13
|
+
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"})
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should get the correct resource" do
|
20
|
+
@client.subscriptions
|
21
|
+
a_get("subscriptions.#{format}").
|
22
|
+
with(:query => {:client_id => @client.client_id, :client_secret => @client.client_secret}).
|
23
|
+
should have_been_made
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should return an array of subscriptions" do
|
27
|
+
subscriptions = @client.subscriptions
|
28
|
+
subscriptions.should be_a Array
|
29
|
+
subscriptions.first.object.should == "user"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe ".create_subscription" do
|
34
|
+
|
35
|
+
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"})
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should get the correct resource" do
|
42
|
+
@client.create_subscription("user", :callback_url => "http://example.com/instagram/callback")
|
43
|
+
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
|
+
should have_been_made
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should return the new subscription when successful" do
|
49
|
+
subscription = @client.create_subscription("user", :callback_url => "http://example.com/instagram/callback")
|
50
|
+
subscription.object.should == "user"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe ".delete_media_comment" do
|
55
|
+
|
56
|
+
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"})
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should get the correct resource" do
|
63
|
+
@client.delete_subscription(:object => "user")
|
64
|
+
a_delete("subscriptions.#{format}").
|
65
|
+
with(:query => {:object => "user", :client_id => @client.client_id, :client_secret => @client.client_secret}).
|
66
|
+
should have_been_made
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
describe ".process_subscriptions" do
|
71
|
+
|
72
|
+
context "without a callbacks block" do
|
73
|
+
it "should raise an ArgumentError" do
|
74
|
+
lambda do
|
75
|
+
@client.process_subscription(nil)
|
76
|
+
end.should raise_error(ArgumentError)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
context "with a callbacks block and valid JSON" do
|
81
|
+
|
82
|
+
before do
|
83
|
+
@json = fixture("subscription_payload.json").read
|
84
|
+
end
|
85
|
+
|
86
|
+
it "should issue a callback to on_user_changed" do
|
87
|
+
@client.process_subscription(@json) do |handler|
|
88
|
+
handler.on_user_changed do |user_id, payload|
|
89
|
+
user_id.should == "1234"
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
it "should issue a callback to on_tag_changed" do
|
95
|
+
@client.process_subscription(@json) do |handler|
|
96
|
+
handler.on_tag_changed do |tag_name, payload|
|
97
|
+
tag_name.should == "nofilter"
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
it "should issue both callbacks in one block" do
|
103
|
+
@client.process_subscription(@json) do |handler|
|
104
|
+
|
105
|
+
handler.on_user_changed do |user_id, payload|
|
106
|
+
user_id.should == "1234"
|
107
|
+
end
|
108
|
+
|
109
|
+
handler.on_tag_changed do |tag_name, payload|
|
110
|
+
tag_name.should == "nofilter"
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
require File.expand_path('../../../spec_helper', __FILE__)
|
2
|
+
|
3
|
+
describe Instagram::Client do
|
4
|
+
Instagram::Configuration::VALID_FORMATS.each do |format|
|
5
|
+
context ".new(:format => '#{format}')" do
|
6
|
+
before do
|
7
|
+
@client = Instagram::Client.new(:format => format, :client_id => 'CID', :client_secret => 'CS', :access_token => 'AT')
|
8
|
+
end
|
9
|
+
|
10
|
+
describe ".tag" do
|
11
|
+
|
12
|
+
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"})
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should get the correct resource" do
|
19
|
+
@client.tag('cat')
|
20
|
+
a_get("tags/cat.#{format}").
|
21
|
+
with(:query => {:access_token => @client.access_token}).
|
22
|
+
should have_been_made
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should return extended information of a given media item" do
|
26
|
+
tag = @client.tag('cat')
|
27
|
+
tag.name.should == 'cat'
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe ".tag_recent_media" do
|
32
|
+
|
33
|
+
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"})
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should get the correct resource" do
|
40
|
+
@client.tag_recent_media('cat')
|
41
|
+
a_get("tags/cat/media/recent.#{format}").
|
42
|
+
with(:query => {:access_token => @client.access_token}).
|
43
|
+
should have_been_made
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should return a list of media taken at a given location" do
|
47
|
+
media = @client.tag_recent_media('cat')
|
48
|
+
media.should be_a Array
|
49
|
+
media.first.user.username.should == "amandavan"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe ".tag_search" do
|
54
|
+
|
55
|
+
before do
|
56
|
+
stub_get("tags/search.#{format}").
|
57
|
+
with(:query => {:access_token => @client.access_token}).
|
58
|
+
with(:query => {:q => 'cat'}).
|
59
|
+
to_return(:body => fixture("tag_search.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should get the correct resource" do
|
63
|
+
@client.tag_search('cat')
|
64
|
+
a_get("tags/search.#{format}").
|
65
|
+
with(:query => {:access_token => @client.access_token}).
|
66
|
+
with(:query => {:q => 'cat'}).
|
67
|
+
should have_been_made
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should return an array of user search results" do
|
71
|
+
tags = @client.tag_search('cat')
|
72
|
+
tags.should be_a Array
|
73
|
+
tags.first.name.should == "cats"
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,237 @@
|
|
1
|
+
require File.expand_path('../../../spec_helper', __FILE__)
|
2
|
+
|
3
|
+
describe Instagram::Client do
|
4
|
+
Instagram::Configuration::VALID_FORMATS.each do |format|
|
5
|
+
context ".new(:format => '#{format}')" do
|
6
|
+
before do
|
7
|
+
@client = Instagram::Client.new(:format => format, :client_id => 'CID', :client_secret => 'CS', :access_token => 'AT')
|
8
|
+
end
|
9
|
+
|
10
|
+
describe ".user" do
|
11
|
+
|
12
|
+
context "with user ID passed" do
|
13
|
+
|
14
|
+
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"})
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should get the correct resource" do
|
21
|
+
@client.user(4)
|
22
|
+
a_get("users/4.#{format}").
|
23
|
+
with(:query => {:access_token => @client.access_token}).
|
24
|
+
should have_been_made
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should return extended information of a given user" do
|
28
|
+
user = @client.user(4)
|
29
|
+
user.full_name.should == "Mike Krieger"
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
context "without user ID passed" do
|
35
|
+
|
36
|
+
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"})
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should get the correct resource" do
|
43
|
+
@client.user()
|
44
|
+
a_get("users/self.#{format}").
|
45
|
+
with(:query => {:access_token => @client.access_token}).
|
46
|
+
should have_been_made
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe ".user_search" do
|
52
|
+
|
53
|
+
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"})
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should get the correct resource" do
|
61
|
+
@client.user_search("Shayne Sweeney")
|
62
|
+
a_get("users/search.#{format}").
|
63
|
+
with(:query => {:access_token => @client.access_token}).
|
64
|
+
with(:query => {:q => "Shayne Sweeney"}).
|
65
|
+
should have_been_made
|
66
|
+
end
|
67
|
+
|
68
|
+
it "should return an array of user search results" do
|
69
|
+
users = @client.user_search("Shayne Sweeney")
|
70
|
+
users.should be_a Array
|
71
|
+
users.first.username.should == "shayne"
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
describe ".user_follows" do
|
76
|
+
|
77
|
+
context "with user ID passed" do
|
78
|
+
|
79
|
+
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"})
|
83
|
+
end
|
84
|
+
|
85
|
+
it "should get the correct resource" do
|
86
|
+
@client.user_follows(4)
|
87
|
+
a_get("users/4/follows.#{format}").
|
88
|
+
with(:query => {:access_token => @client.access_token}).
|
89
|
+
should have_been_made
|
90
|
+
end
|
91
|
+
|
92
|
+
it "should return a list of users whom a given user follows" do
|
93
|
+
follows = @client.user_follows(4)
|
94
|
+
follows.should be_a Array
|
95
|
+
follows.first.username.should == "heartsf"
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
context "without user ID passed" do
|
100
|
+
|
101
|
+
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"})
|
105
|
+
end
|
106
|
+
|
107
|
+
it "should get the correct resource" do
|
108
|
+
@client.user_follows
|
109
|
+
a_get("users/self/follows.#{format}").
|
110
|
+
with(:query => {:access_token => @client.access_token}).
|
111
|
+
should have_been_made
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
describe ".user_followed_by" do
|
117
|
+
|
118
|
+
context "with user ID passed" do
|
119
|
+
|
120
|
+
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"})
|
124
|
+
end
|
125
|
+
|
126
|
+
it "should get the correct resource" do
|
127
|
+
@client.user_followed_by(4)
|
128
|
+
a_get("users/4/followed-by.#{format}").
|
129
|
+
with(:query => {:access_token => @client.access_token}).
|
130
|
+
should have_been_made
|
131
|
+
end
|
132
|
+
|
133
|
+
it "should return a list of users whom a given user is followed by" do
|
134
|
+
followed_by = @client.user_followed_by(4)
|
135
|
+
followed_by.should be_a Array
|
136
|
+
followed_by.first.username.should == "bojieyang"
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
context "without user ID passed" do
|
141
|
+
|
142
|
+
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"})
|
146
|
+
end
|
147
|
+
|
148
|
+
it "should get the correct resource" do
|
149
|
+
@client.user_followed_by
|
150
|
+
a_get("users/self/followed-by.#{format}").
|
151
|
+
with(:query => {:access_token => @client.access_token}).
|
152
|
+
should have_been_made
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
describe ".user_media_feed" do
|
158
|
+
|
159
|
+
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"})
|
163
|
+
end
|
164
|
+
|
165
|
+
it "should get the correct resource" do
|
166
|
+
@client.user_media_feed
|
167
|
+
a_get("users/self/feed.#{format}").
|
168
|
+
with(:query => {:access_token => @client.access_token}).
|
169
|
+
should have_been_made
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
describe ".user_recent_media" do
|
174
|
+
|
175
|
+
context "with user ID passed" do
|
176
|
+
|
177
|
+
before do
|
178
|
+
stub_get("users/4/media/recent.#{format}").
|
179
|
+
with(:query => {:access_token => @client.access_token}).
|
180
|
+
to_return(:body => fixture("recent_media.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
|
181
|
+
end
|
182
|
+
|
183
|
+
it "should get the correct resource" do
|
184
|
+
@client.user_recent_media(4)
|
185
|
+
a_get("users/4/media/recent.#{format}").
|
186
|
+
with(:query => {:access_token => @client.access_token}).
|
187
|
+
should have_been_made
|
188
|
+
end
|
189
|
+
|
190
|
+
it "should return a list of recent media items for the given user" do
|
191
|
+
recent_media = @client.user_recent_media(4)
|
192
|
+
recent_media.should be_a Array
|
193
|
+
recent_media.first.user.username.should == "shayne"
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
context "without user ID passed" do
|
198
|
+
|
199
|
+
before do
|
200
|
+
stub_get("users/self/media/recent.#{format}").
|
201
|
+
with(:query => {:access_token => @client.access_token}).
|
202
|
+
to_return(:body => fixture("recent_media.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
|
203
|
+
end
|
204
|
+
|
205
|
+
it "should get the correct resource" do
|
206
|
+
@client.user_recent_media
|
207
|
+
a_get("users/self/media/recent.#{format}").
|
208
|
+
with(:query => {:access_token => @client.access_token}).
|
209
|
+
should have_been_made
|
210
|
+
end
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
214
|
+
describe ".user_requested_by" do
|
215
|
+
|
216
|
+
before do
|
217
|
+
stub_get("users/self/requested-by.#{format}").
|
218
|
+
with(:query => {:access_token => @client.access_token}).
|
219
|
+
to_return(:body => fixture("requested_by.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
|
220
|
+
end
|
221
|
+
|
222
|
+
it "should get the correct resource" do
|
223
|
+
@client.user_requested_by
|
224
|
+
a_get("users/self/requested-by.#{format}").
|
225
|
+
with(:query => {:access_token => @client.access_token}).
|
226
|
+
should have_been_made
|
227
|
+
end
|
228
|
+
|
229
|
+
it "should return a list of users awaiting approval" do
|
230
|
+
users = @client.user_requested_by
|
231
|
+
users.should be_a Array
|
232
|
+
users.first.username.should == "shayne"
|
233
|
+
end
|
234
|
+
end
|
235
|
+
end
|
236
|
+
end
|
237
|
+
end
|