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,103 +0,0 @@
1
- require 'helper'
2
-
3
- describe Twitter::REST::Undocumented 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 '#following_followers_of' do
10
- context 'with a screen_name passed' do
11
- before do
12
- stub_get('/users/following_followers_of.json').with(:query => {:screen_name => 'sferik', :cursor => '-1'}).to_return(:body => fixture('users_list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
13
- end
14
- it 'requests the correct resource' do
15
- @client.following_followers_of('sferik')
16
- expect(a_get('/users/following_followers_of.json').with(:query => {:screen_name => 'sferik', :cursor => '-1'})).to have_been_made
17
- end
18
- it 'returns an array of numeric IDs for every user following the specified user' do
19
- following_followers_of = @client.following_followers_of('sferik')
20
- expect(following_followers_of).to be_a Twitter::Cursor
21
- expect(following_followers_of.first).to be_a Twitter::User
22
- end
23
- context 'with each' do
24
- before do
25
- stub_get('/users/following_followers_of.json').with(:query => {:screen_name => 'sferik', :cursor => '1322801608223717003'}).to_return(:body => fixture('users_list2.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
26
- end
27
- it 'requests the correct resource' do
28
- @client.following_followers_of('sferik').each {}
29
- expect(a_get('/users/following_followers_of.json').with(:query => {:screen_name => 'sferik', :cursor => '-1'})).to have_been_made
30
- expect(a_get('/users/following_followers_of.json').with(:query => {:screen_name => 'sferik', :cursor => '1322801608223717003'})).to have_been_made
31
- end
32
- end
33
- end
34
- context 'with a user ID passed' do
35
- before do
36
- stub_get('/users/following_followers_of.json').with(:query => {:user_id => '7505382', :cursor => '-1'}).to_return(:body => fixture('users_list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
37
- end
38
- it 'requests the correct resource' do
39
- @client.following_followers_of(7_505_382)
40
- expect(a_get('/users/following_followers_of.json').with(:query => {:user_id => '7505382', :cursor => '-1'})).to have_been_made
41
- end
42
- context 'with each' do
43
- before do
44
- stub_get('/users/following_followers_of.json').with(:query => {:user_id => '7505382', :cursor => '1322801608223717003'}).to_return(:body => fixture('users_list2.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
45
- end
46
- it 'requests the correct resource' do
47
- @client.following_followers_of(7_505_382).each {}
48
- expect(a_get('/users/following_followers_of.json').with(:query => {:user_id => '7505382', :cursor => '-1'})).to have_been_made
49
- expect(a_get('/users/following_followers_of.json').with(:query => {:user_id => '7505382', :cursor => '1322801608223717003'})).to have_been_made
50
- end
51
- end
52
- end
53
- context 'without arguments passed' do
54
- before do
55
- stub_get('/1.1/account/verify_credentials.json').with(:query => {:skip_status => 'true'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
56
- stub_get('/users/following_followers_of.json').with(:query => {:user_id => '7505382', :cursor => '-1'}).to_return(:body => fixture('users_list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
57
- end
58
- it 'requests the correct resource' do
59
- @client.following_followers_of
60
- expect(a_get('/1.1/account/verify_credentials.json').with(:query => {:skip_status => 'true'})).to have_been_made
61
- expect(a_get('/users/following_followers_of.json').with(:query => {:user_id => '7505382', :cursor => '-1'})).to have_been_made
62
- end
63
- it 'returns an array of numeric IDs for every user following the specified user' do
64
- following_followers_of = @client.following_followers_of
65
- expect(following_followers_of).to be_a Twitter::Cursor
66
- expect(following_followers_of.first).to be_a Twitter::User
67
- end
68
- context 'with each' do
69
- before do
70
- stub_get('/users/following_followers_of.json').with(:query => {:user_id => '7505382', :cursor => '1322801608223717003'}).to_return(:body => fixture('users_list2.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
71
- end
72
- it 'requests the correct resource' do
73
- @client.following_followers_of.each {}
74
- expect(a_get('/users/following_followers_of.json').with(:query => {:user_id => '7505382', :cursor => '-1'})).to have_been_made
75
- expect(a_get('/users/following_followers_of.json').with(:query => {:user_id => '7505382', :cursor => '1322801608223717003'})).to have_been_made
76
- end
77
- end
78
- end
79
- end
80
-
81
- describe '#tweet_count' do
82
- before do
83
- stub_request(:get, 'https://cdn.api.twitter.com/1/urls/count.json').with(:query => {:url => 'http://twitter.com'}).to_return(:body => fixture('count.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
84
- end
85
- it 'requests the correct resource' do
86
- @client.tweet_count('http://twitter.com')
87
- expect(a_request(:get, 'https://cdn.api.twitter.com/1/urls/count.json').with(:query => {:url => 'http://twitter.com'})).to have_been_made
88
- end
89
- it 'returns a Tweet count' do
90
- tweet_count = @client.tweet_count('http://twitter.com')
91
- expect(tweet_count).to be_an Integer
92
- expect(tweet_count).to eq(13_845_465)
93
- end
94
- context 'with a URI' do
95
- it 'requests the correct resource' do
96
- uri = URI.parse('http://twitter.com')
97
- @client.tweet_count(uri)
98
- expect(a_request(:get, 'https://cdn.api.twitter.com/1/urls/count.json').with(:query => {:url => 'http://twitter.com'})).to have_been_made
99
- end
100
- end
101
- end
102
-
103
- end
@@ -1,797 +0,0 @@
1
- require 'helper'
2
-
3
- describe Twitter::REST::Users 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 '#settings' do
10
- before do
11
- stub_get('/1.1/account/settings.json').to_return(:body => fixture('settings.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
12
- stub_post('/1.1/account/settings.json').with(:body => {:trend_location_woeid => '23424803'}).to_return(:body => fixture('settings.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
13
- end
14
- it 'requests the correct resource on GET' do
15
- @client.settings
16
- expect(a_get('/1.1/account/settings.json')).to have_been_made
17
- end
18
- it 'returns settings' do
19
- settings = @client.settings
20
- expect(settings).to be_a Twitter::Settings
21
- expect(settings.language).to eq('en')
22
- end
23
- it 'requests the correct resource on POST' do
24
- @client.settings(:trend_location_woeid => '23424803')
25
- expect(a_post('/1.1/account/settings.json').with(:body => {:trend_location_woeid => '23424803'})).to have_been_made
26
- end
27
- it 'returns settings' do
28
- settings = @client.settings(:trend_location_woeid => '23424803')
29
- expect(settings).to be_a Twitter::Settings
30
- expect(settings.language).to eq('en')
31
- end
32
- end
33
-
34
- describe '#verify_credentials' do
35
- before do
36
- stub_get('/1.1/account/verify_credentials.json').to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
37
- end
38
- it 'requests the correct resource' do
39
- @client.verify_credentials
40
- expect(a_get('/1.1/account/verify_credentials.json')).to have_been_made
41
- end
42
- it 'returns the requesting user' do
43
- user = @client.verify_credentials
44
- expect(user).to be_a Twitter::User
45
- expect(user.id).to eq(7_505_382)
46
- end
47
- end
48
-
49
- describe '#update_delivery_device' do
50
- before do
51
- stub_post('/1.1/account/update_delivery_device.json').with(:body => {:device => 'sms'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
52
- end
53
- it 'requests the correct resource' do
54
- @client.update_delivery_device('sms')
55
- expect(a_post('/1.1/account/update_delivery_device.json').with(:body => {:device => 'sms'})).to have_been_made
56
- end
57
- it 'returns a user' do
58
- user = @client.update_delivery_device('sms')
59
- expect(user).to be_a Twitter::User
60
- expect(user.id).to eq(7_505_382)
61
- end
62
- end
63
-
64
- describe '#update_profile' do
65
- before do
66
- stub_post('/1.1/account/update_profile.json').with(:body => {:url => 'http://github.com/sferik/'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
67
- end
68
- it 'requests the correct resource' do
69
- @client.update_profile(:url => 'http://github.com/sferik/')
70
- expect(a_post('/1.1/account/update_profile.json').with(:body => {:url => 'http://github.com/sferik/'})).to have_been_made
71
- end
72
- it 'returns a user' do
73
- user = @client.update_profile(:url => 'http://github.com/sferik/')
74
- expect(user).to be_a Twitter::User
75
- expect(user.id).to eq(7_505_382)
76
- end
77
- end
78
-
79
- describe '#update_profile_background_image' do
80
- before do
81
- stub_post('/1.1/account/update_profile_background_image.json').to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
82
- end
83
- it 'requests the correct resource' do
84
- @client.update_profile_background_image(fixture('we_concept_bg2.png'))
85
- expect(a_post('/1.1/account/update_profile_background_image.json')).to have_been_made
86
- end
87
- it 'returns a user' do
88
- user = @client.update_profile_background_image(fixture('we_concept_bg2.png'))
89
- expect(user).to be_a Twitter::User
90
- expect(user.id).to eq(7_505_382)
91
- end
92
- end
93
-
94
- describe '#update_profile_colors' do
95
- before do
96
- stub_post('/1.1/account/update_profile_colors.json').with(:body => {:profile_background_color => '000000'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
97
- end
98
- it 'requests the correct resource' do
99
- @client.update_profile_colors(:profile_background_color => '000000')
100
- expect(a_post('/1.1/account/update_profile_colors.json').with(:body => {:profile_background_color => '000000'})).to have_been_made
101
- end
102
- it 'returns a user' do
103
- user = @client.update_profile_colors(:profile_background_color => '000000')
104
- expect(user).to be_a Twitter::User
105
- expect(user.id).to eq(7_505_382)
106
- end
107
- end
108
-
109
- describe '#update_profile_image' do
110
- before do
111
- stub_post('/1.1/account/update_profile_image.json').to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
112
- end
113
- it 'requests the correct resource' do
114
- @client.update_profile_image(fixture('me.jpeg'))
115
- expect(a_post('/1.1/account/update_profile_image.json')).to have_been_made
116
- end
117
- it 'returns a user' do
118
- user = @client.update_profile_image(fixture('me.jpeg'))
119
- expect(user).to be_a Twitter::User
120
- expect(user.id).to eq(7_505_382)
121
- end
122
- end
123
-
124
- describe '#suggestions' do
125
- context 'with a category slug passed' do
126
- before do
127
- stub_get('/1.1/users/suggestions/art-design.json').to_return(:body => fixture('category.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
128
- end
129
- it 'requests the correct resource' do
130
- @client.suggestions('art-design')
131
- expect(a_get('/1.1/users/suggestions/art-design.json')).to have_been_made
132
- end
133
- it 'returns the users in a given category of the Twitter suggested user list' do
134
- suggestion = @client.suggestions('art-design')
135
- expect(suggestion).to be_a Twitter::Suggestion
136
- expect(suggestion.name).to eq('Art & Design')
137
- expect(suggestion.users).to be_an Array
138
- expect(suggestion.users.first).to be_a Twitter::User
139
- end
140
- end
141
- context 'without arguments passed' do
142
- before do
143
- stub_get('/1.1/users/suggestions.json').to_return(:body => fixture('suggestions.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
144
- end
145
- it 'requests the correct resource' do
146
- @client.suggestions
147
- expect(a_get('/1.1/users/suggestions.json')).to have_been_made
148
- end
149
- it 'returns the list of suggested user categories' do
150
- suggestions = @client.suggestions
151
- expect(suggestions).to be_an Array
152
- expect(suggestions.first).to be_a Twitter::Suggestion
153
- expect(suggestions.first.name).to eq('Art & Design')
154
- end
155
- end
156
- end
157
-
158
- describe '#suggest_users' do
159
- before do
160
- stub_get('/1.1/users/suggestions/art-design/members.json').to_return(:body => fixture('members.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
161
- end
162
- it 'requests the correct resource' do
163
- @client.suggest_users('art-design')
164
- expect(a_get('/1.1/users/suggestions/art-design/members.json')).to have_been_made
165
- end
166
- 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
167
- suggest_users = @client.suggest_users('art-design')
168
- expect(suggest_users).to be_an Array
169
- expect(suggest_users.first).to be_a Twitter::User
170
- expect(suggest_users.first.id).to eq(13)
171
- end
172
- end
173
-
174
- describe '#blocked' do
175
- before do
176
- stub_get('/1.1/blocks/list.json').with(:query => {:cursor => '-1'}).to_return(:body => fixture('users_list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
177
- end
178
- it 'requests the correct resource' do
179
- @client.blocked
180
- expect(a_get('/1.1/blocks/list.json').with(:query => {:cursor => '-1'})).to have_been_made
181
- end
182
- it 'returns an array of user objects that the authenticating user is blocking' do
183
- blocked = @client.blocked
184
- expect(blocked).to be_a Twitter::Cursor
185
- expect(blocked.first).to be_a Twitter::User
186
- expect(blocked.first.id).to eq(7_505_382)
187
- end
188
- context 'with each' do
189
- before do
190
- stub_get('/1.1/blocks/list.json').with(:query => {:cursor => '1322801608223717003'}).to_return(:body => fixture('users_list2.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
191
- end
192
- it 'requests the correct resource' do
193
- @client.blocked.each {}
194
- expect(a_get('/1.1/blocks/list.json').with(:query => {:cursor => '-1'})).to have_been_made
195
- expect(a_get('/1.1/blocks/list.json').with(:query => {:cursor => '1322801608223717003'})).to have_been_made
196
- end
197
- end
198
- end
199
-
200
- describe '#blocked_ids' do
201
- before do
202
- stub_get('/1.1/blocks/ids.json').with(:query => {:cursor => '-1'}).to_return(:body => fixture('ids_list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
203
- end
204
- it 'requests the correct resource' do
205
- @client.blocked_ids
206
- expect(a_get('/1.1/blocks/ids.json').with(:query => {:cursor => '-1'})).to have_been_made
207
- end
208
- it 'returns an array of numeric user IDs the authenticating user is blocking' do
209
- blocked_ids = @client.blocked_ids
210
- expect(blocked_ids).to be_a Twitter::Cursor
211
- expect(blocked_ids.first).to eq(20_009_713)
212
- end
213
- context 'with each' do
214
- before do
215
- stub_get('/1.1/blocks/ids.json').with(:query => {:cursor => '1305102810874389703'}).to_return(:body => fixture('ids_list2.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
216
- end
217
- it 'requests the correct resource' do
218
- @client.blocked_ids.each {}
219
- expect(a_get('/1.1/blocks/ids.json').with(:query => {:cursor => '-1'})).to have_been_made
220
- expect(a_get('/1.1/blocks/ids.json').with(:query => {:cursor => '1305102810874389703'})).to have_been_made
221
- end
222
- end
223
- end
224
-
225
- describe '#block?' do
226
- context 'with a screen name passed' do
227
- before do
228
- stub_get('/1.1/blocks/ids.json').with(:query => {:cursor => '-1'}).to_return(:body => fixture('ids_list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
229
- stub_get('/1.1/blocks/ids.json').with(:query => {:cursor => '1305102810874389703'}).to_return(:body => fixture('ids_list2.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
230
- stub_get('/1.1/users/show.json').with(:query => {:screen_name => 'pengwynn'}).to_return(:body => fixture('pengwynn.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
231
- stub_get('/1.1/users/show.json').with(:query => {:screen_name => 'sferik'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
232
- end
233
- it 'requests the correct resource' do
234
- @client.block?('sferik')
235
- expect(a_get('/1.1/blocks/ids.json').with(:query => {:cursor => '-1'})).to have_been_made
236
- expect(a_get('/1.1/blocks/ids.json').with(:query => {:cursor => '1305102810874389703'})).to have_been_made
237
- expect(a_get('/1.1/users/show.json').with(:query => {:screen_name => 'sferik'})).to have_been_made
238
- end
239
- it 'returns true if block exists' do
240
- block = @client.block?('pengwynn')
241
- expect(block).to be true
242
- end
243
- it 'returns false if block does not exist' do
244
- block = @client.block?('sferik')
245
- expect(block).to be false
246
- end
247
- end
248
- context 'with a user ID passed' do
249
- before do
250
- stub_get('/1.1/blocks/ids.json').with(:query => {:cursor => '-1'}).to_return(:body => fixture('ids_list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
251
- stub_get('/1.1/blocks/ids.json').with(:query => {:cursor => '1305102810874389703'}).to_return(:body => fixture('ids_list2.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
252
- end
253
- it 'requests the correct resources' do
254
- @client.block?(7_505_382)
255
- expect(a_get('/1.1/blocks/ids.json').with(:query => {:cursor => '-1'})).to have_been_made
256
- expect(a_get('/1.1/blocks/ids.json').with(:query => {:cursor => '1305102810874389703'})).to have_been_made
257
- end
258
- end
259
- context 'with a user object passed' do
260
- before do
261
- stub_get('/1.1/blocks/ids.json').with(:query => {:cursor => '-1'}).to_return(:body => fixture('ids_list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
262
- stub_get('/1.1/blocks/ids.json').with(:query => {:cursor => '1305102810874389703'}).to_return(:body => fixture('ids_list2.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
263
- end
264
- it 'requests the correct resources' do
265
- user = Twitter::User.new(:id => '7505382')
266
- @client.block?(user)
267
- expect(a_get('/1.1/blocks/ids.json').with(:query => {:cursor => '-1'})).to have_been_made
268
- expect(a_get('/1.1/blocks/ids.json').with(:query => {:cursor => '1305102810874389703'})).to have_been_made
269
- end
270
- end
271
- end
272
-
273
- describe '#block' do
274
- before do
275
- stub_post('/1.1/blocks/create.json').with(:body => {:screen_name => 'sferik'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
276
- end
277
- it 'requests the correct resource' do
278
- @client.block('sferik')
279
- expect(a_post('/1.1/blocks/create.json')).to have_been_made
280
- end
281
- it 'returns an array of blocked users' do
282
- users = @client.block('sferik')
283
- expect(users).to be_an Array
284
- expect(users.first).to be_a Twitter::User
285
- expect(users.first.id).to eq(7_505_382)
286
- end
287
- end
288
-
289
- describe '#unblock' do
290
- before do
291
- stub_post('/1.1/blocks/destroy.json').with(:body => {:screen_name => 'sferik'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
292
- end
293
- it 'requests the correct resource' do
294
- @client.unblock('sferik')
295
- expect(a_post('/1.1/blocks/destroy.json').with(:body => {:screen_name => 'sferik'})).to have_been_made
296
- end
297
- it 'returns an array of un-blocked users' do
298
- users = @client.unblock('sferik')
299
- expect(users).to be_an Array
300
- expect(users.first).to be_a Twitter::User
301
- expect(users.first.id).to eq(7_505_382)
302
- end
303
- end
304
-
305
- describe '#users' do
306
- context 'using a post request' do
307
- context 'with screen names passed' do
308
- before do
309
- stub_post('/1.1/users/lookup.json').with(:body => {:screen_name => 'sferik,pengwynn'}).to_return(:body => fixture('users.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
310
- end
311
- it 'requests the correct resource' do
312
- @client.users('sferik', 'pengwynn')
313
- expect(a_post('/1.1/users/lookup.json').with(:body => {:screen_name => 'sferik,pengwynn'})).to have_been_made
314
- end
315
- it 'returns up to 100 users worth of extended information' do
316
- users = @client.users('sferik', 'pengwynn')
317
- expect(users).to be_an Array
318
- expect(users.first).to be_a Twitter::User
319
- expect(users.first.id).to eq(7_505_382)
320
- end
321
- context 'with URI objects passed' do
322
- it 'requests the correct resource' do
323
- sferik = URI.parse('https://twitter.com/sferik')
324
- pengwynn = URI.parse('https://twitter.com/pengwynn')
325
- @client.users(sferik, pengwynn)
326
- expect(a_post('/1.1/users/lookup.json').with(:body => {:screen_name => 'sferik,pengwynn'})).to have_been_made
327
- end
328
- end
329
- context 'with URI strings passed' do
330
- it 'requests the correct resource' do
331
- @client.users('https://twitter.com/sferik', 'https://twitter.com/pengwynn')
332
- expect(a_post('/1.1/users/lookup.json').with(:body => {:screen_name => 'sferik,pengwynn'})).to have_been_made
333
- end
334
- end
335
- end
336
- context 'with numeric screen names passed' do
337
- before do
338
- stub_post('/1.1/users/lookup.json').with(:body => {:screen_name => '0,311'}).to_return(:body => fixture('users.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
339
- end
340
- it 'requests the correct resource' do
341
- @client.users('0', '311')
342
- expect(a_post('/1.1/users/lookup.json').with(:body => {:screen_name => '0,311'})).to have_been_made
343
- end
344
- end
345
- context 'with user IDs passed' do
346
- before do
347
- stub_post('/1.1/users/lookup.json').with(:body => {:user_id => '7505382,14100886'}).to_return(:body => fixture('users.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
348
- end
349
- it 'requests the correct resource' do
350
- @client.users(7_505_382, 14_100_886)
351
- expect(a_post('/1.1/users/lookup.json').with(:body => {:user_id => '7505382,14100886'})).to have_been_made
352
- end
353
- end
354
- context 'with both screen names and user IDs passed' do
355
- before do
356
- stub_post('/1.1/users/lookup.json').with(:body => {:screen_name => 'sferik', :user_id => '14100886'}).to_return(:body => fixture('users.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
357
- end
358
- it 'requests the correct resource' do
359
- @client.users('sferik', 14_100_886)
360
- expect(a_post('/1.1/users/lookup.json').with(:body => {:screen_name => 'sferik', :user_id => '14100886'})).to have_been_made
361
- end
362
- end
363
- context 'with user objects passed' do
364
- before do
365
- stub_post('/1.1/users/lookup.json').with(:body => {:user_id => '7505382,14100886'}).to_return(:body => fixture('users.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
366
- end
367
- it 'requests the correct resource' do
368
- user1 = Twitter::User.new(:id => '7505382')
369
- user2 = Twitter::User.new(:id => '14100886')
370
- @client.users(user1, user2)
371
- expect(a_post('/1.1/users/lookup.json').with(:body => {:user_id => '7505382,14100886'})).to have_been_made
372
- end
373
- end
374
- end
375
- context 'using a get request' do
376
- context 'with screen names passed' do
377
- before do
378
- stub_get('/1.1/users/lookup.json').with(:query => {:screen_name => 'sferik,pengwynn'}).to_return(:body => fixture('users.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
379
- end
380
- it 'requests the correct resource' do
381
- @client.users('sferik', 'pengwynn', :method => :get)
382
- expect(a_get('/1.1/users/lookup.json').with(:query => {:screen_name => 'sferik,pengwynn'})).to have_been_made
383
- end
384
- it 'returns up to 100 users worth of extended information' do
385
- users = @client.users('sferik', 'pengwynn', :method => :get)
386
- expect(users).to be_an Array
387
- expect(users.first).to be_a Twitter::User
388
- expect(users.first.id).to eq(7_505_382)
389
- end
390
- context 'with URI objects passed' do
391
- it 'requests the correct resource' do
392
- sferik = URI.parse('https://twitter.com/sferik')
393
- pengwynn = URI.parse('https://twitter.com/pengwynn')
394
- @client.users(sferik, pengwynn, :method => :get)
395
- expect(a_get('/1.1/users/lookup.json').with(:query => {:screen_name => 'sferik,pengwynn'})).to have_been_made
396
- end
397
- end
398
- context 'with URI objects passed' do
399
- it 'requests the correct resource' do
400
- @client.users('https://twitter.com/sferik', 'https://twitter.com/pengwynn', :method => :get)
401
- expect(a_get('/1.1/users/lookup.json').with(:query => {:screen_name => 'sferik,pengwynn'})).to have_been_made
402
- end
403
- end
404
- end
405
- context 'with numeric screen names passed' do
406
- before do
407
- stub_get('/1.1/users/lookup.json').with(:query => {:screen_name => '0,311'}).to_return(:body => fixture('users.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
408
- end
409
- it 'requests the correct resource' do
410
- @client.users('0', '311', :method => :get)
411
- expect(a_get('/1.1/users/lookup.json').with(:query => {:screen_name => '0,311'})).to have_been_made
412
- end
413
- end
414
- context 'with user IDs passed' do
415
- before do
416
- stub_get('/1.1/users/lookup.json').with(:query => {:user_id => '7505382,14100886'}).to_return(:body => fixture('users.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
417
- end
418
- it 'requests the correct resource' do
419
- @client.users(7_505_382, 14_100_886, :method => :get)
420
- expect(a_get('/1.1/users/lookup.json').with(:query => {:user_id => '7505382,14100886'})).to have_been_made
421
- end
422
- end
423
- context 'with both screen names and user IDs passed' do
424
- before do
425
- stub_get('/1.1/users/lookup.json').with(:query => {:screen_name => 'sferik', :user_id => '14100886'}).to_return(:body => fixture('users.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
426
- end
427
- it 'requests the correct resource' do
428
- @client.users('sferik', 14_100_886, :method => :get)
429
- expect(a_get('/1.1/users/lookup.json').with(:query => {:screen_name => 'sferik', :user_id => '14100886'})).to have_been_made
430
- end
431
- end
432
- context 'with user objects passed' do
433
- before do
434
- stub_get('/1.1/users/lookup.json').with(:query => {:user_id => '7505382,14100886'}).to_return(:body => fixture('users.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
435
- end
436
- it 'requests the correct resource' do
437
- user1 = Twitter::User.new(:id => '7505382')
438
- user2 = Twitter::User.new(:id => '14100886')
439
- @client.users(user1, user2, :method => :get)
440
- expect(a_get('/1.1/users/lookup.json').with(:query => {:user_id => '7505382,14100886'})).to have_been_made
441
- end
442
- end
443
- end
444
- end
445
-
446
- describe '#user' do
447
- context 'with a screen name passed' do
448
- before do
449
- stub_get('/1.1/users/show.json').with(:query => {:screen_name => 'sferik'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
450
- end
451
- it 'requests the correct resource' do
452
- @client.user('sferik')
453
- expect(a_get('/1.1/users/show.json').with(:query => {:screen_name => 'sferik'})).to have_been_made
454
- end
455
- it 'returns extended information of a given user' do
456
- user = @client.user('sferik')
457
- expect(user).to be_a Twitter::User
458
- expect(user.id).to eq(7_505_382)
459
- end
460
- end
461
- context 'with a screen name including "@" passed' do
462
- before do
463
- stub_get('/1.1/users/show.json').with(:query => {:screen_name => '@sferik'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
464
- end
465
- it 'requests the correct resource' do
466
- @client.user('@sferik')
467
- expect(a_get('/1.1/users/show.json').with(:query => {:screen_name => '@sferik'})).to have_been_made
468
- end
469
- end
470
- context 'with a numeric screen name passed' do
471
- before do
472
- stub_get('/1.1/users/show.json').with(:query => {:screen_name => '0'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
473
- end
474
- it 'requests the correct resource' do
475
- @client.user('0')
476
- expect(a_get('/1.1/users/show.json').with(:query => {:screen_name => '0'})).to have_been_made
477
- end
478
- end
479
- context 'with a user ID passed' do
480
- before do
481
- stub_get('/1.1/users/show.json').with(:query => {:user_id => '7505382'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
482
- end
483
- it 'requests the correct resource' do
484
- @client.user(7_505_382)
485
- expect(a_get('/1.1/users/show.json').with(:query => {:user_id => '7505382'})).to have_been_made
486
- end
487
- end
488
- context 'with a user object passed' do
489
- before do
490
- stub_get('/1.1/users/show.json').with(:query => {:user_id => '7505382'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
491
- end
492
- it 'requests the correct resource' do
493
- user = Twitter::User.new(:id => 7_505_382)
494
- @client.user(user)
495
- expect(a_get('/1.1/users/show.json').with(:query => {:user_id => '7505382'})).to have_been_made
496
- end
497
- end
498
- end
499
- context 'without a screen name or user ID passed' do
500
- context 'without options passed' do
501
- before do
502
- stub_get('/1.1/account/verify_credentials.json').to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
503
- end
504
- it 'requests the correct resource' do
505
- @client.user
506
- expect(a_get('/1.1/account/verify_credentials.json')).to have_been_made
507
- end
508
- end
509
- context 'with options passed' do
510
- before do
511
- stub_get('/1.1/account/verify_credentials.json').with(:query => {:skip_status => 'true'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
512
- end
513
- it 'requests the correct resource' do
514
- @client.user(:skip_status => true)
515
- expect(a_get('/1.1/account/verify_credentials.json').with(:query => {:skip_status => 'true'})).to have_been_made
516
- end
517
- end
518
- end
519
-
520
- describe '#user?' do
521
- before do
522
- stub_get('/1.1/users/show.json').with(:query => {:screen_name => 'sferik'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
523
- stub_get('/1.1/users/show.json').with(:query => {:screen_name => 'pengwynn'}).to_return(:body => fixture('not_found.json'), :status => 404, :headers => {:content_type => 'application/json; charset=utf-8'})
524
- end
525
- it 'requests the correct resource' do
526
- @client.user?('sferik')
527
- expect(a_get('/1.1/users/show.json').with(:query => {:screen_name => 'sferik'})).to have_been_made
528
- end
529
- it 'returns true if user exists' do
530
- user = @client.user?('sferik')
531
- expect(user).to be true
532
- end
533
- it 'returns false if user does not exist' do
534
- user = @client.user?('pengwynn')
535
- expect(user).to be false
536
- end
537
- end
538
-
539
- describe '#user_search' do
540
- before do
541
- stub_get('/1.1/users/search.json').with(:query => {:q => 'Erik Michaels-Ober'}).to_return(:body => fixture('user_search.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
542
- end
543
- it 'requests the correct resource' do
544
- @client.user_search('Erik Michaels-Ober')
545
- expect(a_get('/1.1/users/search.json').with(:query => {:q => 'Erik Michaels-Ober'})).to have_been_made
546
- end
547
- it 'returns an array of user search results' do
548
- user_search = @client.user_search('Erik Michaels-Ober')
549
- expect(user_search).to be_an Array
550
- expect(user_search.first).to be_a Twitter::User
551
- expect(user_search.first.id).to eq(7_505_382)
552
- end
553
- end
554
-
555
- describe '#contributees' do
556
- context 'with a screen name passed' do
557
- before do
558
- stub_get('/1.1/users/contributees.json').with(:query => {:screen_name => 'sferik'}).to_return(:body => fixture('contributees.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
559
- end
560
- it 'requests the correct resource' do
561
- @client.contributees('sferik')
562
- expect(a_get('/1.1/users/contributees.json').with(:query => {:screen_name => 'sferik'})).to have_been_made
563
- end
564
- it 'returns contributees' do
565
- contributees = @client.contributees('sferik')
566
- expect(contributees).to be_an Array
567
- expect(contributees.first).to be_a Twitter::User
568
- expect(contributees.first.name).to eq('Twitter API')
569
- end
570
- end
571
- context 'with a user ID passed' do
572
- before do
573
- stub_get('/1.1/users/contributees.json').with(:query => {:user_id => '7505382'}).to_return(:body => fixture('contributees.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
574
- end
575
- it 'requests the correct resource' do
576
- @client.contributees(7_505_382)
577
- expect(a_get('/1.1/users/contributees.json').with(:query => {:user_id => '7505382'})).to have_been_made
578
- end
579
- end
580
- context 'without arguments passed' do
581
- before do
582
- stub_get('/1.1/account/verify_credentials.json').with(:query => {:skip_status => 'true'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
583
- stub_get('/1.1/users/contributees.json').with(:query => {:user_id => '7505382'}).to_return(:body => fixture('contributees.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
584
- end
585
- it 'requests the correct resource' do
586
- @client.contributees
587
- expect(a_get('/1.1/account/verify_credentials.json').with(:query => {:skip_status => 'true'})).to have_been_made
588
- expect(a_get('/1.1/users/contributees.json').with(:query => {:user_id => '7505382'})).to have_been_made
589
- end
590
- it 'returns contributees' do
591
- contributees = @client.contributees
592
- expect(contributees).to be_an Array
593
- expect(contributees.first).to be_a Twitter::User
594
- expect(contributees.first.name).to eq('Twitter API')
595
- end
596
- end
597
- end
598
-
599
- describe '#contributors' do
600
- context 'with a screen name passed' do
601
- before do
602
- stub_get('/1.1/users/contributors.json').with(:query => {:screen_name => 'sferik'}).to_return(:body => fixture('members.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
603
- end
604
- it 'requests the correct resource' do
605
- @client.contributors('sferik')
606
- expect(a_get('/1.1/users/contributors.json').with(:query => {:screen_name => 'sferik'})).to have_been_made
607
- end
608
- it 'returns contributors' do
609
- contributors = @client.contributors('sferik')
610
- expect(contributors).to be_an Array
611
- expect(contributors.first).to be_a Twitter::User
612
- expect(contributors.first.id).to eq(13)
613
- end
614
- end
615
- context 'with a user ID passed' do
616
- before do
617
- stub_get('/1.1/users/contributors.json').with(:query => {:user_id => '7505382'}).to_return(:body => fixture('members.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
618
- end
619
- it 'requests the correct resource' do
620
- @client.contributors(7_505_382)
621
- expect(a_get('/1.1/users/contributors.json').with(:query => {:user_id => '7505382'})).to have_been_made
622
- end
623
- end
624
- context 'without arguments passed' do
625
- before do
626
- stub_get('/1.1/account/verify_credentials.json').with(:query => {:skip_status => 'true'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
627
- stub_get('/1.1/users/contributors.json').with(:query => {:user_id => '7505382'}).to_return(:body => fixture('members.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
628
- end
629
- it 'requests the correct resource' do
630
- @client.contributors
631
- expect(a_get('/1.1/account/verify_credentials.json').with(:query => {:skip_status => 'true'})).to have_been_made
632
- expect(a_get('/1.1/users/contributors.json').with(:query => {:user_id => '7505382'})).to have_been_made
633
- end
634
- it 'returns contributors' do
635
- contributors = @client.contributors
636
- expect(contributors).to be_an Array
637
- expect(contributors.first).to be_a Twitter::User
638
- expect(contributors.first.id).to eq(13)
639
- end
640
- end
641
- end
642
-
643
- describe '#remove_profile_banner' do
644
- before do
645
- stub_post('/1.1/account/remove_profile_banner.json').to_return(:body => fixture('empty.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
646
- end
647
- it 'requests the correct resource' do
648
- @client.remove_profile_banner
649
- expect(a_post('/1.1/account/remove_profile_banner.json')).to have_been_made
650
- end
651
- it 'returns a user' do
652
- response = @client.remove_profile_banner
653
- expect(response).to be true
654
- end
655
- end
656
-
657
- describe '#update_profile_banner' do
658
- before do
659
- stub_post('/1.1/account/update_profile_banner.json').to_return(:body => fixture('empty.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
660
- end
661
- it 'requests the correct resource' do
662
- @client.update_profile_banner(fixture('me.jpeg'))
663
- expect(a_post('/1.1/account/update_profile_banner.json')).to have_been_made
664
- end
665
- it 'returns a user' do
666
- response = @client.update_profile_banner(fixture('me.jpeg'))
667
- expect(response).to be true
668
- end
669
- end
670
-
671
- describe '#profile_banner' do
672
- context 'with a screen_name passed' do
673
- before do
674
- stub_get('/1.1/users/profile_banner.json').with(:query => {:screen_name => 'sferik'}).to_return(:body => fixture('profile_banner.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
675
- end
676
- it 'requests the correct resource' do
677
- @client.profile_banner('sferik')
678
- expect(a_get('/1.1/users/profile_banner.json').with(:query => {:screen_name => 'sferik'})).to have_been_made
679
- end
680
- it 'returns a profile banner' do
681
- banner = @client.profile_banner('sferik')
682
- expect(banner).to be_a Twitter::ProfileBanner
683
- expect(banner.sizes).to be_a Hash
684
- expect(banner.sizes[:mobile].height).to eq(160)
685
- end
686
- end
687
- context 'with a user ID passed' do
688
- before do
689
- stub_get('/1.1/users/profile_banner.json').with(:query => {:user_id => '7505382'}).to_return(:body => fixture('profile_banner.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
690
- end
691
- it 'requests the correct resource' do
692
- @client.profile_banner(7_505_382)
693
- expect(a_get('/1.1/users/profile_banner.json').with(:query => {:user_id => '7505382'})).to have_been_made
694
- end
695
- end
696
- context 'without arguments passed' do
697
- before do
698
- stub_get('/1.1/account/verify_credentials.json').with(:query => {:skip_status => 'true'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
699
- stub_get('/1.1/users/profile_banner.json').with(:query => {:user_id => '7505382'}).to_return(:body => fixture('profile_banner.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
700
- end
701
- it 'requests the correct resource' do
702
- @client.profile_banner
703
- expect(a_get('/1.1/account/verify_credentials.json').with(:query => {:skip_status => 'true'})).to have_been_made
704
- expect(a_get('/1.1/users/profile_banner.json').with(:query => {:user_id => '7505382'})).to have_been_made
705
- end
706
- it 'returns an array of numeric IDs for every user following the specified user' do
707
- banner = @client.profile_banner
708
- expect(banner).to be_a Twitter::ProfileBanner
709
- expect(banner.sizes).to be_a Hash
710
- expect(banner.sizes[:mobile].height).to eq(160)
711
- end
712
- end
713
- end
714
-
715
- describe '#mute' do
716
- before do
717
- stub_post('/1.1/mutes/users/create.json').with(:body => {:screen_name => 'sferik'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
718
- end
719
- it 'requests the correct resource' do
720
- @client.mute('sferik')
721
- expect(a_post('/1.1/mutes/users/create.json')).to have_been_made
722
- end
723
- it 'returns an array of muteed users' do
724
- users = @client.mute('sferik')
725
- expect(users).to be_an Array
726
- expect(users.first).to be_a Twitter::User
727
- expect(users.first.id).to eq(7_505_382)
728
- end
729
- end
730
-
731
- describe '#unmute' do
732
- before do
733
- stub_post('/1.1/mutes/users/destroy.json').with(:body => {:screen_name => 'sferik'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
734
- end
735
- it 'requests the correct resource' do
736
- @client.unmute('sferik')
737
- expect(a_post('/1.1/mutes/users/destroy.json').with(:body => {:screen_name => 'sferik'})).to have_been_made
738
- end
739
- it 'returns an array of un-muteed users' do
740
- users = @client.unmute('sferik')
741
- expect(users).to be_an Array
742
- expect(users.first).to be_a Twitter::User
743
- expect(users.first.id).to eq(7_505_382)
744
- end
745
- end
746
-
747
- describe '#muted' do
748
- before do
749
- stub_get('/1.1/mutes/users/list.json').with(:query => {:cursor => '-1'}).to_return(:body => fixture('users_list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
750
- end
751
- it 'requests the correct resource' do
752
- @client.muted
753
- expect(a_get('/1.1/mutes/users/list.json').with(:query => {:cursor => '-1'})).to have_been_made
754
- end
755
- it 'returns an array of user objects that the authenticating user is muting' do
756
- muted = @client.muted
757
- expect(muted).to be_a Twitter::Cursor
758
- expect(muted.first).to be_a Twitter::User
759
- expect(muted.first.id).to eq(7_505_382)
760
- end
761
- context 'with each' do
762
- before do
763
- stub_get('/1.1/mutes/users/list.json').with(:query => {:cursor => '1322801608223717003'}).to_return(:body => fixture('users_list2.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
764
- end
765
- it 'requests the correct resource' do
766
- @client.muted.each {}
767
- expect(a_get('/1.1/mutes/users/list.json').with(:query => {:cursor => '-1'})).to have_been_made
768
- expect(a_get('/1.1/mutes/users/list.json').with(:query => {:cursor => '1322801608223717003'})).to have_been_made
769
- end
770
- end
771
- end
772
-
773
- describe '#muted_ids' do
774
- before do
775
- stub_get('/1.1/mutes/users/ids.json').with(:query => {:cursor => '-1'}).to_return(:body => fixture('ids_list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
776
- end
777
- it 'requests the correct resource' do
778
- @client.muted_ids
779
- expect(a_get('/1.1/mutes/users/ids.json').with(:query => {:cursor => '-1'})).to have_been_made
780
- end
781
- it 'returns an array of numeric user IDs the authenticating user is muting' do
782
- muted_ids = @client.muted_ids
783
- expect(muted_ids).to be_a Twitter::Cursor
784
- expect(muted_ids.first).to eq(20_009_713)
785
- end
786
- context 'with each' do
787
- before do
788
- stub_get('/1.1/mutes/users/ids.json').with(:query => {:cursor => '1305102810874389703'}).to_return(:body => fixture('ids_list2.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
789
- end
790
- it 'requests the correct resource' do
791
- @client.muted_ids.each {}
792
- expect(a_get('/1.1/mutes/users/ids.json').with(:query => {:cursor => '-1'})).to have_been_made
793
- expect(a_get('/1.1/mutes/users/ids.json').with(:query => {:cursor => '1305102810874389703'})).to have_been_made
794
- end
795
- end
796
- end
797
- end