ifttt-twitter 2.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (217) hide show
  1. data/.gemtest +0 -0
  2. data/.gitignore +12 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +9 -0
  5. data/.yardopts +8 -0
  6. data/Gemfile +7 -0
  7. data/HISTORY.md +520 -0
  8. data/LICENSE.md +20 -0
  9. data/README.md +251 -0
  10. data/Rakefile +13 -0
  11. data/lib/twitter.rb +24 -0
  12. data/lib/twitter/action.rb +9 -0
  13. data/lib/twitter/action_factory.rb +28 -0
  14. data/lib/twitter/authenticatable.rb +24 -0
  15. data/lib/twitter/base.rb +40 -0
  16. data/lib/twitter/client.rb +126 -0
  17. data/lib/twitter/client/accounts.rb +180 -0
  18. data/lib/twitter/client/activity.rb +48 -0
  19. data/lib/twitter/client/block.rb +104 -0
  20. data/lib/twitter/client/direct_messages.rb +110 -0
  21. data/lib/twitter/client/favorites.rb +82 -0
  22. data/lib/twitter/client/friends_and_followers.rb +293 -0
  23. data/lib/twitter/client/help.rb +38 -0
  24. data/lib/twitter/client/legal.rb +32 -0
  25. data/lib/twitter/client/lists.rb +643 -0
  26. data/lib/twitter/client/local_trends.rb +46 -0
  27. data/lib/twitter/client/notification.rb +49 -0
  28. data/lib/twitter/client/places_and_geo.rb +113 -0
  29. data/lib/twitter/client/saved_searches.rb +73 -0
  30. data/lib/twitter/client/search.rb +94 -0
  31. data/lib/twitter/client/spam_reporting.rb +30 -0
  32. data/lib/twitter/client/suggested_users.rb +60 -0
  33. data/lib/twitter/client/timelines.rb +265 -0
  34. data/lib/twitter/client/trends.rb +55 -0
  35. data/lib/twitter/client/tweets.rb +191 -0
  36. data/lib/twitter/client/urls.rb +26 -0
  37. data/lib/twitter/client/users.rb +203 -0
  38. data/lib/twitter/config.rb +106 -0
  39. data/lib/twitter/configuration.rb +20 -0
  40. data/lib/twitter/connection.rb +43 -0
  41. data/lib/twitter/core_ext/hash.rb +81 -0
  42. data/lib/twitter/creatable.rb +14 -0
  43. data/lib/twitter/cursor.rb +44 -0
  44. data/lib/twitter/direct_message.rb +27 -0
  45. data/lib/twitter/error.rb +37 -0
  46. data/lib/twitter/error/bad_gateway.rb +7 -0
  47. data/lib/twitter/error/bad_request.rb +7 -0
  48. data/lib/twitter/error/client_error.rb +7 -0
  49. data/lib/twitter/error/enhance_your_calm.rb +13 -0
  50. data/lib/twitter/error/forbidden.rb +7 -0
  51. data/lib/twitter/error/internal_server_error.rb +7 -0
  52. data/lib/twitter/error/not_acceptable.rb +7 -0
  53. data/lib/twitter/error/not_found.rb +7 -0
  54. data/lib/twitter/error/server_error.rb +7 -0
  55. data/lib/twitter/error/service_unavailable.rb +7 -0
  56. data/lib/twitter/error/unauthorized.rb +7 -0
  57. data/lib/twitter/favorite.rb +28 -0
  58. data/lib/twitter/follow.rb +27 -0
  59. data/lib/twitter/geo_factory.rb +22 -0
  60. data/lib/twitter/language.rb +7 -0
  61. data/lib/twitter/list.rb +22 -0
  62. data/lib/twitter/list_member_added.rb +36 -0
  63. data/lib/twitter/media_factory.rb +21 -0
  64. data/lib/twitter/mention.rb +43 -0
  65. data/lib/twitter/metadata.rb +7 -0
  66. data/lib/twitter/oembed.rb +8 -0
  67. data/lib/twitter/photo.rb +24 -0
  68. data/lib/twitter/place.rb +36 -0
  69. data/lib/twitter/point.rb +27 -0
  70. data/lib/twitter/polygon.rb +14 -0
  71. data/lib/twitter/rate_limit_status.rb +15 -0
  72. data/lib/twitter/relationship.rb +18 -0
  73. data/lib/twitter/reply.rb +36 -0
  74. data/lib/twitter/request.rb +38 -0
  75. data/lib/twitter/request/gateway.rb +20 -0
  76. data/lib/twitter/request/multipart_with_file.rb +37 -0
  77. data/lib/twitter/request/oauth.rb +26 -0
  78. data/lib/twitter/request/phoenix.rb +22 -0
  79. data/lib/twitter/response/parse_json.rb +28 -0
  80. data/lib/twitter/response/raise_client_error.rb +49 -0
  81. data/lib/twitter/response/raise_server_error.rb +23 -0
  82. data/lib/twitter/retweet.rb +36 -0
  83. data/lib/twitter/saved_search.rb +16 -0
  84. data/lib/twitter/settings.rb +17 -0
  85. data/lib/twitter/size.rb +16 -0
  86. data/lib/twitter/status.rb +80 -0
  87. data/lib/twitter/suggestion.rb +22 -0
  88. data/lib/twitter/trend.rb +14 -0
  89. data/lib/twitter/user.rb +65 -0
  90. data/lib/twitter/version.rb +30 -0
  91. data/spec/faraday/request_spec.rb +25 -0
  92. data/spec/faraday/response_spec.rb +68 -0
  93. data/spec/fixtures/about_me.json +1 -0
  94. data/spec/fixtures/all.json +1 -0
  95. data/spec/fixtures/bad_gateway.json +1 -0
  96. data/spec/fixtures/bad_request.json +1 -0
  97. data/spec/fixtures/by_friends.json +1 -0
  98. data/spec/fixtures/category.json +1 -0
  99. data/spec/fixtures/configuration.json +1 -0
  100. data/spec/fixtures/contributees.json +1 -0
  101. data/spec/fixtures/contributors.json +1 -0
  102. data/spec/fixtures/direct_message.json +1 -0
  103. data/spec/fixtures/direct_messages.json +1 -0
  104. data/spec/fixtures/end_session.json +1 -0
  105. data/spec/fixtures/enhance_your_calm.text +11 -0
  106. data/spec/fixtures/false.json +1 -0
  107. data/spec/fixtures/favorites.json +1 -0
  108. data/spec/fixtures/forbidden.json +1 -0
  109. data/spec/fixtures/friendships.json +1 -0
  110. data/spec/fixtures/id_list.json +1 -0
  111. data/spec/fixtures/ids.json +1 -0
  112. data/spec/fixtures/image_facets.json +1 -0
  113. data/spec/fixtures/internal_server_error.json +1 -0
  114. data/spec/fixtures/languages.json +1 -0
  115. data/spec/fixtures/list.json +1 -0
  116. data/spec/fixtures/lists.json +1 -0
  117. data/spec/fixtures/locations.json +1 -0
  118. data/spec/fixtures/matching_trends.json +1 -0
  119. data/spec/fixtures/me.jpeg +0 -0
  120. data/spec/fixtures/media_timeline.json +1 -0
  121. data/spec/fixtures/members.json +1 -0
  122. data/spec/fixtures/n605431196_2079896_558_normal.jpg +0 -0
  123. data/spec/fixtures/no_user_matches.json +1 -0
  124. data/spec/fixtures/not_acceptable.json +1 -0
  125. data/spec/fixtures/not_found.json +1 -0
  126. data/spec/fixtures/oembed.json +1 -0
  127. data/spec/fixtures/pengwynn.json +1 -0
  128. data/spec/fixtures/phoenix_search.phoenix +1 -0
  129. data/spec/fixtures/place.json +1 -0
  130. data/spec/fixtures/places.json +1 -0
  131. data/spec/fixtures/privacy.json +1 -0
  132. data/spec/fixtures/profile_image.text +24 -0
  133. data/spec/fixtures/rate_limit_status.json +1 -0
  134. data/spec/fixtures/recommendations.json +1 -0
  135. data/spec/fixtures/relationship.json +1 -0
  136. data/spec/fixtures/resolve.json +1 -0
  137. data/spec/fixtures/retweet.json +1 -0
  138. data/spec/fixtures/retweeters_of.json +1 -0
  139. data/spec/fixtures/retweets.json +1 -0
  140. data/spec/fixtures/saved_search.json +1 -0
  141. data/spec/fixtures/saved_searches.json +1 -0
  142. data/spec/fixtures/search.json +1 -0
  143. data/spec/fixtures/service_unavailable.json +1 -0
  144. data/spec/fixtures/settings.json +1 -0
  145. data/spec/fixtures/sferik.json +1 -0
  146. data/spec/fixtures/status.json +1 -0
  147. data/spec/fixtures/status_with_media.json +104 -0
  148. data/spec/fixtures/statuses.json +1 -0
  149. data/spec/fixtures/suggestions.json +1 -0
  150. data/spec/fixtures/tos.json +1 -0
  151. data/spec/fixtures/totals.json +1 -0
  152. data/spec/fixtures/trends.json +1 -0
  153. data/spec/fixtures/trends_current.json +1 -0
  154. data/spec/fixtures/trends_daily.json +1 -0
  155. data/spec/fixtures/trends_weekly.json +1 -0
  156. data/spec/fixtures/true.json +1 -0
  157. data/spec/fixtures/unauthorized.json +1 -0
  158. data/spec/fixtures/user_search.json +1 -0
  159. data/spec/fixtures/user_timeline.json +1 -0
  160. data/spec/fixtures/users.json +1 -0
  161. data/spec/fixtures/users_list.json +1 -0
  162. data/spec/fixtures/video_facets.json +1 -0
  163. data/spec/fixtures/we_concept_bg2.png +0 -0
  164. data/spec/helper.rb +49 -0
  165. data/spec/twitter/action_factory_spec.rb +37 -0
  166. data/spec/twitter/action_spec.rb +16 -0
  167. data/spec/twitter/base_spec.rb +29 -0
  168. data/spec/twitter/client/accounts_spec.rb +181 -0
  169. data/spec/twitter/client/activity_spec.rb +43 -0
  170. data/spec/twitter/client/block_spec.rb +106 -0
  171. data/spec/twitter/client/direct_messages_spec.rb +98 -0
  172. data/spec/twitter/client/favorites_spec.rb +80 -0
  173. data/spec/twitter/client/friends_and_followers_spec.rb +478 -0
  174. data/spec/twitter/client/help_spec.rb +44 -0
  175. data/spec/twitter/client/legal_spec.rb +41 -0
  176. data/spec/twitter/client/lists_spec.rb +1104 -0
  177. data/spec/twitter/client/local_trends_spec.rb +58 -0
  178. data/spec/twitter/client/notification_spec.rb +47 -0
  179. data/spec/twitter/client/places_and_geo_spec.rb +100 -0
  180. data/spec/twitter/client/saved_searches_spec.rb +80 -0
  181. data/spec/twitter/client/search_spec.rb +92 -0
  182. data/spec/twitter/client/spam_reporting_spec.rb +28 -0
  183. data/spec/twitter/client/suggested_users_spec.rb +65 -0
  184. data/spec/twitter/client/timelines_spec.rb +231 -0
  185. data/spec/twitter/client/trends_spec.rb +51 -0
  186. data/spec/twitter/client/tweets_spec.rb +189 -0
  187. data/spec/twitter/client/urls_spec.rb +31 -0
  188. data/spec/twitter/client/users_spec.rb +323 -0
  189. data/spec/twitter/client_spec.rb +94 -0
  190. data/spec/twitter/configuration_spec.rb +17 -0
  191. data/spec/twitter/cursor_spec.rb +43 -0
  192. data/spec/twitter/direct_message_spec.rb +56 -0
  193. data/spec/twitter/favorite_spec.rb +29 -0
  194. data/spec/twitter/follow_spec.rb +29 -0
  195. data/spec/twitter/geo_factory_spec.rb +21 -0
  196. data/spec/twitter/list_spec.rb +34 -0
  197. data/spec/twitter/media_factory_spec.rb +17 -0
  198. data/spec/twitter/mention_spec.rb +52 -0
  199. data/spec/twitter/oembed_spec.rb +145 -0
  200. data/spec/twitter/photo_spec.rb +35 -0
  201. data/spec/twitter/place_spec.rb +75 -0
  202. data/spec/twitter/point_spec.rb +32 -0
  203. data/spec/twitter/polygon_spec.rb +18 -0
  204. data/spec/twitter/rate_limit_status_spec.rb +16 -0
  205. data/spec/twitter/relationship_spec.rb +27 -0
  206. data/spec/twitter/reply_spec.rb +41 -0
  207. data/spec/twitter/retweet_spec.rb +41 -0
  208. data/spec/twitter/saved_search_spec.rb +34 -0
  209. data/spec/twitter/settings_spec.rb +16 -0
  210. data/spec/twitter/size_spec.rb +18 -0
  211. data/spec/twitter/status_spec.rb +148 -0
  212. data/spec/twitter/suggestion_spec.rb +20 -0
  213. data/spec/twitter/trend_spec.rb +20 -0
  214. data/spec/twitter/user_spec.rb +50 -0
  215. data/spec/twitter_spec.rb +91 -0
  216. data/twitter.gemspec +42 -0
  217. metadata +564 -0
@@ -0,0 +1,44 @@
1
+ require 'helper'
2
+
3
+ describe Twitter::Client do
4
+
5
+ before do
6
+ @client = Twitter::Client.new
7
+ end
8
+
9
+ describe ".configuration" do
10
+ before do
11
+ stub_get("/1/help/configuration.json").
12
+ to_return(:body => fixture("configuration.json"), :headers => {:content_type => "application/json; charset=utf-8"})
13
+ end
14
+ it "should request the correct resource" do
15
+ @client.configuration
16
+ a_get("/1/help/configuration.json").
17
+ should have_been_made
18
+ end
19
+ it "should return Twitter's current configuration" do
20
+ configuration = @client.configuration
21
+ configuration.should be_a Twitter::Configuration
22
+ configuration.characters_reserved_per_media.should == 20
23
+ end
24
+ end
25
+
26
+ describe ".languages" do
27
+ before do
28
+ stub_get("/1/help/languages.json").
29
+ to_return(:body => fixture("languages.json"), :headers => {:content_type => "application/json; charset=utf-8"})
30
+ end
31
+ it "should request the correct resource" do
32
+ @client.languages
33
+ a_get("/1/help/languages.json").
34
+ should have_been_made
35
+ end
36
+ it "should return the list of languages supported by Twitter" do
37
+ languages = @client.languages
38
+ languages.should be_an Array
39
+ languages.first.should be_a Twitter::Language
40
+ languages.first.name.should == "Portuguese"
41
+ end
42
+ end
43
+
44
+ end
@@ -0,0 +1,41 @@
1
+ require 'helper'
2
+
3
+ describe Twitter::Client do
4
+
5
+ before do
6
+ @client = Twitter::Client.new
7
+ end
8
+
9
+ describe ".privacy" do
10
+ before do
11
+ stub_get("/1/legal/privacy.json").
12
+ to_return(:body => fixture("privacy.json"), :headers => {:content_type => "application/json; charset=utf-8"})
13
+ end
14
+ it "should request the correct resource" do
15
+ @client.privacy
16
+ a_get("/1/legal/privacy.json").
17
+ should have_been_made
18
+ end
19
+ it "should return Twitter's Privacy Policy" do
20
+ privacy = @client.privacy
21
+ privacy.split.first.should == "Twitter"
22
+ end
23
+ end
24
+
25
+ describe ".tos" do
26
+ before do
27
+ stub_get("/1/legal/tos.json").
28
+ to_return(:body => fixture("tos.json"), :headers => {:content_type => "application/json; charset=utf-8"})
29
+ end
30
+ it "should request the correct resource" do
31
+ @client.tos
32
+ a_get("/1/legal/tos.json").
33
+ should have_been_made
34
+ end
35
+ it "should return Twitter's Terms of Service" do
36
+ tos = @client.tos
37
+ tos.split.first.should == "Terms"
38
+ end
39
+ end
40
+
41
+ end
@@ -0,0 +1,1104 @@
1
+ require 'helper'
2
+
3
+ describe Twitter::Client do
4
+
5
+ before do
6
+ @client = Twitter::Client.new
7
+ end
8
+
9
+ describe ".lists_subscribed_to" do
10
+ context "with a screen name passed" do
11
+ before do
12
+ stub_get("/1/lists/all.json").
13
+ with(:query => {:screen_name => "sferik"}).
14
+ to_return(:body => fixture("all.json"), :headers => {:content_type => "application/json; charset=utf-8"})
15
+ end
16
+ it "should request the correct resource" do
17
+ @client.lists_subscribed_to("sferik")
18
+ a_get("/1/lists/all.json").
19
+ with(:query => {:screen_name => "sferik"}).
20
+ should have_been_made
21
+ end
22
+ it "should return the lists the specified user subscribes to" do
23
+ lists = @client.lists_subscribed_to("sferik")
24
+ lists.should be_an Array
25
+ lists.first.should be_a Twitter::List
26
+ lists.first.name.should == "Rubyists"
27
+ end
28
+ end
29
+ context "without a screen name passed" do
30
+ before do
31
+ stub_get("/1/account/verify_credentials.json").
32
+ to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
33
+ stub_get("/1/lists/all.json").
34
+ to_return(:body => fixture("all.json"), :headers => {:content_type => "application/json; charset=utf-8"})
35
+ end
36
+ it "should request the correct resource" do
37
+ @client.lists_subscribed_to
38
+ a_get("/1/lists/all.json").
39
+ should have_been_made
40
+ end
41
+ end
42
+ end
43
+
44
+ describe ".list_timeline" do
45
+ context "with a screen name passed" do
46
+ before do
47
+ stub_get("/1/lists/statuses.json").
48
+ with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents'}).
49
+ to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
50
+ end
51
+ it "should request the correct resource" do
52
+ @client.list_timeline("sferik", "presidents")
53
+ a_get("/1/lists/statuses.json").
54
+ with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents'}).
55
+ should have_been_made
56
+ end
57
+ it "should return the timeline for members of the specified list" do
58
+ statuses = @client.list_timeline("sferik", "presidents")
59
+ statuses.should be_an Array
60
+ statuses.first.should be_a Twitter::Status
61
+ statuses.first.text.should == "Ruby is the best programming language for hiding the ugly bits."
62
+ end
63
+ end
64
+ context "without a screen name passed" do
65
+ before do
66
+ stub_get("/1/account/verify_credentials.json").
67
+ to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
68
+ stub_get("/1/lists/statuses.json").
69
+ with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents'}).
70
+ to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
71
+ end
72
+ it "should request the correct resource" do
73
+ @client.list_timeline("presidents")
74
+ a_get("/1/lists/statuses.json").
75
+ with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents'}).
76
+ should have_been_made
77
+ end
78
+ end
79
+ context "with an Integer list_id passed" do
80
+ before do
81
+ stub_get("/1/lists/statuses.json").
82
+ with(:query => {:owner_screen_name => 'sferik', :list_id => '12345678'}).
83
+ to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
84
+ end
85
+ it "should request the correct resource" do
86
+ @client.list_timeline("sferik", 12345678)
87
+ a_get("/1/lists/statuses.json").
88
+ with(:query => {:owner_screen_name => 'sferik', :list_id => '12345678'}).
89
+ should have_been_made
90
+ end
91
+ end
92
+ context "with an Integer user_id passed" do
93
+ before do
94
+ stub_get("/1/lists/statuses.json").
95
+ with(:query => {:owner_id => '12345678', :slug => 'presidents'}).
96
+ to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
97
+ end
98
+ it "should request the correct resource" do
99
+ @client.list_timeline(12345678, 'presidents')
100
+ a_get("/1/lists/statuses.json").
101
+ with(:query => {:owner_id => '12345678', :slug => 'presidents'}).
102
+ should have_been_made
103
+ end
104
+ end
105
+ end
106
+
107
+ describe ".list_remove_member" do
108
+ context "with a screen name passed" do
109
+ before do
110
+ stub_post("/1/lists/members/destroy.json").
111
+ with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => "813286"}).
112
+ to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
113
+ end
114
+ it "should request the correct resource" do
115
+ @client.list_remove_member("sferik", "presidents", 813286)
116
+ a_post("/1/lists/members/destroy.json").
117
+ with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => "813286"}).
118
+ should have_been_made
119
+ end
120
+ it "should return the list" do
121
+ list = @client.list_remove_member("sferik", "presidents", 813286)
122
+ list.should be_a Twitter::List
123
+ list.name.should == "presidents"
124
+ end
125
+ end
126
+ context "with an Integer user_id passed" do
127
+ before do
128
+ stub_post("/1/lists/members/destroy.json").
129
+ with(:body => {:owner_id => '12345678', :slug => 'presidents', :user_id => "813286"}).
130
+ to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
131
+ end
132
+ it "should request the correct resource" do
133
+ @client.list_remove_member(12345678, "presidents", 813286)
134
+ a_post("/1/lists/members/destroy.json").
135
+ with(:body => {:owner_id => '12345678', :slug => 'presidents', :user_id => "813286"}).
136
+ should have_been_made
137
+ end
138
+ end
139
+ context "with an Integer list_id passed" do
140
+ before do
141
+ stub_post("/1/lists/members/destroy.json").
142
+ with(:body => {:owner_screen_name => 'sferik', :list_id => '12345678', :user_id => "813286"}).
143
+ to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
144
+ end
145
+ it "should request the correct resource" do
146
+ @client.list_remove_member('sferik', 12345678, 813286)
147
+ a_post("/1/lists/members/destroy.json").
148
+ with(:body => {:owner_screen_name => 'sferik', :list_id => '12345678', :user_id => "813286"}).
149
+ should have_been_made
150
+ end
151
+ end
152
+ context "with a screen name to remove" do
153
+ before do
154
+ stub_post("/1/lists/members/destroy.json").
155
+ with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents', :screen_name => "erebor"}).
156
+ to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
157
+ end
158
+ it "should request the correct resource" do
159
+ @client.list_remove_member('sferik', 'presidents', 'erebor')
160
+ a_post("/1/lists/members/destroy.json").
161
+ with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents', :screen_name => "erebor"}).
162
+ should have_been_made
163
+ end
164
+ end
165
+ context "without a screen name passed" do
166
+ before do
167
+ stub_get("/1/account/verify_credentials.json").
168
+ to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
169
+ stub_post("/1/lists/members/destroy.json").
170
+ with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => "813286"}).
171
+ to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
172
+ end
173
+ it "should request the correct resource" do
174
+ @client.list_remove_member("presidents", 813286)
175
+ a_post("/1/lists/members/destroy.json").
176
+ with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => "813286"}).
177
+ should have_been_made
178
+ end
179
+ end
180
+ end
181
+
182
+ describe ".memberships" do
183
+ context "with a screen name passed" do
184
+ before do
185
+ stub_get("/1/lists/memberships.json").
186
+ with(:query => {:screen_name => 'pengwynn', :cursor => "-1"}).
187
+ to_return(:body => fixture("lists.json"), :headers => {:content_type => "application/json; charset=utf-8"})
188
+ end
189
+ it "should request the correct resource" do
190
+ @client.memberships("pengwynn")
191
+ a_get("/1/lists/memberships.json").
192
+ with(:query => {:screen_name => 'pengwynn', :cursor => "-1"}).
193
+ should have_been_made
194
+ end
195
+ it "should return the lists the specified user has been added to" do
196
+ memberships = @client.memberships("pengwynn")
197
+ memberships.should be_a Twitter::Cursor
198
+ memberships.lists.should be_an Array
199
+ memberships.lists.first.should be_an Twitter::List
200
+ memberships.lists.first.name.should == "Rubyists"
201
+ end
202
+ end
203
+ context "without a screen name passed" do
204
+ before do
205
+ stub_get("/1/account/verify_credentials.json").
206
+ to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
207
+ stub_get("/1/lists/memberships.json").
208
+ with(:query => {:cursor => "-1"}).
209
+ to_return(:body => fixture("lists.json"), :headers => {:content_type => "application/json; charset=utf-8"})
210
+ end
211
+ it "should request the correct resource" do
212
+ @client.memberships
213
+ a_get("/1/lists/memberships.json").
214
+ with(:query => {:cursor => "-1"}).
215
+ should have_been_made
216
+ end
217
+ end
218
+ context "with an Integer user_id passed" do
219
+ before do
220
+ stub_get("/1/lists/memberships.json").
221
+ with(:query => {:user_id => '12345678', :cursor => "-1"}).
222
+ to_return(:body => fixture("lists.json"), :headers => {:content_type => "application/json; charset=utf-8"})
223
+ end
224
+ it "should request the correct resource" do
225
+ @client.memberships(12345678)
226
+ a_get("/1/lists/memberships.json").
227
+ with(:query => {:user_id => '12345678', :cursor => "-1"}).
228
+ should have_been_made
229
+ end
230
+ end
231
+ end
232
+
233
+ describe ".list_subscribers" do
234
+ context "with a screen name passed" do
235
+ before do
236
+ stub_get("/1/lists/subscribers.json").
237
+ with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :cursor => "-1"}).
238
+ to_return(:body => fixture("users_list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
239
+ end
240
+ it "should request the correct resource" do
241
+ @client.list_subscribers("sferik", "presidents")
242
+ a_get("/1/lists/subscribers.json").
243
+ with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :cursor => "-1"}).
244
+ should have_been_made
245
+ end
246
+ it "should return the subscribers of the specified list" do
247
+ list_subscribers = @client.list_subscribers("sferik", "presidents")
248
+ list_subscribers.should be_a Twitter::Cursor
249
+ list_subscribers.users.should be_an Array
250
+ list_subscribers.users.first.should be_a Twitter::User
251
+ list_subscribers.users.first.name.should == "Erik Michaels-Ober"
252
+ end
253
+ end
254
+ context "with an Integer user passed" do
255
+ before do
256
+ stub_get("/1/lists/subscribers.json").
257
+ with(:query => {:owner_id => '12345678', :slug => 'presidents', :cursor => "-1"}).
258
+ to_return(:body => fixture("users_list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
259
+ end
260
+ it "should request the correct resource" do
261
+ @client.list_subscribers(12345678, "presidents")
262
+ a_get("/1/lists/subscribers.json").
263
+ with(:query => {:owner_id => '12345678', :slug => 'presidents', :cursor => "-1"}).
264
+ should have_been_made
265
+ end
266
+ end
267
+ context "with an Integer list_id passed" do
268
+ before do
269
+ stub_get("/1/lists/subscribers.json").
270
+ with(:query => {:owner_screen_name => 'sferik', :list_id => '12345678', :cursor => "-1"}).
271
+ to_return(:body => fixture("users_list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
272
+ end
273
+ it "should request the correct resource" do
274
+ @client.list_subscribers('sferik', 12345678)
275
+ a_get("/1/lists/subscribers.json").
276
+ with(:query => {:owner_screen_name => 'sferik', :list_id => '12345678', :cursor => "-1"}).
277
+ should have_been_made
278
+ end
279
+ end
280
+ context "without a screen name passed" do
281
+ before do
282
+ stub_get("/1/account/verify_credentials.json").
283
+ to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
284
+ stub_get("/1/lists/subscribers.json").
285
+ with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :cursor => "-1"}).
286
+ to_return(:body => fixture("users_list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
287
+ end
288
+ it "should request the correct resource" do
289
+ @client.list_subscribers("presidents")
290
+ a_get("/1/lists/subscribers.json").
291
+ with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :cursor => "-1"}).
292
+ should have_been_made
293
+ end
294
+ end
295
+ end
296
+
297
+ describe ".subscriptions" do
298
+ context "with a screen name passed" do
299
+ before do
300
+ stub_get("/1/lists/subscriptions.json").
301
+ with(:query => {:screen_name => 'pengwynn', :cursor => "-1"}).
302
+ to_return(:body => fixture("lists.json"), :headers => {:content_type => "application/json; charset=utf-8"})
303
+ end
304
+ it "should request the correct resource" do
305
+ @client.subscriptions("pengwynn")
306
+ a_get("/1/lists/subscriptions.json").
307
+ with(:query => {:screen_name => 'pengwynn', :cursor => "-1"}).
308
+ should have_been_made
309
+ end
310
+ it "should return the lists the specified user follows" do
311
+ subscriptions = @client.subscriptions("pengwynn")
312
+ subscriptions.should be_a Twitter::Cursor
313
+ subscriptions.lists.should be_an Array
314
+ subscriptions.lists.first.should be_an Twitter::List
315
+ subscriptions.lists.first.name.should == "Rubyists"
316
+ end
317
+ end
318
+ context "without a screen name passed" do
319
+ before do
320
+ stub_get("/1/account/verify_credentials.json").
321
+ to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
322
+ stub_get("/1/lists/subscriptions.json").
323
+ with(:query => {:cursor => "-1"}).
324
+ to_return(:body => fixture("lists.json"), :headers => {:content_type => "application/json; charset=utf-8"})
325
+ end
326
+ it "should request the correct resource" do
327
+ @client.subscriptions
328
+ a_get("/1/lists/subscriptions.json").
329
+ with(:query => {:cursor => "-1"}).
330
+ should have_been_made
331
+ end
332
+ end
333
+ context "with an Integer user_id passed" do
334
+ before do
335
+ stub_get("/1/lists/subscriptions.json").
336
+ with(:query => {:user_id => '12345678', :cursor => "-1"}).
337
+ to_return(:body => fixture("lists.json"), :headers => {:content_type => "application/json; charset=utf-8"})
338
+ end
339
+ it "should request the correct resource" do
340
+ @client.subscriptions(12345678)
341
+ a_get("/1/lists/subscriptions.json").
342
+ with(:query => {:user_id => '12345678', :cursor => "-1"}).
343
+ should have_been_made
344
+ end
345
+ end
346
+ end
347
+
348
+ describe ".list_subscribe" do
349
+ context "with a screen name passed" do
350
+ before do
351
+ stub_post("/1/lists/subscribers/create.json").
352
+ with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents'}).
353
+ to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
354
+ end
355
+ it "should request the correct resource" do
356
+ @client.list_subscribe("sferik", "presidents")
357
+ a_post("/1/lists/subscribers/create.json").
358
+ with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents'}).
359
+ should have_been_made
360
+ end
361
+ it "should return the specified list" do
362
+ list = @client.list_subscribe("sferik", "presidents")
363
+ list.should be_a Twitter::List
364
+ list.name.should == "presidents"
365
+ end
366
+ end
367
+ context "with an Integer user_id passed" do
368
+ before do
369
+ stub_post("/1/lists/subscribers/create.json").
370
+ with(:body => {:owner_id => '12345678', :slug => 'presidents'}).
371
+ to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
372
+ end
373
+ it "should request the correct resource" do
374
+ @client.list_subscribe(12345678, "presidents")
375
+ a_post("/1/lists/subscribers/create.json").
376
+ with(:body => {:owner_id => '12345678', :slug => 'presidents'}).
377
+ should have_been_made
378
+ end
379
+ end
380
+ context "with an Integer list_id passed" do
381
+ before do
382
+ stub_post("/1/lists/subscribers/create.json").
383
+ with(:body => {:owner_screen_name => 'sferik', :list_id => '12345678'}).
384
+ to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
385
+ end
386
+ it "should request the correct resource" do
387
+ @client.list_subscribe('sferik', 12345678)
388
+ a_post("/1/lists/subscribers/create.json").
389
+ with(:body => {:owner_screen_name => 'sferik', :list_id => '12345678'}).
390
+ should have_been_made
391
+ end
392
+ end
393
+ context "without a screen name passed" do
394
+ before do
395
+ stub_get("/1/account/verify_credentials.json").
396
+ to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
397
+ stub_post("/1/lists/subscribers/create.json").
398
+ with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents'}).
399
+ to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
400
+ end
401
+ it "should request the correct resource" do
402
+ @client.list_subscribe("presidents")
403
+ a_post("/1/lists/subscribers/create.json").
404
+ with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents'}).
405
+ should have_been_made
406
+ end
407
+ end
408
+ end
409
+
410
+ describe ".list_subscriber?" do
411
+ context "with a screen name passed" do
412
+ before do
413
+ stub_get("/1/lists/subscribers/show.json").
414
+ with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => '813286'}).
415
+ to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
416
+ stub_get("/1/lists/subscribers/show.json").
417
+ with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => '18755393'}).
418
+ to_return(:body => fixture("not_found.json"), :status => 404, :headers => {:content_type => "application/json; charset=utf-8"})
419
+ stub_get("/1/lists/subscribers/show.json").
420
+ with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => '12345678'}).
421
+ to_return(:body => fixture("not_found.json"), :status => 403, :headers => {:content_type => "application/json; charset=utf-8"})
422
+ end
423
+ it "should request the correct resource" do
424
+ @client.list_subscriber?("sferik", "presidents", 813286)
425
+ a_get("/1/lists/subscribers/show.json").
426
+ with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => '813286'}).
427
+ should have_been_made
428
+ end
429
+ it "should return true if the specified user subscribes to the specified list" do
430
+ list_subscriber = @client.list_subscriber?("sferik", "presidents", 813286)
431
+ list_subscriber.should be_true
432
+ end
433
+ it "should return false if the specified user does not subscribe to the specified list" do
434
+ list_subscriber = @client.list_subscriber?("sferik", "presidents", 18755393)
435
+ list_subscriber.should be_false
436
+ end
437
+ it "should return false if user does not exist" do
438
+ list_subscriber = @client.list_subscriber?("sferik", "presidents", 12345678)
439
+ list_subscriber.should be_false
440
+ end
441
+ end
442
+ context "with an Integer owner_id passed" do
443
+ before do
444
+ stub_get("/1/lists/subscribers/show.json").
445
+ with(:query => {:owner_id => '12345678', :slug => 'presidents', :user_id => '813286'}).
446
+ to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
447
+ end
448
+ it "should request the correct resource" do
449
+ @client.list_subscriber?(12345678, "presidents", 813286)
450
+ a_get("/1/lists/subscribers/show.json").
451
+ with(:query => {:owner_id => '12345678', :slug => 'presidents', :user_id => '813286'}).
452
+ should have_been_made
453
+ end
454
+ end
455
+ context "with an Integer list_id passed" do
456
+ before do
457
+ stub_get("/1/lists/subscribers/show.json").
458
+ with(:query => {:owner_screen_name => 'sferik', :list_id => '12345678', :user_id => '813286'}).
459
+ to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
460
+ end
461
+ it "should request the correct resource" do
462
+ @client.list_subscriber?('sferik', 12345678, 813286)
463
+ a_get("/1/lists/subscribers/show.json").
464
+ with(:query => {:owner_screen_name => 'sferik', :list_id => '12345678', :user_id => '813286'}).
465
+ should have_been_made
466
+ end
467
+ end
468
+ context "with a screen name passed for user_to_check" do
469
+ before do
470
+ stub_get("/1/lists/subscribers/show.json").
471
+ with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :screen_name => 'erebor'}).
472
+ to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
473
+ end
474
+ it "should request the correct resource" do
475
+ @client.list_subscriber?("sferik", "presidents", 'erebor')
476
+ a_get("/1/lists/subscribers/show.json").
477
+ with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :screen_name => 'erebor'}).
478
+ should have_been_made
479
+ end
480
+ end
481
+ context "without a screen name passed" do
482
+ before do
483
+ stub_get("/1/account/verify_credentials.json").
484
+ to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
485
+ stub_get("/1/lists/subscribers/show.json").
486
+ with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => '813286'}).
487
+ to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
488
+ end
489
+ it "should request the correct resource" do
490
+ @client.list_subscriber?("presidents", 813286)
491
+ a_get("/1/lists/subscribers/show.json").
492
+ with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => '813286'}).
493
+ should have_been_made
494
+ end
495
+ end
496
+ end
497
+
498
+ describe ".list_unsubscribe" do
499
+ context "with a screen name passed" do
500
+ before do
501
+ stub_post("/1/lists/subscribers/destroy.json").
502
+ with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents'}).
503
+ to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
504
+ end
505
+ it "should request the correct resource" do
506
+ @client.list_unsubscribe("sferik", "presidents")
507
+ a_post("/1/lists/subscribers/destroy.json").
508
+ with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents'}).
509
+ should have_been_made
510
+ end
511
+ it "should return the specified list" do
512
+ list = @client.list_unsubscribe("sferik", "presidents")
513
+ list.should be_a Twitter::List
514
+ list.name.should == "presidents"
515
+ end
516
+ end
517
+ context "with an Integer user_id passed" do
518
+ before do
519
+ stub_post("/1/lists/subscribers/destroy.json").
520
+ with(:body => {:owner_id => '12345678', :slug => 'presidents'}).
521
+ to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
522
+ end
523
+ it "should request the correct resource" do
524
+ @client.list_unsubscribe(12345678, "presidents")
525
+ a_post("/1/lists/subscribers/destroy.json").
526
+ with(:body => {:owner_id => '12345678', :slug => 'presidents'}).
527
+ should have_been_made
528
+ end
529
+ end
530
+ context "with an Integer list_id passed" do
531
+ before do
532
+ stub_post("/1/lists/subscribers/destroy.json").
533
+ with(:body => {:owner_screen_name => 'sferik', :list_id => '12345678'}).
534
+ to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
535
+ end
536
+ it "should request the correct resource" do
537
+ @client.list_unsubscribe('sferik', 12345678)
538
+ a_post("/1/lists/subscribers/destroy.json").
539
+ with(:body => {:owner_screen_name => 'sferik', :list_id => '12345678'}).
540
+ should have_been_made
541
+ end
542
+ end
543
+ context "without a screen name passed" do
544
+ before do
545
+ stub_get("/1/account/verify_credentials.json").
546
+ to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
547
+ stub_post("/1/lists/subscribers/destroy.json").
548
+ with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents'}).
549
+ to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
550
+ end
551
+ it "should request the correct resource" do
552
+ @client.list_unsubscribe("presidents")
553
+ a_post("/1/lists/subscribers/destroy.json").
554
+ with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents'}).
555
+ should have_been_made
556
+ end
557
+ end
558
+ end
559
+
560
+ describe ".list_add_members" do
561
+ context "with a screen name passed" do
562
+ before do
563
+ stub_post("/1/lists/members/create_all.json").
564
+ with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => "813286,18755393"}).
565
+ to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
566
+ end
567
+ it "should request the correct resource" do
568
+ @client.list_add_members("sferik", "presidents", [813286, 18755393])
569
+ a_post("/1/lists/members/create_all.json").
570
+ with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => "813286,18755393"}).
571
+ should have_been_made
572
+ end
573
+ it "should return the list" do
574
+ list = @client.list_add_members("sferik", "presidents", [813286, 18755393])
575
+ list.should be_a Twitter::List
576
+ list.name.should == "presidents"
577
+ end
578
+ end
579
+ context "with an Integer user_id passed" do
580
+ before do
581
+ stub_post("/1/lists/members/create_all.json").
582
+ with(:body => {:owner_id => '12345678', :slug => 'presidents', :user_id => "813286,18755393"}).
583
+ to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
584
+ end
585
+ it "should request the correct resource" do
586
+ @client.list_add_members(12345678, "presidents", [813286, 18755393])
587
+ a_post("/1/lists/members/create_all.json").
588
+ with(:body => {:owner_id => '12345678', :slug => 'presidents', :user_id => "813286,18755393"}).
589
+ should have_been_made
590
+ end
591
+ end
592
+ context "with an Integer list_id passed" do
593
+ before do
594
+ stub_post("/1/lists/members/create_all.json").
595
+ with(:body => {:owner_screen_name => 'sferik', :list_id => '12345678', :user_id => "813286,18755393"}).
596
+ to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
597
+ end
598
+ it "should request the correct resource" do
599
+ @client.list_add_members('sferik', 12345678, [813286, 18755393])
600
+ a_post("/1/lists/members/create_all.json").
601
+ with(:body => {:owner_screen_name => 'sferik', :list_id => '12345678', :user_id => "813286,18755393"}).
602
+ should have_been_made
603
+ end
604
+ end
605
+ context "with a combination of member IDs and member screen names to add" do
606
+ before do
607
+ stub_post("/1/lists/members/create_all.json").
608
+ with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => "813286,18755393", :screen_name => "pengwynn,erebor"}).
609
+ to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
610
+ end
611
+ it "should request the correct resource" do
612
+ @client.list_add_members('sferik', 'presidents', [813286, 'pengwynn', 18755393, 'erebor'])
613
+ a_post("/1/lists/members/create_all.json").
614
+ with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => "813286,18755393", :screen_name => "pengwynn,erebor"}).
615
+ should have_been_made
616
+ end
617
+ end
618
+ context "without a screen name passed" do
619
+ before do
620
+ stub_get("/1/account/verify_credentials.json").
621
+ to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
622
+ stub_post("/1/lists/members/create_all.json").
623
+ with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => "813286,18755393"}).
624
+ to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
625
+ end
626
+ it "should request the correct resource" do
627
+ @client.list_add_members("presidents", [813286, 18755393])
628
+ a_post("/1/lists/members/create_all.json").
629
+ with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => "813286,18755393"}).
630
+ should have_been_made
631
+ end
632
+ end
633
+ end
634
+
635
+ describe ".list_member?" do
636
+ context "with a screen name passed" do
637
+ before do
638
+ stub_get("/1/lists/members/show.json").
639
+ with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => '813286'}).
640
+ to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
641
+ stub_get("/1/lists/members/show.json").
642
+ with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => '65493023'}).
643
+ to_return(:body => fixture("not_found.json"), :status => 404, :headers => {:content_type => "application/json; charset=utf-8"})
644
+ stub_get("/1/lists/members/show.json").
645
+ with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => '12345678'}).
646
+ to_return(:body => fixture("not_found.json"), :status => 403, :headers => {:content_type => "application/json; charset=utf-8"})
647
+ end
648
+ it "should request the correct resource" do
649
+ @client.list_member?("sferik", "presidents", 813286)
650
+ a_get("/1/lists/members/show.json").
651
+ with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => '813286'}).
652
+ should have_been_made
653
+ end
654
+ it "should return true if user is a list member" do
655
+ list_member = @client.list_member?("sferik", "presidents", 813286)
656
+ list_member.should be_true
657
+ end
658
+ it "should return false if user is not a list member" do
659
+ list_member = @client.list_member?("sferik", "presidents", 65493023)
660
+ list_member.should be_false
661
+ end
662
+ it "should return false if user does not exist" do
663
+ list_member = @client.list_member?("sferik", "presidents", 12345678)
664
+ list_member.should be_false
665
+ end
666
+ end
667
+ context "with an Integer owner_id passed" do
668
+ before do
669
+ stub_get("/1/lists/members/show.json").
670
+ with(:query => {:owner_id => '12345678', :slug => 'presidents', :user_id => '813286'}).
671
+ to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
672
+ end
673
+ it "should request the correct resource" do
674
+ @client.list_member?(12345678, "presidents", 813286)
675
+ a_get("/1/lists/members/show.json").
676
+ with(:query => {:owner_id => '12345678', :slug => 'presidents', :user_id => '813286'}).
677
+ should have_been_made
678
+ end
679
+ end
680
+ context "with an Integer list_id passed" do
681
+ before do
682
+ stub_get("/1/lists/members/show.json").
683
+ with(:query => {:owner_screen_name => 'sferik', :list_id => '12345678', :user_id => '813286'}).
684
+ to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
685
+ end
686
+ it "should request the correct resource" do
687
+ @client.list_member?('sferik', 12345678, 813286)
688
+ a_get("/1/lists/members/show.json").
689
+ with(:query => {:owner_screen_name => 'sferik', :list_id => '12345678', :user_id => '813286'}).
690
+ should have_been_made
691
+ end
692
+ end
693
+ context "with a screen name passed for user_to_check" do
694
+ before do
695
+ stub_get("/1/lists/members/show.json").
696
+ with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :screen_name => 'erebor'}).
697
+ to_return(:body => fixture("list.json"), :headers => {:content_type => "application/.json; charset=utf-8"})
698
+ end
699
+ it "should request the correct resource" do
700
+ @client.list_member?("sferik", "presidents", 'erebor')
701
+ a_get("/1/lists/members/show.json").
702
+ with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :screen_name => 'erebor'}).
703
+ should have_been_made
704
+ end
705
+ end
706
+ context "without a screen name passed" do
707
+ before do
708
+ stub_get("/1/account/verify_credentials.json").
709
+ to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
710
+ stub_get("/1/lists/members/show.json").
711
+ with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => '813286'}).
712
+ to_return(:body => fixture("list.json"), :headers => {:content_type => "application/.json; charset=utf-8"})
713
+ end
714
+ it "should request the correct resource" do
715
+ @client.list_member?("presidents", 813286)
716
+ a_get("/1/lists/members/show.json").
717
+ with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => '813286'}).
718
+ should have_been_made
719
+ end
720
+ end
721
+ end
722
+
723
+ describe ".list_members" do
724
+ context "with a screen name passed" do
725
+ before do
726
+ stub_get("/1/lists/members.json").
727
+ with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :cursor => "-1"}).
728
+ to_return(:body => fixture("users_list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
729
+ end
730
+ it "should request the correct resource" do
731
+ @client.list_members("sferik", "presidents")
732
+ a_get("/1/lists/members.json").
733
+ with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :cursor => "-1"}).
734
+ should have_been_made
735
+ end
736
+ it "should return the members of the specified list" do
737
+ list_members = @client.list_members("sferik", "presidents")
738
+ list_members.should be_a Twitter::Cursor
739
+ list_members.users.should be_an Array
740
+ list_members.users.first.should be_a Twitter::User
741
+ list_members.users.first.name.should == "Erik Michaels-Ober"
742
+ end
743
+ end
744
+ context "with an Integer user_id passed" do
745
+ before do
746
+ stub_get("/1/lists/members.json").
747
+ with(:query => {:owner_id => '12345678', :slug => 'presidents', :cursor => "-1"}).
748
+ to_return(:body => fixture("users_list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
749
+ end
750
+ it "should request the correct resource" do
751
+ @client.list_members(12345678, 'presidents')
752
+ a_get("/1/lists/members.json").
753
+ with(:query => {:owner_id => '12345678', :slug => 'presidents', :cursor => "-1"}).
754
+ should have_been_made
755
+ end
756
+ end
757
+ context "without a screen name passed" do
758
+ before do
759
+ stub_get("/1/account/verify_credentials.json").
760
+ to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
761
+ stub_get("/1/lists/members.json").
762
+ with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :cursor => "-1"}).
763
+ to_return(:body => fixture("users_list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
764
+ end
765
+ it "should request the correct resource" do
766
+ @client.list_members("presidents")
767
+ a_get("/1/lists/members.json").
768
+ with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :cursor => "-1"}).
769
+ should have_been_made
770
+ end
771
+ end
772
+ end
773
+
774
+ describe ".list_add_member" do
775
+ context "with a screen name passed" do
776
+ before do
777
+ stub_post("/1/lists/members/create.json").
778
+ with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => "813286"}).
779
+ to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
780
+ end
781
+ it "should request the correct resource" do
782
+ @client.list_add_member("sferik", "presidents", 813286)
783
+ a_post("/1/lists/members/create.json").
784
+ with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => "813286"}).
785
+ should have_been_made
786
+ end
787
+ it "should return the list" do
788
+ list = @client.list_add_member("sferik", "presidents", 813286)
789
+ list.should be_a Twitter::List
790
+ list.name.should == "presidents"
791
+ end
792
+ end
793
+ context "with an Integer user_id passed" do
794
+ before do
795
+ stub_post("/1/lists/members/create.json").
796
+ with(:body => {:owner_id => '12345678', :slug => 'presidents', :user_id => "813286"}).
797
+ to_return(:body => fixture("users_list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
798
+ end
799
+ it "should request the correct resource" do
800
+ @client.list_add_member(12345678, 'presidents', 813286)
801
+ a_post("/1/lists/members/create.json").
802
+ with(:body => {:owner_id => '12345678', :slug => 'presidents', :user_id => "813286"}).
803
+ should have_been_made
804
+ end
805
+ end
806
+ context "with an Integer list_id passed" do
807
+ before do
808
+ stub_post("/1/lists/members/create.json").
809
+ with(:body => {:owner_screen_name => 'sferik', :list_id => '12345678', :user_id => "813286"}).
810
+ to_return(:body => fixture("users_list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
811
+ end
812
+ it "should request the correct resource" do
813
+ @client.list_add_member('sferik', 12345678, 813286)
814
+ a_post("/1/lists/members/create.json").
815
+ with(:body => {:owner_screen_name => 'sferik', :list_id => '12345678', :user_id => "813286"}).
816
+ should have_been_made
817
+ end
818
+ end
819
+ context "without a screen name passed" do
820
+ before do
821
+ stub_get("/1/account/verify_credentials.json").
822
+ to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
823
+ stub_post("/1/lists/members/create.json").
824
+ with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => "813286"}).
825
+ to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
826
+ end
827
+ it "should request the correct resource" do
828
+ @client.list_add_member("presidents", 813286)
829
+ a_post("/1/lists/members/create.json").
830
+ with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => "813286"}).
831
+ should have_been_made
832
+ end
833
+ end
834
+ end
835
+
836
+ describe ".list_destroy" do
837
+ context "with a screen name passed" do
838
+ before do
839
+ stub_delete("/1/lists/destroy.json").
840
+ with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents'}).
841
+ to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
842
+ end
843
+ it "should request the correct resource" do
844
+ @client.list_destroy("sferik", "presidents")
845
+ a_delete("/1/lists/destroy.json").
846
+ with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents'}).
847
+ should have_been_made
848
+ end
849
+ it "should return the deleted list" do
850
+ list = @client.list_destroy("sferik", "presidents")
851
+ list.should be_a Twitter::List
852
+ list.name.should == "presidents"
853
+ end
854
+ end
855
+ context "without a screen name passed" do
856
+ before do
857
+ stub_get("/1/account/verify_credentials.json").
858
+ to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
859
+ stub_delete("/1/lists/destroy.json").
860
+ with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents'}).
861
+ to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
862
+ end
863
+ it "should request the correct resource" do
864
+ @client.list_destroy("presidents")
865
+ a_delete("/1/lists/destroy.json").
866
+ with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents'}).
867
+ should have_been_made
868
+ end
869
+ end
870
+ context "with an Integer list_id passed" do
871
+ before do
872
+ stub_delete("/1/lists/destroy.json").
873
+ with(:query => {:owner_screen_name => 'sferik', :list_id => '12345678'}).
874
+ to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
875
+ end
876
+ it "should request the correct resource" do
877
+ @client.list_destroy("sferik", 12345678)
878
+ a_delete("/1/lists/destroy.json").
879
+ with(:query => {:owner_screen_name => 'sferik', :list_id => '12345678'}).
880
+ should have_been_made
881
+ end
882
+ end
883
+ context "with an Integer user_id passed" do
884
+ before do
885
+ stub_delete("/1/lists/destroy.json").
886
+ with(:query => {:owner_id => '12345678', :slug => 'presidents'}).
887
+ to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
888
+ end
889
+ it "should request the correct resource" do
890
+ @client.list_destroy(12345678, 'presidents')
891
+ a_delete("/1/lists/destroy.json").
892
+ with(:query => {:owner_id => '12345678', :slug => 'presidents'}).
893
+ should have_been_made
894
+ end
895
+ end
896
+ end
897
+
898
+ describe ".list_update" do
899
+ context "with a screen name passed" do
900
+ before do
901
+ stub_post("/1/lists/update.json").
902
+ with(:body => {:owner_screen_name => 'sferik', :slug => "presidents", :description => "Presidents of the United States of America"}).
903
+ to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
904
+ end
905
+ it "should request the correct resource" do
906
+ @client.list_update("sferik", "presidents", :description => "Presidents of the United States of America")
907
+ a_post("/1/lists/update.json").
908
+ with(:body => {:owner_screen_name => 'sferik', :slug => "presidents", :description => "Presidents of the United States of America"}).
909
+ should have_been_made
910
+ end
911
+ it "should return the updated list" do
912
+ list = @client.list_update("sferik", "presidents", :description => "Presidents of the United States of America")
913
+ list.should be_a Twitter::List
914
+ list.name.should == "presidents"
915
+ end
916
+ end
917
+ context "without a screen name passed" do
918
+ before do
919
+ stub_get("/1/account/verify_credentials.json").
920
+ to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
921
+ stub_post("/1/lists/update.json").
922
+ with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents', :description => "Presidents of the United States of America"}).
923
+ to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
924
+ end
925
+ it "should request the correct resource" do
926
+ @client.list_update("presidents", :description => "Presidents of the United States of America")
927
+ a_post("/1/lists/update.json").
928
+ with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents', :description => "Presidents of the United States of America"}).
929
+ should have_been_made
930
+ end
931
+ end
932
+ context "with an Integer list_id passed" do
933
+ before do
934
+ stub_post("/1/lists/update.json").
935
+ with(:body => {:owner_screen_name => 'sferik', :list_id => '12345678', :description => "Presidents of the United States of America"}).
936
+ to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
937
+ end
938
+ it "should request the correct resource" do
939
+ @client.list_update("sferik", 12345678, :description => "Presidents of the United States of America")
940
+ a_post("/1/lists/update.json").
941
+ with(:body => {:owner_screen_name => 'sferik', :list_id => '12345678', :description => "Presidents of the United States of America"}).
942
+ should have_been_made
943
+ end
944
+ end
945
+ context "with an Integer user_id passed" do
946
+ before do
947
+ stub_post("/1/lists/update.json").
948
+ with(:body => {:owner_id => '12345678', :slug => 'presidents', :description => "Presidents of the United States of America"}).
949
+ to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
950
+ end
951
+ it "should request the correct resource" do
952
+ @client.list_update(12345678, 'presidents', :description => "Presidents of the United States of America")
953
+ a_post("/1/lists/update.json").
954
+ with(:body => {:owner_id => '12345678', :slug => 'presidents', :description => "Presidents of the United States of America"}).
955
+ should have_been_made
956
+ end
957
+ end
958
+ end
959
+
960
+ describe ".list_create" do
961
+ before do
962
+ stub_post("/1/lists/create.json").
963
+ with(:body => {:name => "presidents"}).
964
+ to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
965
+ end
966
+ it "should request the correct resource" do
967
+ @client.list_create("presidents")
968
+ a_post("/1/lists/create.json").
969
+ with(:body => {:name => "presidents"}).
970
+ should have_been_made
971
+ end
972
+ it "should return the created list" do
973
+ list = @client.list_create("presidents")
974
+ list.should be_a Twitter::List
975
+ list.name.should == "presidents"
976
+ end
977
+ end
978
+
979
+ describe ".lists" do
980
+ context "with a screen name passed" do
981
+ before do
982
+ stub_get("/1/lists.json").
983
+ with(:query => {:screen_name => 'sferik', :cursor => "-1"}).
984
+ to_return(:body => fixture("lists.json"), :headers => {:content_type => "application/json; charset=utf-8"})
985
+ end
986
+ it "should request the correct resource" do
987
+ @client.lists("sferik")
988
+ a_get("/1/lists.json").
989
+ with(:query => {:screen_name => 'sferik', :cursor => "-1"}).
990
+ should have_been_made
991
+ end
992
+ it "should return the updated list" do
993
+ lists = @client.lists("sferik")
994
+ lists.should be_a Twitter::Cursor
995
+ lists.lists.should be_an Array
996
+ lists.lists.first.should be_an Twitter::List
997
+ lists.lists.first.name.should == "Rubyists"
998
+ end
999
+ end
1000
+ context "with an Integer user id passed" do
1001
+ before do
1002
+ stub_get("/1/lists.json").
1003
+ with(:query => {:user_id => '12345678', :cursor => "-1"}).
1004
+ to_return(:body => fixture("lists.json"), :headers => {:content_type => "application/json; charset=utf-8"})
1005
+ end
1006
+ it "should request the correct resource" do
1007
+ @client.lists(12345678)
1008
+ a_get("/1/lists.json").
1009
+ with(:query => {:user_id => '12345678', :cursor => "-1"}).
1010
+ should have_been_made
1011
+ end
1012
+ it "should return the updated list" do
1013
+ lists = @client.lists(12345678)
1014
+ lists.should be_a Twitter::Cursor
1015
+ lists.lists.should be_an Array
1016
+ lists.lists.first.should be_an Twitter::List
1017
+ lists.lists.first.name.should == "Rubyists"
1018
+ end
1019
+ end
1020
+ context "without arguments passed" do
1021
+ before do
1022
+ stub_get("/1/lists.json").
1023
+ with(:query => {:cursor => "-1"}).
1024
+ to_return(:body => fixture("lists.json"), :headers => {:content_type => "application/json; charset=utf-8"})
1025
+ end
1026
+ it "should request the correct resource" do
1027
+ @client.lists
1028
+ a_get("/1/lists.json").
1029
+ with(:query => {:cursor => "-1"}).
1030
+ should have_been_made
1031
+ end
1032
+ it "should return the updated list" do
1033
+ lists = @client.lists
1034
+ lists.should be_a Twitter::Cursor
1035
+ lists.lists.should be_an Array
1036
+ lists.lists.first.should be_an Twitter::List
1037
+ lists.lists.first.name.should == "Rubyists"
1038
+ end
1039
+ end
1040
+ end
1041
+
1042
+ describe ".list" do
1043
+ context "with a screen name passed" do
1044
+ before do
1045
+ stub_get("/1/lists/show.json").
1046
+ with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents'}).
1047
+ to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
1048
+ end
1049
+ it "should request the correct resource" do
1050
+ @client.list("sferik", "presidents")
1051
+ a_get("/1/lists/show.json").
1052
+ with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents'}).
1053
+ should have_been_made
1054
+ end
1055
+ it "should return the updated list" do
1056
+ list = @client.list("sferik", "presidents")
1057
+ list.should be_a Twitter::List
1058
+ list.name.should == "presidents"
1059
+ end
1060
+ end
1061
+ context "without a screen name passed" do
1062
+ before do
1063
+ stub_get("/1/account/verify_credentials.json").
1064
+ to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
1065
+ stub_get("/1/lists/show.json").
1066
+ with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents'}).
1067
+ to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
1068
+ end
1069
+ it "should request the correct resource" do
1070
+ @client.list("presidents")
1071
+ a_get("/1/lists/show.json").
1072
+ with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents'}).
1073
+ should have_been_made
1074
+ end
1075
+ end
1076
+ context "with an Integer list_id passed" do
1077
+ before do
1078
+ stub_get("/1/lists/show.json").
1079
+ with(:query => {:owner_screen_name => 'sferik', :list_id => '12345678'}).
1080
+ to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
1081
+ end
1082
+ it "should request the correct resource" do
1083
+ @client.list("sferik", 12345678)
1084
+ a_get("/1/lists/show.json").
1085
+ with(:query => {:owner_screen_name => 'sferik', :list_id => '12345678'}).
1086
+ should have_been_made
1087
+ end
1088
+ end
1089
+ context "with an Integer user_id passed" do
1090
+ before do
1091
+ stub_get("/1/lists/show.json").
1092
+ with(:query => {:owner_id => '12345678', :slug => 'presidents'}).
1093
+ to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
1094
+ end
1095
+ it "should request the correct resource" do
1096
+ @client.list(12345678, 'presidents')
1097
+ a_get("/1/lists/show.json").
1098
+ with(:query => {:owner_id => '12345678', :slug => 'presidents'}).
1099
+ should have_been_made
1100
+ end
1101
+ end
1102
+ end
1103
+
1104
+ end