twitter 4.8.1 → 5.0.0.rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (197) hide show
  1. data.tar.gz.sig +0 -0
  2. data/CHANGELOG.md +30 -0
  3. data/LICENSE.md +1 -1
  4. data/README.md +386 -266
  5. data/lib/twitter.rb +4 -39
  6. data/lib/twitter/arguments.rb +11 -0
  7. data/lib/twitter/base.rb +89 -68
  8. data/lib/twitter/client.rb +69 -110
  9. data/lib/twitter/configuration.rb +7 -3
  10. data/lib/twitter/creatable.rb +2 -4
  11. data/lib/twitter/cursor.rb +50 -42
  12. data/lib/twitter/direct_message.rb +2 -11
  13. data/lib/twitter/entity/uri.rb +13 -0
  14. data/lib/twitter/enumerable.rb +15 -0
  15. data/lib/twitter/error.rb +55 -7
  16. data/lib/twitter/error/already_favorited.rb +1 -1
  17. data/lib/twitter/error/already_posted.rb +10 -0
  18. data/lib/twitter/error/already_retweeted.rb +1 -1
  19. data/lib/twitter/error/bad_gateway.rb +2 -3
  20. data/lib/twitter/error/bad_request.rb +2 -2
  21. data/lib/twitter/error/forbidden.rb +2 -2
  22. data/lib/twitter/error/gateway_timeout.rb +2 -3
  23. data/lib/twitter/error/internal_server_error.rb +2 -3
  24. data/lib/twitter/error/not_acceptable.rb +2 -2
  25. data/lib/twitter/error/not_found.rb +2 -2
  26. data/lib/twitter/error/service_unavailable.rb +2 -3
  27. data/lib/twitter/error/too_many_requests.rb +2 -2
  28. data/lib/twitter/error/unauthorized.rb +2 -2
  29. data/lib/twitter/error/unprocessable_entity.rb +2 -2
  30. data/lib/twitter/factory.rb +2 -8
  31. data/lib/twitter/geo_factory.rb +2 -2
  32. data/lib/twitter/geo_results.rb +36 -0
  33. data/lib/twitter/identity.rb +0 -22
  34. data/lib/twitter/list.rb +18 -4
  35. data/lib/twitter/media/photo.rb +3 -3
  36. data/lib/twitter/media_factory.rb +2 -2
  37. data/lib/twitter/null_object.rb +24 -0
  38. data/lib/twitter/oembed.rb +3 -2
  39. data/lib/twitter/place.rb +15 -9
  40. data/lib/twitter/profile_banner.rb +5 -3
  41. data/lib/twitter/rate_limit.rb +1 -17
  42. data/lib/twitter/relationship.rb +2 -10
  43. data/lib/twitter/rest/api/direct_messages.rb +135 -0
  44. data/lib/twitter/rest/api/favorites.rb +120 -0
  45. data/lib/twitter/rest/api/friends_and_followers.rb +290 -0
  46. data/lib/twitter/rest/api/help.rb +58 -0
  47. data/lib/twitter/rest/api/lists.rb +491 -0
  48. data/lib/twitter/rest/api/oauth.rb +45 -0
  49. data/lib/twitter/rest/api/places_and_geo.rb +104 -0
  50. data/lib/twitter/rest/api/saved_searches.rb +91 -0
  51. data/lib/twitter/rest/api/search.rb +37 -0
  52. data/lib/twitter/rest/api/spam_reporting.rb +29 -0
  53. data/lib/twitter/rest/api/suggested_users.rb +51 -0
  54. data/lib/twitter/rest/api/timelines.rb +202 -0
  55. data/lib/twitter/rest/api/trends.rb +58 -0
  56. data/lib/twitter/rest/api/tweets.rb +293 -0
  57. data/lib/twitter/rest/api/undocumented.rb +52 -0
  58. data/lib/twitter/rest/api/users.rb +383 -0
  59. data/lib/twitter/rest/api/utils.rb +219 -0
  60. data/lib/twitter/rest/client.rb +193 -0
  61. data/lib/twitter/rest/request/multipart_with_file.rb +36 -0
  62. data/lib/twitter/rest/response/parse_json.rb +27 -0
  63. data/lib/twitter/{response → rest/response}/raise_error.rb +8 -11
  64. data/lib/twitter/search_results.rb +33 -21
  65. data/lib/twitter/settings.rb +1 -6
  66. data/lib/twitter/size.rb +1 -1
  67. data/lib/twitter/streaming/client.rb +77 -0
  68. data/lib/twitter/streaming/connection.rb +22 -0
  69. data/lib/twitter/streaming/response.rb +30 -0
  70. data/lib/twitter/suggestion.rb +4 -2
  71. data/lib/twitter/token.rb +8 -0
  72. data/lib/twitter/trend.rb +2 -1
  73. data/lib/twitter/trend_results.rb +59 -0
  74. data/lib/twitter/tweet.rb +41 -85
  75. data/lib/twitter/user.rb +51 -41
  76. data/lib/twitter/version.rb +4 -4
  77. data/spec/fixtures/already_posted.json +1 -0
  78. data/spec/fixtures/ids_list.json +1 -1
  79. data/spec/fixtures/ids_list2.json +1 -1
  80. data/spec/fixtures/search.json +1 -1
  81. data/spec/fixtures/search_malformed.json +1 -1
  82. data/spec/fixtures/track_streaming.json +3 -0
  83. data/spec/helper.rb +8 -13
  84. data/spec/twitter/base_spec.rb +25 -99
  85. data/spec/twitter/configuration_spec.rb +1 -1
  86. data/spec/twitter/cursor_spec.rb +13 -31
  87. data/spec/twitter/direct_message_spec.rb +41 -8
  88. data/spec/twitter/entity/uri_spec.rb +74 -0
  89. data/spec/twitter/error_spec.rb +59 -11
  90. data/spec/twitter/geo/point_spec.rb +1 -1
  91. data/spec/twitter/geo_factory_spec.rb +3 -3
  92. data/spec/twitter/geo_results_spec.rb +35 -0
  93. data/spec/twitter/identifiable_spec.rb +0 -21
  94. data/spec/twitter/list_spec.rb +51 -8
  95. data/spec/twitter/media/photo_spec.rb +118 -3
  96. data/spec/twitter/media_factory_spec.rb +2 -2
  97. data/spec/twitter/null_object_spec.rb +26 -0
  98. data/spec/twitter/oembed_spec.rb +69 -45
  99. data/spec/twitter/place_spec.rb +68 -12
  100. data/spec/twitter/profile_banner_spec.rb +1 -1
  101. data/spec/twitter/rate_limit_spec.rb +12 -12
  102. data/spec/twitter/relationship_spec.rb +31 -9
  103. data/spec/twitter/{api → rest/api}/direct_messages_spec.rb +22 -9
  104. data/spec/twitter/{api → rest/api}/favorites_spec.rb +80 -7
  105. data/spec/twitter/{api → rest/api}/friends_and_followers_spec.rb +104 -65
  106. data/spec/twitter/{api → rest/api}/geo_spec.rb +10 -10
  107. data/spec/twitter/{api → rest/api}/help_spec.rb +6 -6
  108. data/spec/twitter/{api → rest/api}/lists_spec.rb +77 -56
  109. data/spec/twitter/{api → rest/api}/oauth_spec.rb +6 -6
  110. data/spec/twitter/{api → rest/api}/saved_searches_spec.rb +7 -7
  111. data/spec/twitter/{api → rest/api}/search_spec.rb +8 -9
  112. data/spec/twitter/{api → rest/api}/spam_reporting_spec.rb +3 -3
  113. data/spec/twitter/{api → rest/api}/suggested_users_spec.rb +5 -5
  114. data/spec/twitter/{api → rest/api}/timelines_spec.rb +9 -9
  115. data/spec/twitter/{api → rest/api}/trends_spec.rb +6 -6
  116. data/spec/twitter/rest/api/tweets_spec.rb +503 -0
  117. data/spec/twitter/{api → rest/api}/undocumented_spec.rb +19 -45
  118. data/spec/twitter/{api → rest/api}/users_spec.rb +60 -35
  119. data/spec/twitter/rest/client_spec.rb +193 -0
  120. data/spec/twitter/saved_search_spec.rb +11 -0
  121. data/spec/twitter/search_results_spec.rb +29 -42
  122. data/spec/twitter/settings_spec.rb +17 -6
  123. data/spec/twitter/streaming/client_spec.rb +75 -0
  124. data/spec/twitter/token_spec.rb +16 -0
  125. data/spec/twitter/trend_results_spec.rb +89 -0
  126. data/spec/twitter/trend_spec.rb +23 -0
  127. data/spec/twitter/tweet_spec.rb +122 -115
  128. data/spec/twitter/user_spec.rb +136 -77
  129. data/spec/twitter_spec.rb +0 -119
  130. data/twitter.gemspec +8 -5
  131. metadata +148 -141
  132. metadata.gz.sig +0 -0
  133. data/lib/twitter/action/favorite.rb +0 -19
  134. data/lib/twitter/action/follow.rb +0 -30
  135. data/lib/twitter/action/list_member_added.rb +0 -39
  136. data/lib/twitter/action/mention.rb +0 -46
  137. data/lib/twitter/action/reply.rb +0 -27
  138. data/lib/twitter/action/retweet.rb +0 -27
  139. data/lib/twitter/action/tweet.rb +0 -20
  140. data/lib/twitter/action_factory.rb +0 -22
  141. data/lib/twitter/api/arguments.rb +0 -13
  142. data/lib/twitter/api/direct_messages.rb +0 -148
  143. data/lib/twitter/api/favorites.rb +0 -126
  144. data/lib/twitter/api/friends_and_followers.rb +0 -334
  145. data/lib/twitter/api/help.rb +0 -64
  146. data/lib/twitter/api/lists.rb +0 -618
  147. data/lib/twitter/api/oauth.rb +0 -44
  148. data/lib/twitter/api/places_and_geo.rb +0 -121
  149. data/lib/twitter/api/saved_searches.rb +0 -99
  150. data/lib/twitter/api/search.rb +0 -37
  151. data/lib/twitter/api/spam_reporting.rb +0 -30
  152. data/lib/twitter/api/suggested_users.rb +0 -55
  153. data/lib/twitter/api/timelines.rb +0 -214
  154. data/lib/twitter/api/trends.rb +0 -63
  155. data/lib/twitter/api/tweets.rb +0 -304
  156. data/lib/twitter/api/undocumented.rb +0 -97
  157. data/lib/twitter/api/users.rb +0 -439
  158. data/lib/twitter/api/utils.rb +0 -187
  159. data/lib/twitter/configurable.rb +0 -96
  160. data/lib/twitter/default.rb +0 -102
  161. data/lib/twitter/entity/url.rb +0 -9
  162. data/lib/twitter/error/client_error.rb +0 -35
  163. data/lib/twitter/error/decode_error.rb +0 -9
  164. data/lib/twitter/error/identity_map_key_error.rb +0 -9
  165. data/lib/twitter/error/server_error.rb +0 -28
  166. data/lib/twitter/exceptable.rb +0 -36
  167. data/lib/twitter/identity_map.rb +0 -22
  168. data/lib/twitter/request/multipart_with_file.rb +0 -34
  169. data/lib/twitter/response/parse_json.rb +0 -25
  170. data/spec/fixtures/about_me.json +0 -1
  171. data/spec/fixtures/activity_summary.json +0 -1
  172. data/spec/fixtures/bad_gateway.json +0 -1
  173. data/spec/fixtures/bad_request.json +0 -1
  174. data/spec/fixtures/by_friends.json +0 -1
  175. data/spec/fixtures/end_session.json +0 -1
  176. data/spec/fixtures/forbidden.json +0 -1
  177. data/spec/fixtures/internal_server_error.json +0 -1
  178. data/spec/fixtures/not_acceptable.json +0 -1
  179. data/spec/fixtures/phoenix_search.phoenix +0 -1
  180. data/spec/fixtures/resolve.json +0 -1
  181. data/spec/fixtures/service_unavailable.json +0 -1
  182. data/spec/fixtures/totals.json +0 -1
  183. data/spec/fixtures/trends.json +0 -1
  184. data/spec/fixtures/unauthorized.json +0 -1
  185. data/spec/fixtures/video_facets.json +0 -1
  186. data/spec/twitter/action/favorite_spec.rb +0 -29
  187. data/spec/twitter/action/follow_spec.rb +0 -29
  188. data/spec/twitter/action/list_member_added_spec.rb +0 -41
  189. data/spec/twitter/action/mention_spec.rb +0 -52
  190. data/spec/twitter/action/reply_spec.rb +0 -41
  191. data/spec/twitter/action/retweet_spec.rb +0 -41
  192. data/spec/twitter/action_factory_spec.rb +0 -35
  193. data/spec/twitter/action_spec.rb +0 -16
  194. data/spec/twitter/api/tweets_spec.rb +0 -285
  195. data/spec/twitter/client_spec.rb +0 -223
  196. data/spec/twitter/error/client_error_spec.rb +0 -23
  197. data/spec/twitter/error/server_error_spec.rb +0 -20
@@ -1,9 +1,9 @@
1
1
  require 'helper'
2
2
 
3
- describe Twitter::API::OAuth do
3
+ describe Twitter::REST::API::OAuth do
4
4
 
5
5
  before do
6
- @client = Twitter::Client.new(:consumer_key => 'CK', :consumer_secret => 'CS')
6
+ @client = Twitter::REST::Client.new(:consumer_key => "CK", :consumer_secret => "CS")
7
7
  end
8
8
 
9
9
  describe "#token" do
@@ -25,8 +25,8 @@ describe Twitter::API::OAuth do
25
25
  end
26
26
  it "returns the bearer token" do
27
27
  bearer_token = @client.token
28
- expect(bearer_token.access_token).to eq "AAAA%2FAAA%3DAAAAAAAA"
29
- expect(bearer_token.token_type).to eq "bearer"
28
+ expect(bearer_token.access_token).to eq("AAAA%2FAAA%3DAAAAAAAA")
29
+ expect(bearer_token.token_type).to eq("bearer")
30
30
  end
31
31
  end
32
32
 
@@ -41,8 +41,8 @@ describe Twitter::API::OAuth do
41
41
  end
42
42
  it "returns the invalidated token" do
43
43
  token = @client.invalidate_token("AAAA%2FAAA%3DAAAAAAAA")
44
- expect(token.access_token).to eq "AAAA%2FAAA%3DAAAAAAAA"
45
- expect(token.token_type).to eq nil
44
+ expect(token.access_token).to eq("AAAA%2FAAA%3DAAAAAAAA")
45
+ expect(token.token_type).to be_nil
46
46
  end
47
47
  context "with a token" do
48
48
  it "requests the correct resource" do
@@ -1,9 +1,9 @@
1
1
  require 'helper'
2
2
 
3
- describe Twitter::API::SavedSearches do
3
+ describe Twitter::REST::API::SavedSearches do
4
4
 
5
5
  before do
6
- @client = Twitter::Client.new
6
+ @client = Twitter::REST::Client.new(:consumer_key => "CK", :consumer_secret => "CS", :access_token => "AT", :access_token_secret => "AS")
7
7
  end
8
8
 
9
9
  describe "#saved_searches" do
@@ -19,7 +19,7 @@ describe Twitter::API::SavedSearches do
19
19
  saved_searches = @client.saved_searches(16129012)
20
20
  expect(saved_searches).to be_an Array
21
21
  expect(saved_searches.first).to be_a Twitter::SavedSearch
22
- expect(saved_searches.first.name).to eq "twitter"
22
+ expect(saved_searches.first.name).to eq("twitter")
23
23
  end
24
24
  end
25
25
  context "without ids passed" do
@@ -34,7 +34,7 @@ describe Twitter::API::SavedSearches do
34
34
  saved_searches = @client.saved_searches
35
35
  expect(saved_searches).to be_an Array
36
36
  expect(saved_searches.first).to be_a Twitter::SavedSearch
37
- expect(saved_searches.first.name).to eq "twitter"
37
+ expect(saved_searches.first.name).to eq("twitter")
38
38
  end
39
39
  end
40
40
  end
@@ -50,7 +50,7 @@ describe Twitter::API::SavedSearches do
50
50
  it "returns a saved search" do
51
51
  saved_search = @client.saved_search(16129012)
52
52
  expect(saved_search).to be_a Twitter::SavedSearch
53
- expect(saved_search.name).to eq "twitter"
53
+ expect(saved_search.name).to eq("twitter")
54
54
  end
55
55
  end
56
56
 
@@ -65,7 +65,7 @@ describe Twitter::API::SavedSearches do
65
65
  it "returns the created saved search" do
66
66
  saved_search = @client.saved_search_create("twitter")
67
67
  expect(saved_search).to be_a Twitter::SavedSearch
68
- expect(saved_search.name).to eq "twitter"
68
+ expect(saved_search.name).to eq("twitter")
69
69
  end
70
70
  end
71
71
 
@@ -81,7 +81,7 @@ describe Twitter::API::SavedSearches do
81
81
  saved_searches = @client.saved_search_destroy(16129012)
82
82
  expect(saved_searches).to be_an Array
83
83
  expect(saved_searches.first).to be_a Twitter::SavedSearch
84
- expect(saved_searches.first.name).to eq "twitter"
84
+ expect(saved_searches.first.name).to eq("twitter")
85
85
  end
86
86
  end
87
87
 
@@ -1,9 +1,9 @@
1
1
  require 'helper'
2
2
 
3
- describe Twitter::API::Search do
3
+ describe Twitter::REST::API::Search do
4
4
 
5
5
  before do
6
- @client = Twitter::Client.new
6
+ @client = Twitter::REST::Client.new(:consumer_key => "CK", :consumer_secret => "CS", :access_token => "AT", :access_token_secret => "AS")
7
7
  end
8
8
 
9
9
  describe "#search" do
@@ -17,24 +17,23 @@ describe Twitter::API::Search do
17
17
  it "returns recent Tweets related to a query with images and videos embedded" do
18
18
  search = @client.search("twitter")
19
19
  expect(search).to be_a Twitter::SearchResults
20
- expect(search.results).to be_an Array
21
- expect(search.results.first).to be_a Twitter::Tweet
22
- expect(search.results.first.text).to eq "Bubble Mailer #freebandnames"
20
+ expect(search.first).to be_a Twitter::Tweet
21
+ expect(search.first.text).to eq("Bubble Mailer #freebandnames")
23
22
  end
24
23
  it "returns the max_id value for a search result" do
25
24
  search = @client.search("twitter")
26
- expect(search.max_id).to eq 250126199840518145
25
+ expect(search.max_id).to eq(250126199840518145)
27
26
  end
28
27
 
29
28
  context "when search API responds a malformed result" do
30
29
  before do
31
- stub_get("/1.1/search/tweets.json").with(:query => {:q => "twitter"}).to_return(:body => fixture("/search_malformed.json"), :headers => {:content_type => "application/json; charset=utf-8"})
30
+ stub_get("/1.1/search/tweets.json").with(:query => {:q => "twitter"}).to_return(:body => fixture("search_malformed.json"), :headers => {:content_type => "application/json; charset=utf-8"})
32
31
  end
33
32
 
34
33
  it "returns an empty array" do
35
34
  search = @client.search("twitter")
36
- expect(search.results).to be_an Array
37
- expect(search.results).to be_empty
35
+ expect(search.to_a).to be_an Array
36
+ expect(search.to_a).to be_empty
38
37
  end
39
38
  end
40
39
  end
@@ -1,9 +1,9 @@
1
1
  require 'helper'
2
2
 
3
- describe Twitter::API::SpamReporting do
3
+ describe Twitter::REST::API::SpamReporting do
4
4
 
5
5
  before do
6
- @client = Twitter::Client.new
6
+ @client = Twitter::REST::Client.new(:consumer_key => "CK", :consumer_secret => "CS", :access_token => "AT", :access_token_secret => "AS")
7
7
  end
8
8
 
9
9
  describe "#report_spam" do
@@ -18,7 +18,7 @@ describe Twitter::API::SpamReporting do
18
18
  users = @client.report_spam("sferik")
19
19
  expect(users).to be_an Array
20
20
  expect(users.first).to be_a Twitter::User
21
- expect(users.first.id).to eq 7505382
21
+ expect(users.first.id).to eq(7505382)
22
22
  end
23
23
  end
24
24
 
@@ -1,9 +1,9 @@
1
1
  require 'helper'
2
2
 
3
- describe Twitter::API::SuggestedUsers do
3
+ describe Twitter::REST::API::SuggestedUsers do
4
4
 
5
5
  before do
6
- @client = Twitter::Client.new
6
+ @client = Twitter::REST::Client.new(:consumer_key => "CK", :consumer_secret => "CS", :access_token => "AT", :access_token_secret => "AS")
7
7
  end
8
8
 
9
9
  describe "#suggestions" do
@@ -18,7 +18,7 @@ describe Twitter::API::SuggestedUsers do
18
18
  it "returns the users in a given category of the Twitter suggested user list" do
19
19
  suggestion = @client.suggestions("art-design")
20
20
  expect(suggestion).to be_a Twitter::Suggestion
21
- expect(suggestion.name).to eq "Art & Design"
21
+ expect(suggestion.name).to eq("Art & Design")
22
22
  expect(suggestion.users).to be_an Array
23
23
  expect(suggestion.users.first).to be_a Twitter::User
24
24
  end
@@ -35,7 +35,7 @@ describe Twitter::API::SuggestedUsers do
35
35
  suggestions = @client.suggestions
36
36
  expect(suggestions).to be_an Array
37
37
  expect(suggestions.first).to be_a Twitter::Suggestion
38
- expect(suggestions.first.name).to eq "Art & Design"
38
+ expect(suggestions.first.name).to eq("Art & Design")
39
39
  end
40
40
  end
41
41
  end
@@ -52,7 +52,7 @@ describe Twitter::API::SuggestedUsers do
52
52
  suggest_users = @client.suggest_users("art-design")
53
53
  expect(suggest_users).to be_an Array
54
54
  expect(suggest_users.first).to be_a Twitter::User
55
- expect(suggest_users.first.id).to eq 13
55
+ expect(suggest_users.first.id).to eq(13)
56
56
  end
57
57
  end
58
58
 
@@ -1,9 +1,9 @@
1
1
  require 'helper'
2
2
 
3
- describe Twitter::API::Timelines do
3
+ describe Twitter::REST::API::Timelines do
4
4
 
5
5
  before do
6
- @client = Twitter::Client.new
6
+ @client = Twitter::REST::Client.new(:consumer_key => "CK", :consumer_secret => "CS", :access_token => "AT", :access_token_secret => "AS")
7
7
  end
8
8
 
9
9
  describe "#mentions_timeline" do
@@ -18,7 +18,7 @@ describe Twitter::API::Timelines do
18
18
  tweets = @client.mentions_timeline
19
19
  expect(tweets).to be_an Array
20
20
  expect(tweets.first).to be_a Twitter::Tweet
21
- expect(tweets.first.text).to eq "Happy Birthday @imdane. Watch out for those @rally pranksters!"
21
+ expect(tweets.first.text).to eq("Happy Birthday @imdane. Watch out for those @rally pranksters!")
22
22
  end
23
23
  end
24
24
 
@@ -35,7 +35,7 @@ describe Twitter::API::Timelines do
35
35
  tweets = @client.user_timeline("sferik")
36
36
  expect(tweets).to be_an Array
37
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!"
38
+ expect(tweets.first.text).to eq("Happy Birthday @imdane. Watch out for those @rally pranksters!")
39
39
  end
40
40
  end
41
41
  context "without a screen name passed" do
@@ -63,7 +63,7 @@ describe Twitter::API::Timelines do
63
63
  tweets = @client.retweeted_by_user("sferik")
64
64
  expect(tweets).to be_an Array
65
65
  expect(tweets.first).to be_a Twitter::Tweet
66
- expect(tweets.first.text).to eq "RT @olivercameron: Mosaic looks cool: http://t.co/A8013C9k"
66
+ expect(tweets.first.text).to eq("RT @olivercameron: Mosaic looks cool: http://t.co/A8013C9k")
67
67
  end
68
68
  end
69
69
 
@@ -81,7 +81,7 @@ describe Twitter::API::Timelines do
81
81
  tweets = @client.retweeted_by_me
82
82
  expect(tweets).to be_an Array
83
83
  expect(tweets.first).to be_a Twitter::Tweet
84
- expect(tweets.first.text).to eq "RT @olivercameron: Mosaic looks cool: http://t.co/A8013C9k"
84
+ expect(tweets.first.text).to eq("RT @olivercameron: Mosaic looks cool: http://t.co/A8013C9k")
85
85
  end
86
86
  end
87
87
 
@@ -97,7 +97,7 @@ describe Twitter::API::Timelines do
97
97
  tweets = @client.home_timeline
98
98
  expect(tweets).to be_an Array
99
99
  expect(tweets.first).to be_a Twitter::Tweet
100
- expect(tweets.first.text).to eq "Happy Birthday @imdane. Watch out for those @rally pranksters!"
100
+ expect(tweets.first.text).to eq("Happy Birthday @imdane. Watch out for those @rally pranksters!")
101
101
  end
102
102
  end
103
103
 
@@ -115,7 +115,7 @@ describe Twitter::API::Timelines do
115
115
  tweets = @client.retweeted_to_me
116
116
  expect(tweets).to be_an Array
117
117
  expect(tweets.first).to be_a Twitter::Tweet
118
- expect(tweets.first.text).to eq "RT @olivercameron: Mosaic looks cool: http://t.co/A8013C9k"
118
+ expect(tweets.first.text).to eq("RT @olivercameron: Mosaic looks cool: http://t.co/A8013C9k")
119
119
  end
120
120
  end
121
121
 
@@ -131,7 +131,7 @@ describe Twitter::API::Timelines do
131
131
  tweets = @client.retweets_of_me
132
132
  expect(tweets).to be_an Array
133
133
  expect(tweets.first).to be_a Twitter::Tweet
134
- expect(tweets.first.text).to eq "Happy Birthday @imdane. Watch out for those @rally pranksters!"
134
+ expect(tweets.first.text).to eq("Happy Birthday @imdane. Watch out for those @rally pranksters!")
135
135
  end
136
136
  end
137
137
 
@@ -1,9 +1,9 @@
1
1
  require 'helper'
2
2
 
3
- describe Twitter::API::Trends do
3
+ describe Twitter::REST::API::Trends do
4
4
 
5
5
  before do
6
- @client = Twitter::Client.new
6
+ @client = Twitter::REST::Client.new(:consumer_key => "CK", :consumer_secret => "CS", :access_token => "AT", :access_token_secret => "AS")
7
7
  end
8
8
 
9
9
  describe "#trends" do
@@ -17,9 +17,9 @@ describe Twitter::API::Trends do
17
17
  end
18
18
  it "returns the top 10 trending topics for a specific WOEID" do
19
19
  matching_trends = @client.trends(2487956)
20
- expect(matching_trends).to be_an Array
20
+ expect(matching_trends).to be_a Twitter::TrendResults
21
21
  expect(matching_trends.first).to be_a Twitter::Trend
22
- expect(matching_trends.first.name).to eq "#sevenwordsaftersex"
22
+ expect(matching_trends.first.name).to eq("#sevenwordsaftersex")
23
23
  end
24
24
  end
25
25
  context "without arguments passed" do
@@ -45,7 +45,7 @@ describe Twitter::API::Trends do
45
45
  locations = @client.trends_available
46
46
  expect(locations).to be_an Array
47
47
  expect(locations.first).to be_a Twitter::Place
48
- expect(locations.first.name).to eq "Ireland"
48
+ expect(locations.first.name).to eq("Ireland")
49
49
  end
50
50
  end
51
51
 
@@ -61,7 +61,7 @@ describe Twitter::API::Trends do
61
61
  locations = @client.trends_closest
62
62
  expect(locations).to be_an Array
63
63
  expect(locations.first).to be_a Twitter::Place
64
- expect(locations.first.name).to eq "Ireland"
64
+ expect(locations.first.name).to eq("Ireland")
65
65
  end
66
66
  end
67
67
 
@@ -0,0 +1,503 @@
1
+ require 'helper'
2
+
3
+ describe Twitter::REST::API::Tweets 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 "#retweets" do
10
+ before do
11
+ stub_get("/1.1/statuses/retweets/25938088801.json").to_return(:body => fixture("retweets.json"), :headers => {:content_type => "application/json; charset=utf-8"})
12
+ end
13
+ context "with a tweet ID passed" do
14
+ it "requests the correct resource" do
15
+ @client.retweets(25938088801)
16
+ expect(a_get("/1.1/statuses/retweets/25938088801.json")).to have_been_made
17
+ end
18
+ it "returns up to 100 of the first retweets of a given tweet" do
19
+ tweets = @client.retweets(25938088801)
20
+ expect(tweets).to be_an Array
21
+ expect(tweets.first).to be_a Twitter::Tweet
22
+ expect(tweets.first.text).to eq("RT @gruber: As for the Series, I'm for the Giants. Fuck Texas, fuck Nolan Ryan, fuck George Bush.")
23
+ end
24
+ end
25
+ context "with a URI object passed" do
26
+ it "requests the correct resource" do
27
+ tweet = URI.parse("https://twitter.com/sferik/status/25938088801")
28
+ @client.retweets(tweet)
29
+ expect(a_get("/1.1/statuses/retweets/25938088801.json")).to have_been_made
30
+ end
31
+ end
32
+ context "with a URI string passed" do
33
+ it "requests the correct resource" do
34
+ @client.retweets("https://twitter.com/sferik/status/25938088801")
35
+ expect(a_get("/1.1/statuses/retweets/25938088801.json")).to have_been_made
36
+ end
37
+ end
38
+ context "with a Tweet passed" do
39
+ it "requests the correct resource" do
40
+ tweet = Twitter::Tweet.new(:id => 25938088801)
41
+ @client.retweets(tweet)
42
+ expect(a_get("/1.1/statuses/retweets/25938088801.json")).to have_been_made
43
+ end
44
+ end
45
+ end
46
+
47
+ describe "#retweeters_of" do
48
+ context "with ids_only passed" do
49
+ context "with a tweet ID passed" do
50
+ before do
51
+ stub_get("/1.1/statuses/retweets/25938088801.json").to_return(:body => fixture("retweets.json"), :headers => {:content_type => "application/json; charset=utf-8"})
52
+ end
53
+ it "requests the correct resource" do
54
+ @client.retweeters_of(25938088801, :ids_only => true)
55
+ expect(a_get("/1.1/statuses/retweets/25938088801.json")).to have_been_made
56
+ end
57
+ it "returns an array of numeric user IDs of retweeters of a Tweet" do
58
+ ids = @client.retweeters_of(25938088801, :ids_only => true)
59
+ expect(ids).to be_an Array
60
+ expect(ids.first).to eq(7505382)
61
+ end
62
+ end
63
+ end
64
+ context "without ids_only passed" do
65
+ before do
66
+ stub_get("/1.1/statuses/retweets/25938088801.json").to_return(:body => fixture("retweets.json"), :headers => {:content_type => "application/json; charset=utf-8"})
67
+ end
68
+ it "requests the correct resource" do
69
+ @client.retweeters_of(25938088801)
70
+ expect(a_get("/1.1/statuses/retweets/25938088801.json")).to have_been_made
71
+ end
72
+ it "returns an array of user of retweeters of a Tweet" do
73
+ users = @client.retweeters_of(25938088801)
74
+ expect(users).to be_an Array
75
+ expect(users.first).to be_a Twitter::User
76
+ expect(users.first.id).to eq(7505382)
77
+ end
78
+ context "with a URI object passed" do
79
+ it "requests the correct resource" do
80
+ tweet = URI.parse("https://twitter.com/sferik/status/25938088801")
81
+ @client.retweeters_of(tweet)
82
+ expect(a_get("/1.1/statuses/retweets/25938088801.json")).to have_been_made
83
+ end
84
+ end
85
+ context "with a URI string passed" do
86
+ it "requests the correct resource" do
87
+ @client.retweeters_of("https://twitter.com/sferik/status/25938088801")
88
+ expect(a_get("/1.1/statuses/retweets/25938088801.json")).to have_been_made
89
+ end
90
+ end
91
+ context "with a Tweet passed" do
92
+ it "requests the correct resource" do
93
+ tweet = Twitter::Tweet.new(:id => 25938088801)
94
+ @client.retweeters_of(tweet)
95
+ expect(a_get("/1.1/statuses/retweets/25938088801.json")).to have_been_made
96
+ end
97
+ end
98
+ end
99
+ end
100
+
101
+ describe "#status" do
102
+ before do
103
+ stub_get("/1.1/statuses/show/25938088801.json").to_return(:body => fixture("status.json"), :headers => {:content_type => "application/json; charset=utf-8"})
104
+ end
105
+ it "requests the correct resource" do
106
+ @client.status(25938088801)
107
+ expect(a_get("/1.1/statuses/show/25938088801.json")).to have_been_made
108
+ end
109
+ it "returns a Tweet" do
110
+ tweet = @client.status(25938088801)
111
+ expect(tweet).to be_a Twitter::Tweet
112
+ expect(tweet.text).to eq("The problem with your code is that it's doing exactly what you told it to do.")
113
+ end
114
+ context "with a URI object passed" do
115
+ it "requests the correct resource" do
116
+ tweet = URI.parse("https://twitter.com/sferik/status/25938088801")
117
+ @client.status(tweet)
118
+ expect(a_get("/1.1/statuses/show/25938088801.json")).to have_been_made
119
+ end
120
+ end
121
+ context "with a URI string passed" do
122
+ it "requests the correct resource" do
123
+ @client.status("https://twitter.com/sferik/status/25938088801")
124
+ expect(a_get("/1.1/statuses/show/25938088801.json")).to have_been_made
125
+ end
126
+ end
127
+ context "with a Tweet passed" do
128
+ it "requests the correct resource" do
129
+ tweet = Twitter::Tweet.new(:id => 25938088801)
130
+ @client.status(tweet)
131
+ expect(a_get("/1.1/statuses/show/25938088801.json")).to have_been_made
132
+ end
133
+ end
134
+ end
135
+
136
+ describe "#statuses" do
137
+ before do
138
+ stub_get("/1.1/statuses/show/25938088801.json").to_return(:body => fixture("status.json"), :headers => {:content_type => "application/json; charset=utf-8"})
139
+ end
140
+ it "requests the correct resource" do
141
+ @client.statuses(25938088801)
142
+ expect(a_get("/1.1/statuses/show/25938088801.json")).to have_been_made
143
+ end
144
+ it "returns an array of Tweets" do
145
+ tweets = @client.statuses(25938088801)
146
+ expect(tweets).to be_an Array
147
+ expect(tweets.first).to be_a Twitter::Tweet
148
+ expect(tweets.first.text).to eq("The problem with your code is that it's doing exactly what you told it to do.")
149
+ end
150
+ context "with a URI object passed" do
151
+ it "requests the correct resource" do
152
+ tweet = URI.parse("https://twitter.com/sferik/status/25938088801")
153
+ @client.statuses(tweet)
154
+ expect(a_get("/1.1/statuses/show/25938088801.json")).to have_been_made
155
+ end
156
+ end
157
+ context "with a URI string passed" do
158
+ it "requests the correct resource" do
159
+ @client.statuses("https://twitter.com/sferik/status/25938088801")
160
+ expect(a_get("/1.1/statuses/show/25938088801.json")).to have_been_made
161
+ end
162
+ end
163
+ context "with a Tweet passed" do
164
+ it "requests the correct resource" do
165
+ tweet = Twitter::Tweet.new(:id => 25938088801)
166
+ @client.statuses(tweet)
167
+ expect(a_get("/1.1/statuses/show/25938088801.json")).to have_been_made
168
+ end
169
+ end
170
+ end
171
+
172
+ describe "#status_destroy" do
173
+ before do
174
+ stub_post("/1.1/statuses/destroy/25938088801.json").to_return(:body => fixture("status.json"), :headers => {:content_type => "application/json; charset=utf-8"})
175
+ end
176
+ it "requests the correct resource" do
177
+ @client.status_destroy(25938088801)
178
+ expect(a_post("/1.1/statuses/destroy/25938088801.json")).to have_been_made
179
+ end
180
+ it "returns an array of Tweets" do
181
+ tweets = @client.status_destroy(25938088801)
182
+ expect(tweets).to be_an Array
183
+ expect(tweets.first).to be_a Twitter::Tweet
184
+ expect(tweets.first.text).to eq("The problem with your code is that it's doing exactly what you told it to do.")
185
+ end
186
+ context "with a URI object passed" do
187
+ it "requests the correct resource" do
188
+ tweet = URI.parse("https://twitter.com/sferik/status/25938088801")
189
+ @client.status_destroy(tweet)
190
+ expect(a_post("/1.1/statuses/destroy/25938088801.json")).to have_been_made
191
+ end
192
+ end
193
+ context "with a URI string passed" do
194
+ it "requests the correct resource" do
195
+ @client.status_destroy("https://twitter.com/sferik/status/25938088801")
196
+ expect(a_post("/1.1/statuses/destroy/25938088801.json")).to have_been_made
197
+ end
198
+ end
199
+ context "with a Tweet passed" do
200
+ it "requests the correct resource" do
201
+ tweet = Twitter::Tweet.new(:id => 25938088801)
202
+ @client.status_destroy(tweet)
203
+ expect(a_post("/1.1/statuses/destroy/25938088801.json")).to have_been_made
204
+ end
205
+ end
206
+ end
207
+
208
+ describe "#update" do
209
+ before do
210
+ stub_post("/1.1/statuses/update.json").with(:body => {:status => "The problem with your code is that it's doing exactly what you told it to do."}).to_return(:body => fixture("status.json"), :headers => {:content_type => "application/json; charset=utf-8"})
211
+ end
212
+ it "requests the correct resource" do
213
+ @client.update("The problem with your code is that it's doing exactly what you told it to do.")
214
+ expect(a_post("/1.1/statuses/update.json").with(:body => {:status => "The problem with your code is that it's doing exactly what you told it to do."})).to have_been_made
215
+ end
216
+ it "returns a Tweet" do
217
+ tweet = @client.update("The problem with your code is that it's doing exactly what you told it to do.")
218
+ expect(tweet).to be_a Twitter::Tweet
219
+ expect(tweet.text).to eq("The problem with your code is that it's doing exactly what you told it to do.")
220
+ end
221
+ context "already posted" do
222
+ before do
223
+ stub_post("/1.1/statuses/update.json").to_return(:status => 403, :body => fixture("already_posted.json"), :headers => {:content_type => "application/json; charset=utf-8"})
224
+ end
225
+ it "raises an AlreadyPosted error" do
226
+ expect{@client.update("The problem with your code is that it's doing exactly what you told it to do.")}.to raise_error Twitter::Error::AlreadyPosted
227
+ end
228
+ end
229
+ end
230
+
231
+ describe "#retweet" do
232
+ before do
233
+ stub_post("/1.1/statuses/retweet/25938088801.json").to_return(:body => fixture("retweet.json"), :headers => {:content_type => "application/json; charset=utf-8"})
234
+ end
235
+ it "requests the correct resource" do
236
+ @client.retweet(25938088801)
237
+ expect(a_post("/1.1/statuses/retweet/25938088801.json")).to have_been_made
238
+ end
239
+ it "returns an array of Tweets with retweet details embedded" do
240
+ tweets = @client.retweet(25938088801)
241
+ expect(tweets).to be_an Array
242
+ expect(tweets.first).to be_a Twitter::Tweet
243
+ expect(tweets.first.text).to eq("As for the Series, I'm for the Giants. Fuck Texas, fuck Nolan Ryan, fuck George Bush.")
244
+ expect(tweets.first.retweeted_tweet.text).to eq("RT @gruber: As for the Series, I'm for the Giants. Fuck Texas, fuck Nolan Ryan, fuck George Bush.")
245
+ expect(tweets.first.retweeted_tweet.id).not_to eq(tweets.first.id)
246
+ end
247
+ context "already retweeted" do
248
+ before do
249
+ stub_post("/1.1/statuses/retweet/25938088801.json").to_return(:status => 403, :body => fixture("already_retweeted.json"), :headers => {:content_type => "application/json; charset=utf-8"})
250
+ end
251
+ it "does not raise an error" do
252
+ expect{@client.retweet(25938088801)}.not_to raise_error
253
+ end
254
+ end
255
+ context "with a URI object passed" do
256
+ it "requests the correct resource" do
257
+ tweet = URI.parse("https://twitter.com/sferik/status/25938088801")
258
+ @client.retweet(tweet)
259
+ expect(a_post("/1.1/statuses/retweet/25938088801.json")).to have_been_made
260
+ end
261
+ end
262
+ context "with a URI string passed" do
263
+ it "requests the correct resource" do
264
+ @client.retweet("https://twitter.com/sferik/status/25938088801")
265
+ expect(a_post("/1.1/statuses/retweet/25938088801.json")).to have_been_made
266
+ end
267
+ end
268
+ context "with a Tweet passed" do
269
+ it "requests the correct resource" do
270
+ tweet = Twitter::Tweet.new(:id => 25938088801)
271
+ @client.retweet(tweet)
272
+ expect(a_post("/1.1/statuses/retweet/25938088801.json")).to have_been_made
273
+ end
274
+ end
275
+ end
276
+
277
+ describe "#retweet!" do
278
+ before do
279
+ stub_post("/1.1/statuses/retweet/25938088801.json").to_return(:body => fixture("retweet.json"), :headers => {:content_type => "application/json; charset=utf-8"})
280
+ end
281
+ it "requests the correct resource" do
282
+ @client.retweet!(25938088801)
283
+ expect(a_post("/1.1/statuses/retweet/25938088801.json")).to have_been_made
284
+ end
285
+ it "returns an array of Tweets with retweet details embedded" do
286
+ tweets = @client.retweet!(25938088801)
287
+ expect(tweets).to be_an Array
288
+ expect(tweets.first).to be_a Twitter::Tweet
289
+ expect(tweets.first.text).to eq("As for the Series, I'm for the Giants. Fuck Texas, fuck Nolan Ryan, fuck George Bush.")
290
+ expect(tweets.first.retweeted_tweet.text).to eq("RT @gruber: As for the Series, I'm for the Giants. Fuck Texas, fuck Nolan Ryan, fuck George Bush.")
291
+ expect(tweets.first.retweeted_tweet.id).not_to eq(tweets.first.id)
292
+ end
293
+ context "forbidden" do
294
+ before do
295
+ stub_post("/1.1/statuses/retweet/25938088801.json").to_return(:status => 403, :headers => {:content_type => "application/json; charset=utf-8"})
296
+ end
297
+ it "raises a Forbidden error" do
298
+ expect{@client.retweet!(25938088801)}.to raise_error Twitter::Error::Forbidden
299
+ end
300
+ end
301
+ context "already retweeted" do
302
+ before do
303
+ stub_post("/1.1/statuses/retweet/25938088801.json").to_return(:status => 403, :body => fixture("already_retweeted.json"), :headers => {:content_type => "application/json; charset=utf-8"})
304
+ end
305
+ it "raises an AlreadyRetweeted error" do
306
+ expect{@client.retweet!(25938088801)}.to raise_error Twitter::Error::AlreadyRetweeted
307
+ end
308
+ end
309
+ context "with a URI object passed" do
310
+ it "requests the correct resource" do
311
+ tweet = URI.parse("https://twitter.com/sferik/status/25938088801")
312
+ @client.retweet!(tweet)
313
+ expect(a_post("/1.1/statuses/retweet/25938088801.json")).to have_been_made
314
+ end
315
+ end
316
+ context "with a URI string passed" do
317
+ it "requests the correct resource" do
318
+ @client.retweet!("https://twitter.com/sferik/status/25938088801")
319
+ expect(a_post("/1.1/statuses/retweet/25938088801.json")).to have_been_made
320
+ end
321
+ end
322
+ context "with a Tweet passed" do
323
+ it "requests the correct resource" do
324
+ tweet = Twitter::Tweet.new(:id => 25938088801)
325
+ @client.retweet!(tweet)
326
+ expect(a_post("/1.1/statuses/retweet/25938088801.json")).to have_been_made
327
+ end
328
+ end
329
+ end
330
+
331
+ describe "#update_with_media" do
332
+ before do
333
+ stub_post("/1.1/statuses/update_with_media.json").to_return(:body => fixture("status.json"), :headers => {:content_type => "application/json; charset=utf-8"})
334
+ end
335
+ context "a gif image" do
336
+ it "requests the correct resource" do
337
+ @client.update_with_media("The problem with your code is that it's doing exactly what you told it to do.", fixture("pbjt.gif"))
338
+ expect(a_post("/1.1/statuses/update_with_media.json")).to have_been_made
339
+ end
340
+ it "returns a Tweet" do
341
+ tweet = @client.update_with_media("The problem with your code is that it's doing exactly what you told it to do.", fixture("pbjt.gif"))
342
+ expect(tweet).to be_a Twitter::Tweet
343
+ expect(tweet.text).to eq("The problem with your code is that it's doing exactly what you told it to do.")
344
+ end
345
+ end
346
+ context "a jpe image" do
347
+ it "requests the correct resource" do
348
+ @client.update_with_media("You always have options", fixture("wildcomet2.jpe"))
349
+ expect(a_post("/1.1/statuses/update_with_media.json")).to have_been_made
350
+ end
351
+ end
352
+ context "a jpeg image" do
353
+ it "requests the correct resource" do
354
+ @client.update_with_media("You always have options", fixture("me.jpeg"))
355
+ expect(a_post("/1.1/statuses/update_with_media.json")).to have_been_made
356
+ end
357
+ end
358
+ context "a png image" do
359
+ it "requests the correct resource" do
360
+ @client.update_with_media("You always have options", fixture("we_concept_bg2.png"))
361
+ expect(a_post("/1.1/statuses/update_with_media.json")).to have_been_made
362
+ end
363
+ end
364
+ context "a Tempfile" do
365
+ it "requests the correct resource" do
366
+ @client.update_with_media("You always have options", Tempfile.new("tmp"))
367
+ expect(a_post("/1.1/statuses/update_with_media.json")).to have_been_made
368
+ end
369
+ end
370
+ context "already posted" do
371
+ before do
372
+ stub_post("/1.1/statuses/update_with_media.json").to_return(:status => 403, :body => fixture("already_posted.json"), :headers => {:content_type => "application/json; charset=utf-8"})
373
+ end
374
+ it "raises an AlreadyPosted error" do
375
+ expect{@client.update_with_media("The problem with your code is that it's doing exactly what you told it to do.", fixture("pbjt.gif"))}.to raise_error Twitter::Error::AlreadyPosted
376
+ end
377
+ end
378
+ end
379
+
380
+ describe "#oembed" do
381
+ before do
382
+ stub_get("/1.1/statuses/oembed.json").with(:query => {:id => "25938088801"}).to_return(:body => fixture("oembed.json"), :headers => {:content_type => "application/json; charset=utf-8"})
383
+ stub_get("/1.1/statuses/oembed.json").with(:query => {:url => "https://twitter.com/sferik/status/25938088801"}).to_return(:body => fixture("oembed.json"), :headers => {:content_type => "application/json; charset=utf-8"})
384
+ end
385
+ it "requests the correct resource" do
386
+ @client.oembed(25938088801)
387
+ expect(a_get("/1.1/statuses/oembed.json").with(:query => {:id => "25938088801"})).to have_been_made
388
+ end
389
+ it "requests the correct resource when a URL is given" do
390
+ @client.oembed("https://twitter.com/sferik/status/25938088801")
391
+ expect(a_get("/1.1/statuses/oembed.json").with(:query => {:url => "https://twitter.com/sferik/status/25938088801"}))
392
+ end
393
+ it "returns an array of OEmbed instances" do
394
+ oembed = @client.oembed(25938088801)
395
+ expect(oembed).to be_a Twitter::OEmbed
396
+ end
397
+ context "with a URI object passed" do
398
+ it "requests the correct resource" do
399
+ tweet = URI.parse("https://twitter.com/sferik/status/25938088801")
400
+ @client.oembed(tweet)
401
+ expect(a_get("/1.1/statuses/oembed.json").with(:query => {:id => "25938088801"})).to have_been_made
402
+ end
403
+ end
404
+ context "with a URI string passed" do
405
+ it "requests the correct resource" do
406
+ @client.oembed("https://twitter.com/sferik/status/25938088801")
407
+ expect(a_get("/1.1/statuses/oembed.json").with(:query => {:id => "25938088801"})).to have_been_made
408
+ end
409
+ end
410
+ context "with a Tweet passed" do
411
+ it "requests the correct resource" do
412
+ tweet = Twitter::Tweet.new(:id => 25938088801)
413
+ @client.oembed(tweet)
414
+ expect(a_get("/1.1/statuses/oembed.json").with(:query => {:id => "25938088801"})).to have_been_made
415
+ end
416
+ end
417
+ end
418
+
419
+ describe "#oembeds" do
420
+ before do
421
+ stub_get("/1.1/statuses/oembed.json").with(:query => {:id => "25938088801"}).to_return(:body => fixture("oembed.json"), :headers => {:content_type => "application/json; charset=utf-8"})
422
+ end
423
+ it "requests the correct resource" do
424
+ @client.oembeds(25938088801)
425
+ expect(a_get("/1.1/statuses/oembed.json").with(:query => {:id => "25938088801"})).to have_been_made
426
+ end
427
+ it "requests the correct resource when a URL is given" do
428
+ @client.oembeds("https://twitter.com/sferik/status/25938088801")
429
+ expect(a_get("/1.1/statuses/oembed.json").with(:query => {:id => "25938088801"})).to have_been_made
430
+ end
431
+ it "returns an array of OEmbed instances" do
432
+ oembeds = @client.oembeds(25938088801)
433
+ expect(oembeds).to be_an Array
434
+ expect(oembeds.first).to be_a Twitter::OEmbed
435
+ end
436
+ context "with a URI object passed" do
437
+ it "requests the correct resource" do
438
+ tweet = URI.parse("https://twitter.com/sferik/status/25938088801")
439
+ @client.oembeds(tweet)
440
+ expect(a_get("/1.1/statuses/oembed.json").with(:query => {:id => "25938088801"})).to have_been_made
441
+ end
442
+ end
443
+ context "with a URI string passed" do
444
+ it "requests the correct resource" do
445
+ @client.oembeds("https://twitter.com/sferik/status/25938088801")
446
+ expect(a_get("/1.1/statuses/oembed.json").with(:query => {:id => "25938088801"})).to have_been_made
447
+ end
448
+ end
449
+ context "with a Tweet passed" do
450
+ it "requests the correct resource" do
451
+ tweet = Twitter::Tweet.new(:id => 25938088801)
452
+ @client.oembeds(tweet)
453
+ expect(a_get("/1.1/statuses/oembed.json").with(:query => {:id => "25938088801"})).to have_been_made
454
+ end
455
+ end
456
+ end
457
+
458
+ describe "#retweeters_ids" do
459
+ before do
460
+ stub_get("/1.1/statuses/retweeters/ids.json").with(:query => {:id => "25938088801", :cursor => "-1"}).to_return(:body => fixture("ids_list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
461
+ end
462
+ it "requests the correct resource" do
463
+ @client.retweeters_ids(25938088801)
464
+ expect(a_get("/1.1/statuses/retweeters/ids.json").with(:query => {:id => "25938088801", :cursor => "-1"})).to have_been_made
465
+ end
466
+ it "returns a collection of up to 100 user IDs belonging to users who have retweeted the tweet specified by the id parameter" do
467
+ retweeters_ids = @client.retweeters_ids(25938088801)
468
+ expect(retweeters_ids).to be_a Twitter::Cursor
469
+ expect(retweeters_ids.first).to eq(20009713)
470
+ end
471
+ context "with each" do
472
+ before do
473
+ stub_get("/1.1/statuses/retweeters/ids.json").with(:query => {:id => "25938088801", :cursor => "1305102810874389703"}).to_return(:body => fixture("ids_list2.json"), :headers => {:content_type => "application/json; charset=utf-8"})
474
+ end
475
+ it "requests the correct resource" do
476
+ @client.retweeters_ids(25938088801).each{}
477
+ expect(a_get("/1.1/statuses/retweeters/ids.json").with(:query => {:id => "25938088801", :cursor => "-1"})).to have_been_made
478
+ expect(a_get("/1.1/statuses/retweeters/ids.json").with(:query => {:id => "25938088801", :cursor => "1305102810874389703"})).to have_been_made
479
+ end
480
+ end
481
+ context "with a URI object passed" do
482
+ it "requests the correct resource" do
483
+ tweet = URI.parse("https://twitter.com/sferik/status/25938088801")
484
+ @client.retweeters_ids(tweet)
485
+ expect(a_get("/1.1/statuses/retweeters/ids.json").with(:query => {:id => "25938088801", :cursor => "-1"})).to have_been_made
486
+ end
487
+ end
488
+ context "with a URI string passed" do
489
+ it "requests the correct resource" do
490
+ @client.retweeters_ids("https://twitter.com/sferik/status/25938088801")
491
+ expect(a_get("/1.1/statuses/retweeters/ids.json").with(:query => {:id => "25938088801", :cursor => "-1"})).to have_been_made
492
+ end
493
+ end
494
+ context "with a Tweet passed" do
495
+ it "requests the correct resource" do
496
+ tweet = Twitter::Tweet.new(:id => 25938088801)
497
+ @client.retweeters_ids(tweet)
498
+ expect(a_get("/1.1/statuses/retweeters/ids.json").with(:query => {:id => "25938088801", :cursor => "-1"})).to have_been_made
499
+ end
500
+ end
501
+ end
502
+
503
+ end