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,58 @@
1
+ require 'helper'
2
+
3
+ describe Twitter::Client do
4
+
5
+ before do
6
+ @client = Twitter::Client.new
7
+ end
8
+
9
+ describe ".local_trends" do
10
+ context "with woeid passed" do
11
+ before do
12
+ stub_get("/1/trends/2487956.json").
13
+ to_return(:body => fixture("matching_trends.json"), :headers => {:content_type => "application/json; charset=utf-8"})
14
+ end
15
+ it "should request the correct resource" do
16
+ @client.local_trends(2487956)
17
+ a_get("/1/trends/2487956.json").
18
+ should have_been_made
19
+ end
20
+ it "should return the top 10 trending topics for a specific WOEID" do
21
+ matching_trends = @client.local_trends(2487956)
22
+ matching_trends.should be_an Array
23
+ matching_trends.first.should be_an Twitter::Trend
24
+ matching_trends.first.name.should == "#sevenwordsaftersex"
25
+ end
26
+ end
27
+ context "without arguments passed" do
28
+ before do
29
+ stub_get("/1/trends/1.json").
30
+ to_return(:body => fixture("matching_trends.json"), :headers => {:content_type => "application/json; charset=utf-8"})
31
+ end
32
+ it "should request the correct resource" do
33
+ @client.local_trends
34
+ a_get("/1/trends/1.json").
35
+ should have_been_made
36
+ end
37
+ end
38
+ end
39
+
40
+ describe ".trend_locations" do
41
+ before do
42
+ stub_get("/1/trends/available.json").
43
+ to_return(:body => fixture("locations.json"), :headers => {:content_type => "application/json; charset=utf-8"})
44
+ end
45
+ it "should request the correct resource" do
46
+ @client.trend_locations
47
+ a_get("/1/trends/available.json").
48
+ should have_been_made
49
+ end
50
+ it "should return the locations that Twitter has trending topic information for" do
51
+ locations = @client.trend_locations
52
+ locations.should be_an Array
53
+ locations.first.should be_a Twitter::Place
54
+ locations.first.name.should == "Ireland"
55
+ end
56
+ end
57
+
58
+ end
@@ -0,0 +1,47 @@
1
+ require 'helper'
2
+
3
+ describe Twitter::Client do
4
+
5
+ before do
6
+ @client = Twitter::Client.new
7
+ end
8
+
9
+ describe ".enable_notifications" do
10
+ before do
11
+ stub_post("/1/notifications/follow.json").
12
+ with(:body => {:screen_name => "sferik"}).
13
+ to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
14
+ end
15
+ it "should request the correct resource" do
16
+ @client.enable_notifications("sferik")
17
+ a_post("/1/notifications/follow.json").
18
+ with(:body => {:screen_name => "sferik"}).
19
+ should have_been_made
20
+ end
21
+ it "should return the specified user when successful" do
22
+ user = @client.enable_notifications("sferik")
23
+ user.should be_a Twitter::User
24
+ user.name.should == "Erik Michaels-Ober"
25
+ end
26
+ end
27
+
28
+ describe ".disable_notifications" do
29
+ before do
30
+ stub_post("/1/notifications/leave.json").
31
+ with(:body => {:screen_name => "sferik"}).
32
+ to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
33
+ end
34
+ it "should request the correct resource" do
35
+ @client.disable_notifications("sferik")
36
+ a_post("/1/notifications/leave.json").
37
+ with(:body => {:screen_name => "sferik"}).
38
+ should have_been_made
39
+ end
40
+ it "should return the specified user when successful" do
41
+ user = @client.disable_notifications("sferik")
42
+ user.should be_a Twitter::User
43
+ user.name.should == "Erik Michaels-Ober"
44
+ end
45
+ end
46
+
47
+ end
@@ -0,0 +1,100 @@
1
+ require 'helper'
2
+
3
+ describe Twitter::Client do
4
+
5
+ before do
6
+ @client = Twitter::Client.new
7
+ end
8
+
9
+ describe ".places_nearby" do
10
+ before do
11
+ stub_get("/1/geo/search.json").
12
+ with(:query => {:ip => "74.125.19.104"}).
13
+ to_return(:body => fixture("places.json"), :headers => {:content_type => "application/json; charset=utf-8"})
14
+ end
15
+ it "should request the correct resource" do
16
+ @client.places_nearby(:ip => "74.125.19.104")
17
+ a_get("/1/geo/search.json").
18
+ with(:query => {:ip => "74.125.19.104"}).
19
+ should have_been_made
20
+ end
21
+ it "should return nearby places" do
22
+ places = @client.places_nearby(:ip => "74.125.19.104")
23
+ places.should be_an Array
24
+ places.first.name.should == "Bernal Heights"
25
+ end
26
+ end
27
+
28
+ describe ".places_similar" do
29
+ before do
30
+ stub_get("/1/geo/similar_places.json").
31
+ with(:query => {:lat => "37.7821120598956", :long => "-122.400612831116", :name => "Twitter HQ"}).
32
+ to_return(:body => fixture("places.json"), :headers => {:content_type => "application/json; charset=utf-8"})
33
+ end
34
+ it "should request the correct resource" do
35
+ @client.places_similar(:lat => "37.7821120598956", :long => "-122.400612831116", :name => "Twitter HQ")
36
+ a_get("/1/geo/similar_places.json").
37
+ with(:query => {:lat => "37.7821120598956", :long => "-122.400612831116", :name => "Twitter HQ"}).
38
+ should have_been_made
39
+ end
40
+ it "should return similar places" do
41
+ places = @client.places_similar(:lat => "37.7821120598956", :long => "-122.400612831116", :name => "Twitter HQ")
42
+ places.should be_an Array
43
+ places.first.name.should == "Bernal Heights"
44
+ end
45
+ end
46
+
47
+ describe ".reverse_geocode" do
48
+ before do
49
+ stub_get("/1/geo/reverse_geocode.json").
50
+ with(:query => {:lat => "37.7821120598956", :long => "-122.400612831116"}).
51
+ to_return(:body => fixture("places.json"), :headers => {:content_type => "application/json; charset=utf-8"})
52
+ end
53
+ it "should request the correct resource" do
54
+ @client.reverse_geocode(:lat => "37.7821120598956", :long => "-122.400612831116")
55
+ a_get("/1/geo/reverse_geocode.json").
56
+ with(:query => {:lat => "37.7821120598956", :long => "-122.400612831116"}).
57
+ should have_been_made
58
+ end
59
+ it "should return places" do
60
+ places = @client.reverse_geocode(:lat => "37.7821120598956", :long => "-122.400612831116")
61
+ places.should be_an Array
62
+ places.first.name.should == "Bernal Heights"
63
+ end
64
+ end
65
+
66
+ describe ".place" do
67
+ before do
68
+ stub_get("/1/geo/id/247f43d441defc03.json").
69
+ to_return(:body => fixture("place.json"), :headers => {:content_type => "application/json; charset=utf-8"})
70
+ end
71
+ it "should request the correct resource" do
72
+ @client.place("247f43d441defc03")
73
+ a_get("/1/geo/id/247f43d441defc03.json").
74
+ should have_been_made
75
+ end
76
+ it "should return a place" do
77
+ place = @client.place("247f43d441defc03")
78
+ place.name.should == "Twitter HQ"
79
+ end
80
+ end
81
+
82
+ describe ".place_create" do
83
+ before do
84
+ stub_post("/1/geo/place.json").
85
+ with(:body => {:name => "@sferik's Apartment", :token => "22ff5b1f7159032cf69218c4d8bb78bc", :contained_within => "41bcb736f84a799e", :lat => "37.783699", :long => "-122.393581"}).
86
+ to_return(:body => fixture("place.json"), :headers => {:content_type => "application/json; charset=utf-8"})
87
+ end
88
+ it "should request the correct resource" do
89
+ @client.place_create(:name => "@sferik's Apartment", :token => "22ff5b1f7159032cf69218c4d8bb78bc", :contained_within => "41bcb736f84a799e", :lat => "37.783699", :long => "-122.393581")
90
+ a_post("/1/geo/place.json").
91
+ with(:body => {:name => "@sferik's Apartment", :token => "22ff5b1f7159032cf69218c4d8bb78bc", :contained_within => "41bcb736f84a799e", :lat => "37.783699", :long => "-122.393581"}).
92
+ should have_been_made
93
+ end
94
+ it "should return a place" do
95
+ place = @client.place_create(:name => "@sferik's Apartment", :token => "22ff5b1f7159032cf69218c4d8bb78bc", :contained_within => "41bcb736f84a799e", :lat => "37.783699", :long => "-122.393581")
96
+ place.name.should == "Twitter HQ"
97
+ end
98
+ end
99
+
100
+ end
@@ -0,0 +1,80 @@
1
+ require 'helper'
2
+
3
+ describe Twitter::Client do
4
+
5
+ before do
6
+ @client = Twitter::Client.new
7
+ end
8
+
9
+ describe ".saved_searches" do
10
+ before do
11
+ stub_get("/1/saved_searches.json").
12
+ to_return(:body => fixture("saved_searches.json"), :headers => {:content_type => "application/json; charset=utf-8"})
13
+ end
14
+ it "should request the correct resource" do
15
+ @client.saved_searches
16
+ a_get("/1/saved_searches.json").
17
+ should have_been_made
18
+ end
19
+ it "should return the authenticated user's saved search queries" do
20
+ saved_searches = @client.saved_searches
21
+ saved_searches.should be_an Array
22
+ saved_searches.first.should be_a Twitter::SavedSearch
23
+ saved_searches.first.name.should == "twitter"
24
+ end
25
+ end
26
+
27
+ describe ".saved_search" do
28
+ before do
29
+ stub_get("/1/saved_searches/show/16129012.json").
30
+ to_return(:body => fixture("saved_search.json"), :headers => {:content_type => "application/json; charset=utf-8"})
31
+ end
32
+ it "should request the correct resource" do
33
+ @client.saved_search(16129012)
34
+ a_get("/1/saved_searches/show/16129012.json").
35
+ should have_been_made
36
+ end
37
+ it "should return the data for a saved search owned by the authenticating user specified by the given id" do
38
+ saved_search = @client.saved_search(16129012)
39
+ saved_search.should be_a Twitter::SavedSearch
40
+ saved_search.name.should == "twitter"
41
+ end
42
+ end
43
+
44
+ describe ".saved_search_create" do
45
+ before do
46
+ stub_post("/1/saved_searches/create.json").
47
+ with(:body => {:query => "twitter"}).
48
+ to_return(:body => fixture("saved_search.json"), :headers => {:content_type => "application/json; charset=utf-8"})
49
+ end
50
+ it "should request the correct resource" do
51
+ @client.saved_search_create("twitter")
52
+ a_post("/1/saved_searches/create.json").
53
+ with(:body => {:query => "twitter"}).
54
+ should have_been_made
55
+ end
56
+ it "should return the created saved search" do
57
+ saved_search = @client.saved_search_create("twitter")
58
+ saved_search.should be_a Twitter::SavedSearch
59
+ saved_search.name.should == "twitter"
60
+ end
61
+ end
62
+
63
+ describe ".saved_search_destroy" do
64
+ before do
65
+ stub_delete("/1/saved_searches/destroy/16129012.json").
66
+ to_return(:body => fixture("saved_search.json"), :headers => {:content_type => "application/json; charset=utf-8"})
67
+ end
68
+ it "should request the correct resource" do
69
+ @client.saved_search_destroy(16129012)
70
+ a_delete("/1/saved_searches/destroy/16129012.json").
71
+ should have_been_made
72
+ end
73
+ it "should return the deleted saved search" do
74
+ saved_search = @client.saved_search_destroy(16129012)
75
+ saved_search.should be_a Twitter::SavedSearch
76
+ saved_search.name.should == "twitter"
77
+ end
78
+ end
79
+
80
+ end
@@ -0,0 +1,92 @@
1
+ require 'helper'
2
+
3
+ describe Twitter::Client do
4
+
5
+ before do
6
+ @client = Twitter::Client.new
7
+ end
8
+
9
+ describe ".images" do
10
+ before do
11
+ stub_get("/i/search/image_facets.json").
12
+ with(:query => {:q => "twitter"}).
13
+ to_return(:body => fixture("image_facets.json"), :headers => {:content_type => "application/json; charset=utf-8"})
14
+ end
15
+ it "should request the correct resource" do
16
+ @client.images('twitter')
17
+ a_get("/i/search/image_facets.json").
18
+ with(:query => {:q => "twitter"}).
19
+ with(:headers => {'X-Phx' => 'true'}).
20
+ should have_been_made
21
+ end
22
+ it "should return recent statuses that contain images related to a query" do
23
+ images = @client.images('twitter')
24
+ images.should be_an Array
25
+ images.first.should be_a Twitter::Status
26
+ images.first.text.should == "Thanks Twitter family! Beautiful. Cc @laurelstout @seacue @janetvh @mgale @choppedonion http://t.co/drAqoba"
27
+ end
28
+ end
29
+
30
+ describe ".videos" do
31
+ before do
32
+ stub_get("/i/search/video_facets.json").
33
+ with(:query => {:q => "twitter"}).
34
+ to_return(:body => fixture("video_facets.json"), :headers => {:content_type => "application/json; charset=utf-8"})
35
+ end
36
+ it "should request the correct resource" do
37
+ @client.videos('twitter')
38
+ a_get("/i/search/video_facets.json").
39
+ with(:query => {:q => "twitter"}).
40
+ with(:headers => {'X-Phx' => 'true'}).
41
+ should have_been_made
42
+ end
43
+ it "should return recent statuses that contain videos related to a query" do
44
+ videos = @client.videos('twitter')
45
+ videos.should be_an Array
46
+ videos.first.should be_a Twitter::Status
47
+ videos.first.text.should == "@Foofighters LEGENDS with a Legendary set of Music Videos http://t.co/IcVGIQO #VMA #VEVO"
48
+ end
49
+ end
50
+
51
+ describe ".search" do
52
+ before do
53
+ stub_get("/search.json", Twitter.search_endpoint).
54
+ with(:query => {:q => "twitter"}).
55
+ to_return(:body => fixture("/search.json"), :headers => {:content_type => "application/json; charset=utf-8"})
56
+ end
57
+ it "should request the correct resource" do
58
+ @client.search('twitter')
59
+ a_get("/search.json", Twitter.search_endpoint).
60
+ with(:query => {:q => "twitter"}).
61
+ should have_been_made
62
+ end
63
+ it "should return recent statuses related to a query with images and videos embedded" do
64
+ search = @client.search('twitter')
65
+ search.should be_an Array
66
+ search.first.should be_a Twitter::Status
67
+ search.first.text.should == "@KaiserKuo from not too far away your new twitter icon looks like Vader."
68
+ end
69
+ end
70
+
71
+ describe ".phoenix_search" do
72
+ before do
73
+ stub_get("/phoenix_search.phoenix").
74
+ with(:query => {:q => "twitter"}).
75
+ to_return(:body => fixture("phoenix_search.phoenix"), :headers => {:content_type => "application/json; charset=utf-8"})
76
+ end
77
+ it "should request the correct resource" do
78
+ @client.phoenix_search('twitter')
79
+ a_get("/phoenix_search.phoenix").
80
+ with(:query => {:q => "twitter"}).
81
+ with(:headers => {'X-Phx' => 'true'}).
82
+ should have_been_made
83
+ end
84
+ it "should return recent statuses related to a query with images and videos embedded" do
85
+ search = @client.phoenix_search('twitter')
86
+ search.should be_an Array
87
+ search.first.should be_a Twitter::Status
88
+ search.first.text.should == "looking at twitter trends just makes me realize how little i really understand about mankind."
89
+ end
90
+ end
91
+
92
+ end
@@ -0,0 +1,28 @@
1
+ require 'helper'
2
+
3
+ describe Twitter::Client do
4
+
5
+ before do
6
+ @client = Twitter::Client.new
7
+ end
8
+
9
+ describe ".report_spam" do
10
+ before do
11
+ stub_post("/1/report_spam.json").
12
+ with(:body => {:screen_name => "sferik"}).
13
+ to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
14
+ end
15
+ it "should request the correct resource" do
16
+ @client.report_spam("sferik")
17
+ a_post("/1/report_spam.json").
18
+ with(:body => {:screen_name => "sferik"}).
19
+ should have_been_made
20
+ end
21
+ it "should return the specified user" do
22
+ user = @client.report_spam("sferik")
23
+ user.should be_a Twitter::User
24
+ user.name.should == "Erik Michaels-Ober"
25
+ end
26
+ end
27
+
28
+ end
@@ -0,0 +1,65 @@
1
+ require 'helper'
2
+
3
+ describe Twitter::Client do
4
+
5
+ before do
6
+ @client = Twitter::Client.new
7
+ end
8
+
9
+ describe ".suggestions" do
10
+ context "with a category slug passed" do
11
+ before do
12
+ stub_get("/1/users/suggestions/art-design.json").
13
+ to_return(:body => fixture("category.json"), :headers => {:content_type => "application/json; charset=utf-8"})
14
+ end
15
+ it "should request the correct resource" do
16
+ @client.suggestions("art-design")
17
+ a_get("/1/users/suggestions/art-design.json").
18
+ should have_been_made
19
+ end
20
+ it "should return the users in a given category of the Twitter suggested user list" do
21
+ suggestion = @client.suggestions("art-design")
22
+ suggestion.should be_a Twitter::Suggestion
23
+ suggestion.name.should == "Art & Design"
24
+ suggestion.users.should be_an Array
25
+ suggestion.users.first.should be_a Twitter::User
26
+ end
27
+ end
28
+ context "without arguments passed" do
29
+ before do
30
+ stub_get("/1/users/suggestions.json").
31
+ to_return(:body => fixture("suggestions.json"), :headers => {:content_type => "application/json; charset=utf-8"})
32
+ end
33
+ it "should request the correct resource" do
34
+ @client.suggestions
35
+ a_get("/1/users/suggestions.json").
36
+ should have_been_made
37
+ end
38
+ it "should return the list of suggested user categories" do
39
+ suggestions = @client.suggestions
40
+ suggestions.should be_an Array
41
+ suggestions.first.should be_a Twitter::Suggestion
42
+ suggestions.first.name.should == "Art & Design"
43
+ end
44
+ end
45
+ end
46
+
47
+ describe ".suggest_users" do
48
+ before do
49
+ stub_get("/1/users/suggestions/art-design/members.json").
50
+ to_return(:body => fixture("members.json"), :headers => {:content_type => "application/json; charset=utf-8"})
51
+ end
52
+ it "should request the correct resource" do
53
+ @client.suggest_users("art-design")
54
+ a_get("/1/users/suggestions/art-design/members.json").
55
+ should have_been_made
56
+ end
57
+ it "should return users in a given category of the Twitter suggested user list and return their most recent status if they are not a protected user" do
58
+ suggest_users = @client.suggest_users("art-design")
59
+ suggest_users.should be_a Array
60
+ suggest_users.first.should be_a Twitter::User
61
+ suggest_users.first.name.should == "OMGFacts"
62
+ end
63
+ end
64
+
65
+ end