instagram-innonate 0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. data/.gitignore +12 -0
  2. data/.rspec +3 -0
  3. data/.yardopts +9 -0
  4. data/Gemfile +3 -0
  5. data/LICENSE.md +20 -0
  6. data/README.md +144 -0
  7. data/Rakefile +27 -0
  8. data/instagram.gemspec +26 -0
  9. data/lib/faraday/oauth2.rb +36 -0
  10. data/lib/faraday/raise_http_4xx.rb +37 -0
  11. data/lib/faraday/raise_http_5xx.rb +29 -0
  12. data/lib/instagram.rb +26 -0
  13. data/lib/instagram/api.rb +23 -0
  14. data/lib/instagram/client.rb +20 -0
  15. data/lib/instagram/client/comments.rb +62 -0
  16. data/lib/instagram/client/geographies.rb +29 -0
  17. data/lib/instagram/client/likes.rb +58 -0
  18. data/lib/instagram/client/locations.rb +59 -0
  19. data/lib/instagram/client/media.rb +63 -0
  20. data/lib/instagram/client/subscriptions.rb +157 -0
  21. data/lib/instagram/client/tags.rb +59 -0
  22. data/lib/instagram/client/users.rb +309 -0
  23. data/lib/instagram/client/utils.rb +15 -0
  24. data/lib/instagram/configuration.rb +90 -0
  25. data/lib/instagram/connection.rb +31 -0
  26. data/lib/instagram/error.rb +19 -0
  27. data/lib/instagram/oauth.rb +27 -0
  28. data/lib/instagram/request.rb +45 -0
  29. data/lib/instagram/version.rb +3 -0
  30. data/spec/faraday/response_spec.rb +28 -0
  31. data/spec/fixtures/access_token.json +9 -0
  32. data/spec/fixtures/approve_user.json +8 -0
  33. data/spec/fixtures/block_user.json +8 -0
  34. data/spec/fixtures/deny_user.json +8 -0
  35. data/spec/fixtures/follow_user.json +8 -0
  36. data/spec/fixtures/followed_by.json +1 -0
  37. data/spec/fixtures/follows.json +1 -0
  38. data/spec/fixtures/geography_recent_media.json +1 -0
  39. data/spec/fixtures/liked_media.json +1 -0
  40. data/spec/fixtures/location.json +1 -0
  41. data/spec/fixtures/location_recent_media.json +1 -0
  42. data/spec/fixtures/location_search.json +1 -0
  43. data/spec/fixtures/media.json +1 -0
  44. data/spec/fixtures/media_comment.json +1 -0
  45. data/spec/fixtures/media_comment_deleted.json +1 -0
  46. data/spec/fixtures/media_comments.json +1 -0
  47. data/spec/fixtures/media_liked.json +1 -0
  48. data/spec/fixtures/media_likes.json +1 -0
  49. data/spec/fixtures/media_popular.json +1 -0
  50. data/spec/fixtures/media_search.json +1 -0
  51. data/spec/fixtures/media_unliked.json +1 -0
  52. data/spec/fixtures/mikeyk.json +1 -0
  53. data/spec/fixtures/recent_media.json +1 -0
  54. data/spec/fixtures/relationship.json +9 -0
  55. data/spec/fixtures/requested_by.json +12 -0
  56. data/spec/fixtures/shayne.json +1 -0
  57. data/spec/fixtures/subscription.json +12 -0
  58. data/spec/fixtures/subscription_deleted.json +1 -0
  59. data/spec/fixtures/subscription_payload.json +14 -0
  60. data/spec/fixtures/subscriptions.json +22 -0
  61. data/spec/fixtures/tag.json +1 -0
  62. data/spec/fixtures/tag_recent_media.json +1 -0
  63. data/spec/fixtures/tag_search.json +1 -0
  64. data/spec/fixtures/unblock_user.json +8 -0
  65. data/spec/fixtures/unfollow_user.json +8 -0
  66. data/spec/fixtures/user_media_feed.json +1 -0
  67. data/spec/fixtures/user_search.json +1 -0
  68. data/spec/instagram/api_spec.rb +110 -0
  69. data/spec/instagram/client/comments_spec.rb +71 -0
  70. data/spec/instagram/client/geography_spec.rb +37 -0
  71. data/spec/instagram/client/likes_spec.rb +66 -0
  72. data/spec/instagram/client/locations_spec.rb +78 -0
  73. data/spec/instagram/client/media_spec.rb +78 -0
  74. data/spec/instagram/client/subscriptions_spec.rb +148 -0
  75. data/spec/instagram/client/tags_spec.rb +78 -0
  76. data/spec/instagram/client/users_spec.rb +400 -0
  77. data/spec/instagram/client_spec.rb +23 -0
  78. data/spec/instagram_spec.rb +97 -0
  79. data/spec/spec_helper.rb +59 -0
  80. metadata +303 -0
@@ -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
@@ -0,0 +1,400 @@
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_liked_media" do
174
+
175
+ before do
176
+ stub_get("users/self/media/liked.#{format}").
177
+ with(:query => {:access_token => @client.access_token}).
178
+ to_return(:body => fixture("liked_media.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
179
+ end
180
+
181
+ it "should get the correct resource" do
182
+ @client.user_liked_media
183
+ a_get("users/self/media/liked.#{format}").
184
+ with(:query => {:access_token => @client.access_token}).
185
+ should have_been_made
186
+ end
187
+ end
188
+
189
+ describe ".user_recent_media" do
190
+
191
+ context "with user ID passed" do
192
+
193
+ before do
194
+ stub_get("users/4/media/recent.#{format}").
195
+ with(:query => {:access_token => @client.access_token}).
196
+ to_return(:body => fixture("recent_media.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
197
+ end
198
+
199
+ it "should get the correct resource" do
200
+ @client.user_recent_media(4)
201
+ a_get("users/4/media/recent.#{format}").
202
+ with(:query => {:access_token => @client.access_token}).
203
+ should have_been_made
204
+ end
205
+
206
+ it "should return a list of recent media items for the given user" do
207
+ recent_media = @client.user_recent_media(4)
208
+ recent_media.should be_a Array
209
+ recent_media.first.user.username.should == "shayne"
210
+ end
211
+ end
212
+
213
+ context "without user ID passed" do
214
+
215
+ before do
216
+ stub_get("users/self/media/recent.#{format}").
217
+ with(:query => {:access_token => @client.access_token}).
218
+ to_return(:body => fixture("recent_media.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
219
+ end
220
+
221
+ it "should get the correct resource" do
222
+ @client.user_recent_media
223
+ a_get("users/self/media/recent.#{format}").
224
+ with(:query => {:access_token => @client.access_token}).
225
+ should have_been_made
226
+ end
227
+ end
228
+ end
229
+
230
+ describe ".user_requested_by" do
231
+
232
+ before do
233
+ stub_get("users/self/requested-by.#{format}").
234
+ with(:query => {:access_token => @client.access_token}).
235
+ to_return(:body => fixture("requested_by.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
236
+ end
237
+
238
+ it "should get the correct resource" do
239
+ @client.user_requested_by
240
+ a_get("users/self/requested-by.#{format}").
241
+ with(:query => {:access_token => @client.access_token}).
242
+ should have_been_made
243
+ end
244
+
245
+ it "should return a list of users awaiting approval" do
246
+ users = @client.user_requested_by
247
+ users.should be_a Array
248
+ users.first.username.should == "shayne"
249
+ end
250
+ end
251
+
252
+ describe ".user_relationship" do
253
+
254
+ before do
255
+ stub_get("users/4/relationship.#{format}").
256
+ with(:query => {:access_token => @client.access_token}).
257
+ to_return(:body => fixture("relationship.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
258
+ end
259
+
260
+ it "should get the correct resource" do
261
+ @client.user_relationship(4)
262
+ a_get("users/4/relationship.#{format}").
263
+ with(:query => {:access_token => @client.access_token}).
264
+ should have_been_made
265
+ end
266
+
267
+ it "should return a relationship status response" do
268
+ status = @client.user_relationship(4)
269
+ status.incoming_status.should == "requested_by"
270
+ end
271
+ end
272
+
273
+ describe ".follow_user" do
274
+
275
+ before do
276
+ stub_post("users/4/relationship.#{format}").
277
+ with(:body => {:action => "follow", :access_token => @client.access_token}).
278
+ to_return(:body => fixture("follow_user.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
279
+ end
280
+
281
+ it "should get the correct resource" do
282
+ @client.follow_user(4)
283
+ a_post("users/4/relationship.#{format}").
284
+ with(:body => {:action => "follow", :access_token => @client.access_token}).
285
+ should have_been_made
286
+ end
287
+
288
+ it "should return a relationship status response" do
289
+ status = @client.follow_user(4)
290
+ status.outgoing_status.should == "requested"
291
+ end
292
+ end
293
+
294
+ describe ".unfollow_user" do
295
+
296
+ before do
297
+ stub_post("users/4/relationship.#{format}").
298
+ with(:body => {:action => "unfollow", :access_token => @client.access_token}).
299
+ to_return(:body => fixture("unfollow_user.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
300
+ end
301
+
302
+ it "should get the correct resource" do
303
+ @client.unfollow_user(4)
304
+ a_post("users/4/relationship.#{format}").
305
+ with(:body => {:action => "unfollow", :access_token => @client.access_token}).
306
+ should have_been_made
307
+ end
308
+
309
+ it "should return a relationship status response" do
310
+ status = @client.unfollow_user(4)
311
+ status.outgoing_status.should == "none"
312
+ end
313
+ end
314
+
315
+ describe ".block_user" do
316
+
317
+ before do
318
+ stub_post("users/4/relationship.#{format}").
319
+ with(:body => {:action => "block", :access_token => @client.access_token}).
320
+ to_return(:body => fixture("block_user.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
321
+ end
322
+
323
+ it "should get the correct resource" do
324
+ @client.block_user(4)
325
+ a_post("users/4/relationship.#{format}").
326
+ with(:body => {:action => "block", :access_token => @client.access_token}).
327
+ should have_been_made
328
+ end
329
+
330
+ it "should return a relationship status response" do
331
+ status = @client.block_user(4)
332
+ status.outgoing_status.should == "none"
333
+ end
334
+ end
335
+
336
+ describe ".unblock_user" do
337
+
338
+ before do
339
+ stub_post("users/4/relationship.#{format}").
340
+ with(:body => {:action => "unblock", :access_token => @client.access_token}).
341
+ to_return(:body => fixture("unblock_user.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
342
+ end
343
+
344
+ it "should get the correct resource" do
345
+ @client.unblock_user(4)
346
+ a_post("users/4/relationship.#{format}").
347
+ with(:body => {:action => "unblock", :access_token => @client.access_token}).
348
+ should have_been_made
349
+ end
350
+
351
+ it "should return a relationship status response" do
352
+ status = @client.unblock_user(4)
353
+ status.outgoing_status.should == "none"
354
+ end
355
+ end
356
+
357
+ describe ".approve_user" do
358
+
359
+ before do
360
+ stub_post("users/4/relationship.#{format}").
361
+ with(:body => {:action => "approve", :access_token => @client.access_token}).
362
+ to_return(:body => fixture("approve_user.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
363
+ end
364
+
365
+ it "should get the correct resource" do
366
+ @client.approve_user(4)
367
+ a_post("users/4/relationship.#{format}").
368
+ with(:body => {:action => "approve", :access_token => @client.access_token}).
369
+ should have_been_made
370
+ end
371
+
372
+ it "should return a relationship status response" do
373
+ status = @client.approve_user(4)
374
+ status.outgoing_status.should == "follows"
375
+ end
376
+ end
377
+
378
+ describe ".deny_user" do
379
+
380
+ before do
381
+ stub_post("users/4/relationship.#{format}").
382
+ with(:body => {:action => "deny", :access_token => @client.access_token}).
383
+ to_return(:body => fixture("deny_user.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
384
+ end
385
+
386
+ it "should get the correct resource" do
387
+ @client.deny_user(4)
388
+ a_post("users/4/relationship.#{format}").
389
+ with(:body => {:action => "deny", :access_token => @client.access_token}).
390
+ should have_been_made
391
+ end
392
+
393
+ it "should return a relationship status response" do
394
+ status = @client.deny_user(4)
395
+ status.outgoing_status.should == "none"
396
+ end
397
+ end
398
+ end
399
+ end
400
+ end