twitter 5.0.0.rc.1 → 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/CHANGELOG.md +7 -1
- data/CONTRIBUTING.md +13 -15
- data/README.md +53 -33
- data/Rakefile +6 -0
- data/lib/twitter/arguments.rb +3 -0
- data/lib/twitter/base.rb +88 -89
- data/lib/twitter/client.rb +5 -41
- data/lib/twitter/configuration.rb +4 -5
- data/lib/twitter/core_ext/kernel.rb +5 -1
- data/lib/twitter/creatable.rb +6 -1
- data/lib/twitter/cursor.rb +16 -12
- data/lib/twitter/entity/uri.rb +2 -1
- data/lib/twitter/enumerable.rb +1 -1
- data/lib/twitter/error.rb +42 -39
- data/lib/twitter/factory.rb +12 -5
- data/lib/twitter/geo.rb +2 -7
- data/lib/twitter/geo_factory.rb +11 -7
- data/lib/twitter/geo_results.rb +12 -8
- data/lib/twitter/identity.rb +4 -12
- data/lib/twitter/list.rb +6 -3
- data/lib/twitter/media/photo.rb +5 -3
- data/lib/twitter/media_factory.rb +11 -7
- data/lib/twitter/null_object.rb +4 -3
- data/lib/twitter/place.rb +10 -16
- data/lib/twitter/profile_banner.rb +4 -5
- data/lib/twitter/rate_limit.rb +3 -0
- data/lib/twitter/relationship.rb +0 -9
- data/lib/twitter/rest/api/direct_messages.rb +9 -6
- data/lib/twitter/rest/api/favorites.rb +6 -11
- data/lib/twitter/rest/api/friends_and_followers.rb +6 -9
- data/lib/twitter/rest/api/lists.rb +27 -20
- data/lib/twitter/rest/api/oauth.rb +17 -0
- data/lib/twitter/rest/api/places_and_geo.rb +0 -18
- data/lib/twitter/rest/api/saved_searches.rb +6 -4
- data/lib/twitter/rest/api/suggested_users.rb +2 -2
- data/lib/twitter/rest/api/tweets.rb +7 -9
- data/lib/twitter/rest/api/users.rb +6 -6
- data/lib/twitter/rest/api/utils.rb +44 -17
- data/lib/twitter/rest/client.rb +25 -43
- data/lib/twitter/rest/response/parse_error_json.rb +15 -0
- data/lib/twitter/rest/response/parse_json.rb +5 -1
- data/lib/twitter/search_results.rb +12 -8
- data/lib/twitter/size.rb +2 -15
- data/lib/twitter/streaming/client.rb +23 -11
- data/lib/twitter/streaming/event.rb +35 -0
- data/lib/twitter/streaming/friend_list.rb +13 -0
- data/lib/twitter/streaming/message_parser.rb +18 -0
- data/lib/twitter/streaming/response.rb +4 -0
- data/lib/twitter/suggestion.rb +5 -10
- data/lib/twitter/token.rb +3 -1
- data/lib/twitter/trend.rb +2 -7
- data/lib/twitter/trend_results.rb +20 -14
- data/lib/twitter/tweet.rb +18 -23
- data/lib/twitter/user.rb +34 -19
- data/lib/twitter/version.rb +1 -1
- data/spec/fixtures/request_token.txt +6 -0
- data/spec/fixtures/track_streaming_user.json +5 -0
- data/spec/twitter/base_spec.rb +0 -16
- data/spec/twitter/basic_user_spec.rb +3 -3
- data/spec/twitter/cursor_spec.rb +4 -4
- data/spec/twitter/direct_message_spec.rb +9 -9
- data/spec/twitter/entity/uri_spec.rb +12 -11
- data/spec/twitter/geo/point_spec.rb +5 -5
- data/spec/twitter/geo/polygon_spec.rb +5 -5
- data/spec/twitter/geo_factory_spec.rb +2 -2
- data/spec/twitter/geo_spec.rb +6 -6
- data/spec/twitter/identifiable_spec.rb +5 -5
- data/spec/twitter/list_spec.rb +7 -7
- data/spec/twitter/media/photo_spec.rb +19 -18
- data/spec/twitter/media_factory_spec.rb +2 -2
- data/spec/twitter/null_object_spec.rb +7 -6
- data/spec/twitter/oembed_spec.rb +6 -6
- data/spec/twitter/place_spec.rb +37 -37
- data/spec/twitter/rate_limit_spec.rb +0 -17
- data/spec/twitter/relationship_spec.rb +4 -12
- data/spec/twitter/rest/api/direct_messages_spec.rb +8 -8
- data/spec/twitter/rest/api/friends_and_followers_spec.rb +50 -120
- data/spec/twitter/rest/api/geo_spec.rb +0 -14
- data/spec/twitter/rest/api/lists_spec.rb +39 -39
- data/spec/twitter/rest/api/oauth_spec.rb +15 -4
- data/spec/twitter/rest/api/saved_searches_spec.rb +6 -6
- data/spec/twitter/rest/api/tweets_spec.rb +6 -6
- data/spec/twitter/rest/api/users_spec.rb +4 -4
- data/spec/twitter/rest/client_spec.rb +9 -9
- data/spec/twitter/saved_search_spec.rb +5 -5
- data/spec/twitter/search_results_spec.rb +3 -3
- data/spec/twitter/settings_spec.rb +2 -2
- data/spec/twitter/size_spec.rb +5 -15
- data/spec/twitter/source_user_spec.rb +3 -3
- data/spec/twitter/streaming/client_spec.rb +33 -16
- data/spec/twitter/streaming/event_spec.rb +45 -0
- data/spec/twitter/suggestion_spec.rb +5 -15
- data/spec/twitter/target_user_spec.rb +3 -3
- data/spec/twitter/token_spec.rb +2 -2
- data/spec/twitter/trend_results_spec.rb +6 -6
- data/spec/twitter/trend_spec.rb +7 -17
- data/spec/twitter/tweet_spec.rb +31 -25
- data/spec/twitter/user_spec.rb +16 -16
- data/twitter.gemspec +5 -2
- metadata +67 -15
- metadata.gz.sig +0 -0
@@ -86,45 +86,45 @@ describe Twitter::REST::API::DirectMessages do
|
|
86
86
|
end
|
87
87
|
end
|
88
88
|
|
89
|
-
describe "#
|
89
|
+
describe "#destroy_direct_message" do
|
90
90
|
before do
|
91
91
|
stub_post("/1.1/direct_messages/destroy.json").with(:body => {:id => "1825785544"}).to_return(:body => fixture("direct_message.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
92
92
|
end
|
93
93
|
it "requests the correct resource" do
|
94
|
-
@client.
|
94
|
+
@client.destroy_direct_message(1825785544)
|
95
95
|
expect(a_post("/1.1/direct_messages/destroy.json").with(:body => {:id => "1825785544"})).to have_been_made
|
96
96
|
end
|
97
97
|
it "returns an array of deleted messages" do
|
98
|
-
direct_messages = @client.
|
98
|
+
direct_messages = @client.destroy_direct_message(1825785544)
|
99
99
|
expect(direct_messages).to be_an Array
|
100
100
|
expect(direct_messages.first).to be_a Twitter::DirectMessage
|
101
101
|
expect(direct_messages.first.sender.id).to eq(7505382)
|
102
102
|
end
|
103
103
|
end
|
104
104
|
|
105
|
-
describe "#
|
105
|
+
describe "#create_direct_message" do
|
106
106
|
before do
|
107
107
|
stub_post("/1.1/direct_messages/new.json").with(:body => {:screen_name => "pengwynn", :text => "Creating a fixture for the Twitter gem"}).to_return(:body => fixture("direct_message.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
108
108
|
end
|
109
109
|
it "requests the correct resource" do
|
110
|
-
@client.
|
110
|
+
@client.create_direct_message("pengwynn", "Creating a fixture for the Twitter gem")
|
111
111
|
expect(a_post("/1.1/direct_messages/new.json").with(:body => {:screen_name => "pengwynn", :text => "Creating a fixture for the Twitter gem"})).to have_been_made
|
112
112
|
end
|
113
113
|
it "returns the sent message" do
|
114
|
-
direct_message = @client.
|
114
|
+
direct_message = @client.create_direct_message("pengwynn", "Creating a fixture for the Twitter gem")
|
115
115
|
expect(direct_message).to be_a Twitter::DirectMessage
|
116
116
|
expect(direct_message.text).to eq("Creating a fixture for the Twitter gem")
|
117
117
|
end
|
118
118
|
context "with a URI object passed" do
|
119
119
|
it "requests the correct resource" do
|
120
120
|
user = URI.parse("https://twitter.com/pengwynn")
|
121
|
-
@client.
|
121
|
+
@client.create_direct_message(user, "Creating a fixture for the Twitter gem")
|
122
122
|
expect(a_post("/1.1/direct_messages/new.json").with(:body => {:screen_name => "pengwynn", :text => "Creating a fixture for the Twitter gem"})).to have_been_made
|
123
123
|
end
|
124
124
|
end
|
125
125
|
context "with a URI string passed" do
|
126
126
|
it "requests the correct resource" do
|
127
|
-
@client.
|
127
|
+
@client.create_direct_message("https://twitter.com/pengwynn", "Creating a fixture for the Twitter gem")
|
128
128
|
expect(a_post("/1.1/direct_messages/new.json").with(:body => {:screen_name => "pengwynn", :text => "Creating a fixture for the Twitter gem"})).to have_been_made
|
129
129
|
end
|
130
130
|
end
|
@@ -293,133 +293,63 @@ describe Twitter::REST::API::FriendsAndFollowers do
|
|
293
293
|
end
|
294
294
|
|
295
295
|
describe "#follow" do
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
stub_post("/1.1/friendships/create.json").with(:body => {:user_id => "7505382", :follow => "true"}).to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
302
|
-
end
|
303
|
-
it "requests the correct resource" do
|
304
|
-
@client.follow("sferik", "pengwynn", :follow => true)
|
305
|
-
expect(a_get("/1.1/account/verify_credentials.json")).to have_been_made
|
306
|
-
expect(a_get("/1.1/friends/ids.json").with(:query => {:cursor => "-1", :screen_name => "sferik"})).to have_been_made
|
307
|
-
expect(a_post("/1.1/users/lookup.json").with(:body => {:screen_name => "sferik,pengwynn"})).to have_been_made
|
308
|
-
expect(a_post("/1.1/friendships/create.json").with(:body => {:user_id => "7505382", :follow => "true"})).to have_been_made
|
309
|
-
end
|
310
|
-
it "returns an array of befriended users" do
|
311
|
-
users = @client.follow("sferik", "pengwynn", :follow => true)
|
312
|
-
expect(users).to be_an Array
|
313
|
-
expect(users.first).to be_a Twitter::User
|
314
|
-
expect(users.first.id).to eq(7505382)
|
315
|
-
end
|
316
|
-
end
|
317
|
-
context "with :follow => false passed" do
|
318
|
-
before do
|
319
|
-
stub_get("/1.1/account/verify_credentials.json").to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
320
|
-
stub_get("/1.1/friends/ids.json").with(:query => {:cursor => "-1", :screen_name => "sferik"}).to_return(:body => fixture("ids_list2.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
321
|
-
stub_post("/1.1/users/lookup.json").with(:body => {:screen_name => "sferik,pengwynn"}).to_return(:body => fixture("friendships.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
322
|
-
stub_post("/1.1/friendships/create.json").with(:body => {:user_id => "7505382"}).to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
323
|
-
end
|
324
|
-
it "requests the correct resource" do
|
325
|
-
@client.follow("sferik", "pengwynn", :follow => false)
|
326
|
-
expect(a_get("/1.1/account/verify_credentials.json")).to have_been_made
|
327
|
-
expect(a_get("/1.1/friends/ids.json").with(:query => {:cursor => "-1", :screen_name => "sferik"})).to have_been_made
|
328
|
-
expect(a_post("/1.1/users/lookup.json").with(:body => {:screen_name => "sferik,pengwynn"})).to have_been_made
|
329
|
-
expect(a_post("/1.1/friendships/create.json").with(:body => {:user_id => "7505382"})).to have_been_made
|
330
|
-
end
|
296
|
+
before do
|
297
|
+
stub_get("/1.1/account/verify_credentials.json").to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
298
|
+
stub_get("/1.1/friends/ids.json").with(:query => {:cursor => "-1", :screen_name => "sferik"}).to_return(:body => fixture("ids_list2.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
299
|
+
stub_post("/1.1/users/lookup.json").with(:body => {:screen_name => "sferik,pengwynn"}).to_return(:body => fixture("friendships.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
300
|
+
stub_post("/1.1/friendships/create.json").with(:body => {:user_id => "7505382"}).to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
331
301
|
end
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
end
|
339
|
-
it "requests the correct resource" do
|
340
|
-
@client.follow("sferik", "pengwynn")
|
341
|
-
expect(a_get("/1.1/account/verify_credentials.json")).to have_been_made
|
342
|
-
expect(a_get("/1.1/friends/ids.json").with(:query => {:cursor => "-1", :screen_name => "sferik"})).to have_been_made
|
343
|
-
expect(a_post("/1.1/users/lookup.json").with(:body => {:screen_name => "sferik,pengwynn"})).to have_been_made
|
344
|
-
expect(a_post("/1.1/friendships/create.json").with(:body => {:user_id => "7505382"})).to have_been_made
|
345
|
-
end
|
302
|
+
it "requests the correct resource" do
|
303
|
+
@client.follow("sferik", "pengwynn")
|
304
|
+
expect(a_get("/1.1/account/verify_credentials.json")).to have_been_made
|
305
|
+
expect(a_get("/1.1/friends/ids.json").with(:query => {:cursor => "-1", :screen_name => "sferik"})).to have_been_made
|
306
|
+
expect(a_post("/1.1/users/lookup.json").with(:body => {:screen_name => "sferik,pengwynn"})).to have_been_made
|
307
|
+
expect(a_post("/1.1/friendships/create.json").with(:body => {:user_id => "7505382"})).to have_been_made
|
346
308
|
end
|
347
309
|
end
|
348
310
|
|
349
311
|
describe "#follow!" do
|
350
|
-
|
351
|
-
|
352
|
-
stub_post("/1.1/friendships/create.json").with(:body => {:screen_name => "sferik", :follow => "true"}).to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
353
|
-
end
|
354
|
-
it "requests the correct resource" do
|
355
|
-
@client.follow!("sferik", :follow => true)
|
356
|
-
expect(a_post("/1.1/friendships/create.json").with(:body => {:screen_name => "sferik", :follow => "true"})).to have_been_made
|
357
|
-
end
|
358
|
-
it "returns an array of befriended users" do
|
359
|
-
users = @client.follow!("sferik", :follow => true)
|
360
|
-
expect(users).to be_an Array
|
361
|
-
expect(users.first).to be_a Twitter::User
|
362
|
-
expect(users.first.id).to eq(7505382)
|
363
|
-
end
|
312
|
+
before do
|
313
|
+
stub_post("/1.1/friendships/create.json").with(:body => {:screen_name => "sferik"}).to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
364
314
|
end
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
end
|
369
|
-
it "requests the correct resource" do
|
370
|
-
@client.follow!("sferik", :follow => false)
|
371
|
-
expect(a_post("/1.1/friendships/create.json").with(:body => {:screen_name => "sferik"})).to have_been_made
|
372
|
-
end
|
373
|
-
it "returns an array of befriended users" do
|
374
|
-
users = @client.follow!("sferik", :follow => false)
|
375
|
-
expect(users).to be_an Array
|
376
|
-
expect(users.first).to be_a Twitter::User
|
377
|
-
expect(users.first.id).to eq(7505382)
|
378
|
-
end
|
315
|
+
it "requests the correct resource" do
|
316
|
+
@client.follow!("sferik")
|
317
|
+
expect(a_post("/1.1/friendships/create.json").with(:body => {:screen_name => "sferik"})).to have_been_made
|
379
318
|
end
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
@client.follow!("sferik")
|
386
|
-
expect(a_post("/1.1/friendships/create.json").with(:body => {:screen_name => "sferik"})).to have_been_made
|
387
|
-
end
|
388
|
-
it "returns an array of befriended users" do
|
389
|
-
users = @client.follow!("sferik")
|
390
|
-
expect(users).to be_an Array
|
391
|
-
expect(users.first).to be_a Twitter::User
|
392
|
-
expect(users.first.id).to eq(7505382)
|
393
|
-
end
|
319
|
+
it "returns an array of befriended users" do
|
320
|
+
users = @client.follow!("sferik")
|
321
|
+
expect(users).to be_an Array
|
322
|
+
expect(users.first).to be_a Twitter::User
|
323
|
+
expect(users.first.id).to eq(7505382)
|
394
324
|
end
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
it "requests the correct resources" do
|
400
|
-
user = Twitter::User.new(:id => "7505382")
|
401
|
-
@client.follow!(user)
|
402
|
-
expect(a_post("/1.1/friendships/create.json").with(:body => {:user_id => "7505382"})).to have_been_made
|
403
|
-
end
|
325
|
+
end
|
326
|
+
context "with a user object passed" do
|
327
|
+
before do
|
328
|
+
stub_post("/1.1/friendships/create.json").with(:body => {:user_id => "7505382"}).to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
404
329
|
end
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
it "requests the correct resource" do
|
410
|
-
user = URI.parse("https://twitter.com/sferik")
|
411
|
-
@client.follow!(user)
|
412
|
-
expect(a_post("/1.1/friendships/create.json").with(:body => {:screen_name => "sferik"})).to have_been_made
|
413
|
-
end
|
330
|
+
it "requests the correct resources" do
|
331
|
+
user = Twitter::User.new(:id => "7505382")
|
332
|
+
@client.follow!(user)
|
333
|
+
expect(a_post("/1.1/friendships/create.json").with(:body => {:user_id => "7505382"})).to have_been_made
|
414
334
|
end
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
335
|
+
end
|
336
|
+
context "with a URI object passed" do
|
337
|
+
before do
|
338
|
+
stub_post("/1.1/friendships/create.json").with(:body => {:screen_name => "sferik"}).to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
339
|
+
end
|
340
|
+
it "requests the correct resource" do
|
341
|
+
user = URI.parse("https://twitter.com/sferik")
|
342
|
+
@client.follow!(user)
|
343
|
+
expect(a_post("/1.1/friendships/create.json").with(:body => {:screen_name => "sferik"})).to have_been_made
|
344
|
+
end
|
345
|
+
end
|
346
|
+
context "with a URI string passed" do
|
347
|
+
before do
|
348
|
+
stub_post("/1.1/friendships/create.json").with(:body => {:screen_name => "sferik"}).to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
349
|
+
end
|
350
|
+
it "requests the correct resource" do
|
351
|
+
@client.follow!("https://twitter.com/sferik")
|
352
|
+
expect(a_post("/1.1/friendships/create.json").with(:body => {:screen_name => "sferik"})).to have_been_made
|
423
353
|
end
|
424
354
|
end
|
425
355
|
|
@@ -432,7 +362,7 @@ describe Twitter::REST::API::FriendsAndFollowers do
|
|
432
362
|
expect(a_post("/1.1/friendships/destroy.json").with(:body => {:screen_name => "sferik"})).to have_been_made
|
433
363
|
end
|
434
364
|
it "returns an array of unfollowed users" do
|
435
|
-
users = @client.
|
365
|
+
users = @client.unfollow("sferik")
|
436
366
|
expect(users).to be_an Array
|
437
367
|
expect(users.first).to be_a Twitter::User
|
438
368
|
expect(users.first.id).to eq(7505382)
|
@@ -532,11 +462,11 @@ describe Twitter::REST::API::FriendsAndFollowers do
|
|
532
462
|
end
|
533
463
|
it "returns true if user A follows user B" do
|
534
464
|
friendship = @client.friendship?("sferik", "pengwynn")
|
535
|
-
expect(friendship).to
|
465
|
+
expect(friendship).to be true
|
536
466
|
end
|
537
467
|
it "returns false if user A does not follow user B" do
|
538
468
|
friendship = @client.friendship?("pengwynn", "sferik")
|
539
|
-
expect(friendship).to
|
469
|
+
expect(friendship).to be false
|
540
470
|
end
|
541
471
|
end
|
542
472
|
context "with user IDs passed" do
|
@@ -65,18 +65,4 @@ describe Twitter::REST::API::PlacesAndGeo do
|
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
68
|
-
describe "#place_create" do
|
69
|
-
before do
|
70
|
-
stub_post("/1.1/geo/place.json").with(:body => {:name => "@sferik's Apartment", :token => "22ff5b1f7159032cf69218c4d8bb78bc", :contained_within => "41bcb736f84a799e", :lat => "37.783699", :long => "-122.393581"}).to_return(:body => fixture("place.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
71
|
-
end
|
72
|
-
it "requests the correct resource" do
|
73
|
-
@client.place_create(:name => "@sferik's Apartment", :token => "22ff5b1f7159032cf69218c4d8bb78bc", :contained_within => "41bcb736f84a799e", :lat => "37.783699", :long => "-122.393581")
|
74
|
-
expect(a_post("/1.1/geo/place.json").with(:body => {:name => "@sferik's Apartment", :token => "22ff5b1f7159032cf69218c4d8bb78bc", :contained_within => "41bcb736f84a799e", :lat => "37.783699", :long => "-122.393581"})).to have_been_made
|
75
|
-
end
|
76
|
-
it "returns a place" do
|
77
|
-
place = @client.place_create(:name => "@sferik's Apartment", :token => "22ff5b1f7159032cf69218c4d8bb78bc", :contained_within => "41bcb736f84a799e", :lat => "37.783699", :long => "-122.393581")
|
78
|
-
expect(place.name).to eq("Twitter HQ")
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
68
|
end
|
@@ -77,17 +77,17 @@ describe Twitter::REST::API::Lists do
|
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
80
|
-
describe "#
|
80
|
+
describe "#remove_list_member" do
|
81
81
|
context "with a screen name passed" do
|
82
82
|
before do
|
83
83
|
stub_post("/1.1/lists/members/destroy.json").with(:body => {:owner_screen_name => "sferik", :slug => "presidents", :user_id => "813286"}).to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
84
84
|
end
|
85
85
|
it "requests the correct resource" do
|
86
|
-
@client.
|
86
|
+
@client.remove_list_member("sferik", "presidents", 813286)
|
87
87
|
expect(a_post("/1.1/lists/members/destroy.json").with(:body => {:owner_screen_name => "sferik", :slug => "presidents", :user_id => "813286"})).to have_been_made
|
88
88
|
end
|
89
89
|
it "returns the list" do
|
90
|
-
list = @client.
|
90
|
+
list = @client.remove_list_member("sferik", "presidents", 813286)
|
91
91
|
expect(list).to be_a Twitter::List
|
92
92
|
expect(list.name).to eq("presidents")
|
93
93
|
end
|
@@ -98,7 +98,7 @@ describe Twitter::REST::API::Lists do
|
|
98
98
|
stub_post("/1.1/lists/members/destroy.json").with(:body => {:owner_screen_name => "sferik", :slug => "presidents", :user_id => "813286"}).to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
99
99
|
end
|
100
100
|
it "requests the correct resource" do
|
101
|
-
@client.
|
101
|
+
@client.remove_list_member("presidents", 813286)
|
102
102
|
expect(a_post("/1.1/lists/members/destroy.json").with(:body => {:owner_screen_name => "sferik", :slug => "presidents", :user_id => "813286"})).to have_been_made
|
103
103
|
end
|
104
104
|
end
|
@@ -278,15 +278,15 @@ describe Twitter::REST::API::Lists do
|
|
278
278
|
end
|
279
279
|
it "returns true if the specified user subscribes to the specified list" do
|
280
280
|
list_subscriber = @client.list_subscriber?("sferik", "presidents", 813286)
|
281
|
-
expect(list_subscriber).to
|
281
|
+
expect(list_subscriber).to be true
|
282
282
|
end
|
283
283
|
it "returns false if the specified user does not subscribe to the specified list" do
|
284
284
|
list_subscriber = @client.list_subscriber?("sferik", "presidents", 18755393)
|
285
|
-
expect(list_subscriber).to
|
285
|
+
expect(list_subscriber).to be false
|
286
286
|
end
|
287
287
|
it "returns false if user does not exist" do
|
288
288
|
list_subscriber = @client.list_subscriber?("sferik", "presidents", 12345678)
|
289
|
-
expect(list_subscriber).to
|
289
|
+
expect(list_subscriber).to be false
|
290
290
|
end
|
291
291
|
end
|
292
292
|
context "with a owner ID passed" do
|
@@ -365,17 +365,17 @@ describe Twitter::REST::API::Lists do
|
|
365
365
|
end
|
366
366
|
end
|
367
367
|
|
368
|
-
describe "#
|
368
|
+
describe "#add_list_members" do
|
369
369
|
context "with a screen name passed" do
|
370
370
|
before do
|
371
371
|
stub_post("/1.1/lists/members/create_all.json").with(:body => {:owner_screen_name => "sferik", :slug => "presidents", :user_id => "813286,18755393"}).to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
372
372
|
end
|
373
373
|
it "requests the correct resource" do
|
374
|
-
@client.
|
374
|
+
@client.add_list_members("sferik", "presidents", [813286, 18755393])
|
375
375
|
expect(a_post("/1.1/lists/members/create_all.json").with(:body => {:owner_screen_name => "sferik", :slug => "presidents", :user_id => "813286,18755393"})).to have_been_made
|
376
376
|
end
|
377
377
|
it "returns the list" do
|
378
|
-
list = @client.
|
378
|
+
list = @client.add_list_members("sferik", "presidents", [813286, 18755393])
|
379
379
|
expect(list).to be_a Twitter::List
|
380
380
|
expect(list.name).to eq("presidents")
|
381
381
|
end
|
@@ -385,7 +385,7 @@ describe Twitter::REST::API::Lists do
|
|
385
385
|
stub_post("/1.1/lists/members/create_all.json").with(:body => {:owner_screen_name => "sferik", :slug => "presidents", :user_id => "813286,18755393", :screen_name => "pengwynn,erebor"}).to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
386
386
|
end
|
387
387
|
it "requests the correct resource" do
|
388
|
-
@client.
|
388
|
+
@client.add_list_members("sferik", "presidents", [813286, "pengwynn", 18755393, "erebor"])
|
389
389
|
expect(a_post("/1.1/lists/members/create_all.json").with(:body => {:owner_screen_name => "sferik", :slug => "presidents", :user_id => "813286,18755393", :screen_name => "pengwynn,erebor"})).to have_been_made
|
390
390
|
end
|
391
391
|
end
|
@@ -395,7 +395,7 @@ describe Twitter::REST::API::Lists do
|
|
395
395
|
stub_post("/1.1/lists/members/create_all.json").with(:body => {:owner_screen_name => "sferik", :slug => "presidents", :user_id => "813286,18755393"}).to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
396
396
|
end
|
397
397
|
it "requests the correct resource" do
|
398
|
-
@client.
|
398
|
+
@client.add_list_members("presidents", [813286, 18755393])
|
399
399
|
expect(a_post("/1.1/lists/members/create_all.json").with(:body => {:owner_screen_name => "sferik", :slug => "presidents", :user_id => "813286,18755393"})).to have_been_made
|
400
400
|
end
|
401
401
|
end
|
@@ -414,15 +414,15 @@ describe Twitter::REST::API::Lists do
|
|
414
414
|
end
|
415
415
|
it "returns true if user is a list member" do
|
416
416
|
list_member = @client.list_member?("sferik", "presidents", 813286)
|
417
|
-
expect(list_member).to
|
417
|
+
expect(list_member).to be true
|
418
418
|
end
|
419
419
|
it "returns false if user is not a list member" do
|
420
420
|
list_member = @client.list_member?("sferik", "presidents", 65493023)
|
421
|
-
expect(list_member).to
|
421
|
+
expect(list_member).to be false
|
422
422
|
end
|
423
423
|
it "returns false if user does not exist" do
|
424
424
|
list_member = @client.list_member?("sferik", "presidents", 12345678)
|
425
|
-
expect(list_member).to
|
425
|
+
expect(list_member).to be false
|
426
426
|
end
|
427
427
|
end
|
428
428
|
context "with an owner ID passed" do
|
@@ -541,17 +541,17 @@ describe Twitter::REST::API::Lists do
|
|
541
541
|
end
|
542
542
|
end
|
543
543
|
|
544
|
-
describe "#
|
544
|
+
describe "#add_list_member" do
|
545
545
|
context "with a screen name passed" do
|
546
546
|
before do
|
547
547
|
stub_post("/1.1/lists/members/create.json").with(:body => {:owner_screen_name => "sferik", :slug => "presidents", :user_id => "813286"}).to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
548
548
|
end
|
549
549
|
it "requests the correct resource" do
|
550
|
-
@client.
|
550
|
+
@client.add_list_member("sferik", "presidents", 813286)
|
551
551
|
expect(a_post("/1.1/lists/members/create.json").with(:body => {:owner_screen_name => "sferik", :slug => "presidents", :user_id => "813286"})).to have_been_made
|
552
552
|
end
|
553
553
|
it "returns the list" do
|
554
|
-
list = @client.
|
554
|
+
list = @client.add_list_member("sferik", "presidents", 813286)
|
555
555
|
expect(list).to be_a Twitter::List
|
556
556
|
expect(list.name).to eq("presidents")
|
557
557
|
end
|
@@ -562,23 +562,23 @@ describe Twitter::REST::API::Lists do
|
|
562
562
|
stub_post("/1.1/lists/members/create.json").with(:body => {:owner_screen_name => "sferik", :slug => "presidents", :user_id => "813286"}).to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
563
563
|
end
|
564
564
|
it "requests the correct resource" do
|
565
|
-
@client.
|
565
|
+
@client.add_list_member("presidents", 813286)
|
566
566
|
expect(a_post("/1.1/lists/members/create.json").with(:body => {:owner_screen_name => "sferik", :slug => "presidents", :user_id => "813286"})).to have_been_made
|
567
567
|
end
|
568
568
|
end
|
569
569
|
end
|
570
570
|
|
571
|
-
describe "#
|
571
|
+
describe "#destroy_list" do
|
572
572
|
context "with a screen name passed" do
|
573
573
|
before do
|
574
574
|
stub_post("/1.1/lists/destroy.json").with(:body => {:owner_screen_name => "sferik", :slug => "presidents"}).to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
575
575
|
end
|
576
576
|
it "requests the correct resource" do
|
577
|
-
@client.
|
577
|
+
@client.destroy_list("sferik", "presidents")
|
578
578
|
expect(a_post("/1.1/lists/destroy.json").with(:body => {:owner_screen_name => "sferik", :slug => "presidents"})).to have_been_made
|
579
579
|
end
|
580
580
|
it "returns the deleted list" do
|
581
|
-
list = @client.
|
581
|
+
list = @client.destroy_list("sferik", "presidents")
|
582
582
|
expect(list).to be_a Twitter::List
|
583
583
|
expect(list.name).to eq("presidents")
|
584
584
|
end
|
@@ -589,7 +589,7 @@ describe Twitter::REST::API::Lists do
|
|
589
589
|
stub_post("/1.1/lists/destroy.json").with(:body => {:owner_screen_name => "sferik", :slug => "presidents"}).to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
590
590
|
end
|
591
591
|
it "requests the correct resource" do
|
592
|
-
@client.
|
592
|
+
@client.destroy_list("presidents")
|
593
593
|
expect(a_post("/1.1/lists/destroy.json").with(:body => {:owner_screen_name => "sferik", :slug => "presidents"})).to have_been_made
|
594
594
|
end
|
595
595
|
end
|
@@ -598,7 +598,7 @@ describe Twitter::REST::API::Lists do
|
|
598
598
|
stub_post("/1.1/lists/destroy.json").with(:body => {:owner_screen_name => "sferik", :list_id => "12345678"}).to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
599
599
|
end
|
600
600
|
it "requests the correct resource" do
|
601
|
-
@client.
|
601
|
+
@client.destroy_list("sferik", 12345678)
|
602
602
|
expect(a_post("/1.1/lists/destroy.json").with(:body => {:owner_screen_name => "sferik", :list_id => "12345678"})).to have_been_made
|
603
603
|
end
|
604
604
|
end
|
@@ -608,7 +608,7 @@ describe Twitter::REST::API::Lists do
|
|
608
608
|
end
|
609
609
|
it "requests the correct resource" do
|
610
610
|
list = Twitter::List.new(:id => "12345678", :user => {:id => 7505382, :screen_name => "sferik"})
|
611
|
-
@client.
|
611
|
+
@client.destroy_list(list)
|
612
612
|
expect(a_post("/1.1/lists/destroy.json").with(:body => {:owner_id => "7505382", :list_id => "12345678"})).to have_been_made
|
613
613
|
end
|
614
614
|
end
|
@@ -660,16 +660,16 @@ describe Twitter::REST::API::Lists do
|
|
660
660
|
end
|
661
661
|
end
|
662
662
|
|
663
|
-
describe "#
|
663
|
+
describe "#create_list" do
|
664
664
|
before do
|
665
665
|
stub_post("/1.1/lists/create.json").with(:body => {:name => "presidents"}).to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
666
666
|
end
|
667
667
|
it "requests the correct resource" do
|
668
|
-
@client.
|
668
|
+
@client.create_list("presidents")
|
669
669
|
expect(a_post("/1.1/lists/create.json").with(:body => {:name => "presidents"})).to have_been_made
|
670
670
|
end
|
671
671
|
it "returns the created list" do
|
672
|
-
list = @client.
|
672
|
+
list = @client.create_list("presidents")
|
673
673
|
expect(list).to be_a Twitter::List
|
674
674
|
expect(list.name).to eq("presidents")
|
675
675
|
end
|
@@ -807,17 +807,17 @@ describe Twitter::REST::API::Lists do
|
|
807
807
|
end
|
808
808
|
end
|
809
809
|
|
810
|
-
describe "#
|
810
|
+
describe "#remove_list_members" do
|
811
811
|
context "with a screen name passed" do
|
812
812
|
before do
|
813
813
|
stub_post("/1.1/lists/members/destroy_all.json").with(:body => {:owner_screen_name => "sferik", :slug => "presidents", :user_id => "813286,18755393"}).to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
814
814
|
end
|
815
815
|
it "requests the correct resource" do
|
816
|
-
@client.
|
816
|
+
@client.remove_list_members("sferik", "presidents", [813286, 18755393])
|
817
817
|
expect(a_post("/1.1/lists/members/destroy_all.json").with(:body => {:owner_screen_name => "sferik", :slug => "presidents", :user_id => "813286,18755393"})).to have_been_made
|
818
818
|
end
|
819
819
|
it "returns the list" do
|
820
|
-
list = @client.
|
820
|
+
list = @client.remove_list_members("sferik", "presidents", [813286, 18755393])
|
821
821
|
expect(list).to be_a Twitter::List
|
822
822
|
expect(list.name).to eq("presidents")
|
823
823
|
end
|
@@ -827,7 +827,7 @@ describe Twitter::REST::API::Lists do
|
|
827
827
|
stub_post("/1.1/lists/members/destroy_all.json").with(:body => {:owner_id => "7505382", :slug => "presidents", :user_id => "813286,18755393"}).to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
828
828
|
end
|
829
829
|
it "requests the correct resource" do
|
830
|
-
@client.
|
830
|
+
@client.remove_list_members(7505382, "presidents", [813286, 18755393])
|
831
831
|
expect(a_post("/1.1/lists/members/destroy_all.json").with(:body => {:owner_id => "7505382", :slug => "presidents", :user_id => "813286,18755393"})).to have_been_made
|
832
832
|
end
|
833
833
|
end
|
@@ -836,7 +836,7 @@ describe Twitter::REST::API::Lists do
|
|
836
836
|
stub_post("/1.1/lists/members/destroy_all.json").with(:body => {:owner_screen_name => "sferik", :slug => "presidents", :user_id => "813286,18755393", :screen_name => "pengwynn,erebor"}).to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
837
837
|
end
|
838
838
|
it "requests the correct resource" do
|
839
|
-
@client.
|
839
|
+
@client.remove_list_members("sferik", "presidents", [813286, "pengwynn", 18755393, "erebor"])
|
840
840
|
expect(a_post("/1.1/lists/members/destroy_all.json").with(:body => {:owner_screen_name => "sferik", :slug => "presidents", :user_id => "813286,18755393", :screen_name => "pengwynn,erebor"})).to have_been_made
|
841
841
|
end
|
842
842
|
end
|
@@ -846,23 +846,23 @@ describe Twitter::REST::API::Lists do
|
|
846
846
|
stub_post("/1.1/lists/members/destroy_all.json").with(:body => {:owner_screen_name => "sferik", :slug => "presidents", :user_id => "813286,18755393"}).to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
847
847
|
end
|
848
848
|
it "requests the correct resource" do
|
849
|
-
@client.
|
849
|
+
@client.remove_list_members("presidents", [813286, 18755393])
|
850
850
|
expect(a_post("/1.1/lists/members/destroy_all.json").with(:body => {:owner_screen_name => "sferik", :slug => "presidents", :user_id => "813286,18755393"})).to have_been_made
|
851
851
|
end
|
852
852
|
end
|
853
853
|
end
|
854
854
|
|
855
|
-
describe "#
|
855
|
+
describe "#owned_lists" do
|
856
856
|
context "with a screen name passed" do
|
857
857
|
before do
|
858
858
|
stub_get("/1.1/lists/ownerships.json").with(:query => {:screen_name => "sferik", :cursor => "-1"}).to_return(:body => fixture("ownerships.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
859
859
|
end
|
860
860
|
it "requests the correct resource" do
|
861
|
-
@client.
|
861
|
+
@client.owned_lists("sferik")
|
862
862
|
expect(a_get("/1.1/lists/ownerships.json").with(:query => {:screen_name => "sferik", :cursor => "-1"})).to have_been_made
|
863
863
|
end
|
864
864
|
it "returns the requested list" do
|
865
|
-
lists = @client.
|
865
|
+
lists = @client.owned_lists("sferik")
|
866
866
|
expect(lists).to be_a Twitter::Cursor
|
867
867
|
expect(lists.first).to be_a Twitter::List
|
868
868
|
expect(lists.first.name).to eq("My favstar.fm list")
|
@@ -874,11 +874,11 @@ describe Twitter::REST::API::Lists do
|
|
874
874
|
stub_get("/1.1/lists/ownerships.json").with(:query => {:screen_name => "sferik", :cursor => "-1"}).to_return(:body => fixture("ownerships.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
875
875
|
end
|
876
876
|
it "requests the correct resource" do
|
877
|
-
@client.
|
877
|
+
@client.owned_lists
|
878
878
|
expect(a_get("/1.1/lists/ownerships.json").with(:query => {:screen_name => "sferik", :cursor => "-1"})).to have_been_made
|
879
879
|
end
|
880
880
|
it "returns the requested list" do
|
881
|
-
lists = @client.
|
881
|
+
lists = @client.owned_lists
|
882
882
|
expect(lists).to be_a Twitter::Cursor
|
883
883
|
expect(lists.first).to be_a Twitter::List
|
884
884
|
expect(lists.first.name).to eq("My favstar.fm list")
|