twitter 5.11.0 → 5.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (178) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +11 -1
  3. data/README.md +7 -5
  4. data/lib/twitter/arguments.rb +1 -0
  5. data/lib/twitter/base.rb +4 -5
  6. data/lib/twitter/basic_user.rb +1 -0
  7. data/lib/twitter/client.rb +10 -9
  8. data/lib/twitter/configuration.rb +4 -2
  9. data/lib/twitter/cursor.rb +3 -2
  10. data/lib/twitter/direct_message.rb +1 -0
  11. data/lib/twitter/entity.rb +1 -0
  12. data/lib/twitter/entity/hashtag.rb +1 -0
  13. data/lib/twitter/entity/symbol.rb +1 -0
  14. data/lib/twitter/entity/user_mention.rb +4 -1
  15. data/lib/twitter/error.rb +22 -19
  16. data/lib/twitter/geo.rb +1 -0
  17. data/lib/twitter/geo_results.rb +3 -2
  18. data/lib/twitter/identity.rb +1 -0
  19. data/lib/twitter/language.rb +1 -0
  20. data/lib/twitter/list.rb +12 -5
  21. data/lib/twitter/media/photo.rb +1 -0
  22. data/lib/twitter/metadata.rb +1 -0
  23. data/lib/twitter/null_object.rb +22 -0
  24. data/lib/twitter/oembed.rb +5 -2
  25. data/lib/twitter/place.rb +4 -1
  26. data/lib/twitter/profile.rb +1 -1
  27. data/lib/twitter/rest/client.rb +4 -4
  28. data/lib/twitter/rest/favorites.rb +4 -3
  29. data/lib/twitter/rest/lists.rb +18 -3
  30. data/lib/twitter/rest/request/multipart_with_file.rb +1 -1
  31. data/lib/twitter/rest/response/parse_json.rb +1 -1
  32. data/lib/twitter/rest/response/raise_error.rb +4 -5
  33. data/lib/twitter/rest/tweets.rb +2 -1
  34. data/lib/twitter/rest/users.rb +10 -7
  35. data/lib/twitter/saved_search.rb +1 -0
  36. data/lib/twitter/search_results.rb +3 -2
  37. data/lib/twitter/settings.rb +7 -3
  38. data/lib/twitter/size.rb +4 -1
  39. data/lib/twitter/streaming/deleted_tweet.rb +1 -0
  40. data/lib/twitter/streaming/event.rb +2 -2
  41. data/lib/twitter/streaming/message_parser.rb +1 -1
  42. data/lib/twitter/suggestion.rb +4 -1
  43. data/lib/twitter/token.rb +1 -0
  44. data/lib/twitter/trend.rb +1 -0
  45. data/lib/twitter/trend_results.rb +3 -2
  46. data/lib/twitter/tweet.rb +9 -6
  47. data/lib/twitter/user.rb +15 -13
  48. data/lib/twitter/utils.rb +2 -6
  49. data/lib/twitter/version.rb +1 -1
  50. data/twitter.gemspec +6 -9
  51. metadata +6 -259
  52. data/Rakefile +0 -37
  53. data/spec/fixtures/already_favorited.json +0 -1
  54. data/spec/fixtures/already_posted.json +0 -1
  55. data/spec/fixtures/already_retweeted.json +0 -1
  56. data/spec/fixtures/bearer_token.json +0 -1
  57. data/spec/fixtures/category.json +0 -1
  58. data/spec/fixtures/configuration.json +0 -1
  59. data/spec/fixtures/contributees.json +0 -1
  60. data/spec/fixtures/count.json +0 -1
  61. data/spec/fixtures/direct_message.json +0 -1
  62. data/spec/fixtures/direct_messages.json +0 -1
  63. data/spec/fixtures/empty.json +0 -0
  64. data/spec/fixtures/followers_list.json +0 -1
  65. data/spec/fixtures/followers_list2.json +0 -1
  66. data/spec/fixtures/following.json +0 -1
  67. data/spec/fixtures/forbidden.json +0 -1
  68. data/spec/fixtures/friends_list.json +0 -1
  69. data/spec/fixtures/friends_list2.json +0 -1
  70. data/spec/fixtures/friendships.json +0 -1
  71. data/spec/fixtures/ids.json +0 -1
  72. data/spec/fixtures/ids_list.json +0 -1
  73. data/spec/fixtures/ids_list2.json +0 -1
  74. data/spec/fixtures/languages.json +0 -1
  75. data/spec/fixtures/list.json +0 -1
  76. data/spec/fixtures/lists.json +0 -1
  77. data/spec/fixtures/locations.json +0 -1
  78. data/spec/fixtures/matching_trends.json +0 -1
  79. data/spec/fixtures/me.jpeg +0 -0
  80. data/spec/fixtures/members.json +0 -1
  81. data/spec/fixtures/memberships.json +0 -1
  82. data/spec/fixtures/memberships2.json +0 -1
  83. data/spec/fixtures/not_following.json +0 -1
  84. data/spec/fixtures/not_found.json +0 -1
  85. data/spec/fixtures/oembed.json +0 -1
  86. data/spec/fixtures/ownerships.json +0 -1
  87. data/spec/fixtures/pbjt.gif +0 -0
  88. data/spec/fixtures/pengwynn.json +0 -1
  89. data/spec/fixtures/place.json +0 -1
  90. data/spec/fixtures/places.json +0 -1
  91. data/spec/fixtures/privacy.json +0 -1
  92. data/spec/fixtures/profile_banner.json +0 -1
  93. data/spec/fixtures/request_token.txt +0 -6
  94. data/spec/fixtures/retweet.json +0 -1
  95. data/spec/fixtures/retweets.json +0 -1
  96. data/spec/fixtures/saved_search.json +0 -1
  97. data/spec/fixtures/saved_searches.json +0 -1
  98. data/spec/fixtures/search.json +0 -1
  99. data/spec/fixtures/search2.json +0 -1
  100. data/spec/fixtures/search_malformed.json +0 -1
  101. data/spec/fixtures/settings.json +0 -1
  102. data/spec/fixtures/sferik.json +0 -1
  103. data/spec/fixtures/status.json +0 -1
  104. data/spec/fixtures/statuses.json +0 -1
  105. data/spec/fixtures/subscriptions.json +0 -1
  106. data/spec/fixtures/subscriptions2.json +0 -1
  107. data/spec/fixtures/suggestions.json +0 -1
  108. data/spec/fixtures/tos.json +0 -1
  109. data/spec/fixtures/track_streaming.json +0 -3
  110. data/spec/fixtures/track_streaming_user.json +0 -6
  111. data/spec/fixtures/upload.json +0 -1
  112. data/spec/fixtures/user_search.json +0 -1
  113. data/spec/fixtures/user_timeline.json +0 -1
  114. data/spec/fixtures/users.json +0 -1
  115. data/spec/fixtures/users_list.json +0 -1
  116. data/spec/fixtures/users_list2.json +0 -1
  117. data/spec/fixtures/we_concept_bg2.png +0 -0
  118. data/spec/fixtures/wildcomet2.jpe +0 -0
  119. data/spec/helper.rb +0 -68
  120. data/spec/twitter/base_spec.rb +0 -39
  121. data/spec/twitter/basic_user_spec.rb +0 -23
  122. data/spec/twitter/configuration_spec.rb +0 -17
  123. data/spec/twitter/cursor_spec.rb +0 -30
  124. data/spec/twitter/direct_message_spec.rb +0 -232
  125. data/spec/twitter/entity/uri_spec.rb +0 -75
  126. data/spec/twitter/error_spec.rb +0 -52
  127. data/spec/twitter/geo/point_spec.rb +0 -41
  128. data/spec/twitter/geo/polygon_spec.rb +0 -29
  129. data/spec/twitter/geo_factory_spec.rb +0 -19
  130. data/spec/twitter/geo_results_spec.rb +0 -35
  131. data/spec/twitter/geo_spec.rb +0 -29
  132. data/spec/twitter/identifiable_spec.rb +0 -29
  133. data/spec/twitter/list_spec.rb +0 -88
  134. data/spec/twitter/media/photo_spec.rb +0 -151
  135. data/spec/twitter/media_factory_spec.rb +0 -15
  136. data/spec/twitter/oembed_spec.rb +0 -170
  137. data/spec/twitter/place_spec.rb +0 -168
  138. data/spec/twitter/profile_banner_spec.rb +0 -13
  139. data/spec/twitter/rate_limit_spec.rb +0 -59
  140. data/spec/twitter/relationship_spec.rb +0 -49
  141. data/spec/twitter/rest/client_spec.rb +0 -217
  142. data/spec/twitter/rest/direct_messages_spec.rb +0 -133
  143. data/spec/twitter/rest/favorites_spec.rb +0 -188
  144. data/spec/twitter/rest/friends_and_followers_spec.rb +0 -667
  145. data/spec/twitter/rest/geo_spec.rb +0 -68
  146. data/spec/twitter/rest/help_spec.rb +0 -68
  147. data/spec/twitter/rest/lists_spec.rb +0 -910
  148. data/spec/twitter/rest/media_spec.rb +0 -54
  149. data/spec/twitter/rest/oauth_spec.rb +0 -63
  150. data/spec/twitter/rest/saved_searches_spec.rb +0 -98
  151. data/spec/twitter/rest/search_spec.rb +0 -42
  152. data/spec/twitter/rest/spam_reporting_spec.rb +0 -25
  153. data/spec/twitter/rest/suggested_users_spec.rb +0 -59
  154. data/spec/twitter/rest/timelines_spec.rb +0 -138
  155. data/spec/twitter/rest/trends_spec.rb +0 -68
  156. data/spec/twitter/rest/tweets_spec.rb +0 -614
  157. data/spec/twitter/rest/undocumented_spec.rb +0 -103
  158. data/spec/twitter/rest/users_spec.rb +0 -797
  159. data/spec/twitter/saved_search_spec.rb +0 -45
  160. data/spec/twitter/search_results_spec.rb +0 -30
  161. data/spec/twitter/settings_spec.rb +0 -27
  162. data/spec/twitter/size_spec.rb +0 -28
  163. data/spec/twitter/source_user_spec.rb +0 -23
  164. data/spec/twitter/streaming/client_spec.rb +0 -123
  165. data/spec/twitter/streaming/connection_spec.rb +0 -32
  166. data/spec/twitter/streaming/deleted_tweet_spec.rb +0 -23
  167. data/spec/twitter/streaming/event_spec.rb +0 -43
  168. data/spec/twitter/streaming/friend_list_spec.rb +0 -11
  169. data/spec/twitter/streaming/message_parser_spec.rb +0 -54
  170. data/spec/twitter/streaming/response_spec.rb +0 -21
  171. data/spec/twitter/suggestion_spec.rb +0 -40
  172. data/spec/twitter/target_user_spec.rb +0 -23
  173. data/spec/twitter/token_spec.rb +0 -16
  174. data/spec/twitter/trend_results_spec.rb +0 -89
  175. data/spec/twitter/trend_spec.rb +0 -51
  176. data/spec/twitter/tweet_spec.rb +0 -456
  177. data/spec/twitter/user_spec.rb +0 -447
  178. data/spec/twitter/utils_spec.rb +0 -34
@@ -1,54 +0,0 @@
1
- require 'helper'
2
-
3
- describe Twitter::REST::Media do
4
- before do
5
- @client = Twitter::REST::Client.new(:consumer_key => 'CK', :consumer_secret => 'CS', :access_token => 'AT', :access_token_secret => 'AS')
6
- end
7
-
8
- describe '#upload' do
9
- before do
10
- stub_request(:post, 'https://upload.twitter.com/1.1/media/upload.json').to_return(:body => fixture('upload.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
11
- end
12
- context 'a gif image' do
13
- it 'requests the correct resource' do
14
- @client.upload(fixture('pbjt.gif'))
15
- expect(a_request(:post, 'https://upload.twitter.com/1.1/media/upload.json')).to have_been_made
16
- end
17
- it 'returns an Integer' do
18
- media_id = @client.upload(fixture('pbjt.gif'))
19
- expect(a_request(:post, 'https://upload.twitter.com/1.1/media/upload.json')).to have_been_made
20
- expect(media_id).to be_an Integer
21
- expect(media_id).to eq(470_030_289_822_314_497)
22
- end
23
- end
24
- context 'a jpe image' do
25
- it 'requests the correct resource' do
26
- @client.upload(fixture('wildcomet2.jpe'))
27
- expect(a_request(:post, 'https://upload.twitter.com/1.1/media/upload.json')).to have_been_made
28
- end
29
- end
30
- context 'a jpeg image' do
31
- it 'requests the correct resource' do
32
- @client.upload(fixture('me.jpeg'))
33
- expect(a_request(:post, 'https://upload.twitter.com/1.1/media/upload.json')).to have_been_made
34
- end
35
- end
36
- context 'a png image' do
37
- it 'requests the correct resource' do
38
- @client.upload(fixture('we_concept_bg2.png'))
39
- expect(a_request(:post, 'https://upload.twitter.com/1.1/media/upload.json')).to have_been_made
40
- end
41
- end
42
- context 'a Tempfile' do
43
- it 'requests the correct resource' do
44
- @client.upload(Tempfile.new('tmp'))
45
- expect(a_request(:post, 'https://upload.twitter.com/1.1/media/upload.json')).to have_been_made
46
- end
47
- end
48
- context 'A non IO object' do
49
- it 'raises an error' do
50
- expect { @client.upload('Unacceptable IO') }.to raise_error(Twitter::Error::UnacceptableIO)
51
- end
52
- end
53
- end
54
- end
@@ -1,63 +0,0 @@
1
- require 'helper'
2
-
3
- describe Twitter::REST::OAuth do
4
-
5
- before do
6
- @client = Twitter::REST::Client.new(:consumer_key => 'CK', :consumer_secret => 'CS')
7
- end
8
-
9
- describe '#token' do
10
- before do
11
- # Faraday treats Basic Auth differently so we have to use the full URL with credentials
12
- @oauth2_token_url = 'https://CK:CS@api.twitter.com/oauth2/token'
13
- stub_request(:post, @oauth2_token_url).with(:body => {'grant_type' => 'client_credentials'}).to_return(:body => fixture('bearer_token.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
14
- end
15
- it 'requests the correct resource' do
16
- @client.token
17
- expect(a_request(:post, @oauth2_token_url).with(:body => {:grant_type => 'client_credentials'}, :headers => {:content_type => 'application/x-www-form-urlencoded; charset=UTF-8', :accept => '*/*'})).to have_been_made
18
- end
19
- it 'returns the bearer token' do
20
- bearer_token = @client.token
21
- expect(bearer_token.access_token).to eq('AAAA%2FAAA%3DAAAAAAAA')
22
- expect(bearer_token.token_type).to eq('bearer')
23
- end
24
- end
25
-
26
- describe '#invalidate_token' do
27
- before do
28
- stub_post('/oauth2/invalidate_token').with(:body => {:access_token => 'AAAA%2FAAA%3DAAAAAAAA'}).to_return(:body => '{"access_token":"AAAA%2FAAA%3DAAAAAAAA"}', :headers => {:content_type => 'application/json; charset=utf-8'})
29
- @client.bearer_token = 'AAAA%2FAAA%3DAAAAAAAA'
30
- end
31
- it 'requests the correct resource' do
32
- @client.invalidate_token('AAAA%2FAAA%3DAAAAAAAA')
33
- expect(a_post('/oauth2/invalidate_token').with(:body => {:access_token => 'AAAA%2FAAA%3DAAAAAAAA'})).to have_been_made
34
- end
35
- it 'returns the invalidated token' do
36
- token = @client.invalidate_token('AAAA%2FAAA%3DAAAAAAAA')
37
- expect(token.access_token).to eq('AAAA%2FAAA%3DAAAAAAAA')
38
- expect(token.token_type).to be_nil
39
- end
40
- context 'with a token' do
41
- it 'requests the correct resource' do
42
- token = Twitter::Token.new(:access_token => 'AAAA%2FAAA%3DAAAAAAAA')
43
- @client.invalidate_token(token)
44
- expect(a_post('/oauth2/invalidate_token').with(:body => {:access_token => 'AAAA%2FAAA%3DAAAAAAAA'})).to have_been_made
45
- end
46
- end
47
- end
48
-
49
- describe '#reverse_token' do
50
- before do
51
- # WebMock treats Basic Auth differently so we have to chack against the full URL with credentials.
52
- @oauth_request_token_url = 'https://api.twitter.com/oauth/request_token?x_auth_mode=reverse_auth'
53
- stub_request(:post, @oauth_request_token_url).to_return(:body => fixture('request_token.txt'), :headers => {:content_type => 'text/html; charset=utf-8'})
54
- end
55
- it 'requests the correct resource' do
56
- @client.reverse_token
57
- expect(a_request(:post, @oauth_request_token_url).with(:params => {:x_auth_mode => 'reverse_auth'})).to have_been_made
58
- end
59
- it 'requests the correct resource' do
60
- expect(@client.reverse_token).to eql fixture('request_token.txt').read
61
- end
62
- end
63
- end
@@ -1,98 +0,0 @@
1
- require 'helper'
2
-
3
- describe Twitter::REST::SavedSearches do
4
-
5
- before do
6
- @client = Twitter::REST::Client.new(:consumer_key => 'CK', :consumer_secret => 'CS', :access_token => 'AT', :access_token_secret => 'AS')
7
- end
8
-
9
- describe '#saved_searches' do
10
- context 'with ids passed' do
11
- before do
12
- stub_get('/1.1/saved_searches/show/16129012.json').to_return(:body => fixture('saved_search.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
13
- stub_get('/1.1/saved_searches/show/16129013.json').to_return(:body => fixture('saved_search.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
14
- end
15
- it 'requests the correct resource' do
16
- @client.saved_searches(16_129_012, 16_129_013)
17
- expect(a_get('/1.1/saved_searches/show/16129012.json')).to have_been_made
18
- expect(a_get('/1.1/saved_searches/show/16129013.json')).to have_been_made
19
- end
20
- it 'returns an array of saved searches' do
21
- saved_searches = @client.saved_searches(16_129_012, 16_129_013)
22
- expect(saved_searches).to be_an Array
23
- expect(saved_searches.size).to eq(2)
24
- expect(saved_searches.first).to be_a Twitter::SavedSearch
25
- expect(saved_searches.first.name).to eq('twitter')
26
- expect(saved_searches.last).to be_a Twitter::SavedSearch
27
- expect(saved_searches.last.name).to eq('twitter')
28
- end
29
- end
30
- context 'without ids passed' do
31
- before do
32
- stub_get('/1.1/saved_searches/list.json').to_return(:body => fixture('saved_searches.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
33
- end
34
- it 'requests the correct resource' do
35
- @client.saved_searches
36
- expect(a_get('/1.1/saved_searches/list.json')).to have_been_made
37
- end
38
- it 'returns the saved search queries for the authenticated user' do
39
- saved_searches = @client.saved_searches
40
- expect(saved_searches).to be_an Array
41
- expect(saved_searches.first).to be_a Twitter::SavedSearch
42
- expect(saved_searches.first.name).to eq('twitter')
43
- end
44
- end
45
- end
46
-
47
- describe '#saved_search' do
48
- before do
49
- stub_get('/1.1/saved_searches/show/16129012.json').to_return(:body => fixture('saved_search.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
50
- end
51
- it 'requests the correct resource' do
52
- @client.saved_search(16_129_012)
53
- expect(a_get('/1.1/saved_searches/show/16129012.json')).to have_been_made
54
- end
55
- it 'returns a saved search' do
56
- saved_search = @client.saved_search(16_129_012)
57
- expect(saved_search).to be_a Twitter::SavedSearch
58
- expect(saved_search.name).to eq('twitter')
59
- end
60
- end
61
-
62
- describe '#create_saved_search' do
63
- before do
64
- stub_post('/1.1/saved_searches/create.json').with(:body => {:query => 'twitter'}).to_return(:body => fixture('saved_search.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
65
- end
66
- it 'requests the correct resource' do
67
- @client.create_saved_search('twitter')
68
- expect(a_post('/1.1/saved_searches/create.json').with(:body => {:query => 'twitter'})).to have_been_made
69
- end
70
- it 'returns the created saved search' do
71
- saved_search = @client.create_saved_search('twitter')
72
- expect(saved_search).to be_a Twitter::SavedSearch
73
- expect(saved_search.name).to eq('twitter')
74
- end
75
- end
76
-
77
- describe '#destroy_saved_search' do
78
- before do
79
- stub_post('/1.1/saved_searches/destroy/16129012.json').to_return(:body => fixture('saved_search.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
80
- stub_post('/1.1/saved_searches/destroy/16129013.json').to_return(:body => fixture('saved_search.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
81
- end
82
- it 'requests the correct resource' do
83
- @client.destroy_saved_search(16_129_012, 16_129_013)
84
- expect(a_post('/1.1/saved_searches/destroy/16129012.json')).to have_been_made
85
- expect(a_post('/1.1/saved_searches/destroy/16129013.json')).to have_been_made
86
- end
87
- it 'returns an array of deleted saved searches' do
88
- saved_searches = @client.destroy_saved_search(16_129_012, 16_129_013)
89
- expect(saved_searches).to be_an Array
90
- expect(saved_searches.size).to eq(2)
91
- expect(saved_searches.first).to be_a Twitter::SavedSearch
92
- expect(saved_searches.first.name).to eq('twitter')
93
- expect(saved_searches.last).to be_a Twitter::SavedSearch
94
- expect(saved_searches.last.name).to eq('twitter')
95
- end
96
- end
97
-
98
- end
@@ -1,42 +0,0 @@
1
- require 'helper'
2
-
3
- describe Twitter::REST::Search do
4
-
5
- before do
6
- @client = Twitter::REST::Client.new(:consumer_key => 'CK', :consumer_secret => 'CS', :access_token => 'AT', :access_token_secret => 'AS')
7
- end
8
-
9
- describe '#search' do
10
- context 'without count specified' do
11
- before do
12
- stub_get('/1.1/search/tweets.json').with(:query => {:q => '#freebandnames', :count => '100'}).to_return(:body => fixture('search.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
13
- end
14
- it 'requests the correct resource' do
15
- @client.search('#freebandnames')
16
- expect(a_get('/1.1/search/tweets.json').with(:query => {:q => '#freebandnames', :count => '100'})).to have_been_made
17
- end
18
- it 'returns recent Tweets related to a query with images and videos embedded' do
19
- search = @client.search('#freebandnames')
20
- expect(search).to be_a Twitter::SearchResults
21
- expect(search.first).to be_a Twitter::Tweet
22
- expect(search.first.text).to eq('@Just_Reboot #FreeBandNames mono surround')
23
- end
24
- end
25
- context 'with count specified' do
26
- before do
27
- stub_get('/1.1/search/tweets.json').with(:query => {:q => '#freebandnames', :count => '3'}).to_return(:body => fixture('search.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
28
- end
29
- it 'requests the correct resource' do
30
- @client.search('#freebandnames', :count => 3)
31
- expect(a_get('/1.1/search/tweets.json').with(:query => {:q => '#freebandnames', :count => '3'})).to have_been_made
32
- end
33
- it 'returns recent Tweets related to a query with images and videos embedded' do
34
- search = @client.search('#freebandnames', :count => 3)
35
- expect(search).to be_a Twitter::SearchResults
36
- expect(search.first).to be_a Twitter::Tweet
37
- expect(search.first.text).to eq('@Just_Reboot #FreeBandNames mono surround')
38
- end
39
- end
40
- end
41
-
42
- end
@@ -1,25 +0,0 @@
1
- require 'helper'
2
-
3
- describe Twitter::REST::SpamReporting do
4
-
5
- before do
6
- @client = Twitter::REST::Client.new(:consumer_key => 'CK', :consumer_secret => 'CS', :access_token => 'AT', :access_token_secret => 'AS')
7
- end
8
-
9
- describe '#report_spam' do
10
- before do
11
- stub_post('/1.1/users/report_spam.json').with(:body => {:screen_name => 'sferik'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
12
- end
13
- it 'requests the correct resource' do
14
- @client.report_spam('sferik')
15
- expect(a_post('/1.1/users/report_spam.json').with(:body => {:screen_name => 'sferik'})).to have_been_made
16
- end
17
- it 'returns an array of users' do
18
- users = @client.report_spam('sferik')
19
- expect(users).to be_an Array
20
- expect(users.first).to be_a Twitter::User
21
- expect(users.first.id).to eq(7_505_382)
22
- end
23
- end
24
-
25
- end
@@ -1,59 +0,0 @@
1
- require 'helper'
2
-
3
- describe Twitter::REST::SuggestedUsers do
4
-
5
- before do
6
- @client = Twitter::REST::Client.new(:consumer_key => 'CK', :consumer_secret => 'CS', :access_token => 'AT', :access_token_secret => 'AS')
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.id).to eq(13)
56
- end
57
- end
58
-
59
- end
@@ -1,138 +0,0 @@
1
- require 'helper'
2
-
3
- describe Twitter::REST::Timelines do
4
-
5
- before do
6
- @client = Twitter::REST::Client.new(:consumer_key => 'CK', :consumer_secret => 'CS', :access_token => 'AT', :access_token_secret => 'AS')
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 users 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(a_get('/1.1/statuses/home_timeline.json').with(:query => {:include_rts => 'true', :count => '200'})).to have_been_made
112
- expect(a_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