twitter 4.2.0 → 4.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. data/CHANGELOG.md +4 -0
  2. data/lib/twitter/api/direct_messages.rb +150 -0
  3. data/lib/twitter/api/favorites.rb +132 -0
  4. data/lib/twitter/api/friends_and_followers.rb +259 -0
  5. data/lib/twitter/api/help.rb +64 -0
  6. data/lib/twitter/api/lists.rb +570 -0
  7. data/lib/twitter/api/places_and_geo.rb +121 -0
  8. data/lib/twitter/api/saved_searches.rb +98 -0
  9. data/lib/twitter/api/search.rb +37 -0
  10. data/lib/twitter/api/spam_reporting.rb +30 -0
  11. data/lib/twitter/api/suggested_users.rb +54 -0
  12. data/lib/twitter/api/timelines.rb +213 -0
  13. data/lib/twitter/api/trends.rb +63 -0
  14. data/lib/twitter/api/tweets.rb +284 -0
  15. data/lib/twitter/api/undocumented.rb +116 -0
  16. data/lib/twitter/api/users.rb +427 -0
  17. data/lib/twitter/api/utils.rb +111 -0
  18. data/lib/twitter/client.rb +41 -13
  19. data/lib/twitter/core_ext/enumerable.rb +1 -1
  20. data/lib/twitter/default.rb +16 -18
  21. data/lib/twitter/error/already_favorited.rb +1 -1
  22. data/lib/twitter/error/already_retweeted.rb +1 -1
  23. data/lib/twitter/profile_banner.rb +18 -0
  24. data/lib/twitter/version.rb +1 -1
  25. data/spec/fixtures/profile_banner.json +1 -0
  26. data/spec/twitter/api/direct_messages_spec.rb +32 -32
  27. data/spec/twitter/api/favorites_spec.rb +114 -0
  28. data/spec/twitter/api/{friendships_spec.rb → friends_and_followers_spec.rb} +146 -146
  29. data/spec/twitter/api/geo_spec.rb +28 -28
  30. data/spec/twitter/api/help_spec.rb +1 -1
  31. data/spec/twitter/api/lists_spec.rb +82 -82
  32. data/spec/twitter/api/saved_searches_spec.rb +1 -1
  33. data/spec/twitter/api/search_spec.rb +1 -17
  34. data/spec/twitter/api/{report_spam_spec.rb → spam_reporting_spec.rb} +1 -1
  35. data/spec/twitter/api/suggested_users_spec.rb +94 -0
  36. data/spec/twitter/api/timelines_spec.rb +138 -0
  37. data/spec/twitter/api/trends_spec.rb +1 -1
  38. data/spec/twitter/api/tweets_spec.rb +249 -0
  39. data/spec/twitter/api/undocumented_spec.rb +103 -0
  40. data/spec/twitter/api/users_spec.rb +308 -17
  41. data/spec/twitter/client_spec.rb +1 -1
  42. data/spec/twitter/profile_banner_spec.rb +13 -0
  43. data/twitter.gemspec +3 -2
  44. metadata +44 -21
  45. data/lib/twitter/api.rb +0 -2558
  46. data/spec/twitter/api/account_spec.rb +0 -152
  47. data/spec/twitter/api/activity_spec.rb +0 -37
  48. data/spec/twitter/api/blocks_spec.rb +0 -122
  49. data/spec/twitter/api/statuses_spec.rb +0 -541
@@ -1,67 +1,67 @@
1
1
  require 'helper'
2
2
 
3
- describe Twitter::API do
3
+ describe Twitter::API::PlacesAndGeo do
4
4
 
5
5
  before do
6
6
  @client = Twitter::Client.new
7
7
  end
8
8
 
9
- describe "#places_nearby" do
9
+ describe "#place" do
10
10
  before do
11
- stub_get("/1.1/geo/search.json").with(:query => {:ip => "74.125.19.104"}).to_return(:body => fixture("places.json"), :headers => {:content_type => "application/json; charset=utf-8"})
11
+ stub_get("/1.1/geo/id/247f43d441defc03.json").to_return(:body => fixture("place.json"), :headers => {:content_type => "application/json; charset=utf-8"})
12
12
  end
13
13
  it "requests the correct resource" do
14
- @client.places_nearby(:ip => "74.125.19.104")
15
- expect(a_get("/1.1/geo/search.json").with(:query => {:ip => "74.125.19.104"})).to have_been_made
14
+ @client.place("247f43d441defc03")
15
+ expect(a_get("/1.1/geo/id/247f43d441defc03.json")).to have_been_made
16
16
  end
17
- it "returns nearby places" do
18
- places = @client.places_nearby(:ip => "74.125.19.104")
19
- expect(places).to be_an Array
20
- expect(places.first.name).to eq "Bernal Heights"
17
+ it "returns a place" do
18
+ place = @client.place("247f43d441defc03")
19
+ expect(place.name).to eq "Twitter HQ"
21
20
  end
22
21
  end
23
22
 
24
- describe "#places_similar" do
23
+ describe "#reverse_geocode" do
25
24
  before do
26
- stub_get("/1.1/geo/similar_places.json").with(:query => {:lat => "37.7821120598956", :long => "-122.400612831116", :name => "Twitter HQ"}).to_return(:body => fixture("places.json"), :headers => {:content_type => "application/json; charset=utf-8"})
25
+ stub_get("/1.1/geo/reverse_geocode.json").with(:query => {:lat => "37.7821120598956", :long => "-122.400612831116"}).to_return(:body => fixture("places.json"), :headers => {:content_type => "application/json; charset=utf-8"})
27
26
  end
28
27
  it "requests the correct resource" do
29
- @client.places_similar(:lat => "37.7821120598956", :long => "-122.400612831116", :name => "Twitter HQ")
30
- expect(a_get("/1.1/geo/similar_places.json").with(:query => {:lat => "37.7821120598956", :long => "-122.400612831116", :name => "Twitter HQ"})).to have_been_made
28
+ @client.reverse_geocode(:lat => "37.7821120598956", :long => "-122.400612831116")
29
+ expect(a_get("/1.1/geo/reverse_geocode.json").with(:query => {:lat => "37.7821120598956", :long => "-122.400612831116"})).to have_been_made
31
30
  end
32
- it "returns similar places" do
33
- places = @client.places_similar(:lat => "37.7821120598956", :long => "-122.400612831116", :name => "Twitter HQ")
31
+ it "returns places" do
32
+ places = @client.reverse_geocode(:lat => "37.7821120598956", :long => "-122.400612831116")
34
33
  expect(places).to be_an Array
35
34
  expect(places.first.name).to eq "Bernal Heights"
36
35
  end
37
36
  end
38
37
 
39
- describe "#reverse_geocode" do
38
+ describe "#geo_search" do
40
39
  before do
41
- stub_get("/1.1/geo/reverse_geocode.json").with(:query => {:lat => "37.7821120598956", :long => "-122.400612831116"}).to_return(:body => fixture("places.json"), :headers => {:content_type => "application/json; charset=utf-8"})
40
+ stub_get("/1.1/geo/search.json").with(:query => {:ip => "74.125.19.104"}).to_return(:body => fixture("places.json"), :headers => {:content_type => "application/json; charset=utf-8"})
42
41
  end
43
42
  it "requests the correct resource" do
44
- @client.reverse_geocode(:lat => "37.7821120598956", :long => "-122.400612831116")
45
- expect(a_get("/1.1/geo/reverse_geocode.json").with(:query => {:lat => "37.7821120598956", :long => "-122.400612831116"})).to have_been_made
43
+ @client.geo_search(:ip => "74.125.19.104")
44
+ expect(a_get("/1.1/geo/search.json").with(:query => {:ip => "74.125.19.104"})).to have_been_made
46
45
  end
47
- it "returns places" do
48
- places = @client.reverse_geocode(:lat => "37.7821120598956", :long => "-122.400612831116")
46
+ it "returns nearby places" do
47
+ places = @client.geo_search(:ip => "74.125.19.104")
49
48
  expect(places).to be_an Array
50
49
  expect(places.first.name).to eq "Bernal Heights"
51
50
  end
52
51
  end
53
52
 
54
- describe "#place" do
53
+ describe "#similar_places" do
55
54
  before do
56
- stub_get("/1.1/geo/id/247f43d441defc03.json").to_return(:body => fixture("place.json"), :headers => {:content_type => "application/json; charset=utf-8"})
55
+ stub_get("/1.1/geo/similar_places.json").with(:query => {:lat => "37.7821120598956", :long => "-122.400612831116", :name => "Twitter HQ"}).to_return(:body => fixture("places.json"), :headers => {:content_type => "application/json; charset=utf-8"})
57
56
  end
58
57
  it "requests the correct resource" do
59
- @client.place("247f43d441defc03")
60
- expect(a_get("/1.1/geo/id/247f43d441defc03.json")).to have_been_made
58
+ @client.similar_places(:lat => "37.7821120598956", :long => "-122.400612831116", :name => "Twitter HQ")
59
+ expect(a_get("/1.1/geo/similar_places.json").with(:query => {:lat => "37.7821120598956", :long => "-122.400612831116", :name => "Twitter HQ"})).to have_been_made
61
60
  end
62
- it "returns a place" do
63
- place = @client.place("247f43d441defc03")
64
- expect(place.name).to eq "Twitter HQ"
61
+ it "returns similar places" do
62
+ places = @client.similar_places(:lat => "37.7821120598956", :long => "-122.400612831116", :name => "Twitter HQ")
63
+ expect(places).to be_an Array
64
+ expect(places.first.name).to eq "Bernal Heights"
65
65
  end
66
66
  end
67
67
 
@@ -1,6 +1,6 @@
1
1
  require 'helper'
2
2
 
3
- describe Twitter::API do
3
+ describe Twitter::API::Help do
4
4
 
5
5
  before do
6
6
  @client = Twitter::Client.new
@@ -1,11 +1,27 @@
1
1
  require 'helper'
2
2
 
3
- describe Twitter::API do
3
+ describe Twitter::API::Lists do
4
4
 
5
5
  before do
6
6
  @client = Twitter::Client.new
7
7
  end
8
8
 
9
+ describe "#lists" do
10
+ before do
11
+ stub_get("/1.1/lists/list.json").to_return(:body => fixture("lists.json"), :headers => {:content_type => "application/json; charset=utf-8"})
12
+ end
13
+ it "requests the correct resource" do
14
+ @client.lists
15
+ expect(a_get("/1.1/lists/list.json")).to have_been_made
16
+ end
17
+ it "returns the requested list" do
18
+ lists = @client.lists
19
+ expect(lists).to be_an Array
20
+ expect(lists.first).to be_a Twitter::List
21
+ expect(lists.first.name).to eq "Rubyists"
22
+ end
23
+ end
24
+
9
25
  describe "#list_timeline" do
10
26
  context "with a screen name passed" do
11
27
  before do
@@ -119,35 +135,6 @@ describe Twitter::API do
119
135
  end
120
136
  end
121
137
 
122
- describe "#subscriptions" do
123
- context "with a screen name passed" do
124
- before do
125
- stub_get("/1.1/lists/subscriptions.json").with(:query => {:screen_name => 'pengwynn', :cursor => "-1"}).to_return(:body => fixture("subscriptions.json"), :headers => {:content_type => "application/json; charset=utf-8"})
126
- end
127
- it "requests the correct resource" do
128
- @client.subscriptions("pengwynn")
129
- expect(a_get("/1.1/lists/subscriptions.json").with(:query => {:screen_name => 'pengwynn', :cursor => "-1"})).to have_been_made
130
- end
131
- it "returns the lists the specified user follows" do
132
- subscriptions = @client.subscriptions("pengwynn")
133
- expect(subscriptions).to be_a Twitter::Cursor
134
- expect(subscriptions.lists).to be_an Array
135
- expect(subscriptions.lists.first).to be_a Twitter::List
136
- expect(subscriptions.lists.first.name).to eq "Rubyists"
137
- end
138
- end
139
- context "without a screen name passed" do
140
- before do
141
- stub_get("/1.1/account/verify_credentials.json").to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
142
- stub_get("/1.1/lists/subscriptions.json").with(:query => {:cursor => "-1"}).to_return(:body => fixture("subscriptions.json"), :headers => {:content_type => "application/json; charset=utf-8"})
143
- end
144
- it "requests the correct resource" do
145
- @client.subscriptions
146
- expect(a_get("/1.1/lists/subscriptions.json").with(:query => {:cursor => "-1"})).to have_been_made
147
- end
148
- end
149
- end
150
-
151
138
  describe "#list_subscribe" do
152
139
  context "with a screen name passed" do
153
140
  before do
@@ -311,42 +298,6 @@ describe Twitter::API do
311
298
  end
312
299
  end
313
300
 
314
- describe "#list_remove_members" do
315
- context "with a screen name passed" do
316
- before do
317
- 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"})
318
- end
319
- it "requests the correct resource" do
320
- @client.list_remove_members("sferik", "presidents", [813286, 18755393])
321
- 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
322
- end
323
- it "returns the list" do
324
- list = @client.list_remove_members("sferik", "presidents", [813286, 18755393])
325
- expect(list).to be_a Twitter::List
326
- expect(list.name).to eq "presidents"
327
- end
328
- end
329
- context "with a combination of member IDs and member screen names to add" do
330
- before do
331
- 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"})
332
- end
333
- it "requests the correct resource" do
334
- @client.list_remove_members('sferik', 'presidents', [813286, 'pengwynn', 18755393, 'erebor'])
335
- 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
336
- end
337
- end
338
- context "without a screen name passed" do
339
- before do
340
- stub_get("/1.1/account/verify_credentials.json").to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
341
- 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"})
342
- end
343
- it "requests the correct resource" do
344
- @client.list_remove_members("presidents", [813286, 18755393])
345
- 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
346
- end
347
- end
348
- end
349
-
350
301
  describe "#list_member?" do
351
302
  context "with a screen name passed" do
352
303
  before do
@@ -583,22 +534,6 @@ describe Twitter::API do
583
534
  end
584
535
  end
585
536
 
586
- describe "#lists" do
587
- before do
588
- stub_get("/1.1/lists/list.json").to_return(:body => fixture("lists.json"), :headers => {:content_type => "application/json; charset=utf-8"})
589
- end
590
- it "requests the correct resource" do
591
- @client.lists
592
- expect(a_get("/1.1/lists/list.json")).to have_been_made
593
- end
594
- it "returns the requested list" do
595
- lists = @client.lists
596
- expect(lists).to be_an Array
597
- expect(lists.first).to be_a Twitter::List
598
- expect(lists.first.name).to eq "Rubyists"
599
- end
600
- end
601
-
602
537
  describe "#list" do
603
538
  context "with a screen name passed" do
604
539
  before do
@@ -664,4 +599,69 @@ describe Twitter::API do
664
599
  end
665
600
  end
666
601
 
602
+ describe "#subscriptions" do
603
+ context "with a screen name passed" do
604
+ before do
605
+ stub_get("/1.1/lists/subscriptions.json").with(:query => {:screen_name => 'pengwynn', :cursor => "-1"}).to_return(:body => fixture("subscriptions.json"), :headers => {:content_type => "application/json; charset=utf-8"})
606
+ end
607
+ it "requests the correct resource" do
608
+ @client.subscriptions("pengwynn")
609
+ expect(a_get("/1.1/lists/subscriptions.json").with(:query => {:screen_name => 'pengwynn', :cursor => "-1"})).to have_been_made
610
+ end
611
+ it "returns the lists the specified user follows" do
612
+ subscriptions = @client.subscriptions("pengwynn")
613
+ expect(subscriptions).to be_a Twitter::Cursor
614
+ expect(subscriptions.lists).to be_an Array
615
+ expect(subscriptions.lists.first).to be_a Twitter::List
616
+ expect(subscriptions.lists.first.name).to eq "Rubyists"
617
+ end
618
+ end
619
+ context "without a screen name passed" do
620
+ before do
621
+ stub_get("/1.1/account/verify_credentials.json").to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
622
+ stub_get("/1.1/lists/subscriptions.json").with(:query => {:cursor => "-1"}).to_return(:body => fixture("subscriptions.json"), :headers => {:content_type => "application/json; charset=utf-8"})
623
+ end
624
+ it "requests the correct resource" do
625
+ @client.subscriptions
626
+ expect(a_get("/1.1/lists/subscriptions.json").with(:query => {:cursor => "-1"})).to have_been_made
627
+ end
628
+ end
629
+ end
630
+
631
+ describe "#list_remove_members" do
632
+ context "with a screen name passed" do
633
+ before do
634
+ 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"})
635
+ end
636
+ it "requests the correct resource" do
637
+ @client.list_remove_members("sferik", "presidents", [813286, 18755393])
638
+ 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
639
+ end
640
+ it "returns the list" do
641
+ list = @client.list_remove_members("sferik", "presidents", [813286, 18755393])
642
+ expect(list).to be_a Twitter::List
643
+ expect(list.name).to eq "presidents"
644
+ end
645
+ end
646
+ context "with a combination of member IDs and member screen names to add" do
647
+ before do
648
+ 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"})
649
+ end
650
+ it "requests the correct resource" do
651
+ @client.list_remove_members('sferik', 'presidents', [813286, 'pengwynn', 18755393, 'erebor'])
652
+ 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
653
+ end
654
+ end
655
+ context "without a screen name passed" do
656
+ before do
657
+ stub_get("/1.1/account/verify_credentials.json").to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
658
+ 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"})
659
+ end
660
+ it "requests the correct resource" do
661
+ @client.list_remove_members("presidents", [813286, 18755393])
662
+ 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
663
+ end
664
+ end
665
+ end
666
+
667
667
  end
@@ -1,6 +1,6 @@
1
1
  require 'helper'
2
2
 
3
- describe Twitter::API do
3
+ describe Twitter::API::SavedSearches do
4
4
 
5
5
  before do
6
6
  @client = Twitter::Client.new
@@ -1,6 +1,6 @@
1
1
  require 'helper'
2
2
 
3
- describe Twitter::API do
3
+ describe Twitter::API::Search do
4
4
 
5
5
  before do
6
6
  @client = Twitter::Client.new
@@ -39,20 +39,4 @@ describe Twitter::API do
39
39
  end
40
40
  end
41
41
 
42
- describe "#phoenix_search" do
43
- before do
44
- stub_get("/phoenix_search.phoenix").with(:query => {:q => "twitter"}).to_return(:body => fixture("phoenix_search.phoenix"), :headers => {:content_type => "application/json; charset=utf-8"})
45
- end
46
- it "requests the correct resource" do
47
- @client.phoenix_search('twitter')
48
- expect(a_get("/phoenix_search.phoenix").with(:query => {:q => "twitter"})).to have_been_made
49
- end
50
- it "returns recent Tweets related to a query with images and videos embedded" do
51
- search = @client.phoenix_search('twitter')
52
- expect(search).to be_an Array
53
- expect(search.first).to be_a Twitter::Tweet
54
- expect(search.first.text).to eq "looking at twitter trends just makes me realize how little i really understand about mankind."
55
- end
56
- end
57
-
58
42
  end
@@ -1,6 +1,6 @@
1
1
  require 'helper'
2
2
 
3
- describe Twitter::API do
3
+ describe Twitter::API::SpamReporting do
4
4
 
5
5
  before do
6
6
  @client = Twitter::Client.new
@@ -0,0 +1,94 @@
1
+ require 'helper'
2
+
3
+ describe Twitter::API::SuggestedUsers do
4
+
5
+ before do
6
+ @client = Twitter::Client.new
7
+ end
8
+
9
+ describe "#suggestions" do
10
+ context "with a category slug passed" do
11
+ before do
12
+ stub_get("/1.1/users/suggestions/art-design.json").to_return(:body => fixture("category.json"), :headers => {:content_type => "application/json; charset=utf-8"})
13
+ end
14
+ it "requests the correct resource" do
15
+ @client.suggestions("art-design")
16
+ expect(a_get("/1.1/users/suggestions/art-design.json")).to have_been_made
17
+ end
18
+ it "returns the users in a given category of the Twitter suggested user list" do
19
+ suggestion = @client.suggestions("art-design")
20
+ expect(suggestion).to be_a Twitter::Suggestion
21
+ expect(suggestion.name).to eq "Art & Design"
22
+ expect(suggestion.users).to be_an Array
23
+ expect(suggestion.users.first).to be_a Twitter::User
24
+ end
25
+ end
26
+ context "without arguments passed" do
27
+ before do
28
+ stub_get("/1.1/users/suggestions.json").to_return(:body => fixture("suggestions.json"), :headers => {:content_type => "application/json; charset=utf-8"})
29
+ end
30
+ it "requests the correct resource" do
31
+ @client.suggestions
32
+ expect(a_get("/1.1/users/suggestions.json")).to have_been_made
33
+ end
34
+ it "returns the list of suggested user categories" do
35
+ suggestions = @client.suggestions
36
+ expect(suggestions).to be_an Array
37
+ expect(suggestions.first).to be_a Twitter::Suggestion
38
+ expect(suggestions.first.name).to eq "Art & Design"
39
+ end
40
+ end
41
+ end
42
+
43
+ describe "#suggest_users" do
44
+ before do
45
+ stub_get("/1.1/users/suggestions/art-design/members.json").to_return(:body => fixture("members.json"), :headers => {:content_type => "application/json; charset=utf-8"})
46
+ end
47
+ it "requests the correct resource" do
48
+ @client.suggest_users("art-design")
49
+ expect(a_get("/1.1/users/suggestions/art-design/members.json")).to have_been_made
50
+ end
51
+ it "returns users in a given category of the Twitter suggested user list and return their most recent status if they are not a protected user" do
52
+ suggest_users = @client.suggest_users("art-design")
53
+ expect(suggest_users).to be_an Array
54
+ expect(suggest_users.first).to be_a Twitter::User
55
+ expect(suggest_users.first.name).to eq "OMGFacts"
56
+ end
57
+ end
58
+
59
+ describe "#following_followers_of" do
60
+ context "with a screen_name passed" do
61
+ before do
62
+ stub_get("/users/following_followers_of.json").with(:query => {:cursor => "-1", :screen_name => "sferik"}).to_return(:body => fixture("users_list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
63
+ end
64
+ it "requests the correct resource" do
65
+ @client.following_followers_of("sferik")
66
+ expect(a_get("/users/following_followers_of.json").with(:query => {:cursor => "-1", :screen_name => "sferik"})).to have_been_made
67
+ end
68
+ it "returns an array of numeric IDs for every user following the specified user" do
69
+ following_followers_of = @client.following_followers_of("sferik")
70
+ expect(following_followers_of).to be_a Twitter::Cursor
71
+ expect(following_followers_of.users).to be_an Array
72
+ expect(following_followers_of.users.first).to be_a Twitter::User
73
+ end
74
+ end
75
+ context "without arguments passed" do
76
+ before do
77
+ stub_get("/1.1/account/verify_credentials.json").to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
78
+ stub_get("/users/following_followers_of.json").with(:query => {:cursor => "-1", :screen_name => "sferik"}).to_return(:body => fixture("users_list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
79
+ end
80
+ it "requests the correct resource" do
81
+ @client.following_followers_of
82
+ expect(a_get("/1.1/account/verify_credentials.json")).to have_been_made
83
+ expect(a_get("/users/following_followers_of.json").with(:query => {:cursor => "-1", :screen_name => "sferik"})).to have_been_made
84
+ end
85
+ it "returns an array of numeric IDs for every user following the specified user" do
86
+ following_followers_of = @client.following_followers_of
87
+ expect(following_followers_of).to be_a Twitter::Cursor
88
+ expect(following_followers_of.users).to be_an Array
89
+ expect(following_followers_of.users.first).to be_a Twitter::User
90
+ end
91
+ end
92
+ end
93
+
94
+ end
@@ -0,0 +1,138 @@
1
+ require 'helper'
2
+
3
+ describe Twitter::API::Timelines do
4
+
5
+ before do
6
+ @client = Twitter::Client.new
7
+ end
8
+
9
+ describe "#mentions_timeline" do
10
+ before do
11
+ stub_get("/1.1/statuses/mentions_timeline.json").to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
12
+ end
13
+ it "requests the correct resource" do
14
+ @client.mentions_timeline
15
+ expect(a_get("/1.1/statuses/mentions_timeline.json")).to have_been_made
16
+ end
17
+ it "returns the 20 most recent mentions (status containing @username) for the authenticating user" do
18
+ tweets = @client.mentions_timeline
19
+ expect(tweets).to be_an Array
20
+ expect(tweets.first).to be_a Twitter::Tweet
21
+ expect(tweets.first.text).to eq "Happy Birthday @imdane. Watch out for those @rally pranksters!"
22
+ end
23
+ end
24
+
25
+ describe "#user_timeline" do
26
+ context "with a screen name passed" do
27
+ before do
28
+ 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"})
29
+ end
30
+ it "requests the correct resource" do
31
+ @client.user_timeline("sferik")
32
+ expect(a_get("/1.1/statuses/user_timeline.json").with(:query => {:screen_name => "sferik"})).to have_been_made
33
+ end
34
+ it "returns the 20 most recent Tweets posted by the user specified by screen name or user id" do
35
+ tweets = @client.user_timeline("sferik")
36
+ expect(tweets).to be_an Array
37
+ expect(tweets.first).to be_a Twitter::Tweet
38
+ expect(tweets.first.text).to eq "Happy Birthday @imdane. Watch out for those @rally pranksters!"
39
+ end
40
+ end
41
+ context "without a screen name passed" do
42
+ before do
43
+ stub_get("/1.1/statuses/user_timeline.json").to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
44
+ end
45
+ it "requests the correct resource" do
46
+ @client.user_timeline
47
+ expect(a_get("/1.1/statuses/user_timeline.json")).to have_been_made
48
+ end
49
+ end
50
+ end
51
+
52
+ describe "#retweeted_by_user" do
53
+ before do
54
+ 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"})
55
+ 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"})
56
+ end
57
+ it "requests the correct resource" do
58
+ @client.retweeted_by_user("sferik")
59
+ expect(a_get("/1.1/statuses/user_timeline.json").with(:query => {:include_rts => "true", :screen_name => "sferik", :count => "200"})).to have_been_made
60
+ 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)
61
+ end
62
+ it "returns the 20 most recent retweets posted by the authenticating user" do
63
+ tweets = @client.retweeted_by_user("sferik")
64
+ expect(tweets).to be_an Array
65
+ expect(tweets.first).to be_a Twitter::Tweet
66
+ expect(tweets.first.text).to eq "RT @olivercameron: Mosaic looks cool: http://t.co/A8013C9k"
67
+ end
68
+ end
69
+
70
+ describe "#retweeted_by_me" do
71
+ before do
72
+ 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"})
73
+ 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"})
74
+ end
75
+ it "requests the correct resource" do
76
+ @client.retweeted_by_me
77
+ expect(a_get("/1.1/statuses/user_timeline.json").with(:query => {:include_rts => "true", :count => "200"})).to have_been_made
78
+ 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)
79
+ end
80
+ it "returns the 20 most recent retweets posted by the authenticating user" do
81
+ tweets = @client.retweeted_by_me
82
+ expect(tweets).to be_an Array
83
+ expect(tweets.first).to be_a Twitter::Tweet
84
+ expect(tweets.first.text).to eq "RT @olivercameron: Mosaic looks cool: http://t.co/A8013C9k"
85
+ end
86
+ end
87
+
88
+ describe "#home_timeline" do
89
+ before do
90
+ stub_get("/1.1/statuses/home_timeline.json").to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
91
+ end
92
+ it "requests the correct resource" do
93
+ @client.home_timeline
94
+ expect(a_get("/1.1/statuses/home_timeline.json")).to have_been_made
95
+ end
96
+ it "returns the 20 most recent Tweets, including retweets if they exist, posted by the authenticating user and the user's they follow" do
97
+ tweets = @client.home_timeline
98
+ expect(tweets).to be_an Array
99
+ expect(tweets.first).to be_a Twitter::Tweet
100
+ expect(tweets.first.text).to eq "Happy Birthday @imdane. Watch out for those @rally pranksters!"
101
+ end
102
+ end
103
+
104
+ describe "#retweeted_to_me" do
105
+ before do
106
+ 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"})
107
+ 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"})
108
+ end
109
+ it "requests the correct resource" do
110
+ @client.retweeted_to_me
111
+ expect(stub_get("/1.1/statuses/home_timeline.json").with(:query => {:include_rts => "true", :count => "200"})).to have_been_made
112
+ 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)
113
+ end
114
+ it "returns the 20 most recent retweets posted by users the authenticating user follow" do
115
+ tweets = @client.retweeted_to_me
116
+ expect(tweets).to be_an Array
117
+ expect(tweets.first).to be_a Twitter::Tweet
118
+ expect(tweets.first.text).to eq "RT @olivercameron: Mosaic looks cool: http://t.co/A8013C9k"
119
+ end
120
+ end
121
+
122
+ describe "#retweets_of_me" do
123
+ before do
124
+ stub_get("/1.1/statuses/retweets_of_me.json").to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
125
+ end
126
+ it "requests the correct resource" do
127
+ @client.retweets_of_me
128
+ expect(a_get("/1.1/statuses/retweets_of_me.json")).to have_been_made
129
+ end
130
+ it "returns the 20 most recent tweets of the authenticated user that have been retweeted by others" do
131
+ tweets = @client.retweets_of_me
132
+ expect(tweets).to be_an Array
133
+ expect(tweets.first).to be_a Twitter::Tweet
134
+ expect(tweets.first.text).to eq "Happy Birthday @imdane. Watch out for those @rally pranksters!"
135
+ end
136
+ end
137
+
138
+ end