instagram-fixed 0.8
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 +145 -0
- data/Rakefile +27 -0
- data/instagram.gemspec +37 -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 +26 -0
- data/lib/instagram/api.rb +23 -0
- data/lib/instagram/client.rb +20 -0
- data/lib/instagram/client/comments.rb +62 -0
- data/lib/instagram/client/geographies.rb +29 -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/subscriptions.rb +157 -0
- data/lib/instagram/client/tags.rb +59 -0
- data/lib/instagram/client/users.rb +309 -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 +19 -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/approve_user.json +8 -0
- data/spec/fixtures/block_user.json +8 -0
- data/spec/fixtures/deny_user.json +8 -0
- data/spec/fixtures/follow_user.json +8 -0
- data/spec/fixtures/followed_by.json +1 -0
- data/spec/fixtures/follows.json +1 -0
- data/spec/fixtures/geography_recent_media.json +1 -0
- data/spec/fixtures/liked_media.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/relationship.json +9 -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/unblock_user.json +8 -0
- data/spec/fixtures/unfollow_user.json +8 -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/geography_spec.rb +37 -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/subscriptions_spec.rb +148 -0
- data/spec/instagram/client/tags_spec.rb +78 -0
- data/spec/instagram/client/users_spec.rb +400 -0
- data/spec/instagram/client_spec.rb +23 -0
- data/spec/instagram_spec.rb +97 -0
- data/spec/spec_helper.rb +59 -0
- metadata +253 -0
@@ -0,0 +1,37 @@
|
|
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
|
+
|
11
|
+
describe ".geography_recent_media" do
|
12
|
+
|
13
|
+
context "with geography ID passed" do
|
14
|
+
|
15
|
+
before do
|
16
|
+
stub_get("geographies/12345/media/recent.#{format}").
|
17
|
+
with(:query => {:access_token => @client.access_token}).
|
18
|
+
to_return(:body => fixture("geography_recent_media.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should get the correct resource" do
|
22
|
+
@client.geography_recent_media(12345)
|
23
|
+
a_get("geographies/12345/media/recent.#{format}").
|
24
|
+
with(:query => {:access_token => @client.access_token}).
|
25
|
+
should have_been_made
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should return a list of recent media items within the specifed geography" do
|
29
|
+
recent_media = @client.geography_recent_media(12345)
|
30
|
+
recent_media.should be_a Array
|
31
|
+
recent_media.first.user.username.should == "amandavan"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,66 @@
|
|
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 ".media_likes" do
|
12
|
+
|
13
|
+
before do
|
14
|
+
stub_get("media/777/likes.#{format}").
|
15
|
+
with(:query => {:access_token => @client.access_token}).
|
16
|
+
to_return(:body => fixture("media_likes.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should get the correct resource" do
|
20
|
+
@client.media_likes(777)
|
21
|
+
a_get("media/777/likes.#{format}").
|
22
|
+
with(:query => {:access_token => @client.access_token}).
|
23
|
+
should have_been_made
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should return an array of user search results" do
|
27
|
+
comments = @client.media_likes(777)
|
28
|
+
comments.should be_a Array
|
29
|
+
comments.first.username.should == "chris"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe ".like_media" do
|
34
|
+
|
35
|
+
before do
|
36
|
+
stub_post("media/777/likes.#{format}").
|
37
|
+
with(:body => {:access_token => @client.access_token}).
|
38
|
+
to_return(:body => fixture("media_liked.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should get the correct resource" do
|
42
|
+
@client.like_media(777)
|
43
|
+
a_post("media/777/likes.#{format}").
|
44
|
+
with(:body => {:access_token => @client.access_token}).
|
45
|
+
should have_been_made
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe ".unlike_media" do
|
50
|
+
|
51
|
+
before do
|
52
|
+
stub_delete("media/777/likes.#{format}").
|
53
|
+
with(:query => {:access_token => @client.access_token}).
|
54
|
+
to_return(:body => fixture("media_unliked.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should get the correct resource" do
|
58
|
+
@client.unlike_media(777)
|
59
|
+
a_delete("media/777/likes.#{format}").
|
60
|
+
with(:query => {:access_token => @client.access_token}).
|
61
|
+
should have_been_made
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
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 ".location" do
|
11
|
+
|
12
|
+
before do
|
13
|
+
stub_get("locations/514276.#{format}").
|
14
|
+
with(:query => {:access_token => @client.access_token}).
|
15
|
+
to_return(:body => fixture("location.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should get the correct resource" do
|
19
|
+
@client.location(514276)
|
20
|
+
a_get("locations/514276.#{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 location" do
|
26
|
+
location = @client.location(514276)
|
27
|
+
location.name.should == "Instagram"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe ".location_recent_media" do
|
32
|
+
|
33
|
+
before do
|
34
|
+
stub_get("locations/514276/media/recent.#{format}").
|
35
|
+
with(:query => {:access_token => @client.access_token}).
|
36
|
+
to_return(:body => fixture("location_recent_media.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should get the correct resource" do
|
40
|
+
@client.location_recent_media(514276)
|
41
|
+
a_get("locations/514276/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.location_recent_media(514276)
|
48
|
+
media.data.should be_a Array
|
49
|
+
media.data.first.user.username.should == "josh"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe ".location_search" do
|
54
|
+
|
55
|
+
before do
|
56
|
+
stub_get("locations/search.#{format}").
|
57
|
+
with(:query => {:access_token => @client.access_token}).
|
58
|
+
with(:query => {:lat => "37.7808851", :lng => "-122.3948632"}).
|
59
|
+
to_return(:body => fixture("location_search.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should get the correct resource" do
|
63
|
+
@client.location_search("37.7808851", "-122.3948632")
|
64
|
+
a_get("locations/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
|
+
locations = @client.location_search("37.7808851", "-122.3948632")
|
72
|
+
locations.should be_a Array
|
73
|
+
locations.first.name.should == "Instagram"
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
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 ".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
|
+
media_search = @client.media_search("37.7808851", "-122.3948632")
|
72
|
+
media_search.data.should be_a Array
|
73
|
+
media_search.data.first.user.username.should == "mikeyk"
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,148 @@
|
|
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
|
+
|
117
|
+
context "with a valid signature" do
|
118
|
+
|
119
|
+
before do
|
120
|
+
@json = fixture("subscription_payload.json").read
|
121
|
+
end
|
122
|
+
|
123
|
+
it "should not raise an Instagram::InvalidSignature error" do
|
124
|
+
lambda do
|
125
|
+
@client.process_subscription(@json, :signature => "f1dbe2b6184ac2131209c87bba8e0382d089a8a2") do |handler|
|
126
|
+
# hi
|
127
|
+
end
|
128
|
+
end.should_not raise_error(Instagram::InvalidSignature)
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
context "with an invalid signature" do
|
133
|
+
|
134
|
+
before do
|
135
|
+
@json = fixture("subscription_payload.json").read
|
136
|
+
end
|
137
|
+
|
138
|
+
it "should raise an Instagram::InvalidSignature error" do
|
139
|
+
lambda do
|
140
|
+
@client.process_subscription(@json, :signature => "31337H4X0R") do |handler|
|
141
|
+
# hi
|
142
|
+
end
|
143
|
+
end.should raise_error(Instagram::InvalidSignature)
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
148
|
+
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.data.should be_a Array
|
49
|
+
media.data.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
|