/
statuses_spec.rb
543 lines (515 loc) · 26.3 KB
/
statuses_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
require 'helper'
describe Twitter::API do
before do
@client = Twitter::Client.new
end
describe "#favorites" do
context "with a screen name passed" do
before do
stub_get("/1.1/favorites/list.json").with(:query => {:screen_name => "sferik"}).to_return(:body => fixture("favorites.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "requests the correct resource" do
@client.favorites("sferik")
expect(a_get("/1.1/favorites/list.json").with(:query => {:screen_name => "sferik"})).to have_been_made
end
it "returns the 20 most recent favorite Tweets for the authenticating user or user specified by the ID parameter" do
favorites = @client.favorites("sferik")
expect(favorites).to be_an Array
expect(favorites.first).to be_a Twitter::Tweet
expect(favorites.first.user.id).to eq 2404341
end
end
context "without arguments passed" do
before do
stub_get("/1.1/favorites/list.json").to_return(:body => fixture("favorites.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "requests the correct resource" do
@client.favorites
expect(a_get("/1.1/favorites/list.json")).to have_been_made
end
it "returns the 20 most recent favorite Tweets for the authenticating user or user specified by the ID parameter" do
favorites = @client.favorites
expect(favorites).to be_an Array
expect(favorites.first).to be_a Twitter::Tweet
expect(favorites.first.user.id).to eq 2404341
end
end
end
describe "#favorite" do
before do
stub_post("/1.1/favorites/create.json").with(:body => {:id => "25938088801"}).to_return(:body => fixture("status.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "requests the correct resource" do
@client.favorite(25938088801)
expect(a_post("/1.1/favorites/create.json").with(:body => {:id => "25938088801"})).to have_been_made
end
it "returns an array of favorited Tweets" do
tweets = @client.favorite(25938088801)
expect(tweets).to be_an Array
expect(tweets.first).to be_a Twitter::Tweet
expect(tweets.first.text).to eq "The problem with your code is that it's doing exactly what you told it to do."
end
context "already favorited" do
before do
stub_post("/1.1/favorites/create.json").with(:body => {:id => "25938088801"}).to_return(:status => 403, :body => fixture("already_favorited.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "does not raises an error" do
expect{@client.favorite(25938088801)}.not_to raise_error
end
end
end
describe "#favorite!" do
before do
stub_post("/1.1/favorites/create.json").with(:body => {:id => "25938088801"}).to_return(:body => fixture("status.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "requests the correct resource" do
@client.favorite!(25938088801)
expect(a_post("/1.1/favorites/create.json").with(:body => {:id => "25938088801"})).to have_been_made
end
it "returns an array of favorited Tweets" do
tweets = @client.favorite!(25938088801)
expect(tweets).to be_an Array
expect(tweets.first).to be_a Twitter::Tweet
expect(tweets.first.text).to eq "The problem with your code is that it's doing exactly what you told it to do."
end
context "forbidden" do
before do
stub_post("/1.1/favorites/create.json").with(:body => {:id => "25938088801"}).to_return(:status => 403, :headers => {:content_type => "application/json; charset=utf-8"})
end
it "raises a Forbidden error" do
expect{@client.favorite!(25938088801)}.to raise_error(Twitter::Error::Forbidden)
end
end
context "already favorited" do
before do
stub_post("/1.1/favorites/create.json").with(:body => {:id => "25938088801"}).to_return(:status => 403, :body => fixture("already_favorited.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "raises an AlreadyFavorited error" do
expect{@client.favorite!(25938088801)}.to raise_error(Twitter::Error::AlreadyFavorited, "Tweet with the ID 25938088801 has already been favorited by the authenticated user.")
end
end
end
describe "#unfavorite" do
before do
stub_post("/1.1/favorites/destroy.json").with(:body => {:id => "25938088801"}).to_return(:body => fixture("status.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "requests the correct resource" do
@client.unfavorite(25938088801)
expect(a_post("/1.1/favorites/destroy.json").with(:body => {:id => "25938088801"})).to have_been_made
end
it "returns an array of un-favorited Tweets" do
tweets = @client.unfavorite(25938088801)
expect(tweets).to be_an Array
expect(tweets.first).to be_a Twitter::Tweet
expect(tweets.first.text).to eq "The problem with your code is that it's doing exactly what you told it to do."
end
end
describe "#home_timeline" do
before do
stub_get("/1.1/statuses/home_timeline.json").to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "requests the correct resource" do
@client.home_timeline
expect(a_get("/1.1/statuses/home_timeline.json")).to have_been_made
end
it "returns the 20 most recent Tweets, including retweets if they exist, posted by the authenticating user and the user's they follow" do
tweets = @client.home_timeline
expect(tweets).to be_an Array
expect(tweets.first).to be_a Twitter::Tweet
expect(tweets.first.text).to eq "Happy Birthday @imdane. Watch out for those @rally pranksters!"
end
end
describe "#mentions_timeline" do
before do
stub_get("/1.1/statuses/mentions_timeline.json").to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "requests the correct resource" do
@client.mentions_timeline
expect(a_get("/1.1/statuses/mentions_timeline.json")).to have_been_made
end
it "returns the 20 most recent mentions (status containing @username) for the authenticating user" do
tweets = @client.mentions_timeline
expect(tweets).to be_an Array
expect(tweets.first).to be_a Twitter::Tweet
expect(tweets.first.text).to eq "Happy Birthday @imdane. Watch out for those @rally pranksters!"
end
end
describe "#retweeted_by_user" do
before do
stub_get("/1.1/statuses/user_timeline.json").with(:query => {:include_rts => "true", :screen_name => "sferik", :count => "200"}).to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
stub_get("/1.1/statuses/user_timeline.json").with(:query => {:include_rts => "true", :screen_name => "sferik", :count => "200", :max_id => "244102729860009983"}).to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "requests the correct resource" do
@client.retweeted_by_user("sferik")
expect(a_get("/1.1/statuses/user_timeline.json").with(:query => {:include_rts => "true", :screen_name => "sferik", :count => "200"})).to have_been_made
expect(a_get("/1.1/statuses/user_timeline.json").with(:query => {:include_rts => "true", :screen_name => "sferik", :count => "200", :max_id => "244102729860009983"})).to have_been_made.times(3)
end
it "returns the 20 most recent retweets posted by the authenticating user" do
tweets = @client.retweeted_by_user("sferik")
expect(tweets).to be_an Array
expect(tweets.first).to be_a Twitter::Tweet
expect(tweets.first.text).to eq "RT @olivercameron: Mosaic looks cool: http://t.co/A8013C9k"
end
end
describe "#retweeted_by_me" do
before do
stub_get("/1.1/statuses/user_timeline.json").with(:query => {:include_rts => "true", :count => "200"}).to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
stub_get("/1.1/statuses/user_timeline.json").with(:query => {:include_rts => "true", :count => "200", :max_id => "244102729860009983"}).to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "requests the correct resource" do
@client.retweeted_by_me
expect(a_get("/1.1/statuses/user_timeline.json").with(:query => {:include_rts => "true", :count => "200"})).to have_been_made
expect(a_get("/1.1/statuses/user_timeline.json").with(:query => {:include_rts => "true", :count => "200", :max_id => "244102729860009983"})).to have_been_made.times(3)
end
it "returns the 20 most recent retweets posted by the authenticating user" do
tweets = @client.retweeted_by_me
expect(tweets).to be_an Array
expect(tweets.first).to be_a Twitter::Tweet
expect(tweets.first.text).to eq "RT @olivercameron: Mosaic looks cool: http://t.co/A8013C9k"
end
end
describe "#retweeted_to_me" do
before do
stub_get("/1.1/statuses/home_timeline.json").with(:query => {:include_rts => "true", :count => "200"}).to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
stub_get("/1.1/statuses/home_timeline.json").with(:query => {:include_rts => "true", :count => "200", :max_id => "244102729860009983"}).to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "requests the correct resource" do
@client.retweeted_to_me
expect(stub_get("/1.1/statuses/home_timeline.json").with(:query => {:include_rts => "true", :count => "200"})).to have_been_made
expect(stub_get("/1.1/statuses/home_timeline.json").with(:query => {:include_rts => "true", :count => "200", :max_id => "244102729860009983"})).to have_been_made.times(3)
end
it "returns the 20 most recent retweets posted by users the authenticating user follow" do
tweets = @client.retweeted_to_me
expect(tweets).to be_an Array
expect(tweets.first).to be_a Twitter::Tweet
expect(tweets.first.text).to eq "RT @olivercameron: Mosaic looks cool: http://t.co/A8013C9k"
end
end
describe "#retweets_of_me" do
before do
stub_get("/1.1/statuses/user_timeline.json").with(:query => {:include_rts => "false", :count => "200"}).to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
stub_get("/1.1/statuses/user_timeline.json").with(:query => {:include_rts => "false", :count => "200", :max_id => "244102490646278145"}).to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "requests the correct resource" do
@client.retweets_of_me
expect(a_get("/1.1/statuses/user_timeline.json").with(:query => {:include_rts => "false", :count => "200"})).to have_been_made
expect(a_get("/1.1/statuses/user_timeline.json").with(:query => {:include_rts => "false", :count => "200", :max_id => "244102490646278145"})).to have_been_made
end
it "returns the 20 most recent tweets of the authenticated user that have been retweeted by others" do
tweets = @client.retweets_of_me
expect(tweets).to be_an Array
expect(tweets.first).to be_a Twitter::Tweet
expect(tweets.first.text).to eq "RT @olivercameron: Mosaic looks cool: http://t.co/A8013C9k"
end
end
describe "#user_timeline" do
context "with a screen name passed" do
before do
stub_get("/1.1/statuses/user_timeline.json").with(:query => {:screen_name => "sferik"}).to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "requests the correct resource" do
@client.user_timeline("sferik")
expect(a_get("/1.1/statuses/user_timeline.json").with(:query => {:screen_name => "sferik"})).to have_been_made
end
it "returns the 20 most recent Tweets posted by the user specified by screen name or user id" do
tweets = @client.user_timeline("sferik")
expect(tweets).to be_an Array
expect(tweets.first).to be_a Twitter::Tweet
expect(tweets.first.text).to eq "Happy Birthday @imdane. Watch out for those @rally pranksters!"
end
end
context "without a screen name passed" do
before do
stub_get("/1.1/statuses/user_timeline.json").to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "requests the correct resource" do
@client.user_timeline
expect(a_get("/1.1/statuses/user_timeline.json")).to have_been_made
end
end
end
describe "#media_timeline" do
context "with a screen name passed" do
before do
stub_get("/1.1/statuses/media_timeline.json").with(:query => {:screen_name => "sferik"}).to_return(:body => fixture("media_timeline.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "requests the correct resource" do
@client.media_timeline("sferik")
expect(a_get("/1.1/statuses/media_timeline.json").with(:query => {:screen_name => "sferik"})).to have_been_made
end
it "returns the 20 most recent images posted by the user specified by screen name or user id" do
tweets = @client.media_timeline("sferik")
expect(tweets).to be_an Array
expect(tweets.first).to be_a Twitter::Tweet
expect(tweets.first.text).to eq "Google is throwing up a question mark for Sunday's weather in Boston. At least they're being honest. http://t.co/Jh7bAhS"
end
end
context "without a screen name passed" do
before do
stub_get("/1.1/statuses/media_timeline.json").to_return(:body => fixture("media_timeline.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "requests the correct resource" do
@client.media_timeline
expect(a_get("/1.1/statuses/media_timeline.json")).to have_been_made
end
end
end
describe "#retweeters_of" do
context "with ids_only passed" do
before do
stub_get("/1.1/statuses/retweets/28561922516.json").to_return(:body => fixture("retweets.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "requests the correct resource" do
@client.retweeters_of(28561922516, :ids_only => true)
expect(a_get("/1.1/statuses/retweets/28561922516.json")).to have_been_made
end
it "returns an array of numeric user IDs of retweeters of a Tweet" do
ids = @client.retweeters_of(28561922516, :ids_only => true)
expect(ids).to be_an Array
expect(ids.first).to eq 7505382
end
end
context "without ids_only passed" do
before do
stub_get("/1.1/statuses/retweets/28561922516.json").to_return(:body => fixture("retweets.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "requests the correct resource" do
@client.retweeters_of(28561922516)
expect(a_get("/1.1/statuses/retweets/28561922516.json")).to have_been_made
end
it "returns an array of user of retweeters of a Tweet" do
users = @client.retweeters_of(28561922516)
expect(users).to be_an Array
expect(users.first).to be_a Twitter::User
expect(users.first.id).to eq 7505382
end
end
end
describe "#retweets" do
before do
stub_get("/1.1/statuses/retweets/28561922516.json").to_return(:body => fixture("retweets.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "requests the correct resource" do
@client.retweets(28561922516)
expect(a_get("/1.1/statuses/retweets/28561922516.json")).to have_been_made
end
it "returns up to 100 of the first retweets of a given tweet" do
tweets = @client.retweets(28561922516)
expect(tweets).to be_an Array
expect(tweets.first).to be_a Twitter::Tweet
expect(tweets.first.text).to eq "RT @gruber: As for the Series, I'm for the Giants. Fuck Texas, fuck Nolan Ryan, fuck George Bush."
end
end
describe "#status" do
before do
stub_get("/1.1/statuses/show/25938088801.json").to_return(:body => fixture("status.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "requests the correct resource" do
@client.status(25938088801)
expect(a_get("/1.1/statuses/show/25938088801.json")).to have_been_made
end
it "returns a Tweet" do
tweet = @client.status(25938088801)
expect(tweet).to be_a Twitter::Tweet
expect(tweet.text).to eq "The problem with your code is that it's doing exactly what you told it to do."
end
end
describe "#statuses" do
before do
stub_get("/1.1/statuses/show/25938088801.json").to_return(:body => fixture("status.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "requests the correct resource" do
@client.statuses(25938088801)
expect(a_get("/1.1/statuses/show/25938088801.json")).to have_been_made
end
it "returns an array of Tweets" do
tweets = @client.statuses(25938088801)
expect(tweets).to be_an Array
expect(tweets.first).to be_a Twitter::Tweet
expect(tweets.first.text).to eq "The problem with your code is that it's doing exactly what you told it to do."
end
end
describe "#status_activity" do
before do
stub_get("/i/statuses/25938088801/activity/summary.json").to_return(:body => fixture("activity_summary.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "requests the correct resource" do
@client.status_activity(25938088801)
expect(a_get("/i/statuses/25938088801/activity/summary.json")).to have_been_made
end
it "returns a Tweet" do
tweet = @client.status_activity(25938088801)
expect(tweet).to be_a Twitter::Tweet
expect(tweet.retweeters_count).to eq 1
end
end
describe "#statuses_activity" do
before do
stub_get("/i/statuses/25938088801/activity/summary.json").to_return(:body => fixture("activity_summary.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "requests the correct resource" do
@client.statuses_activity(25938088801)
expect(a_get("/i/statuses/25938088801/activity/summary.json")).to have_been_made
end
it "returns an array of Tweets" do
tweets = @client.statuses_activity(25938088801)
expect(tweets).to be_an Array
expect(tweets.first).to be_a Twitter::Tweet
expect(tweets.first.retweeters_count).to eq 1
end
end
describe "#status_destroy" do
before do
stub_post("/1.1/statuses/destroy/25938088801.json").to_return(:body => fixture("status.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "requests the correct resource" do
@client.status_destroy(25938088801)
expect(a_post("/1.1/statuses/destroy/25938088801.json")).to have_been_made
end
it "returns an array of Tweets" do
tweets = @client.status_destroy(25938088801)
expect(tweets).to be_an Array
expect(tweets.first).to be_a Twitter::Tweet
expect(tweets.first.text).to eq "The problem with your code is that it's doing exactly what you told it to do."
end
end
describe "#retweet" do
before do
stub_post("/1.1/statuses/retweet/28561922516.json").to_return(:body => fixture("retweet.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "requests the correct resource" do
@client.retweet(28561922516)
expect(a_post("/1.1/statuses/retweet/28561922516.json")).to have_been_made
end
it "returns an array of Tweets with retweet details embedded" do
tweets = @client.retweet(28561922516)
expect(tweets).to be_an Array
expect(tweets.first).to be_a Twitter::Tweet
expect(tweets.first.text).to eq "As for the Series, I'm for the Giants. Fuck Texas, fuck Nolan Ryan, fuck George Bush."
expect(tweets.first.retweeted_tweet.text).to eq "RT @gruber: As for the Series, I'm for the Giants. Fuck Texas, fuck Nolan Ryan, fuck George Bush."
expect(tweets.first.retweeted_tweet.id).not_to eq tweets.first.id
end
context "already retweeted" do
before do
stub_post("/1.1/statuses/retweet/28561922516.json").to_return(:status => 403, :body => fixture("already_retweeted.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "does not raise an error" do
expect{@client.retweet(28561922516)}.not_to raise_error
end
end
end
describe "#retweet!" do
before do
stub_post("/1.1/statuses/retweet/28561922516.json").to_return(:body => fixture("retweet.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "requests the correct resource" do
@client.retweet!(28561922516)
expect(a_post("/1.1/statuses/retweet/28561922516.json")).to have_been_made
end
it "returns an array of Tweets with retweet details embedded" do
tweets = @client.retweet!(28561922516)
expect(tweets).to be_an Array
expect(tweets.first).to be_a Twitter::Tweet
expect(tweets.first.text).to eq "As for the Series, I'm for the Giants. Fuck Texas, fuck Nolan Ryan, fuck George Bush."
expect(tweets.first.retweeted_tweet.text).to eq "RT @gruber: As for the Series, I'm for the Giants. Fuck Texas, fuck Nolan Ryan, fuck George Bush."
expect(tweets.first.retweeted_tweet.id).not_to eq tweets.first.id
end
context "fobidden" do
before do
stub_post("/1.1/statuses/retweet/28561922516.json").to_return(:status => 403, :headers => {:content_type => "application/json; charset=utf-8"})
end
it "raises a Forbidden error" do
expect{@client.retweet!(28561922516)}.to raise_error(Twitter::Error::Forbidden)
end
end
context "already retweeted" do
before do
stub_post("/1.1/statuses/retweet/28561922516.json").to_return(:status => 403, :body => fixture("already_retweeted.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "raises an AlreadyRetweeted error" do
expect{@client.retweet!(28561922516)}.to raise_error(Twitter::Error::AlreadyRetweeted, "Tweet with the ID 28561922516 has already been retweeted by the authenticated user.")
end
end
end
describe "#tweet" do
before do
stub_post("/1.1/statuses/update.json").with(:body => {:status => "The problem with your code is that it's doing exactly what you told it to do."}).to_return(:body => fixture("status.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "requests the correct resource" do
@client.update("The problem with your code is that it's doing exactly what you told it to do.")
expect(a_post("/1.1/statuses/update.json").with(:body => {:status => "The problem with your code is that it's doing exactly what you told it to do."})).to have_been_made
end
it "returns a Tweet" do
tweet = @client.update("The problem with your code is that it's doing exactly what you told it to do.")
expect(tweet).to be_a Twitter::Tweet
expect(tweet.text).to eq "The problem with your code is that it's doing exactly what you told it to do."
end
end
describe "#update_with_media" do
before do
stub_post("/1.1/statuses/update_with_media.json").to_return(:body => fixture("status_with_media.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
context "a gif image" do
it "requests the correct resource" do
@client.update_with_media("You always have options", fixture("pbjt.gif"))
expect(a_post("/1.1/statuses/update_with_media.json")).to have_been_made
end
it "returns a Tweet" do
tweet = @client.update_with_media("You always have options", fixture("pbjt.gif"))
expect(tweet).to be_a Twitter::Tweet
expect(tweet.text).to eq "You always have options http://t.co/CBYa7Ri"
end
end
context "a jpe image" do
it "requests the correct resource" do
@client.update_with_media("You always have options", fixture("wildcomet2.jpe"))
expect(a_post("/1.1/statuses/update_with_media.json")).to have_been_made
end
end
context "a jpeg image" do
it "requests the correct resource" do
@client.update_with_media("You always have options", fixture("me.jpeg"))
expect(a_post("/1.1/statuses/update_with_media.json")).to have_been_made
end
end
context "a png image" do
it "requests the correct resource" do
@client.update_with_media("You always have options", fixture("we_concept_bg2.png"))
expect(a_post("/1.1/statuses/update_with_media.json")).to have_been_made
end
end
context "a Tempfile" do
it "requests the correct resource" do
@client.update_with_media("You always have options", Tempfile.new("tmp"))
expect(a_post("/1.1/statuses/update_with_media.json")).to have_been_made
end
end
end
describe "#oembed" do
before do
stub_get("/1.1/statuses/oembed.json").with(:query => {:id => "25938088801"}).to_return(:body => fixture("oembed.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "requests the correct resource" do
@client.oembed(25938088801)
expect(a_get("/1.1/statuses/oembed.json").with(:query => {:id => "25938088801"})).to have_been_made
end
it "returns an array of OEmbed instances" do
oembed = @client.oembed(25938088801)
expect(oembed).to be_a Twitter::OEmbed
end
end
describe "#oembeds" do
before do
stub_get("/1.1/statuses/oembed.json").with(:query => {:id => "25938088801"}).to_return(:body => fixture("oembed.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "requests the correct resource" do
@client.oembeds(25938088801)
expect(a_get("/1.1/statuses/oembed.json").with(:query => {:id => "25938088801"})).to have_been_made
end
it "returns an array of OEmbed instances" do
oembeds = @client.oembeds(25938088801)
expect(oembeds).to be_an Array
expect(oembeds.first).to be_a Twitter::OEmbed
end
end
end