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,68 +0,0 @@
1
- require 'helper'
2
-
3
- describe Twitter::REST::PlacesAndGeo 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 '#place' do
10
- before do
11
- stub_get('/1.1/geo/id/247f43d441defc03.json').to_return(:body => fixture('place.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
12
- end
13
- it 'requests the correct resource' do
14
- @client.place('247f43d441defc03')
15
- expect(a_get('/1.1/geo/id/247f43d441defc03.json')).to have_been_made
16
- end
17
- it 'returns a place' do
18
- place = @client.place('247f43d441defc03')
19
- expect(place.name).to eq('Twitter HQ')
20
- end
21
- end
22
-
23
- describe '#reverse_geocode' do
24
- before do
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'})
26
- end
27
- it 'requests the correct resource' do
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
30
- end
31
- it 'returns places' do
32
- places = @client.reverse_geocode(:lat => '37.7821120598956', :long => '-122.400612831116')
33
- expect(places).to be_a Twitter::GeoResults
34
- expect(places.first.name).to eq('Bernal Heights')
35
- end
36
- end
37
-
38
- describe '#geo_search' do
39
- before do
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'})
41
- end
42
- it 'requests the correct resource' do
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
45
- end
46
- it 'returns nearby places' do
47
- places = @client.geo_search(:ip => '74.125.19.104')
48
- expect(places).to be_a Twitter::GeoResults
49
- expect(places.first.name).to eq('Bernal Heights')
50
- end
51
- end
52
-
53
- describe '#similar_places' do
54
- before do
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'})
56
- end
57
- it 'requests the correct resource' do
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
60
- end
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_a Twitter::GeoResults
64
- expect(places.first.name).to eq('Bernal Heights')
65
- end
66
- end
67
-
68
- end
@@ -1,68 +0,0 @@
1
- require 'helper'
2
-
3
- describe Twitter::REST::Help 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 '#configuration' do
10
- before do
11
- stub_get('/1.1/help/configuration.json').to_return(:body => fixture('configuration.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
12
- end
13
- it 'requests the correct resource' do
14
- @client.configuration
15
- expect(a_get('/1.1/help/configuration.json')).to have_been_made
16
- end
17
- it 'returns the Twitter configuration' do
18
- configuration = @client.configuration
19
- expect(configuration).to be_a Twitter::Configuration
20
- expect(configuration.characters_reserved_per_media).to eq(20)
21
- end
22
- end
23
-
24
- describe '#languages' do
25
- before do
26
- stub_get('/1.1/help/languages.json').to_return(:body => fixture('languages.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
27
- end
28
- it 'requests the correct resource' do
29
- @client.languages
30
- expect(a_get('/1.1/help/languages.json')).to have_been_made
31
- end
32
- it 'returns the list of languages supported by Twitter' do
33
- languages = @client.languages
34
- expect(languages).to be_an Array
35
- expect(languages.first).to be_a Twitter::Language
36
- expect(languages.first.name).to eq('Portuguese')
37
- end
38
- end
39
-
40
- describe '#privacy' do
41
- before do
42
- stub_get('/1.1/help/privacy.json').to_return(:body => fixture('privacy.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
43
- end
44
- it 'requests the correct resource' do
45
- @client.privacy
46
- expect(a_get('/1.1/help/privacy.json')).to have_been_made
47
- end
48
- it 'returns the Twitter Privacy Policy' do
49
- privacy = @client.privacy
50
- expect(privacy.split.first).to eq('Twitter')
51
- end
52
- end
53
-
54
- describe '#tos' do
55
- before do
56
- stub_get('/1.1/help/tos.json').to_return(:body => fixture('tos.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
57
- end
58
- it 'requests the correct resource' do
59
- @client.tos
60
- expect(a_get('/1.1/help/tos.json')).to have_been_made
61
- end
62
- it 'returns the Twitter Terms of Service' do
63
- tos = @client.tos
64
- expect(tos.split.first).to eq('Terms')
65
- end
66
- end
67
-
68
- end
@@ -1,910 +0,0 @@
1
- require 'helper'
2
-
3
- describe Twitter::REST::Lists 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 '#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
-
25
- describe '#list_timeline' do
26
- context 'with a screen name passed' do
27
- before do
28
- stub_get('/1.1/lists/statuses.json').with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents'}).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.list_timeline('sferik', 'presidents')
32
- expect(a_get('/1.1/lists/statuses.json').with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents'})).to have_been_made
33
- end
34
- it 'returns the timeline for members of the specified list' do
35
- tweets = @client.list_timeline('sferik', 'presidents')
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
- context 'with a URI object passed' do
41
- it 'requests the correct resource' do
42
- list = URI.parse('https://twitter.com/sferik/presidents')
43
- @client.list_timeline(list)
44
- expect(a_get('/1.1/lists/statuses.json').with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents'})).to have_been_made
45
- end
46
- end
47
- context 'with a URI string passed' do
48
- it 'requests the correct resource' do
49
- @client.list_timeline('https://twitter.com/sferik/presidents')
50
- expect(a_get('/1.1/lists/statuses.json').with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents'})).to have_been_made
51
- end
52
- end
53
- context 'with URI objects passed' do
54
- it 'requests the correct resource' do
55
- user = URI.parse('https://twitter.com/sferik')
56
- list = URI.parse('https://twitter.com/sferik/presidents')
57
- @client.list_timeline(user, list)
58
- expect(a_get('/1.1/lists/statuses.json').with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents'})).to have_been_made
59
- end
60
- end
61
- context 'with URI strings passed' do
62
- it 'requests the correct resource' do
63
- @client.list_timeline('https://twitter.com/sferik', 'https://twitter.com/sferik/presidents')
64
- expect(a_get('/1.1/lists/statuses.json').with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents'})).to have_been_made
65
- end
66
- end
67
- end
68
- context 'without a screen name passed' do
69
- before do
70
- 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'})
71
- stub_get('/1.1/lists/statuses.json').with(:query => {:owner_id => '7505382', :slug => 'presidents'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
72
- end
73
- it 'requests the correct resource' do
74
- @client.list_timeline('presidents')
75
- expect(a_get('/1.1/account/verify_credentials.json').with(:query => {:skip_status => 'true'})).to have_been_made
76
- expect(a_get('/1.1/lists/statuses.json').with(:query => {:owner_id => '7505382', :slug => 'presidents'})).to have_been_made
77
- end
78
- end
79
- end
80
-
81
- describe '#remove_list_member' do
82
- context 'with a screen name passed' do
83
- before do
84
- stub_post('/1.1/lists/members/destroy.json').with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => '813286'}).to_return(:body => fixture('list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
85
- end
86
- it 'requests the correct resource' do
87
- @client.remove_list_member('sferik', 'presidents', 813_286)
88
- expect(a_post('/1.1/lists/members/destroy.json').with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => '813286'})).to have_been_made
89
- end
90
- it 'returns the list' do
91
- list = @client.remove_list_member('sferik', 'presidents', 813_286)
92
- expect(list).to be_a Twitter::List
93
- expect(list.name).to eq('presidents')
94
- end
95
- end
96
- context 'without a screen name passed' do
97
- before do
98
- 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'})
99
- stub_post('/1.1/lists/members/destroy.json').with(:body => {:owner_id => '7505382', :slug => 'presidents', :user_id => '813286'}).to_return(:body => fixture('list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
100
- end
101
- it 'requests the correct resource' do
102
- @client.remove_list_member('presidents', 813_286)
103
- expect(a_get('/1.1/account/verify_credentials.json').with(:query => {:skip_status => 'true'})).to have_been_made
104
- expect(a_post('/1.1/lists/members/destroy.json').with(:body => {:owner_id => '7505382', :slug => 'presidents', :user_id => '813286'})).to have_been_made
105
- end
106
- end
107
- end
108
-
109
- describe '#memberships' do
110
- context 'with a screen name passed' do
111
- before do
112
- stub_get('/1.1/lists/memberships.json').with(:query => {:screen_name => 'sferik', :cursor => '-1'}).to_return(:body => fixture('memberships.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
113
- end
114
- it 'requests the correct resource' do
115
- @client.memberships('sferik')
116
- expect(a_get('/1.1/lists/memberships.json').with(:query => {:screen_name => 'sferik', :cursor => '-1'})).to have_been_made
117
- end
118
- it 'returns the lists the specified user has been added to' do
119
- memberships = @client.memberships('sferik')
120
- expect(memberships).to be_a Twitter::Cursor
121
- expect(memberships.first).to be_a Twitter::List
122
- expect(memberships.first.name).to eq('developer')
123
- end
124
- context 'with each' do
125
- before do
126
- stub_get('/1.1/lists/memberships.json').with(:query => {:screen_name => 'sferik', :cursor => '1401037770457540712'}).to_return(:body => fixture('memberships2.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
127
- end
128
- it 'requests the correct resource' do
129
- @client.memberships('sferik').each {}
130
- expect(a_get('/1.1/lists/memberships.json').with(:query => {:screen_name => 'sferik', :cursor => '-1'})).to have_been_made
131
- expect(a_get('/1.1/lists/memberships.json').with(:query => {:screen_name => 'sferik', :cursor => '1401037770457540712'})).to have_been_made
132
- end
133
- end
134
- end
135
- context 'with a user ID passed' do
136
- before do
137
- stub_get('/1.1/lists/memberships.json').with(:query => {:user_id => '7505382', :cursor => '-1'}).to_return(:body => fixture('memberships.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
138
- end
139
- it 'requests the correct resource' do
140
- @client.memberships(7_505_382)
141
- expect(a_get('/1.1/lists/memberships.json').with(:query => {:user_id => '7505382', :cursor => '-1'})).to have_been_made
142
- end
143
- context 'with each' do
144
- before do
145
- stub_get('/1.1/lists/memberships.json').with(:query => {:user_id => '7505382', :cursor => '1401037770457540712'}).to_return(:body => fixture('memberships2.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
146
- end
147
- it 'requests the correct resource' do
148
- @client.memberships(7_505_382).each {}
149
- expect(a_get('/1.1/lists/memberships.json').with(:query => {:user_id => '7505382', :cursor => '-1'})).to have_been_made
150
- expect(a_get('/1.1/lists/memberships.json').with(:query => {:user_id => '7505382', :cursor => '1401037770457540712'})).to have_been_made
151
- end
152
- end
153
- end
154
- context 'without a screen name passed' do
155
- before do
156
- 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'})
157
- stub_get('/1.1/lists/memberships.json').with(:query => {:user_id => '7505382', :cursor => '-1'}).to_return(:body => fixture('memberships.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
158
- end
159
- it 'requests the correct resource' do
160
- @client.memberships
161
- expect(a_get('/1.1/account/verify_credentials.json').with(:query => {:skip_status => 'true'})).to have_been_made
162
- expect(a_get('/1.1/lists/memberships.json').with(:query => {:user_id => '7505382', :cursor => '-1'})).to have_been_made
163
- end
164
- context 'with each' do
165
- before do
166
- stub_get('/1.1/lists/memberships.json').with(:query => {:user_id => '7505382', :cursor => '1401037770457540712'}).to_return(:body => fixture('memberships2.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
167
- end
168
- it 'requests the correct resource' do
169
- @client.memberships.each {}
170
- expect(a_get('/1.1/account/verify_credentials.json').with(:query => {:skip_status => 'true'})).to have_been_made
171
- expect(a_get('/1.1/lists/memberships.json').with(:query => {:user_id => '7505382', :cursor => '-1'})).to have_been_made
172
- expect(a_get('/1.1/lists/memberships.json').with(:query => {:user_id => '7505382', :cursor => '1401037770457540712'})).to have_been_made
173
- end
174
- end
175
- end
176
- end
177
-
178
- describe '#list_subscribers' do
179
- context 'with a screen name passed' do
180
- before do
181
- stub_get('/1.1/lists/subscribers.json').with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :cursor => '-1'}).to_return(:body => fixture('users_list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
182
- end
183
- it 'requests the correct resource' do
184
- @client.list_subscribers('sferik', 'presidents')
185
- expect(a_get('/1.1/lists/subscribers.json').with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :cursor => '-1'})).to have_been_made
186
- end
187
- it 'returns the subscribers of the specified list' do
188
- list_subscribers = @client.list_subscribers('sferik', 'presidents')
189
- expect(list_subscribers).to be_a Twitter::Cursor
190
- expect(list_subscribers.first).to be_a Twitter::User
191
- expect(list_subscribers.first.id).to eq(7_505_382)
192
- end
193
- context 'with each' do
194
- before do
195
- stub_get('/1.1/lists/subscribers.json').with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :cursor => '1322801608223717003'}).to_return(:body => fixture('users_list2.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
196
- end
197
- it 'requests the correct resource' do
198
- @client.list_subscribers('sferik', 'presidents').each {}
199
- expect(a_get('/1.1/lists/subscribers.json').with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :cursor => '-1'})).to have_been_made
200
- expect(a_get('/1.1/lists/subscribers.json').with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :cursor => '1322801608223717003'})).to have_been_made
201
- end
202
- end
203
- end
204
- context 'with a user ID passed' do
205
- before do
206
- stub_get('/1.1/lists/subscribers.json').with(:query => {:owner_id => '7505382', :slug => 'presidents', :cursor => '-1'}).to_return(:body => fixture('users_list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
207
- end
208
- it 'requests the correct resource' do
209
- @client.list_subscribers(7_505_382, 'presidents')
210
- expect(a_get('/1.1/lists/subscribers.json').with(:query => {:owner_id => '7505382', :slug => 'presidents', :cursor => '-1'})).to have_been_made
211
- end
212
- context 'with each' do
213
- before do
214
- stub_get('/1.1/lists/subscribers.json').with(:query => {:owner_id => '7505382', :slug => 'presidents', :cursor => '1322801608223717003'}).to_return(:body => fixture('users_list2.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
215
- end
216
- it 'requests the correct resource' do
217
- @client.list_subscribers(7_505_382, 'presidents').each {}
218
- expect(a_get('/1.1/lists/subscribers.json').with(:query => {:owner_id => '7505382', :slug => 'presidents', :cursor => '-1'})).to have_been_made
219
- expect(a_get('/1.1/lists/subscribers.json').with(:query => {:owner_id => '7505382', :slug => 'presidents', :cursor => '1322801608223717003'})).to have_been_made
220
- end
221
- end
222
- end
223
- context 'without a screen name passed' do
224
- before do
225
- 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'})
226
- stub_get('/1.1/lists/subscribers.json').with(:query => {:owner_id => '7505382', :slug => 'presidents', :cursor => '-1'}).to_return(:body => fixture('users_list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
227
- end
228
- it 'requests the correct resource' do
229
- @client.list_subscribers('presidents')
230
- expect(a_get('/1.1/account/verify_credentials.json').with(:query => {:skip_status => 'true'})).to have_been_made
231
- expect(a_get('/1.1/lists/subscribers.json').with(:query => {:owner_id => '7505382', :slug => 'presidents', :cursor => '-1'})).to have_been_made
232
- end
233
- context 'with each' do
234
- before do
235
- stub_get('/1.1/lists/subscribers.json').with(:query => {:owner_id => '7505382', :slug => 'presidents', :cursor => '1322801608223717003'}).to_return(:body => fixture('users_list2.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
236
- end
237
- it 'requests the correct resource' do
238
- @client.list_subscribers('presidents').each {}
239
- expect(a_get('/1.1/account/verify_credentials.json').with(:query => {:skip_status => 'true'})).to have_been_made
240
- expect(a_get('/1.1/lists/subscribers.json').with(:query => {:owner_id => '7505382', :slug => 'presidents', :cursor => '-1'})).to have_been_made
241
- expect(a_get('/1.1/lists/subscribers.json').with(:query => {:owner_id => '7505382', :slug => 'presidents', :cursor => '1322801608223717003'})).to have_been_made
242
- end
243
- end
244
- end
245
- end
246
-
247
- describe '#list_subscribe' do
248
- context 'with a screen name passed' do
249
- before do
250
- stub_post('/1.1/lists/subscribers/create.json').with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents'}).to_return(:body => fixture('list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
251
- end
252
- it 'requests the correct resource' do
253
- @client.list_subscribe('sferik', 'presidents')
254
- expect(a_post('/1.1/lists/subscribers/create.json').with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents'})).to have_been_made
255
- end
256
- it 'returns the specified list' do
257
- list = @client.list_subscribe('sferik', 'presidents')
258
- expect(list).to be_a Twitter::List
259
- expect(list.name).to eq('presidents')
260
- end
261
- end
262
- context 'without a screen name passed' do
263
- before do
264
- 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'})
265
- stub_post('/1.1/lists/subscribers/create.json').with(:body => {:owner_id => '7505382', :slug => 'presidents'}).to_return(:body => fixture('list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
266
- end
267
- it 'requests the correct resource' do
268
- @client.list_subscribe('presidents')
269
- expect(a_get('/1.1/account/verify_credentials.json').with(:query => {:skip_status => 'true'})).to have_been_made
270
- expect(a_post('/1.1/lists/subscribers/create.json').with(:body => {:owner_id => '7505382', :slug => 'presidents'})).to have_been_made
271
- end
272
- end
273
- end
274
-
275
- describe '#list_subscriber?' do
276
- context 'with a screen name passed' do
277
- before do
278
- stub_get('/1.1/lists/subscribers/show.json').with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => '813286'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
279
- stub_get('/1.1/lists/subscribers/show.json').with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => '18755393'}).to_return(:body => fixture('not_found.json'), :status => 404, :headers => {:content_type => 'application/json; charset=utf-8'})
280
- stub_get('/1.1/lists/subscribers/show.json').with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => '12345678'}).to_return(:body => fixture('not_found.json'), :status => 403, :headers => {:content_type => 'application/json; charset=utf-8'})
281
- end
282
- it 'requests the correct resource' do
283
- @client.list_subscriber?('sferik', 'presidents', 813_286)
284
- expect(a_get('/1.1/lists/subscribers/show.json').with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => '813286'})).to have_been_made
285
- end
286
- it 'returns true if the specified user subscribes to the specified list' do
287
- list_subscriber = @client.list_subscriber?('sferik', 'presidents', 813_286)
288
- expect(list_subscriber).to be true
289
- end
290
- it 'returns false if the specified user does not subscribe to the specified list' do
291
- list_subscriber = @client.list_subscriber?('sferik', 'presidents', 18_755_393)
292
- expect(list_subscriber).to be false
293
- end
294
- it 'returns false if user does not exist' do
295
- list_subscriber = @client.list_subscriber?('sferik', 'presidents', 12_345_678)
296
- expect(list_subscriber).to be false
297
- end
298
- end
299
- context 'with a owner ID passed' do
300
- before do
301
- stub_get('/1.1/lists/subscribers/show.json').with(:query => {:owner_id => '12345678', :slug => 'presidents', :user_id => '813286'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
302
- end
303
- it 'requests the correct resource' do
304
- @client.list_subscriber?(12_345_678, 'presidents', 813_286)
305
- expect(a_get('/1.1/lists/subscribers/show.json').with(:query => {:owner_id => '12345678', :slug => 'presidents', :user_id => '813286'})).to have_been_made
306
- end
307
- end
308
- context 'with a list ID passed' do
309
- before do
310
- stub_get('/1.1/lists/subscribers/show.json').with(:query => {:owner_screen_name => 'sferik', :list_id => '12345678', :user_id => '813286'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
311
- end
312
- it 'requests the correct resource' do
313
- @client.list_subscriber?('sferik', 12_345_678, 813_286)
314
- expect(a_get('/1.1/lists/subscribers/show.json').with(:query => {:owner_screen_name => 'sferik', :list_id => '12345678', :user_id => '813286'})).to have_been_made
315
- end
316
- end
317
- context 'with a list object passed' do
318
- before do
319
- stub_get('/1.1/lists/subscribers/show.json').with(:query => {:owner_id => '7505382', :list_id => '12345678', :user_id => '813286'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
320
- end
321
- it 'requests the correct resource' do
322
- list = Twitter::List.new(:id => 12_345_678, :user => {:id => 7_505_382, :screen_name => 'sferik'})
323
- @client.list_subscriber?(list, 813_286)
324
- expect(a_get('/1.1/lists/subscribers/show.json').with(:query => {:owner_id => '7505382', :list_id => '12345678', :user_id => '813286'})).to have_been_made
325
- end
326
- end
327
- context 'with a screen name passed for user_to_check' do
328
- before do
329
- stub_get('/1.1/lists/subscribers/show.json').with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :screen_name => 'erebor'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
330
- end
331
- it 'requests the correct resource' do
332
- @client.list_subscriber?('sferik', 'presidents', 'erebor')
333
- expect(a_get('/1.1/lists/subscribers/show.json').with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :screen_name => 'erebor'})).to have_been_made
334
- end
335
- end
336
- context 'without a screen name passed' do
337
- before do
338
- 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'})
339
- stub_get('/1.1/lists/subscribers/show.json').with(:query => {:owner_id => '7505382', :slug => 'presidents', :user_id => '813286'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
340
- end
341
- it 'requests the correct resource' do
342
- @client.list_subscriber?('presidents', 813_286)
343
- expect(a_get('/1.1/account/verify_credentials.json').with(:query => {:skip_status => 'true'})).to have_been_made
344
- expect(a_get('/1.1/lists/subscribers/show.json').with(:query => {:owner_id => '7505382', :slug => 'presidents', :user_id => '813286'})).to have_been_made
345
- end
346
- end
347
- end
348
-
349
- describe '#list_unsubscribe' do
350
- context 'with a screen name passed' do
351
- before do
352
- stub_post('/1.1/lists/subscribers/destroy.json').with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents'}).to_return(:body => fixture('list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
353
- end
354
- it 'requests the correct resource' do
355
- @client.list_unsubscribe('sferik', 'presidents')
356
- expect(a_post('/1.1/lists/subscribers/destroy.json').with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents'})).to have_been_made
357
- end
358
- it 'returns the specified list' do
359
- list = @client.list_unsubscribe('sferik', 'presidents')
360
- expect(list).to be_a Twitter::List
361
- expect(list.name).to eq('presidents')
362
- end
363
- end
364
- context 'without a screen name passed' do
365
- before do
366
- 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'})
367
- stub_post('/1.1/lists/subscribers/destroy.json').with(:body => {:owner_id => '7505382', :slug => 'presidents'}).to_return(:body => fixture('list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
368
- end
369
- it 'requests the correct resource' do
370
- @client.list_unsubscribe('presidents')
371
- expect(a_get('/1.1/account/verify_credentials.json').with(:query => {:skip_status => 'true'})).to have_been_made
372
- expect(a_post('/1.1/lists/subscribers/destroy.json').with(:body => {:owner_id => '7505382', :slug => 'presidents'})).to have_been_made
373
- end
374
- end
375
- end
376
-
377
- describe '#add_list_members' do
378
- context 'with a screen name passed' do
379
- before do
380
- stub_post('/1.1/lists/members/create_all.json').with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => '813286,18755393'}).to_return(:body => fixture('list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
381
- end
382
- it 'requests the correct resource' do
383
- @client.add_list_members('sferik', 'presidents', [813_286, 18_755_393])
384
- expect(a_post('/1.1/lists/members/create_all.json').with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => '813286,18755393'})).to have_been_made
385
- end
386
- it 'returns the list' do
387
- list = @client.add_list_members('sferik', 'presidents', [813_286, 18_755_393])
388
- expect(list).to be_a Twitter::List
389
- expect(list.name).to eq('presidents')
390
- end
391
- end
392
- context 'with a combination of member IDs and member screen names to add' do
393
- before do
394
- stub_post('/1.1/lists/members/create_all.json').with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => '813286,18755393', :screen_name => 'pengwynn,erebor'}).to_return(:body => fixture('list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
395
- end
396
- it 'requests the correct resource' do
397
- @client.add_list_members('sferik', 'presidents', [813_286, 'pengwynn', 18_755_393, 'erebor'])
398
- expect(a_post('/1.1/lists/members/create_all.json').with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => '813286,18755393', :screen_name => 'pengwynn,erebor'})).to have_been_made
399
- end
400
- end
401
- context 'without a screen name passed' do
402
- before do
403
- 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'})
404
- stub_post('/1.1/lists/members/create_all.json').with(:body => {:owner_id => '7505382', :slug => 'presidents', :user_id => '813286,18755393'}).to_return(:body => fixture('list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
405
- end
406
- it 'requests the correct resource' do
407
- @client.add_list_members('presidents', [813_286, 18_755_393])
408
- expect(a_get('/1.1/account/verify_credentials.json').with(:query => {:skip_status => 'true'})).to have_been_made
409
- expect(a_post('/1.1/lists/members/create_all.json').with(:body => {:owner_id => '7505382', :slug => 'presidents', :user_id => '813286,18755393'})).to have_been_made
410
- end
411
- end
412
- end
413
-
414
- describe '#list_member?' do
415
- context 'with a screen name passed' do
416
- before do
417
- stub_get('/1.1/lists/members/show.json').with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => '813286'}).to_return(:body => fixture('list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
418
- stub_get('/1.1/lists/members/show.json').with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => '65493023'}).to_return(:body => fixture('not_found.json'), :status => 404, :headers => {:content_type => 'application/json; charset=utf-8'})
419
- stub_get('/1.1/lists/members/show.json').with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => '12345678'}).to_return(:body => fixture('not_found.json'), :status => 403, :headers => {:content_type => 'application/json; charset=utf-8'})
420
- end
421
- it 'requests the correct resource' do
422
- @client.list_member?('sferik', 'presidents', 813_286)
423
- expect(a_get('/1.1/lists/members/show.json').with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => '813286'})).to have_been_made
424
- end
425
- it 'returns true if user is a list member' do
426
- list_member = @client.list_member?('sferik', 'presidents', 813_286)
427
- expect(list_member).to be true
428
- end
429
- it 'returns false if user is not a list member' do
430
- list_member = @client.list_member?('sferik', 'presidents', 65_493_023)
431
- expect(list_member).to be false
432
- end
433
- it 'returns false if user does not exist' do
434
- list_member = @client.list_member?('sferik', 'presidents', 12_345_678)
435
- expect(list_member).to be false
436
- end
437
- end
438
- context 'with an owner ID passed' do
439
- before do
440
- stub_get('/1.1/lists/members/show.json').with(:query => {:owner_id => '12345678', :slug => 'presidents', :user_id => '813286'}).to_return(:body => fixture('list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
441
- end
442
- it 'requests the correct resource' do
443
- @client.list_member?(12_345_678, 'presidents', 813_286)
444
- expect(a_get('/1.1/lists/members/show.json').with(:query => {:owner_id => '12345678', :slug => 'presidents', :user_id => '813286'})).to have_been_made
445
- end
446
- end
447
- context 'with a list ID passed' do
448
- before do
449
- stub_get('/1.1/lists/members/show.json').with(:query => {:owner_screen_name => 'sferik', :list_id => '12345678', :user_id => '813286'}).to_return(:body => fixture('list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
450
- end
451
- it 'requests the correct resource' do
452
- @client.list_member?('sferik', 12_345_678, 813_286)
453
- expect(a_get('/1.1/lists/members/show.json').with(:query => {:owner_screen_name => 'sferik', :list_id => '12345678', :user_id => '813286'})).to have_been_made
454
- end
455
- end
456
- context 'with a list object passed' do
457
- before do
458
- stub_get('/1.1/lists/members/show.json').with(:query => {:owner_id => '7505382', :list_id => '12345678', :user_id => '813286'}).to_return(:body => fixture('list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
459
- end
460
- it 'requests the correct resource' do
461
- list = Twitter::List.new(:id => 12_345_678, :user => {:id => 7_505_382, :screen_name => 'sferik'})
462
- @client.list_member?(list, 813_286)
463
- expect(a_get('/1.1/lists/members/show.json').with(:query => {:owner_id => '7505382', :list_id => '12345678', :user_id => '813286'})).to have_been_made
464
- end
465
- end
466
- context 'with a screen name passed for user_to_check' do
467
- before do
468
- stub_get('/1.1/lists/members/show.json').with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :screen_name => 'erebor'}).to_return(:body => fixture('list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
469
- end
470
- it 'requests the correct resource' do
471
- @client.list_member?('sferik', 'presidents', 'erebor')
472
- expect(a_get('/1.1/lists/members/show.json').with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :screen_name => 'erebor'})).to have_been_made
473
- end
474
- end
475
- context 'without a screen name passed' do
476
- before do
477
- 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'})
478
- stub_get('/1.1/lists/members/show.json').with(:query => {:owner_id => '7505382', :slug => 'presidents', :user_id => '813286'}).to_return(:body => fixture('list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
479
- end
480
- it 'requests the correct resource' do
481
- @client.list_member?('presidents', 813_286)
482
- expect(a_get('/1.1/account/verify_credentials.json').with(:query => {:skip_status => 'true'})).to have_been_made
483
- expect(a_get('/1.1/lists/members/show.json').with(:query => {:owner_id => '7505382', :slug => 'presidents', :user_id => '813286'})).to have_been_made
484
- end
485
- end
486
- end
487
-
488
- describe '#list_members' do
489
- context 'with a screen name passed' do
490
- before do
491
- stub_get('/1.1/lists/members.json').with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :cursor => '-1'}).to_return(:body => fixture('users_list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
492
- end
493
- it 'requests the correct resource' do
494
- @client.list_members('sferik', 'presidents')
495
- expect(a_get('/1.1/lists/members.json').with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :cursor => '-1'})).to have_been_made
496
- end
497
- it 'returns the members of the specified list' do
498
- list_members = @client.list_members('sferik', 'presidents')
499
- expect(list_members).to be_a Twitter::Cursor
500
- expect(list_members.first).to be_a Twitter::User
501
- expect(list_members.first.id).to eq(7_505_382)
502
- end
503
- context 'with each' do
504
- before do
505
- stub_get('/1.1/lists/members.json').with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :cursor => '1322801608223717003'}).to_return(:body => fixture('users_list2.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
506
- end
507
- it 'requests the correct resource' do
508
- @client.list_members('sferik', 'presidents').each {}
509
- expect(a_get('/1.1/lists/members.json').with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :cursor => '-1'})).to have_been_made
510
- expect(a_get('/1.1/lists/members.json').with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :cursor => '1322801608223717003'})).to have_been_made
511
- end
512
- end
513
- end
514
- context 'with a user ID passed' do
515
- before do
516
- stub_get('/1.1/lists/members.json').with(:query => {:owner_id => '7505382', :slug => 'presidents', :cursor => '-1'}).to_return(:body => fixture('users_list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
517
- end
518
- it 'requests the correct resource' do
519
- @client.list_members(7_505_382, 'presidents')
520
- expect(a_get('/1.1/lists/members.json').with(:query => {:owner_id => '7505382', :slug => 'presidents', :cursor => '-1'})).to have_been_made
521
- end
522
- context 'with each' do
523
- before do
524
- stub_get('/1.1/lists/members.json').with(:query => {:owner_id => '7505382', :slug => 'presidents', :cursor => '1322801608223717003'}).to_return(:body => fixture('users_list2.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
525
- end
526
- it 'requests the correct resource' do
527
- @client.list_members(7_505_382, 'presidents').each {}
528
- expect(a_get('/1.1/lists/members.json').with(:query => {:owner_id => '7505382', :slug => 'presidents', :cursor => '-1'})).to have_been_made
529
- expect(a_get('/1.1/lists/members.json').with(:query => {:owner_id => '7505382', :slug => 'presidents', :cursor => '1322801608223717003'})).to have_been_made
530
- end
531
- end
532
- end
533
- context 'without a screen name passed' do
534
- before do
535
- 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'})
536
- stub_get('/1.1/lists/members.json').with(:query => {:owner_id => '7505382', :slug => 'presidents', :cursor => '-1'}).to_return(:body => fixture('users_list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
537
- end
538
- it 'requests the correct resource' do
539
- @client.list_members('presidents')
540
- expect(a_get('/1.1/account/verify_credentials.json').with(:query => {:skip_status => 'true'})).to have_been_made
541
- expect(a_get('/1.1/lists/members.json').with(:query => {:owner_id => '7505382', :slug => 'presidents', :cursor => '-1'})).to have_been_made
542
- end
543
- context 'with each' do
544
- before do
545
- stub_get('/1.1/lists/members.json').with(:query => {:owner_id => '7505382', :slug => 'presidents', :cursor => '1322801608223717003'}).to_return(:body => fixture('users_list2.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
546
- end
547
- it 'requests the correct resource' do
548
- @client.list_members('presidents').each {}
549
- expect(a_get('/1.1/account/verify_credentials.json').with(:query => {:skip_status => 'true'})).to have_been_made
550
- expect(a_get('/1.1/lists/members.json').with(:query => {:owner_id => '7505382', :slug => 'presidents', :cursor => '-1'})).to have_been_made
551
- expect(a_get('/1.1/lists/members.json').with(:query => {:owner_id => '7505382', :slug => 'presidents', :cursor => '1322801608223717003'})).to have_been_made
552
- end
553
- end
554
- end
555
- end
556
-
557
- describe '#add_list_member' do
558
- context 'with a screen name passed' do
559
- before do
560
- stub_post('/1.1/lists/members/create.json').with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => '813286'}).to_return(:body => fixture('list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
561
- end
562
- it 'requests the correct resource' do
563
- @client.add_list_member('sferik', 'presidents', 813_286)
564
- expect(a_post('/1.1/lists/members/create.json').with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => '813286'})).to have_been_made
565
- end
566
- it 'returns the list' do
567
- list = @client.add_list_member('sferik', 'presidents', 813_286)
568
- expect(list).to be_a Twitter::List
569
- expect(list.name).to eq('presidents')
570
- end
571
- end
572
- context 'without a screen name passed' do
573
- before do
574
- 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'})
575
- stub_post('/1.1/lists/members/create.json').with(:body => {:owner_id => '7505382', :slug => 'presidents', :user_id => '813286'}).to_return(:body => fixture('list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
576
- end
577
- it 'requests the correct resource' do
578
- @client.add_list_member('presidents', 813_286)
579
- expect(a_get('/1.1/account/verify_credentials.json').with(:query => {:skip_status => 'true'})).to have_been_made
580
- expect(a_post('/1.1/lists/members/create.json').with(:body => {:owner_id => '7505382', :slug => 'presidents', :user_id => '813286'})).to have_been_made
581
- end
582
- end
583
- end
584
-
585
- describe '#destroy_list' do
586
- context 'with a screen name passed' do
587
- before do
588
- stub_post('/1.1/lists/destroy.json').with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents'}).to_return(:body => fixture('list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
589
- end
590
- it 'requests the correct resource' do
591
- @client.destroy_list('sferik', 'presidents')
592
- expect(a_post('/1.1/lists/destroy.json').with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents'})).to have_been_made
593
- end
594
- it 'returns the deleted list' do
595
- list = @client.destroy_list('sferik', 'presidents')
596
- expect(list).to be_a Twitter::List
597
- expect(list.name).to eq('presidents')
598
- end
599
- end
600
- context 'without a screen name passed' do
601
- before do
602
- 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'})
603
- stub_post('/1.1/lists/destroy.json').with(:body => {:owner_id => '7505382', :slug => 'presidents'}).to_return(:body => fixture('list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
604
- end
605
- it 'requests the correct resource' do
606
- @client.destroy_list('presidents')
607
- expect(a_get('/1.1/account/verify_credentials.json').with(:query => {:skip_status => 'true'})).to have_been_made
608
- expect(a_post('/1.1/lists/destroy.json').with(:body => {:owner_id => '7505382', :slug => 'presidents'})).to have_been_made
609
- end
610
- end
611
- context 'with a list ID passed' do
612
- before do
613
- stub_post('/1.1/lists/destroy.json').with(:body => {:owner_screen_name => 'sferik', :list_id => '12345678'}).to_return(:body => fixture('list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
614
- end
615
- it 'requests the correct resource' do
616
- @client.destroy_list('sferik', 12_345_678)
617
- expect(a_post('/1.1/lists/destroy.json').with(:body => {:owner_screen_name => 'sferik', :list_id => '12345678'})).to have_been_made
618
- end
619
- end
620
- context 'with a list object passed' do
621
- before do
622
- stub_post('/1.1/lists/destroy.json').with(:body => {:owner_id => '7505382', :list_id => '12345678'}).to_return(:body => fixture('list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
623
- end
624
- it 'requests the correct resource' do
625
- list = Twitter::List.new(:id => '12345678', :user => {:id => 7_505_382, :screen_name => 'sferik'})
626
- @client.destroy_list(list)
627
- expect(a_post('/1.1/lists/destroy.json').with(:body => {:owner_id => '7505382', :list_id => '12345678'})).to have_been_made
628
- end
629
- end
630
- end
631
-
632
- describe '#list_update' do
633
- context 'with a screen name passed' do
634
- before do
635
- stub_post('/1.1/lists/update.json').with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents', :description => 'Presidents of the United States of America'}).to_return(:body => fixture('list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
636
- end
637
- it 'requests the correct resource' do
638
- @client.list_update('sferik', 'presidents', :description => 'Presidents of the United States of America')
639
- expect(a_post('/1.1/lists/update.json').with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents', :description => 'Presidents of the United States of America'})).to have_been_made
640
- end
641
- it 'returns the updated list' do
642
- list = @client.list_update('sferik', 'presidents', :description => 'Presidents of the United States of America')
643
- expect(list).to be_a Twitter::List
644
- expect(list.name).to eq('presidents')
645
- end
646
- end
647
- context 'without a screen name passed' do
648
- before do
649
- 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'})
650
- stub_post('/1.1/lists/update.json').with(:body => {:owner_id => '7505382', :slug => 'presidents', :description => 'Presidents of the United States of America'}).to_return(:body => fixture('list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
651
- end
652
- it 'requests the correct resource' do
653
- @client.list_update('presidents', :description => 'Presidents of the United States of America')
654
- expect(a_get('/1.1/account/verify_credentials.json').with(:query => {:skip_status => 'true'})).to have_been_made
655
- expect(a_post('/1.1/lists/update.json').with(:body => {:owner_id => '7505382', :slug => 'presidents', :description => 'Presidents of the United States of America'})).to have_been_made
656
- end
657
- end
658
- context 'with a list ID passed' do
659
- before do
660
- stub_post('/1.1/lists/update.json').with(:body => {:owner_screen_name => 'sferik', :list_id => '12345678', :description => 'Presidents of the United States of America'}).to_return(:body => fixture('list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
661
- end
662
- it 'requests the correct resource' do
663
- @client.list_update('sferik', 12_345_678, :description => 'Presidents of the United States of America')
664
- expect(a_post('/1.1/lists/update.json').with(:body => {:owner_screen_name => 'sferik', :list_id => '12345678', :description => 'Presidents of the United States of America'})).to have_been_made
665
- end
666
- end
667
- context 'with a list object passed' do
668
- before do
669
- stub_post('/1.1/lists/update.json').with(:body => {:owner_id => '7505382', :list_id => '12345678', :description => 'Presidents of the United States of America'}).to_return(:body => fixture('list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
670
- end
671
- it 'requests the correct resource' do
672
- list = Twitter::List.new(:id => '12345678', :user => {:id => 7_505_382, :screen_name => 'sferik'})
673
- @client.list_update(list, :description => 'Presidents of the United States of America')
674
- expect(a_post('/1.1/lists/update.json').with(:body => {:owner_id => '7505382', :list_id => '12345678', :description => 'Presidents of the United States of America'})).to have_been_made
675
- end
676
- end
677
- end
678
-
679
- describe '#create_list' do
680
- before do
681
- stub_post('/1.1/lists/create.json').with(:body => {:name => 'presidents'}).to_return(:body => fixture('list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
682
- end
683
- it 'requests the correct resource' do
684
- @client.create_list('presidents')
685
- expect(a_post('/1.1/lists/create.json').with(:body => {:name => 'presidents'})).to have_been_made
686
- end
687
- it 'returns the created list' do
688
- list = @client.create_list('presidents')
689
- expect(list).to be_a Twitter::List
690
- expect(list.name).to eq('presidents')
691
- end
692
- end
693
-
694
- describe '#list' do
695
- context 'with a screen name passed' do
696
- before do
697
- stub_get('/1.1/lists/show.json').with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents'}).to_return(:body => fixture('list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
698
- end
699
- it 'requests the correct resource' do
700
- @client.list('sferik', 'presidents')
701
- expect(a_get('/1.1/lists/show.json').with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents'})).to have_been_made
702
- end
703
- it 'returns the updated list' do
704
- list = @client.list('sferik', 'presidents')
705
- expect(list).to be_a Twitter::List
706
- expect(list.name).to eq('presidents')
707
- end
708
- end
709
- context 'with a user ID passed' do
710
- before do
711
- stub_get('/1.1/lists/show.json').with(:query => {:owner_id => '12345678', :slug => 'presidents'}).to_return(:body => fixture('list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
712
- end
713
- it 'requests the correct resource' do
714
- @client.list(12_345_678, 'presidents')
715
- expect(a_get('/1.1/lists/show.json').with(:query => {:owner_id => '12345678', :slug => 'presidents'})).to have_been_made
716
- end
717
- end
718
- context 'with a user object passed' do
719
- before do
720
- stub_get('/1.1/lists/show.json').with(:query => {:owner_id => '12345678', :slug => 'presidents'}).to_return(:body => fixture('list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
721
- end
722
- it 'requests the correct resource' do
723
- user = Twitter::User.new(:id => '12345678')
724
- @client.list(user, 'presidents')
725
- expect(a_get('/1.1/lists/show.json').with(:query => {:owner_id => '12345678', :slug => 'presidents'})).to have_been_made
726
- end
727
- end
728
- context 'without a screen name passed' do
729
- before do
730
- 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'})
731
- stub_get('/1.1/lists/show.json').with(:query => {:owner_id => '7505382', :slug => 'presidents'}).to_return(:body => fixture('list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
732
- end
733
- it 'requests the correct resource' do
734
- @client.list('presidents')
735
- expect(a_get('/1.1/account/verify_credentials.json').with(:query => {:skip_status => 'true'})).to have_been_made
736
- expect(a_get('/1.1/lists/show.json').with(:query => {:owner_id => '7505382', :slug => 'presidents'})).to have_been_made
737
- end
738
- end
739
- context 'with a list ID passed' do
740
- before do
741
- stub_get('/1.1/lists/show.json').with(:query => {:owner_screen_name => 'sferik', :list_id => '12345678'}).to_return(:body => fixture('list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
742
- end
743
- it 'requests the correct resource' do
744
- @client.list('sferik', 12_345_678)
745
- expect(a_get('/1.1/lists/show.json').with(:query => {:owner_screen_name => 'sferik', :list_id => '12345678'})).to have_been_made
746
- end
747
- end
748
- context 'with a list object passed' do
749
- before do
750
- stub_get('/1.1/lists/show.json').with(:query => {:owner_id => '7505382', :list_id => '12345678'}).to_return(:body => fixture('list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
751
- end
752
- it 'requests the correct resource' do
753
- list = Twitter::List.new(:id => '12345678', :user => {:id => 7_505_382, :screen_name => 'sferik'})
754
- @client.list(list)
755
- expect(a_get('/1.1/lists/show.json').with(:query => {:owner_id => '7505382', :list_id => '12345678'})).to have_been_made
756
- end
757
- end
758
- end
759
-
760
- describe '#subscriptions' do
761
- context 'with a screen name passed' do
762
- before do
763
- stub_get('/1.1/lists/subscriptions.json').with(:query => {:screen_name => 'sferik', :cursor => '-1'}).to_return(:body => fixture('subscriptions.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
764
- end
765
- it 'requests the correct resource' do
766
- @client.subscriptions('sferik')
767
- expect(a_get('/1.1/lists/subscriptions.json').with(:query => {:screen_name => 'sferik', :cursor => '-1'})).to have_been_made
768
- end
769
- it 'returns the lists the specified user follows' do
770
- subscriptions = @client.subscriptions('sferik')
771
- expect(subscriptions).to be_a Twitter::Cursor
772
- expect(subscriptions.first).to be_a Twitter::List
773
- expect(subscriptions.first.name).to eq('Rubyists')
774
- end
775
- context 'with each' do
776
- before do
777
- stub_get('/1.1/lists/subscriptions.json').with(:query => {:screen_name => 'sferik', :cursor => '1401037770457540712'}).to_return(:body => fixture('subscriptions2.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
778
- end
779
- it 'requests the correct resource' do
780
- @client.subscriptions('sferik').each {}
781
- expect(a_get('/1.1/lists/subscriptions.json').with(:query => {:screen_name => 'sferik', :cursor => '-1'})).to have_been_made
782
- expect(a_get('/1.1/lists/subscriptions.json').with(:query => {:screen_name => 'sferik', :cursor => '1401037770457540712'})).to have_been_made
783
- end
784
- end
785
- end
786
- context 'with a user ID passed' do
787
- before do
788
- stub_get('/1.1/lists/subscriptions.json').with(:query => {:user_id => '7505382', :cursor => '-1'}).to_return(:body => fixture('subscriptions.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
789
- end
790
- it 'requests the correct resource' do
791
- @client.subscriptions(7_505_382)
792
- expect(a_get('/1.1/lists/subscriptions.json').with(:query => {:user_id => '7505382', :cursor => '-1'})).to have_been_made
793
- end
794
- context 'with each' do
795
- before do
796
- stub_get('/1.1/lists/subscriptions.json').with(:query => {:user_id => '7505382', :cursor => '1401037770457540712'}).to_return(:body => fixture('subscriptions2.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
797
- end
798
- it 'requests the correct resource' do
799
- @client.subscriptions(7_505_382).each {}
800
- expect(a_get('/1.1/lists/subscriptions.json').with(:query => {:user_id => '7505382', :cursor => '-1'})).to have_been_made
801
- expect(a_get('/1.1/lists/subscriptions.json').with(:query => {:user_id => '7505382', :cursor => '1401037770457540712'})).to have_been_made
802
- end
803
- end
804
- end
805
- context 'without a screen name passed' do
806
- before do
807
- 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'})
808
- stub_get('/1.1/lists/subscriptions.json').with(:query => {:user_id => '7505382', :cursor => '-1'}).to_return(:body => fixture('subscriptions.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
809
- end
810
- it 'requests the correct resource' do
811
- @client.subscriptions
812
- expect(a_get('/1.1/account/verify_credentials.json').with(:query => {:skip_status => 'true'})).to have_been_made
813
- expect(a_get('/1.1/lists/subscriptions.json').with(:query => {:user_id => '7505382', :cursor => '-1'})).to have_been_made
814
- end
815
- context 'with each' do
816
- before do
817
- stub_get('/1.1/lists/subscriptions.json').with(:query => {:user_id => '7505382', :cursor => '1401037770457540712'}).to_return(:body => fixture('subscriptions2.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
818
- end
819
- it 'requests the correct resource' do
820
- @client.subscriptions.each {}
821
- expect(a_get('/1.1/account/verify_credentials.json').with(:query => {:skip_status => 'true'})).to have_been_made
822
- expect(a_get('/1.1/lists/subscriptions.json').with(:query => {:user_id => '7505382', :cursor => '-1'})).to have_been_made
823
- expect(a_get('/1.1/lists/subscriptions.json').with(:query => {:user_id => '7505382', :cursor => '1401037770457540712'})).to have_been_made
824
- end
825
- end
826
- end
827
- end
828
-
829
- describe '#remove_list_members' do
830
- context 'with a screen name passed' do
831
- before do
832
- 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'})
833
- end
834
- it 'requests the correct resource' do
835
- @client.remove_list_members('sferik', 'presidents', [813_286, 18_755_393])
836
- 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
837
- end
838
- it 'returns the list' do
839
- list = @client.remove_list_members('sferik', 'presidents', [813_286, 18_755_393])
840
- expect(list).to be_a Twitter::List
841
- expect(list.name).to eq('presidents')
842
- end
843
- end
844
- context 'with a user ID passed' do
845
- before do
846
- stub_post('/1.1/lists/members/destroy_all.json').with(:body => {:owner_id => '7505382', :slug => 'presidents', :user_id => '813286,18755393'}).to_return(:body => fixture('list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
847
- end
848
- it 'requests the correct resource' do
849
- @client.remove_list_members(7_505_382, 'presidents', [813_286, 18_755_393])
850
- expect(a_post('/1.1/lists/members/destroy_all.json').with(:body => {:owner_id => '7505382', :slug => 'presidents', :user_id => '813286,18755393'})).to have_been_made
851
- end
852
- end
853
- context 'with a combination of member IDs and member screen names to add' do
854
- before do
855
- 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'})
856
- end
857
- it 'requests the correct resource' do
858
- @client.remove_list_members('sferik', 'presidents', [813_286, 'pengwynn', 18_755_393, 'erebor'])
859
- 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
860
- end
861
- end
862
- context 'without a screen name passed' do
863
- before do
864
- 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'})
865
- stub_post('/1.1/lists/members/destroy_all.json').with(:body => {:owner_id => '7505382', :slug => 'presidents', :user_id => '813286,18755393'}).to_return(:body => fixture('list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
866
- end
867
- it 'requests the correct resource' do
868
- @client.remove_list_members('presidents', [813_286, 18_755_393])
869
- expect(a_get('/1.1/account/verify_credentials.json').with(:query => {:skip_status => 'true'})).to have_been_made
870
- expect(a_post('/1.1/lists/members/destroy_all.json').with(:body => {:owner_id => '7505382', :slug => 'presidents', :user_id => '813286,18755393'})).to have_been_made
871
- end
872
- end
873
- end
874
-
875
- describe '#owned_lists' do
876
- context 'with a screen name passed' do
877
- before do
878
- stub_get('/1.1/lists/ownerships.json').with(:query => {:screen_name => 'sferik', :cursor => '-1'}).to_return(:body => fixture('ownerships.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
879
- end
880
- it 'requests the correct resource' do
881
- @client.owned_lists('sferik')
882
- expect(a_get('/1.1/lists/ownerships.json').with(:query => {:screen_name => 'sferik', :cursor => '-1'})).to have_been_made
883
- end
884
- it 'returns the requested list' do
885
- lists = @client.owned_lists('sferik')
886
- expect(lists).to be_a Twitter::Cursor
887
- expect(lists.first).to be_a Twitter::List
888
- expect(lists.first.name).to eq('My favstar.fm list')
889
- end
890
- end
891
- context 'without a screen name passed' do
892
- before do
893
- 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'})
894
- stub_get('/1.1/lists/ownerships.json').with(:query => {:user_id => '7505382', :cursor => '-1'}).to_return(:body => fixture('ownerships.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
895
- end
896
- it 'requests the correct resource' do
897
- @client.owned_lists
898
- expect(a_get('/1.1/account/verify_credentials.json').with(:query => {:skip_status => 'true'})).to have_been_made
899
- expect(a_get('/1.1/lists/ownerships.json').with(:query => {:user_id => '7505382', :cursor => '-1'})).to have_been_made
900
- end
901
- it 'returns the requested list' do
902
- lists = @client.owned_lists
903
- expect(lists).to be_a Twitter::Cursor
904
- expect(lists.first).to be_a Twitter::List
905
- expect(lists.first.name).to eq('My favstar.fm list')
906
- end
907
- end
908
- end
909
-
910
- end