twitter 4.8.1 → 5.0.0

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 (215) hide show
  1. data/CHANGELOG.md +36 -0
  2. data/CONTRIBUTING.md +13 -15
  3. data/LICENSE.md +1 -1
  4. data/README.md +401 -261
  5. data/Rakefile +6 -0
  6. data/lib/twitter/arguments.rb +14 -0
  7. data/lib/twitter/base.rb +109 -89
  8. data/lib/twitter/client.rb +38 -115
  9. data/lib/twitter/configuration.rb +5 -2
  10. data/lib/twitter/core_ext/kernel.rb +5 -1
  11. data/lib/twitter/creatable.rb +7 -4
  12. data/lib/twitter/cursor.rb +57 -45
  13. data/lib/twitter/direct_message.rb +2 -11
  14. data/lib/twitter/entity/uri.rb +14 -0
  15. data/lib/twitter/enumerable.rb +15 -0
  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/error.rb +65 -14
  31. data/lib/twitter/factory.rb +13 -12
  32. data/lib/twitter/geo.rb +2 -7
  33. data/lib/twitter/geo_factory.rb +11 -7
  34. data/lib/twitter/geo_results.rb +40 -0
  35. data/lib/twitter/identity.rb +4 -34
  36. data/lib/twitter/list.rb +21 -4
  37. data/lib/twitter/media/photo.rb +6 -4
  38. data/lib/twitter/media_factory.rb +11 -7
  39. data/lib/twitter/null_object.rb +25 -0
  40. data/lib/twitter/oembed.rb +3 -2
  41. data/lib/twitter/place.rb +15 -15
  42. data/lib/twitter/profile_banner.rb +3 -2
  43. data/lib/twitter/rate_limit.rb +4 -17
  44. data/lib/twitter/relationship.rb +2 -19
  45. data/lib/twitter/rest/api/direct_messages.rb +138 -0
  46. data/lib/twitter/rest/api/favorites.rb +115 -0
  47. data/lib/twitter/rest/api/friends_and_followers.rb +287 -0
  48. data/lib/twitter/rest/api/help.rb +58 -0
  49. data/lib/twitter/rest/api/lists.rb +498 -0
  50. data/lib/twitter/rest/api/oauth.rb +62 -0
  51. data/lib/twitter/rest/api/places_and_geo.rb +86 -0
  52. data/lib/twitter/rest/api/saved_searches.rb +93 -0
  53. data/lib/twitter/rest/api/search.rb +37 -0
  54. data/lib/twitter/rest/api/spam_reporting.rb +29 -0
  55. data/lib/twitter/rest/api/suggested_users.rb +51 -0
  56. data/lib/twitter/rest/api/timelines.rb +202 -0
  57. data/lib/twitter/rest/api/trends.rb +58 -0
  58. data/lib/twitter/rest/api/tweets.rb +291 -0
  59. data/lib/twitter/rest/api/undocumented.rb +52 -0
  60. data/lib/twitter/rest/api/users.rb +383 -0
  61. data/lib/twitter/rest/api/utils.rb +246 -0
  62. data/lib/twitter/rest/client.rb +175 -0
  63. data/lib/twitter/rest/request/multipart_with_file.rb +36 -0
  64. data/lib/twitter/rest/response/parse_error_json.rb +15 -0
  65. data/lib/twitter/rest/response/parse_json.rb +31 -0
  66. data/lib/twitter/{response → rest/response}/raise_error.rb +8 -11
  67. data/lib/twitter/search_results.rb +37 -21
  68. data/lib/twitter/settings.rb +1 -6
  69. data/lib/twitter/size.rb +2 -15
  70. data/lib/twitter/streaming/client.rb +89 -0
  71. data/lib/twitter/streaming/connection.rb +22 -0
  72. data/lib/twitter/streaming/event.rb +35 -0
  73. data/lib/twitter/streaming/friend_list.rb +13 -0
  74. data/lib/twitter/streaming/message_parser.rb +18 -0
  75. data/lib/twitter/streaming/response.rb +34 -0
  76. data/lib/twitter/suggestion.rb +5 -8
  77. data/lib/twitter/token.rb +11 -1
  78. data/lib/twitter/trend.rb +4 -8
  79. data/lib/twitter/trend_results.rb +65 -0
  80. data/lib/twitter/tweet.rb +43 -92
  81. data/lib/twitter/user.rb +72 -47
  82. data/lib/twitter/version.rb +4 -4
  83. data/lib/twitter.rb +4 -39
  84. data/spec/fixtures/already_posted.json +1 -0
  85. data/spec/fixtures/ids_list.json +1 -1
  86. data/spec/fixtures/ids_list2.json +1 -1
  87. data/spec/fixtures/request_token.txt +6 -0
  88. data/spec/fixtures/search.json +1 -1
  89. data/spec/fixtures/search_malformed.json +1 -1
  90. data/spec/fixtures/track_streaming.json +3 -0
  91. data/spec/fixtures/track_streaming_user.json +5 -0
  92. data/spec/helper.rb +8 -13
  93. data/spec/twitter/base_spec.rb +13 -103
  94. data/spec/twitter/basic_user_spec.rb +3 -3
  95. data/spec/twitter/configuration_spec.rb +1 -1
  96. data/spec/twitter/cursor_spec.rb +17 -35
  97. data/spec/twitter/direct_message_spec.rb +44 -11
  98. data/spec/twitter/entity/uri_spec.rb +75 -0
  99. data/spec/twitter/error_spec.rb +59 -11
  100. data/spec/twitter/geo/point_spec.rb +6 -6
  101. data/spec/twitter/geo/polygon_spec.rb +5 -5
  102. data/spec/twitter/geo_factory_spec.rb +4 -4
  103. data/spec/twitter/geo_results_spec.rb +35 -0
  104. data/spec/twitter/geo_spec.rb +6 -6
  105. data/spec/twitter/identifiable_spec.rb +5 -26
  106. data/spec/twitter/list_spec.rb +54 -11
  107. data/spec/twitter/media/photo_spec.rb +122 -6
  108. data/spec/twitter/media_factory_spec.rb +3 -3
  109. data/spec/twitter/null_object_spec.rb +27 -0
  110. data/spec/twitter/oembed_spec.rb +69 -45
  111. data/spec/twitter/place_spec.rb +84 -28
  112. data/spec/twitter/profile_banner_spec.rb +1 -1
  113. data/spec/twitter/rate_limit_spec.rb +8 -25
  114. data/spec/twitter/relationship_spec.rb +26 -12
  115. data/spec/twitter/{api → rest/api}/direct_messages_spec.rb +28 -15
  116. data/spec/twitter/{api → rest/api}/favorites_spec.rb +80 -7
  117. data/spec/twitter/{api → rest/api}/friends_and_followers_spec.rb +121 -152
  118. data/spec/twitter/{api → rest/api}/geo_spec.rb +9 -23
  119. data/spec/twitter/{api → rest/api}/help_spec.rb +6 -6
  120. data/spec/twitter/{api → rest/api}/lists_spec.rb +116 -95
  121. data/spec/twitter/{api → rest/api}/oauth_spec.rb +21 -10
  122. data/spec/twitter/{api → rest/api}/saved_searches_spec.rb +13 -13
  123. data/spec/twitter/{api → rest/api}/search_spec.rb +8 -9
  124. data/spec/twitter/{api → rest/api}/spam_reporting_spec.rb +3 -3
  125. data/spec/twitter/{api → rest/api}/suggested_users_spec.rb +5 -5
  126. data/spec/twitter/{api → rest/api}/timelines_spec.rb +9 -9
  127. data/spec/twitter/{api → rest/api}/trends_spec.rb +6 -6
  128. data/spec/twitter/rest/api/tweets_spec.rb +503 -0
  129. data/spec/twitter/{api → rest/api}/undocumented_spec.rb +19 -45
  130. data/spec/twitter/{api → rest/api}/users_spec.rb +64 -39
  131. data/spec/twitter/rest/client_spec.rb +193 -0
  132. data/spec/twitter/saved_search_spec.rb +14 -3
  133. data/spec/twitter/search_results_spec.rb +32 -45
  134. data/spec/twitter/settings_spec.rb +17 -6
  135. data/spec/twitter/size_spec.rb +5 -15
  136. data/spec/twitter/source_user_spec.rb +3 -3
  137. data/spec/twitter/streaming/client_spec.rb +92 -0
  138. data/spec/twitter/streaming/event_spec.rb +45 -0
  139. data/spec/twitter/suggestion_spec.rb +5 -15
  140. data/spec/twitter/target_user_spec.rb +3 -3
  141. data/spec/twitter/token_spec.rb +16 -0
  142. data/spec/twitter/trend_results_spec.rb +89 -0
  143. data/spec/twitter/trend_spec.rb +26 -13
  144. data/spec/twitter/tweet_spec.rb +137 -124
  145. data/spec/twitter/user_spec.rb +139 -80
  146. data/spec/twitter_spec.rb +0 -119
  147. data/twitter.gemspec +12 -6
  148. data.tar.gz.sig +0 -0
  149. metadata +197 -138
  150. metadata.gz.sig +0 -0
  151. data/lib/twitter/action/favorite.rb +0 -19
  152. data/lib/twitter/action/follow.rb +0 -30
  153. data/lib/twitter/action/list_member_added.rb +0 -39
  154. data/lib/twitter/action/mention.rb +0 -46
  155. data/lib/twitter/action/reply.rb +0 -27
  156. data/lib/twitter/action/retweet.rb +0 -27
  157. data/lib/twitter/action/tweet.rb +0 -20
  158. data/lib/twitter/action_factory.rb +0 -22
  159. data/lib/twitter/api/arguments.rb +0 -13
  160. data/lib/twitter/api/direct_messages.rb +0 -148
  161. data/lib/twitter/api/favorites.rb +0 -126
  162. data/lib/twitter/api/friends_and_followers.rb +0 -334
  163. data/lib/twitter/api/help.rb +0 -64
  164. data/lib/twitter/api/lists.rb +0 -618
  165. data/lib/twitter/api/oauth.rb +0 -44
  166. data/lib/twitter/api/places_and_geo.rb +0 -121
  167. data/lib/twitter/api/saved_searches.rb +0 -99
  168. data/lib/twitter/api/search.rb +0 -37
  169. data/lib/twitter/api/spam_reporting.rb +0 -30
  170. data/lib/twitter/api/suggested_users.rb +0 -55
  171. data/lib/twitter/api/timelines.rb +0 -214
  172. data/lib/twitter/api/trends.rb +0 -63
  173. data/lib/twitter/api/tweets.rb +0 -304
  174. data/lib/twitter/api/undocumented.rb +0 -97
  175. data/lib/twitter/api/users.rb +0 -439
  176. data/lib/twitter/api/utils.rb +0 -187
  177. data/lib/twitter/configurable.rb +0 -96
  178. data/lib/twitter/default.rb +0 -102
  179. data/lib/twitter/entity/url.rb +0 -9
  180. data/lib/twitter/error/client_error.rb +0 -35
  181. data/lib/twitter/error/decode_error.rb +0 -9
  182. data/lib/twitter/error/identity_map_key_error.rb +0 -9
  183. data/lib/twitter/error/server_error.rb +0 -28
  184. data/lib/twitter/exceptable.rb +0 -36
  185. data/lib/twitter/identity_map.rb +0 -22
  186. data/lib/twitter/request/multipart_with_file.rb +0 -34
  187. data/lib/twitter/response/parse_json.rb +0 -25
  188. data/spec/fixtures/about_me.json +0 -1
  189. data/spec/fixtures/activity_summary.json +0 -1
  190. data/spec/fixtures/bad_gateway.json +0 -1
  191. data/spec/fixtures/bad_request.json +0 -1
  192. data/spec/fixtures/by_friends.json +0 -1
  193. data/spec/fixtures/end_session.json +0 -1
  194. data/spec/fixtures/forbidden.json +0 -1
  195. data/spec/fixtures/internal_server_error.json +0 -1
  196. data/spec/fixtures/not_acceptable.json +0 -1
  197. data/spec/fixtures/phoenix_search.phoenix +0 -1
  198. data/spec/fixtures/resolve.json +0 -1
  199. data/spec/fixtures/service_unavailable.json +0 -1
  200. data/spec/fixtures/totals.json +0 -1
  201. data/spec/fixtures/trends.json +0 -1
  202. data/spec/fixtures/unauthorized.json +0 -1
  203. data/spec/fixtures/video_facets.json +0 -1
  204. data/spec/twitter/action/favorite_spec.rb +0 -29
  205. data/spec/twitter/action/follow_spec.rb +0 -29
  206. data/spec/twitter/action/list_member_added_spec.rb +0 -41
  207. data/spec/twitter/action/mention_spec.rb +0 -52
  208. data/spec/twitter/action/reply_spec.rb +0 -41
  209. data/spec/twitter/action/retweet_spec.rb +0 -41
  210. data/spec/twitter/action_factory_spec.rb +0 -35
  211. data/spec/twitter/action_spec.rb +0 -16
  212. data/spec/twitter/api/tweets_spec.rb +0 -285
  213. data/spec/twitter/client_spec.rb +0 -223
  214. data/spec/twitter/error/client_error_spec.rb +0 -23
  215. data/spec/twitter/error/server_error_spec.rb +0 -20
@@ -1,9 +1,9 @@
1
1
  require 'helper'
2
2
 
3
- describe Twitter::API::FriendsAndFollowers do
3
+ describe Twitter::REST::API::FriendsAndFollowers 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 "#friend_ids" do
@@ -18,15 +18,14 @@ describe Twitter::API::FriendsAndFollowers do
18
18
  it "returns an array of numeric IDs for every user the specified user is following" do
19
19
  friend_ids = @client.friend_ids("sferik")
20
20
  expect(friend_ids).to be_a Twitter::Cursor
21
- expect(friend_ids.ids).to be_an Array
22
- expect(friend_ids.ids.first).to eq 14100886
21
+ expect(friend_ids.first).to eq(20009713)
23
22
  end
24
- context "with all" do
23
+ context "with each" do
25
24
  before do
26
25
  stub_get("/1.1/friends/ids.json").with(:query => {:cursor => "1305102810874389703", :screen_name => "sferik"}).to_return(:body => fixture("ids_list2.json"), :headers => {:content_type => "application/json; charset=utf-8"})
27
26
  end
28
27
  it "requests the correct resource" do
29
- @client.friend_ids("sferik").all
28
+ @client.friend_ids("sferik").each{}
30
29
  expect(a_get("/1.1/friends/ids.json").with(:query => {:cursor => "-1", :screen_name => "sferik"})).to have_been_made
31
30
  expect(a_get("/1.1/friends/ids.json").with(:query => {:cursor => "1305102810874389703", :screen_name => "sferik"})).to have_been_made
32
31
  end
@@ -40,12 +39,12 @@ describe Twitter::API::FriendsAndFollowers do
40
39
  @client.friend_ids(7505382)
41
40
  expect(a_get("/1.1/friends/ids.json").with(:query => {:cursor => "-1", :user_id => "7505382"})).to have_been_made
42
41
  end
43
- context "with all" do
42
+ context "with each" do
44
43
  before do
45
44
  stub_get("/1.1/friends/ids.json").with(:query => {:cursor => "1305102810874389703", :user_id => "7505382"}).to_return(:body => fixture("ids_list2.json"), :headers => {:content_type => "application/json; charset=utf-8"})
46
45
  end
47
46
  it "requests the correct resource" do
48
- @client.friend_ids(7505382).all
47
+ @client.friend_ids(7505382).each{}
49
48
  expect(a_get("/1.1/friends/ids.json").with(:query => {:cursor => "-1", :user_id => "7505382"})).to have_been_made
50
49
  expect(a_get("/1.1/friends/ids.json").with(:query => {:cursor => "1305102810874389703", :user_id => "7505382"})).to have_been_made
51
50
  end
@@ -64,15 +63,14 @@ describe Twitter::API::FriendsAndFollowers do
64
63
  it "returns an array of numeric IDs for every user the specified user is following" do
65
64
  friend_ids = @client.friend_ids
66
65
  expect(friend_ids).to be_a Twitter::Cursor
67
- expect(friend_ids.ids).to be_an Array
68
- expect(friend_ids.ids.first).to eq 14100886
66
+ expect(friend_ids.first).to eq(20009713)
69
67
  end
70
- context "with all" do
68
+ context "with each" do
71
69
  before do
72
70
  stub_get("/1.1/friends/ids.json").with(:query => {:cursor => "1305102810874389703", :screen_name => "sferik"}).to_return(:body => fixture("ids_list2.json"), :headers => {:content_type => "application/json; charset=utf-8"})
73
71
  end
74
72
  it "requests the correct resource" do
75
- @client.friend_ids.all
73
+ @client.friend_ids.each{}
76
74
  expect(a_get("/1.1/account/verify_credentials.json")).to have_been_made
77
75
  expect(a_get("/1.1/friends/ids.json").with(:query => {:cursor => "-1", :screen_name => "sferik"})).to have_been_made
78
76
  expect(a_get("/1.1/friends/ids.json").with(:query => {:cursor => "1305102810874389703", :screen_name => "sferik"})).to have_been_made
@@ -93,15 +91,14 @@ describe Twitter::API::FriendsAndFollowers do
93
91
  it "returns an array of numeric IDs for every user following the specified user" do
94
92
  follower_ids = @client.follower_ids("sferik")
95
93
  expect(follower_ids).to be_a Twitter::Cursor
96
- expect(follower_ids.ids).to be_an Array
97
- expect(follower_ids.ids.first).to eq 14100886
94
+ expect(follower_ids.first).to eq(20009713)
98
95
  end
99
- context "with all" do
96
+ context "with each" do
100
97
  before do
101
98
  stub_get("/1.1/followers/ids.json").with(:query => {:cursor => "1305102810874389703", :screen_name => "sferik"}).to_return(:body => fixture("ids_list2.json"), :headers => {:content_type => "application/json; charset=utf-8"})
102
99
  end
103
100
  it "requests the correct resource" do
104
- @client.follower_ids("sferik").all
101
+ @client.follower_ids("sferik").each{}
105
102
  expect(a_get("/1.1/followers/ids.json").with(:query => {:cursor => "-1", :screen_name => "sferik"})).to have_been_made
106
103
  expect(a_get("/1.1/followers/ids.json").with(:query => {:cursor => "1305102810874389703", :screen_name => "sferik"})).to have_been_made
107
104
  end
@@ -115,12 +112,12 @@ describe Twitter::API::FriendsAndFollowers do
115
112
  @client.follower_ids(7505382)
116
113
  expect(a_get("/1.1/followers/ids.json").with(:query => {:cursor => "-1", :user_id => "7505382"})).to have_been_made
117
114
  end
118
- context "with all" do
115
+ context "with each" do
119
116
  before do
120
117
  stub_get("/1.1/followers/ids.json").with(:query => {:cursor => "1305102810874389703", :user_id => "7505382"}).to_return(:body => fixture("ids_list2.json"), :headers => {:content_type => "application/json; charset=utf-8"})
121
118
  end
122
119
  it "requests the correct resource" do
123
- @client.follower_ids(7505382).all
120
+ @client.follower_ids(7505382).each{}
124
121
  expect(a_get("/1.1/followers/ids.json").with(:query => {:cursor => "-1", :user_id => "7505382"})).to have_been_made
125
122
  expect(a_get("/1.1/followers/ids.json").with(:query => {:cursor => "1305102810874389703", :user_id => "7505382"})).to have_been_made
126
123
  end
@@ -139,15 +136,14 @@ describe Twitter::API::FriendsAndFollowers do
139
136
  it "returns an array of numeric IDs for every user following the specified user" do
140
137
  follower_ids = @client.follower_ids
141
138
  expect(follower_ids).to be_a Twitter::Cursor
142
- expect(follower_ids.ids).to be_an Array
143
- expect(follower_ids.ids.first).to eq 14100886
139
+ expect(follower_ids.first).to eq(20009713)
144
140
  end
145
- context "with all" do
141
+ context "with each" do
146
142
  before do
147
143
  stub_get("/1.1/followers/ids.json").with(:query => {:cursor => "1305102810874389703", :screen_name => "sferik"}).to_return(:body => fixture("ids_list2.json"), :headers => {:content_type => "application/json; charset=utf-8"})
148
144
  end
149
145
  it "requests the correct resource" do
150
- @client.follower_ids.all
146
+ @client.follower_ids.each{}
151
147
  expect(a_get("/1.1/account/verify_credentials.json")).to have_been_made
152
148
  expect(a_get("/1.1/followers/ids.json").with(:query => {:cursor => "-1", :screen_name => "sferik"})).to have_been_made
153
149
  expect(a_get("/1.1/followers/ids.json").with(:query => {:cursor => "1305102810874389703", :screen_name => "sferik"})).to have_been_made
@@ -169,8 +165,8 @@ describe Twitter::API::FriendsAndFollowers do
169
165
  friendships = @client.friendships("sferik", "pengwynn")
170
166
  expect(friendships).to be_an Array
171
167
  expect(friendships.first).to be_a Twitter::User
172
- expect(friendships.first.id).to eq 7505382
173
- expect(friendships.first.connections).to eq ["none"]
168
+ expect(friendships.first.id).to eq(7505382)
169
+ expect(friendships.first.connections).to eq(["none"])
174
170
  end
175
171
  end
176
172
  context "with numeric screen names passed" do
@@ -215,8 +211,8 @@ describe Twitter::API::FriendsAndFollowers do
215
211
  friendships = @client.friendships("sferik", "pengwynn")
216
212
  expect(friendships).to be_an Array
217
213
  expect(friendships.first).to be_a Twitter::User
218
- expect(friendships.first.id).to eq 7505382
219
- expect(friendships.first.connections).to eq ["none"]
214
+ expect(friendships.first.id).to eq(7505382)
215
+ expect(friendships.first.connections).to eq(["none"])
220
216
  end
221
217
  end
222
218
  context "with numeric screen names passed" do
@@ -259,15 +255,14 @@ describe Twitter::API::FriendsAndFollowers do
259
255
  it "returns an array of numeric IDs for every user who has a pending request to follow the authenticating user" do
260
256
  friendships_incoming = @client.friendships_incoming
261
257
  expect(friendships_incoming).to be_a Twitter::Cursor
262
- expect(friendships_incoming.ids).to be_an Array
263
- expect(friendships_incoming.ids.first).to eq 14100886
258
+ expect(friendships_incoming.first).to eq(20009713)
264
259
  end
265
- context "with all" do
260
+ context "with each" do
266
261
  before do
267
262
  stub_get("/1.1/friendships/incoming.json").with(:query => {:cursor => "1305102810874389703"}).to_return(:body => fixture("ids_list2.json"), :headers => {:content_type => "application/json; charset=utf-8"})
268
263
  end
269
264
  it "requests the correct resource" do
270
- @client.friendships_incoming.all
265
+ @client.friendships_incoming.each{}
271
266
  expect(a_get("/1.1/friendships/incoming.json").with(:query => {:cursor => "1305102810874389703"})).to have_been_made
272
267
  end
273
268
  end
@@ -284,119 +279,77 @@ describe Twitter::API::FriendsAndFollowers do
284
279
  it "returns an array of numeric IDs for every protected user for whom the authenticating user has a pending follow request" do
285
280
  friendships_outgoing = @client.friendships_outgoing
286
281
  expect(friendships_outgoing).to be_a Twitter::Cursor
287
- expect(friendships_outgoing.ids).to be_an Array
288
- expect(friendships_outgoing.ids.first).to eq 14100886
282
+ expect(friendships_outgoing.first).to eq(20009713)
289
283
  end
290
- context "with all" do
284
+ context "with each" do
291
285
  before do
292
286
  stub_get("/1.1/friendships/outgoing.json").with(:query => {:cursor => "1305102810874389703"}).to_return(:body => fixture("ids_list2.json"), :headers => {:content_type => "application/json; charset=utf-8"})
293
287
  end
294
288
  it "requests the correct resource" do
295
- @client.friendships_outgoing.all
289
+ @client.friendships_outgoing.each{}
296
290
  expect(a_get("/1.1/friendships/outgoing.json").with(:query => {:cursor => "1305102810874389703"})).to have_been_made
297
291
  end
298
292
  end
299
293
  end
300
294
 
301
295
  describe "#follow" do
302
- context "with :follow => true passed" do
303
- before do
304
- stub_get("/1.1/account/verify_credentials.json").to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
305
- stub_get("/1.1/friends/ids.json").with(:query => {:cursor => "-1", :screen_name => "sferik"}).to_return(:body => fixture("ids_list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
306
- stub_post("/1.1/users/lookup.json").with(:body => {:screen_name => "sferik,pengwynn"}).to_return(:body => fixture("friendships.json"), :headers => {:content_type => "application/json; charset=utf-8"})
307
- stub_post("/1.1/friendships/create.json").with(:body => {:user_id => "7505382", :follow => "true"}).to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
308
- end
309
- it "requests the correct resource" do
310
- @client.follow("sferik", "pengwynn", :follow => true)
311
- expect(a_get("/1.1/account/verify_credentials.json")).to have_been_made
312
- expect(a_get("/1.1/friends/ids.json").with(:query => {:cursor => "-1", :screen_name => "sferik"})).to have_been_made
313
- expect(a_post("/1.1/users/lookup.json").with(:body => {:screen_name => "sferik,pengwynn"})).to have_been_made
314
- expect(a_post("/1.1/friendships/create.json").with(:body => {:user_id => "7505382", :follow => "true"})).to have_been_made
315
- end
316
- it "returns an array of befriended users" do
317
- users = @client.follow("sferik", "pengwynn", :follow => true)
318
- expect(users).to be_an Array
319
- expect(users.first).to be_a Twitter::User
320
- expect(users.first.id).to eq 7505382
321
- end
322
- end
323
- context "with :follow => false passed" do
324
- before do
325
- stub_get("/1.1/account/verify_credentials.json").to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
326
- stub_get("/1.1/friends/ids.json").with(:query => {:cursor => "-1", :screen_name => "sferik"}).to_return(:body => fixture("ids_list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
327
- stub_post("/1.1/users/lookup.json").with(:body => {:screen_name => "sferik,pengwynn"}).to_return(:body => fixture("friendships.json"), :headers => {:content_type => "application/json; charset=utf-8"})
328
- stub_post("/1.1/friendships/create.json").with(:body => {:user_id => "7505382"}).to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
329
- end
330
- it "requests the correct resource" do
331
- @client.follow("sferik", "pengwynn", :follow => false)
332
- expect(a_get("/1.1/account/verify_credentials.json")).to have_been_made
333
- expect(a_get("/1.1/friends/ids.json").with(:query => {:cursor => "-1", :screen_name => "sferik"})).to have_been_made
334
- expect(a_post("/1.1/users/lookup.json").with(:body => {:screen_name => "sferik,pengwynn"})).to have_been_made
335
- expect(a_post("/1.1/friendships/create.json").with(:body => {:user_id => "7505382"})).to have_been_made
336
- end
296
+ before do
297
+ stub_get("/1.1/account/verify_credentials.json").to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
298
+ stub_get("/1.1/friends/ids.json").with(:query => {:cursor => "-1", :screen_name => "sferik"}).to_return(:body => fixture("ids_list2.json"), :headers => {:content_type => "application/json; charset=utf-8"})
299
+ stub_post("/1.1/users/lookup.json").with(:body => {:screen_name => "sferik,pengwynn"}).to_return(:body => fixture("friendships.json"), :headers => {:content_type => "application/json; charset=utf-8"})
300
+ stub_post("/1.1/friendships/create.json").with(:body => {:user_id => "7505382"}).to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
337
301
  end
338
- context "without :follow passed" do
339
- before do
340
- stub_get("/1.1/account/verify_credentials.json").to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
341
- stub_get("/1.1/friends/ids.json").with(:query => {:cursor => "-1", :screen_name => "sferik"}).to_return(:body => fixture("ids_list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
342
- stub_post("/1.1/users/lookup.json").with(:body => {:screen_name => "sferik,pengwynn"}).to_return(:body => fixture("friendships.json"), :headers => {:content_type => "application/json; charset=utf-8"})
343
- stub_post("/1.1/friendships/create.json").with(:body => {:user_id => "7505382"}).to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
344
- end
345
- it "requests the correct resource" do
346
- @client.follow("sferik", "pengwynn")
347
- expect(a_get("/1.1/account/verify_credentials.json")).to have_been_made
348
- expect(a_get("/1.1/friends/ids.json").with(:query => {:cursor => "-1", :screen_name => "sferik"})).to have_been_made
349
- expect(a_post("/1.1/users/lookup.json").with(:body => {:screen_name => "sferik,pengwynn"})).to have_been_made
350
- expect(a_post("/1.1/friendships/create.json").with(:body => {:user_id => "7505382"})).to have_been_made
351
- end
302
+ it "requests the correct resource" do
303
+ @client.follow("sferik", "pengwynn")
304
+ expect(a_get("/1.1/account/verify_credentials.json")).to have_been_made
305
+ expect(a_get("/1.1/friends/ids.json").with(:query => {:cursor => "-1", :screen_name => "sferik"})).to have_been_made
306
+ expect(a_post("/1.1/users/lookup.json").with(:body => {:screen_name => "sferik,pengwynn"})).to have_been_made
307
+ expect(a_post("/1.1/friendships/create.json").with(:body => {:user_id => "7505382"})).to have_been_made
352
308
  end
353
309
  end
354
310
 
355
311
  describe "#follow!" do
356
- context "with :follow => true passed" do
357
- before do
358
- stub_post("/1.1/friendships/create.json").with(:body => {:screen_name => "sferik", :follow => "true"}).to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
359
- end
360
- it "requests the correct resource" do
361
- @client.follow!("sferik", :follow => true)
362
- expect(a_post("/1.1/friendships/create.json").with(:body => {:screen_name => "sferik", :follow => "true"})).to have_been_made
363
- end
364
- it "returns an array of befriended users" do
365
- users = @client.follow!("sferik", :follow => true)
366
- expect(users).to be_an Array
367
- expect(users.first).to be_a Twitter::User
368
- expect(users.first.id).to eq 7505382
369
- end
312
+ before do
313
+ stub_post("/1.1/friendships/create.json").with(:body => {:screen_name => "sferik"}).to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
370
314
  end
371
- context "with :follow => false passed" do
372
- before do
373
- stub_post("/1.1/friendships/create.json").with(:body => {:screen_name => "sferik"}).to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
374
- end
375
- it "requests the correct resource" do
376
- @client.follow!("sferik", :follow => false)
377
- expect(a_post("/1.1/friendships/create.json").with(:body => {:screen_name => "sferik"})).to have_been_made
378
- end
379
- it "returns an array of befriended users" do
380
- users = @client.follow!("sferik", :follow => false)
381
- expect(users).to be_an Array
382
- expect(users.first).to be_a Twitter::User
383
- expect(users.first.id).to eq 7505382
384
- end
315
+ it "requests the correct resource" do
316
+ @client.follow!("sferik")
317
+ expect(a_post("/1.1/friendships/create.json").with(:body => {:screen_name => "sferik"})).to have_been_made
385
318
  end
386
- context "without :follow passed" do
387
- before do
388
- stub_post("/1.1/friendships/create.json").with(:body => {:screen_name => "sferik"}).to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
389
- end
390
- it "requests the correct resource" do
391
- @client.follow!("sferik")
392
- expect(a_post("/1.1/friendships/create.json").with(:body => {:screen_name => "sferik"})).to have_been_made
393
- end
394
- it "returns an array of befriended users" do
395
- users = @client.follow!("sferik")
396
- expect(users).to be_an Array
397
- expect(users.first).to be_a Twitter::User
398
- expect(users.first.id).to eq 7505382
399
- end
319
+ it "returns an array of befriended users" do
320
+ users = @client.follow!("sferik")
321
+ expect(users).to be_an Array
322
+ expect(users.first).to be_a Twitter::User
323
+ expect(users.first.id).to eq(7505382)
324
+ end
325
+ end
326
+ context "with a user object passed" do
327
+ before do
328
+ stub_post("/1.1/friendships/create.json").with(:body => {:user_id => "7505382"}).to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
329
+ end
330
+ it "requests the correct resources" do
331
+ user = Twitter::User.new(:id => "7505382")
332
+ @client.follow!(user)
333
+ expect(a_post("/1.1/friendships/create.json").with(:body => {:user_id => "7505382"})).to have_been_made
334
+ end
335
+ end
336
+ context "with a URI object passed" do
337
+ before do
338
+ stub_post("/1.1/friendships/create.json").with(:body => {:screen_name => "sferik"}).to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
339
+ end
340
+ it "requests the correct resource" do
341
+ user = URI.parse("https://twitter.com/sferik")
342
+ @client.follow!(user)
343
+ expect(a_post("/1.1/friendships/create.json").with(:body => {:screen_name => "sferik"})).to have_been_made
344
+ end
345
+ end
346
+ context "with a URI string passed" do
347
+ before do
348
+ stub_post("/1.1/friendships/create.json").with(:body => {:screen_name => "sferik"}).to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
349
+ end
350
+ it "requests the correct resource" do
351
+ @client.follow!("https://twitter.com/sferik")
352
+ expect(a_post("/1.1/friendships/create.json").with(:body => {:screen_name => "sferik"})).to have_been_made
400
353
  end
401
354
  end
402
355
 
@@ -409,10 +362,10 @@ describe Twitter::API::FriendsAndFollowers do
409
362
  expect(a_post("/1.1/friendships/destroy.json").with(:body => {:screen_name => "sferik"})).to have_been_made
410
363
  end
411
364
  it "returns an array of unfollowed users" do
412
- users = @client.friendship_destroy("sferik")
365
+ users = @client.unfollow("sferik")
413
366
  expect(users).to be_an Array
414
367
  expect(users.first).to be_a Twitter::User
415
- expect(users.first.id).to eq 7505382
368
+ expect(users.first.id).to eq(7505382)
416
369
  end
417
370
  end
418
371
 
@@ -427,7 +380,7 @@ describe Twitter::API::FriendsAndFollowers do
427
380
  it "returns detailed information about the relationship between two users" do
428
381
  relationship = @client.friendship_update("sferik", :retweets => true)
429
382
  expect(relationship).to be_a Twitter::Relationship
430
- expect(relationship.source.id).to eq 7505382
383
+ expect(relationship.source.id).to eq(7505382)
431
384
  end
432
385
  end
433
386
 
@@ -443,7 +396,7 @@ describe Twitter::API::FriendsAndFollowers do
443
396
  it "returns detailed information about the relationship between two users" do
444
397
  relationship = @client.friendship("sferik", "pengwynn")
445
398
  expect(relationship).to be_a Twitter::Relationship
446
- expect(relationship.source.id).to eq 7505382
399
+ expect(relationship.source.id).to eq(7505382)
447
400
  end
448
401
  end
449
402
  context "with numeric screen names passed" do
@@ -475,6 +428,26 @@ describe Twitter::API::FriendsAndFollowers do
475
428
  expect(a_get("/1.1/friendships/show.json").with(:query => {:source_id => "7505382", :target_id => "14100886"})).to have_been_made
476
429
  end
477
430
  end
431
+ context "with URI objects passed" do
432
+ before do
433
+ stub_get("/1.1/friendships/show.json").with(:query => {:source_screen_name => "sferik", :target_screen_name => "pengwynn"}).to_return(:body => fixture("following.json"), :headers => {:content_type => "application/json; charset=utf-8"})
434
+ end
435
+ it "requests the correct resource" do
436
+ user1 = URI.parse("https://twitter.com/sferik")
437
+ user2 = URI.parse("https://twitter.com/pengwynn")
438
+ @client.friendship(user1, user2)
439
+ expect(a_get("/1.1/friendships/show.json").with(:query => {:source_screen_name => "sferik", :target_screen_name => "pengwynn"})).to have_been_made
440
+ end
441
+ end
442
+ context "with URI strings passed" do
443
+ before do
444
+ stub_get("/1.1/friendships/show.json").with(:query => {:source_screen_name => "sferik", :target_screen_name => "pengwynn"}).to_return(:body => fixture("following.json"), :headers => {:content_type => "application/json; charset=utf-8"})
445
+ end
446
+ it "requests the correct resource" do
447
+ @client.friendship("https://twitter.com/sferik", "https://twitter.com/pengwynn")
448
+ expect(a_get("/1.1/friendships/show.json").with(:query => {:source_screen_name => "sferik", :target_screen_name => "pengwynn"})).to have_been_made
449
+ end
450
+ end
478
451
  end
479
452
 
480
453
  describe "#friendship?" do
@@ -489,11 +462,11 @@ describe Twitter::API::FriendsAndFollowers do
489
462
  end
490
463
  it "returns true if user A follows user B" do
491
464
  friendship = @client.friendship?("sferik", "pengwynn")
492
- expect(friendship).to be_true
465
+ expect(friendship).to be true
493
466
  end
494
467
  it "returns false if user A does not follow user B" do
495
468
  friendship = @client.friendship?("pengwynn", "sferik")
496
- expect(friendship).to be_false
469
+ expect(friendship).to be false
497
470
  end
498
471
  end
499
472
  context "with user IDs passed" do
@@ -530,15 +503,14 @@ describe Twitter::API::FriendsAndFollowers do
530
503
  it "returns a cursor of followers with details for every user the specified user is followed by" do
531
504
  followers = @client.followers("sferik")
532
505
  expect(followers).to be_a Twitter::Cursor
533
- expect(followers.users).to be_an Array
534
- expect(followers.users.first).to be_a Twitter::User
506
+ expect(followers.first).to be_a Twitter::User
535
507
  end
536
- context "with all" do
508
+ context "with each" do
537
509
  before do
538
510
  stub_get("/1.1/followers/list.json").with(:query => {:cursor => "1419103567112105362", :screen_name => "sferik"}).to_return(:body => fixture("followers_list2.json"), :headers => {:content_type => "application/json; charset=utf-8"})
539
511
  end
540
512
  it "requests the correct resource" do
541
- @client.followers("sferik").all
513
+ @client.followers("sferik").each{}
542
514
  expect(a_get("/1.1/followers/list.json").with(:query => {:cursor => "-1", :screen_name => "sferik"})).to have_been_made
543
515
  expect(a_get("/1.1/followers/list.json").with(:query => {:cursor => "1419103567112105362", :screen_name => "sferik"})).to have_been_made
544
516
  end
@@ -552,12 +524,12 @@ describe Twitter::API::FriendsAndFollowers do
552
524
  @client.followers(7505382)
553
525
  expect(a_get("/1.1/followers/list.json").with(:query => {:cursor => "-1", :user_id => "7505382"})).to have_been_made
554
526
  end
555
- context "with all" do
527
+ context "with each" do
556
528
  before do
557
529
  stub_get("/1.1/followers/list.json").with(:query => {:cursor => "1419103567112105362", :user_id => "7505382"}).to_return(:body => fixture("followers_list2.json"), :headers => {:content_type => "application/json; charset=utf-8"})
558
530
  end
559
531
  it "requests the correct resource" do
560
- @client.followers(7505382).all
532
+ @client.followers(7505382).each{}
561
533
  expect(a_get("/1.1/followers/list.json").with(:query => {:cursor => "-1", :user_id => "7505382"})).to have_been_made
562
534
  expect(a_get("/1.1/followers/list.json").with(:query => {:cursor => "1419103567112105362", :user_id => "7505382"})).to have_been_made
563
535
  end
@@ -576,15 +548,14 @@ describe Twitter::API::FriendsAndFollowers do
576
548
  it "returns a cursor of followers with details for every user the specified user is followed by" do
577
549
  followers = @client.followers
578
550
  expect(followers).to be_a Twitter::Cursor
579
- expect(followers.users).to be_an Array
580
- expect(followers.users.first).to be_a Twitter::User
551
+ expect(followers.first).to be_a Twitter::User
581
552
  end
582
- context "with all" do
553
+ context "with each" do
583
554
  before do
584
555
  stub_get("/1.1/followers/list.json").with(:query => {:cursor => "1419103567112105362", :screen_name => "sferik"}).to_return(:body => fixture("followers_list2.json"), :headers => {:content_type => "application/json; charset=utf-8"})
585
556
  end
586
557
  it "requests the correct resource" do
587
- @client.followers.all
558
+ @client.followers.each{}
588
559
  expect(a_get("/1.1/account/verify_credentials.json")).to have_been_made
589
560
  expect(a_get("/1.1/followers/list.json").with(:query => {:cursor => "-1", :screen_name => "sferik"})).to have_been_made
590
561
  expect(a_get("/1.1/followers/list.json").with(:query => {:cursor => "1419103567112105362", :screen_name => "sferik"})).to have_been_made
@@ -605,15 +576,14 @@ describe Twitter::API::FriendsAndFollowers do
605
576
  it "returns a cursor of friends with details for every user the specified user is following" do
606
577
  friends = @client.friends("sferik")
607
578
  expect(friends).to be_a Twitter::Cursor
608
- expect(friends.users).to be_an Array
609
- expect(friends.users.first).to be_a Twitter::User
579
+ expect(friends.first).to be_a Twitter::User
610
580
  end
611
- context "with all" do
581
+ context "with each" do
612
582
  before do
613
583
  stub_get("/1.1/friends/list.json").with(:query => {:cursor => "1418947360875712729", :screen_name => "sferik"}).to_return(:body => fixture("friends_list2.json"), :headers => {:content_type => "application/json; charset=utf-8"})
614
584
  end
615
585
  it "requests the correct resource" do
616
- @client.friends("sferik").all
586
+ @client.friends("sferik").each{}
617
587
  expect(a_get("/1.1/friends/list.json").with(:query => {:cursor => "-1", :screen_name => "sferik"})).to have_been_made
618
588
  expect(a_get("/1.1/friends/list.json").with(:query => {:cursor => "1418947360875712729", :screen_name => "sferik"})).to have_been_made
619
589
  end
@@ -627,12 +597,12 @@ describe Twitter::API::FriendsAndFollowers do
627
597
  @client.friends(7505382)
628
598
  expect(a_get("/1.1/friends/list.json").with(:query => {:cursor => "-1", :user_id => "7505382"})).to have_been_made
629
599
  end
630
- context "with all" do
600
+ context "with each" do
631
601
  before do
632
602
  stub_get("/1.1/friends/list.json").with(:query => {:cursor => "1418947360875712729", :user_id => "7505382"}).to_return(:body => fixture("friends_list2.json"), :headers => {:content_type => "application/json; charset=utf-8"})
633
603
  end
634
604
  it "requests the correct resource" do
635
- @client.friends(7505382).all
605
+ @client.friends(7505382).each{}
636
606
  expect(a_get("/1.1/friends/list.json").with(:query => {:cursor => "-1", :user_id => "7505382"})).to have_been_made
637
607
  expect(a_get("/1.1/friends/list.json").with(:query => {:cursor => "1418947360875712729", :user_id => "7505382"})).to have_been_made
638
608
  end
@@ -651,15 +621,14 @@ describe Twitter::API::FriendsAndFollowers do
651
621
  it "returns a cursor of friends with details for every user the specified user is following" do
652
622
  friends = @client.friends
653
623
  expect(friends).to be_a Twitter::Cursor
654
- expect(friends.users).to be_an Array
655
- expect(friends.users.first).to be_a Twitter::User
624
+ expect(friends.first).to be_a Twitter::User
656
625
  end
657
- context "with all" do
626
+ context "with each" do
658
627
  before do
659
628
  stub_get("/1.1/friends/list.json").with(:query => {:cursor => "1418947360875712729", :screen_name => "sferik"}).to_return(:body => fixture("friends_list2.json"), :headers => {:content_type => "application/json; charset=utf-8"})
660
629
  end
661
630
  it "requests the correct resource" do
662
- @client.friends.all
631
+ @client.friends.each{}
663
632
  expect(a_get("/1.1/account/verify_credentials.json")).to have_been_made
664
633
  expect(a_get("/1.1/friends/list.json").with(:query => {:cursor => "-1", :screen_name => "sferik"})).to have_been_made
665
634
  expect(a_get("/1.1/friends/list.json").with(:query => {:cursor => "1418947360875712729", :screen_name => "sferik"})).to have_been_made
@@ -684,7 +653,7 @@ describe Twitter::API::FriendsAndFollowers do
684
653
  no_retweet_ids = @client.no_retweet_ids
685
654
  expect(no_retweet_ids).to be_an Array
686
655
  expect(no_retweet_ids.first).to be_an Integer
687
- expect(no_retweet_ids.first).to eq 47
656
+ expect(no_retweet_ids.first).to eq(47)
688
657
  end
689
658
  end
690
659
  end
@@ -1,9 +1,9 @@
1
1
  require 'helper'
2
2
 
3
- describe Twitter::API::PlacesAndGeo do
3
+ describe Twitter::REST::API::PlacesAndGeo 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 "#place" do
@@ -16,7 +16,7 @@ describe Twitter::API::PlacesAndGeo do
16
16
  end
17
17
  it "returns a place" do
18
18
  place = @client.place("247f43d441defc03")
19
- expect(place.name).to eq "Twitter HQ"
19
+ expect(place.name).to eq("Twitter HQ")
20
20
  end
21
21
  end
22
22
 
@@ -30,8 +30,8 @@ describe Twitter::API::PlacesAndGeo do
30
30
  end
31
31
  it "returns places" do
32
32
  places = @client.reverse_geocode(:lat => "37.7821120598956", :long => "-122.400612831116")
33
- expect(places).to be_an Array
34
- expect(places.first.name).to eq "Bernal Heights"
33
+ expect(places).to be_a Twitter::GeoResults
34
+ expect(places.first.name).to eq("Bernal Heights")
35
35
  end
36
36
  end
37
37
 
@@ -45,8 +45,8 @@ describe Twitter::API::PlacesAndGeo do
45
45
  end
46
46
  it "returns nearby places" do
47
47
  places = @client.geo_search(:ip => "74.125.19.104")
48
- expect(places).to be_an Array
49
- expect(places.first.name).to eq "Bernal Heights"
48
+ expect(places).to be_a Twitter::GeoResults
49
+ expect(places.first.name).to eq("Bernal Heights")
50
50
  end
51
51
  end
52
52
 
@@ -60,22 +60,8 @@ describe Twitter::API::PlacesAndGeo do
60
60
  end
61
61
  it "returns similar places" do
62
62
  places = @client.similar_places(:lat => "37.7821120598956", :long => "-122.400612831116", :name => "Twitter HQ")
63
- expect(places).to be_an Array
64
- expect(places.first.name).to eq "Bernal Heights"
65
- end
66
- end
67
-
68
- describe "#place_create" do
69
- before do
70
- stub_post("/1.1/geo/place.json").with(:body => {:name => "@sferik's Apartment", :token => "22ff5b1f7159032cf69218c4d8bb78bc", :contained_within => "41bcb736f84a799e", :lat => "37.783699", :long => "-122.393581"}).to_return(:body => fixture("place.json"), :headers => {:content_type => "application/json; charset=utf-8"})
71
- end
72
- it "requests the correct resource" do
73
- @client.place_create(:name => "@sferik's Apartment", :token => "22ff5b1f7159032cf69218c4d8bb78bc", :contained_within => "41bcb736f84a799e", :lat => "37.783699", :long => "-122.393581")
74
- expect(a_post("/1.1/geo/place.json").with(:body => {:name => "@sferik's Apartment", :token => "22ff5b1f7159032cf69218c4d8bb78bc", :contained_within => "41bcb736f84a799e", :lat => "37.783699", :long => "-122.393581"})).to have_been_made
75
- end
76
- it "returns a place" do
77
- place = @client.place_create(:name => "@sferik's Apartment", :token => "22ff5b1f7159032cf69218c4d8bb78bc", :contained_within => "41bcb736f84a799e", :lat => "37.783699", :long => "-122.393581")
78
- expect(place.name).to eq "Twitter HQ"
63
+ expect(places).to be_a Twitter::GeoResults
64
+ expect(places.first.name).to eq("Bernal Heights")
79
65
  end
80
66
  end
81
67
 
@@ -1,9 +1,9 @@
1
1
  require 'helper'
2
2
 
3
- describe Twitter::API::Help do
3
+ describe Twitter::REST::API::Help 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 "#configuration" do
@@ -17,7 +17,7 @@ describe Twitter::API::Help do
17
17
  it "returns Twitter's current configuration" do
18
18
  configuration = @client.configuration
19
19
  expect(configuration).to be_a Twitter::Configuration
20
- expect(configuration.characters_reserved_per_media).to eq 20
20
+ expect(configuration.characters_reserved_per_media).to eq(20)
21
21
  end
22
22
  end
23
23
 
@@ -33,7 +33,7 @@ describe Twitter::API::Help do
33
33
  languages = @client.languages
34
34
  expect(languages).to be_an Array
35
35
  expect(languages.first).to be_a Twitter::Language
36
- expect(languages.first.name).to eq "Portuguese"
36
+ expect(languages.first.name).to eq("Portuguese")
37
37
  end
38
38
  end
39
39
 
@@ -47,7 +47,7 @@ describe Twitter::API::Help do
47
47
  end
48
48
  it "returns Twitter's Privacy Policy" do
49
49
  privacy = @client.privacy
50
- expect(privacy.split.first).to eq "Twitter"
50
+ expect(privacy.split.first).to eq("Twitter")
51
51
  end
52
52
  end
53
53
 
@@ -61,7 +61,7 @@ describe Twitter::API::Help do
61
61
  end
62
62
  it "returns Twitter's Terms of Service" do
63
63
  tos = @client.tos
64
- expect(tos.split.first).to eq "Terms"
64
+ expect(tos.split.first).to eq("Terms")
65
65
  end
66
66
  end
67
67