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.
- data/CHANGELOG.md +36 -0
- data/CONTRIBUTING.md +13 -15
- data/LICENSE.md +1 -1
- data/README.md +401 -261
- data/Rakefile +6 -0
- data/lib/twitter/arguments.rb +14 -0
- data/lib/twitter/base.rb +109 -89
- data/lib/twitter/client.rb +38 -115
- data/lib/twitter/configuration.rb +5 -2
- data/lib/twitter/core_ext/kernel.rb +5 -1
- data/lib/twitter/creatable.rb +7 -4
- data/lib/twitter/cursor.rb +57 -45
- data/lib/twitter/direct_message.rb +2 -11
- data/lib/twitter/entity/uri.rb +14 -0
- data/lib/twitter/enumerable.rb +15 -0
- data/lib/twitter/error/already_favorited.rb +1 -1
- data/lib/twitter/error/already_posted.rb +10 -0
- data/lib/twitter/error/already_retweeted.rb +1 -1
- data/lib/twitter/error/bad_gateway.rb +2 -3
- data/lib/twitter/error/bad_request.rb +2 -2
- data/lib/twitter/error/forbidden.rb +2 -2
- data/lib/twitter/error/gateway_timeout.rb +2 -3
- data/lib/twitter/error/internal_server_error.rb +2 -3
- data/lib/twitter/error/not_acceptable.rb +2 -2
- data/lib/twitter/error/not_found.rb +2 -2
- data/lib/twitter/error/service_unavailable.rb +2 -3
- data/lib/twitter/error/too_many_requests.rb +2 -2
- data/lib/twitter/error/unauthorized.rb +2 -2
- data/lib/twitter/error/unprocessable_entity.rb +2 -2
- data/lib/twitter/error.rb +65 -14
- data/lib/twitter/factory.rb +13 -12
- data/lib/twitter/geo.rb +2 -7
- data/lib/twitter/geo_factory.rb +11 -7
- data/lib/twitter/geo_results.rb +40 -0
- data/lib/twitter/identity.rb +4 -34
- data/lib/twitter/list.rb +21 -4
- data/lib/twitter/media/photo.rb +6 -4
- data/lib/twitter/media_factory.rb +11 -7
- data/lib/twitter/null_object.rb +25 -0
- data/lib/twitter/oembed.rb +3 -2
- data/lib/twitter/place.rb +15 -15
- data/lib/twitter/profile_banner.rb +3 -2
- data/lib/twitter/rate_limit.rb +4 -17
- data/lib/twitter/relationship.rb +2 -19
- data/lib/twitter/rest/api/direct_messages.rb +138 -0
- data/lib/twitter/rest/api/favorites.rb +115 -0
- data/lib/twitter/rest/api/friends_and_followers.rb +287 -0
- data/lib/twitter/rest/api/help.rb +58 -0
- data/lib/twitter/rest/api/lists.rb +498 -0
- data/lib/twitter/rest/api/oauth.rb +62 -0
- data/lib/twitter/rest/api/places_and_geo.rb +86 -0
- data/lib/twitter/rest/api/saved_searches.rb +93 -0
- data/lib/twitter/rest/api/search.rb +37 -0
- data/lib/twitter/rest/api/spam_reporting.rb +29 -0
- data/lib/twitter/rest/api/suggested_users.rb +51 -0
- data/lib/twitter/rest/api/timelines.rb +202 -0
- data/lib/twitter/rest/api/trends.rb +58 -0
- data/lib/twitter/rest/api/tweets.rb +291 -0
- data/lib/twitter/rest/api/undocumented.rb +52 -0
- data/lib/twitter/rest/api/users.rb +383 -0
- data/lib/twitter/rest/api/utils.rb +246 -0
- data/lib/twitter/rest/client.rb +175 -0
- data/lib/twitter/rest/request/multipart_with_file.rb +36 -0
- data/lib/twitter/rest/response/parse_error_json.rb +15 -0
- data/lib/twitter/rest/response/parse_json.rb +31 -0
- data/lib/twitter/{response → rest/response}/raise_error.rb +8 -11
- data/lib/twitter/search_results.rb +37 -21
- data/lib/twitter/settings.rb +1 -6
- data/lib/twitter/size.rb +2 -15
- data/lib/twitter/streaming/client.rb +89 -0
- data/lib/twitter/streaming/connection.rb +22 -0
- data/lib/twitter/streaming/event.rb +35 -0
- data/lib/twitter/streaming/friend_list.rb +13 -0
- data/lib/twitter/streaming/message_parser.rb +18 -0
- data/lib/twitter/streaming/response.rb +34 -0
- data/lib/twitter/suggestion.rb +5 -8
- data/lib/twitter/token.rb +11 -1
- data/lib/twitter/trend.rb +4 -8
- data/lib/twitter/trend_results.rb +65 -0
- data/lib/twitter/tweet.rb +43 -92
- data/lib/twitter/user.rb +72 -47
- data/lib/twitter/version.rb +4 -4
- data/lib/twitter.rb +4 -39
- data/spec/fixtures/already_posted.json +1 -0
- data/spec/fixtures/ids_list.json +1 -1
- data/spec/fixtures/ids_list2.json +1 -1
- data/spec/fixtures/request_token.txt +6 -0
- data/spec/fixtures/search.json +1 -1
- data/spec/fixtures/search_malformed.json +1 -1
- data/spec/fixtures/track_streaming.json +3 -0
- data/spec/fixtures/track_streaming_user.json +5 -0
- data/spec/helper.rb +8 -13
- data/spec/twitter/base_spec.rb +13 -103
- data/spec/twitter/basic_user_spec.rb +3 -3
- data/spec/twitter/configuration_spec.rb +1 -1
- data/spec/twitter/cursor_spec.rb +17 -35
- data/spec/twitter/direct_message_spec.rb +44 -11
- data/spec/twitter/entity/uri_spec.rb +75 -0
- data/spec/twitter/error_spec.rb +59 -11
- data/spec/twitter/geo/point_spec.rb +6 -6
- data/spec/twitter/geo/polygon_spec.rb +5 -5
- data/spec/twitter/geo_factory_spec.rb +4 -4
- data/spec/twitter/geo_results_spec.rb +35 -0
- data/spec/twitter/geo_spec.rb +6 -6
- data/spec/twitter/identifiable_spec.rb +5 -26
- data/spec/twitter/list_spec.rb +54 -11
- data/spec/twitter/media/photo_spec.rb +122 -6
- data/spec/twitter/media_factory_spec.rb +3 -3
- data/spec/twitter/null_object_spec.rb +27 -0
- data/spec/twitter/oembed_spec.rb +69 -45
- data/spec/twitter/place_spec.rb +84 -28
- data/spec/twitter/profile_banner_spec.rb +1 -1
- data/spec/twitter/rate_limit_spec.rb +8 -25
- data/spec/twitter/relationship_spec.rb +26 -12
- data/spec/twitter/{api → rest/api}/direct_messages_spec.rb +28 -15
- data/spec/twitter/{api → rest/api}/favorites_spec.rb +80 -7
- data/spec/twitter/{api → rest/api}/friends_and_followers_spec.rb +121 -152
- data/spec/twitter/{api → rest/api}/geo_spec.rb +9 -23
- data/spec/twitter/{api → rest/api}/help_spec.rb +6 -6
- data/spec/twitter/{api → rest/api}/lists_spec.rb +116 -95
- data/spec/twitter/{api → rest/api}/oauth_spec.rb +21 -10
- data/spec/twitter/{api → rest/api}/saved_searches_spec.rb +13 -13
- data/spec/twitter/{api → rest/api}/search_spec.rb +8 -9
- data/spec/twitter/{api → rest/api}/spam_reporting_spec.rb +3 -3
- data/spec/twitter/{api → rest/api}/suggested_users_spec.rb +5 -5
- data/spec/twitter/{api → rest/api}/timelines_spec.rb +9 -9
- data/spec/twitter/{api → rest/api}/trends_spec.rb +6 -6
- data/spec/twitter/rest/api/tweets_spec.rb +503 -0
- data/spec/twitter/{api → rest/api}/undocumented_spec.rb +19 -45
- data/spec/twitter/{api → rest/api}/users_spec.rb +64 -39
- data/spec/twitter/rest/client_spec.rb +193 -0
- data/spec/twitter/saved_search_spec.rb +14 -3
- data/spec/twitter/search_results_spec.rb +32 -45
- data/spec/twitter/settings_spec.rb +17 -6
- data/spec/twitter/size_spec.rb +5 -15
- data/spec/twitter/source_user_spec.rb +3 -3
- data/spec/twitter/streaming/client_spec.rb +92 -0
- data/spec/twitter/streaming/event_spec.rb +45 -0
- data/spec/twitter/suggestion_spec.rb +5 -15
- data/spec/twitter/target_user_spec.rb +3 -3
- data/spec/twitter/token_spec.rb +16 -0
- data/spec/twitter/trend_results_spec.rb +89 -0
- data/spec/twitter/trend_spec.rb +26 -13
- data/spec/twitter/tweet_spec.rb +137 -124
- data/spec/twitter/user_spec.rb +139 -80
- data/spec/twitter_spec.rb +0 -119
- data/twitter.gemspec +12 -6
- data.tar.gz.sig +0 -0
- metadata +197 -138
- metadata.gz.sig +0 -0
- data/lib/twitter/action/favorite.rb +0 -19
- data/lib/twitter/action/follow.rb +0 -30
- data/lib/twitter/action/list_member_added.rb +0 -39
- data/lib/twitter/action/mention.rb +0 -46
- data/lib/twitter/action/reply.rb +0 -27
- data/lib/twitter/action/retweet.rb +0 -27
- data/lib/twitter/action/tweet.rb +0 -20
- data/lib/twitter/action_factory.rb +0 -22
- data/lib/twitter/api/arguments.rb +0 -13
- data/lib/twitter/api/direct_messages.rb +0 -148
- data/lib/twitter/api/favorites.rb +0 -126
- data/lib/twitter/api/friends_and_followers.rb +0 -334
- data/lib/twitter/api/help.rb +0 -64
- data/lib/twitter/api/lists.rb +0 -618
- data/lib/twitter/api/oauth.rb +0 -44
- data/lib/twitter/api/places_and_geo.rb +0 -121
- data/lib/twitter/api/saved_searches.rb +0 -99
- data/lib/twitter/api/search.rb +0 -37
- data/lib/twitter/api/spam_reporting.rb +0 -30
- data/lib/twitter/api/suggested_users.rb +0 -55
- data/lib/twitter/api/timelines.rb +0 -214
- data/lib/twitter/api/trends.rb +0 -63
- data/lib/twitter/api/tweets.rb +0 -304
- data/lib/twitter/api/undocumented.rb +0 -97
- data/lib/twitter/api/users.rb +0 -439
- data/lib/twitter/api/utils.rb +0 -187
- data/lib/twitter/configurable.rb +0 -96
- data/lib/twitter/default.rb +0 -102
- data/lib/twitter/entity/url.rb +0 -9
- data/lib/twitter/error/client_error.rb +0 -35
- data/lib/twitter/error/decode_error.rb +0 -9
- data/lib/twitter/error/identity_map_key_error.rb +0 -9
- data/lib/twitter/error/server_error.rb +0 -28
- data/lib/twitter/exceptable.rb +0 -36
- data/lib/twitter/identity_map.rb +0 -22
- data/lib/twitter/request/multipart_with_file.rb +0 -34
- data/lib/twitter/response/parse_json.rb +0 -25
- data/spec/fixtures/about_me.json +0 -1
- data/spec/fixtures/activity_summary.json +0 -1
- data/spec/fixtures/bad_gateway.json +0 -1
- data/spec/fixtures/bad_request.json +0 -1
- data/spec/fixtures/by_friends.json +0 -1
- data/spec/fixtures/end_session.json +0 -1
- data/spec/fixtures/forbidden.json +0 -1
- data/spec/fixtures/internal_server_error.json +0 -1
- data/spec/fixtures/not_acceptable.json +0 -1
- data/spec/fixtures/phoenix_search.phoenix +0 -1
- data/spec/fixtures/resolve.json +0 -1
- data/spec/fixtures/service_unavailable.json +0 -1
- data/spec/fixtures/totals.json +0 -1
- data/spec/fixtures/trends.json +0 -1
- data/spec/fixtures/unauthorized.json +0 -1
- data/spec/fixtures/video_facets.json +0 -1
- data/spec/twitter/action/favorite_spec.rb +0 -29
- data/spec/twitter/action/follow_spec.rb +0 -29
- data/spec/twitter/action/list_member_added_spec.rb +0 -41
- data/spec/twitter/action/mention_spec.rb +0 -52
- data/spec/twitter/action/reply_spec.rb +0 -41
- data/spec/twitter/action/retweet_spec.rb +0 -41
- data/spec/twitter/action_factory_spec.rb +0 -35
- data/spec/twitter/action_spec.rb +0 -16
- data/spec/twitter/api/tweets_spec.rb +0 -285
- data/spec/twitter/client_spec.rb +0 -223
- data/spec/twitter/error/client_error_spec.rb +0 -23
- 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.
|
|
22
|
-
expect(friend_ids.ids.first).to eq 14100886
|
|
21
|
+
expect(friend_ids.first).to eq(20009713)
|
|
23
22
|
end
|
|
24
|
-
context "with
|
|
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").
|
|
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
|
|
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).
|
|
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.
|
|
68
|
-
expect(friend_ids.ids.first).to eq 14100886
|
|
66
|
+
expect(friend_ids.first).to eq(20009713)
|
|
69
67
|
end
|
|
70
|
-
context "with
|
|
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.
|
|
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.
|
|
97
|
-
expect(follower_ids.ids.first).to eq 14100886
|
|
94
|
+
expect(follower_ids.first).to eq(20009713)
|
|
98
95
|
end
|
|
99
|
-
context "with
|
|
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").
|
|
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
|
|
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).
|
|
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.
|
|
143
|
-
expect(follower_ids.ids.first).to eq 14100886
|
|
139
|
+
expect(follower_ids.first).to eq(20009713)
|
|
144
140
|
end
|
|
145
|
-
context "with
|
|
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.
|
|
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
|
|
173
|
-
expect(friendships.first.connections).to eq
|
|
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
|
|
219
|
-
expect(friendships.first.connections).to eq
|
|
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.
|
|
263
|
-
expect(friendships_incoming.ids.first).to eq 14100886
|
|
258
|
+
expect(friendships_incoming.first).to eq(20009713)
|
|
264
259
|
end
|
|
265
|
-
context "with
|
|
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.
|
|
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.
|
|
288
|
-
expect(friendships_outgoing.ids.first).to eq 14100886
|
|
282
|
+
expect(friendships_outgoing.first).to eq(20009713)
|
|
289
283
|
end
|
|
290
|
-
context "with
|
|
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.
|
|
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
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
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
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
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
|
-
|
|
357
|
-
|
|
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
|
-
|
|
372
|
-
|
|
373
|
-
|
|
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
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
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.
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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.
|
|
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
|
|
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").
|
|
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
|
|
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).
|
|
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.
|
|
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
|
|
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.
|
|
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.
|
|
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
|
|
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").
|
|
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
|
|
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).
|
|
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.
|
|
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
|
|
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.
|
|
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
|
|
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
|
|
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
|
|
34
|
-
expect(places.first.name).to eq
|
|
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
|
|
49
|
-
expect(places.first.name).to eq
|
|
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
|
|
64
|
-
expect(places.first.name).to eq
|
|
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
|
+
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
|
|
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
|
|
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
|
|
64
|
+
expect(tos.split.first).to eq("Terms")
|
|
65
65
|
end
|
|
66
66
|
end
|
|
67
67
|
|