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
|
@@ -0,0 +1,503 @@
|
|
|
1
|
+
require 'helper'
|
|
2
|
+
|
|
3
|
+
describe Twitter::REST::API::Tweets do
|
|
4
|
+
|
|
5
|
+
before do
|
|
6
|
+
@client = Twitter::REST::Client.new(:consumer_key => "CK", :consumer_secret => "CS", :access_token => "AT", :access_token_secret => "AS")
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
describe "#retweets" do
|
|
10
|
+
before do
|
|
11
|
+
stub_get("/1.1/statuses/retweets/25938088801.json").to_return(:body => fixture("retweets.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
|
12
|
+
end
|
|
13
|
+
context "with a tweet ID passed" do
|
|
14
|
+
it "requests the correct resource" do
|
|
15
|
+
@client.retweets(25938088801)
|
|
16
|
+
expect(a_get("/1.1/statuses/retweets/25938088801.json")).to have_been_made
|
|
17
|
+
end
|
|
18
|
+
it "returns up to 100 of the first retweets of a given tweet" do
|
|
19
|
+
tweets = @client.retweets(25938088801)
|
|
20
|
+
expect(tweets).to be_an Array
|
|
21
|
+
expect(tweets.first).to be_a Twitter::Tweet
|
|
22
|
+
expect(tweets.first.text).to eq("RT @gruber: As for the Series, I'm for the Giants. Fuck Texas, fuck Nolan Ryan, fuck George Bush.")
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
context "with a URI object passed" do
|
|
26
|
+
it "requests the correct resource" do
|
|
27
|
+
tweet = URI.parse("https://twitter.com/sferik/status/25938088801")
|
|
28
|
+
@client.retweets(tweet)
|
|
29
|
+
expect(a_get("/1.1/statuses/retweets/25938088801.json")).to have_been_made
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
context "with a URI string passed" do
|
|
33
|
+
it "requests the correct resource" do
|
|
34
|
+
@client.retweets("https://twitter.com/sferik/status/25938088801")
|
|
35
|
+
expect(a_get("/1.1/statuses/retweets/25938088801.json")).to have_been_made
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
context "with a Tweet passed" do
|
|
39
|
+
it "requests the correct resource" do
|
|
40
|
+
tweet = Twitter::Tweet.new(:id => 25938088801)
|
|
41
|
+
@client.retweets(tweet)
|
|
42
|
+
expect(a_get("/1.1/statuses/retweets/25938088801.json")).to have_been_made
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
describe "#retweeters_of" do
|
|
48
|
+
context "with ids_only passed" do
|
|
49
|
+
context "with a tweet ID passed" do
|
|
50
|
+
before do
|
|
51
|
+
stub_get("/1.1/statuses/retweets/25938088801.json").to_return(:body => fixture("retweets.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
|
52
|
+
end
|
|
53
|
+
it "requests the correct resource" do
|
|
54
|
+
@client.retweeters_of(25938088801, :ids_only => true)
|
|
55
|
+
expect(a_get("/1.1/statuses/retweets/25938088801.json")).to have_been_made
|
|
56
|
+
end
|
|
57
|
+
it "returns an array of numeric user IDs of retweeters of a Tweet" do
|
|
58
|
+
ids = @client.retweeters_of(25938088801, :ids_only => true)
|
|
59
|
+
expect(ids).to be_an Array
|
|
60
|
+
expect(ids.first).to eq(7505382)
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
context "without ids_only passed" do
|
|
65
|
+
before do
|
|
66
|
+
stub_get("/1.1/statuses/retweets/25938088801.json").to_return(:body => fixture("retweets.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
|
67
|
+
end
|
|
68
|
+
it "requests the correct resource" do
|
|
69
|
+
@client.retweeters_of(25938088801)
|
|
70
|
+
expect(a_get("/1.1/statuses/retweets/25938088801.json")).to have_been_made
|
|
71
|
+
end
|
|
72
|
+
it "returns an array of user of retweeters of a Tweet" do
|
|
73
|
+
users = @client.retweeters_of(25938088801)
|
|
74
|
+
expect(users).to be_an Array
|
|
75
|
+
expect(users.first).to be_a Twitter::User
|
|
76
|
+
expect(users.first.id).to eq(7505382)
|
|
77
|
+
end
|
|
78
|
+
context "with a URI object passed" do
|
|
79
|
+
it "requests the correct resource" do
|
|
80
|
+
tweet = URI.parse("https://twitter.com/sferik/status/25938088801")
|
|
81
|
+
@client.retweeters_of(tweet)
|
|
82
|
+
expect(a_get("/1.1/statuses/retweets/25938088801.json")).to have_been_made
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
context "with a URI string passed" do
|
|
86
|
+
it "requests the correct resource" do
|
|
87
|
+
@client.retweeters_of("https://twitter.com/sferik/status/25938088801")
|
|
88
|
+
expect(a_get("/1.1/statuses/retweets/25938088801.json")).to have_been_made
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
context "with a Tweet passed" do
|
|
92
|
+
it "requests the correct resource" do
|
|
93
|
+
tweet = Twitter::Tweet.new(:id => 25938088801)
|
|
94
|
+
@client.retweeters_of(tweet)
|
|
95
|
+
expect(a_get("/1.1/statuses/retweets/25938088801.json")).to have_been_made
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
describe "#status" do
|
|
102
|
+
before do
|
|
103
|
+
stub_get("/1.1/statuses/show/25938088801.json").to_return(:body => fixture("status.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
|
104
|
+
end
|
|
105
|
+
it "requests the correct resource" do
|
|
106
|
+
@client.status(25938088801)
|
|
107
|
+
expect(a_get("/1.1/statuses/show/25938088801.json")).to have_been_made
|
|
108
|
+
end
|
|
109
|
+
it "returns a Tweet" do
|
|
110
|
+
tweet = @client.status(25938088801)
|
|
111
|
+
expect(tweet).to be_a Twitter::Tweet
|
|
112
|
+
expect(tweet.text).to eq("The problem with your code is that it's doing exactly what you told it to do.")
|
|
113
|
+
end
|
|
114
|
+
context "with a URI object passed" do
|
|
115
|
+
it "requests the correct resource" do
|
|
116
|
+
tweet = URI.parse("https://twitter.com/sferik/status/25938088801")
|
|
117
|
+
@client.status(tweet)
|
|
118
|
+
expect(a_get("/1.1/statuses/show/25938088801.json")).to have_been_made
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
context "with a URI string passed" do
|
|
122
|
+
it "requests the correct resource" do
|
|
123
|
+
@client.status("https://twitter.com/sferik/status/25938088801")
|
|
124
|
+
expect(a_get("/1.1/statuses/show/25938088801.json")).to have_been_made
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
context "with a Tweet passed" do
|
|
128
|
+
it "requests the correct resource" do
|
|
129
|
+
tweet = Twitter::Tweet.new(:id => 25938088801)
|
|
130
|
+
@client.status(tweet)
|
|
131
|
+
expect(a_get("/1.1/statuses/show/25938088801.json")).to have_been_made
|
|
132
|
+
end
|
|
133
|
+
end
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
describe "#statuses" do
|
|
137
|
+
before do
|
|
138
|
+
stub_get("/1.1/statuses/show/25938088801.json").to_return(:body => fixture("status.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
|
139
|
+
end
|
|
140
|
+
it "requests the correct resource" do
|
|
141
|
+
@client.statuses(25938088801)
|
|
142
|
+
expect(a_get("/1.1/statuses/show/25938088801.json")).to have_been_made
|
|
143
|
+
end
|
|
144
|
+
it "returns an array of Tweets" do
|
|
145
|
+
tweets = @client.statuses(25938088801)
|
|
146
|
+
expect(tweets).to be_an Array
|
|
147
|
+
expect(tweets.first).to be_a Twitter::Tweet
|
|
148
|
+
expect(tweets.first.text).to eq("The problem with your code is that it's doing exactly what you told it to do.")
|
|
149
|
+
end
|
|
150
|
+
context "with a URI object passed" do
|
|
151
|
+
it "requests the correct resource" do
|
|
152
|
+
tweet = URI.parse("https://twitter.com/sferik/status/25938088801")
|
|
153
|
+
@client.statuses(tweet)
|
|
154
|
+
expect(a_get("/1.1/statuses/show/25938088801.json")).to have_been_made
|
|
155
|
+
end
|
|
156
|
+
end
|
|
157
|
+
context "with a URI string passed" do
|
|
158
|
+
it "requests the correct resource" do
|
|
159
|
+
@client.statuses("https://twitter.com/sferik/status/25938088801")
|
|
160
|
+
expect(a_get("/1.1/statuses/show/25938088801.json")).to have_been_made
|
|
161
|
+
end
|
|
162
|
+
end
|
|
163
|
+
context "with a Tweet passed" do
|
|
164
|
+
it "requests the correct resource" do
|
|
165
|
+
tweet = Twitter::Tweet.new(:id => 25938088801)
|
|
166
|
+
@client.statuses(tweet)
|
|
167
|
+
expect(a_get("/1.1/statuses/show/25938088801.json")).to have_been_made
|
|
168
|
+
end
|
|
169
|
+
end
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
describe "#destroy_status" do
|
|
173
|
+
before do
|
|
174
|
+
stub_post("/1.1/statuses/destroy/25938088801.json").to_return(:body => fixture("status.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
|
175
|
+
end
|
|
176
|
+
it "requests the correct resource" do
|
|
177
|
+
@client.destroy_status(25938088801)
|
|
178
|
+
expect(a_post("/1.1/statuses/destroy/25938088801.json")).to have_been_made
|
|
179
|
+
end
|
|
180
|
+
it "returns an array of Tweets" do
|
|
181
|
+
tweets = @client.destroy_status(25938088801)
|
|
182
|
+
expect(tweets).to be_an Array
|
|
183
|
+
expect(tweets.first).to be_a Twitter::Tweet
|
|
184
|
+
expect(tweets.first.text).to eq("The problem with your code is that it's doing exactly what you told it to do.")
|
|
185
|
+
end
|
|
186
|
+
context "with a URI object passed" do
|
|
187
|
+
it "requests the correct resource" do
|
|
188
|
+
tweet = URI.parse("https://twitter.com/sferik/status/25938088801")
|
|
189
|
+
@client.destroy_status(tweet)
|
|
190
|
+
expect(a_post("/1.1/statuses/destroy/25938088801.json")).to have_been_made
|
|
191
|
+
end
|
|
192
|
+
end
|
|
193
|
+
context "with a URI string passed" do
|
|
194
|
+
it "requests the correct resource" do
|
|
195
|
+
@client.destroy_status("https://twitter.com/sferik/status/25938088801")
|
|
196
|
+
expect(a_post("/1.1/statuses/destroy/25938088801.json")).to have_been_made
|
|
197
|
+
end
|
|
198
|
+
end
|
|
199
|
+
context "with a Tweet passed" do
|
|
200
|
+
it "requests the correct resource" do
|
|
201
|
+
tweet = Twitter::Tweet.new(:id => 25938088801)
|
|
202
|
+
@client.destroy_status(tweet)
|
|
203
|
+
expect(a_post("/1.1/statuses/destroy/25938088801.json")).to have_been_made
|
|
204
|
+
end
|
|
205
|
+
end
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
describe "#update" do
|
|
209
|
+
before do
|
|
210
|
+
stub_post("/1.1/statuses/update.json").with(:body => {:status => "The problem with your code is that it's doing exactly what you told it to do."}).to_return(:body => fixture("status.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
|
211
|
+
end
|
|
212
|
+
it "requests the correct resource" do
|
|
213
|
+
@client.update("The problem with your code is that it's doing exactly what you told it to do.")
|
|
214
|
+
expect(a_post("/1.1/statuses/update.json").with(:body => {:status => "The problem with your code is that it's doing exactly what you told it to do."})).to have_been_made
|
|
215
|
+
end
|
|
216
|
+
it "returns a Tweet" do
|
|
217
|
+
tweet = @client.update("The problem with your code is that it's doing exactly what you told it to do.")
|
|
218
|
+
expect(tweet).to be_a Twitter::Tweet
|
|
219
|
+
expect(tweet.text).to eq("The problem with your code is that it's doing exactly what you told it to do.")
|
|
220
|
+
end
|
|
221
|
+
context "already posted" do
|
|
222
|
+
before do
|
|
223
|
+
stub_post("/1.1/statuses/update.json").to_return(:status => 403, :body => fixture("already_posted.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
|
224
|
+
end
|
|
225
|
+
it "raises an AlreadyPosted error" do
|
|
226
|
+
expect{@client.update("The problem with your code is that it's doing exactly what you told it to do.")}.to raise_error Twitter::Error::AlreadyPosted
|
|
227
|
+
end
|
|
228
|
+
end
|
|
229
|
+
end
|
|
230
|
+
|
|
231
|
+
describe "#retweet" do
|
|
232
|
+
before do
|
|
233
|
+
stub_post("/1.1/statuses/retweet/25938088801.json").to_return(:body => fixture("retweet.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
|
234
|
+
end
|
|
235
|
+
it "requests the correct resource" do
|
|
236
|
+
@client.retweet(25938088801)
|
|
237
|
+
expect(a_post("/1.1/statuses/retweet/25938088801.json")).to have_been_made
|
|
238
|
+
end
|
|
239
|
+
it "returns an array of Tweets with retweet details embedded" do
|
|
240
|
+
tweets = @client.retweet(25938088801)
|
|
241
|
+
expect(tweets).to be_an Array
|
|
242
|
+
expect(tweets.first).to be_a Twitter::Tweet
|
|
243
|
+
expect(tweets.first.text).to eq("As for the Series, I'm for the Giants. Fuck Texas, fuck Nolan Ryan, fuck George Bush.")
|
|
244
|
+
expect(tweets.first.retweeted_tweet.text).to eq("RT @gruber: As for the Series, I'm for the Giants. Fuck Texas, fuck Nolan Ryan, fuck George Bush.")
|
|
245
|
+
expect(tweets.first.retweeted_tweet.id).not_to eq(tweets.first.id)
|
|
246
|
+
end
|
|
247
|
+
context "already retweeted" do
|
|
248
|
+
before do
|
|
249
|
+
stub_post("/1.1/statuses/retweet/25938088801.json").to_return(:status => 403, :body => fixture("already_retweeted.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
|
250
|
+
end
|
|
251
|
+
it "does not raise an error" do
|
|
252
|
+
expect{@client.retweet(25938088801)}.not_to raise_error
|
|
253
|
+
end
|
|
254
|
+
end
|
|
255
|
+
context "with a URI object passed" do
|
|
256
|
+
it "requests the correct resource" do
|
|
257
|
+
tweet = URI.parse("https://twitter.com/sferik/status/25938088801")
|
|
258
|
+
@client.retweet(tweet)
|
|
259
|
+
expect(a_post("/1.1/statuses/retweet/25938088801.json")).to have_been_made
|
|
260
|
+
end
|
|
261
|
+
end
|
|
262
|
+
context "with a URI string passed" do
|
|
263
|
+
it "requests the correct resource" do
|
|
264
|
+
@client.retweet("https://twitter.com/sferik/status/25938088801")
|
|
265
|
+
expect(a_post("/1.1/statuses/retweet/25938088801.json")).to have_been_made
|
|
266
|
+
end
|
|
267
|
+
end
|
|
268
|
+
context "with a Tweet passed" do
|
|
269
|
+
it "requests the correct resource" do
|
|
270
|
+
tweet = Twitter::Tweet.new(:id => 25938088801)
|
|
271
|
+
@client.retweet(tweet)
|
|
272
|
+
expect(a_post("/1.1/statuses/retweet/25938088801.json")).to have_been_made
|
|
273
|
+
end
|
|
274
|
+
end
|
|
275
|
+
end
|
|
276
|
+
|
|
277
|
+
describe "#retweet!" do
|
|
278
|
+
before do
|
|
279
|
+
stub_post("/1.1/statuses/retweet/25938088801.json").to_return(:body => fixture("retweet.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
|
280
|
+
end
|
|
281
|
+
it "requests the correct resource" do
|
|
282
|
+
@client.retweet!(25938088801)
|
|
283
|
+
expect(a_post("/1.1/statuses/retweet/25938088801.json")).to have_been_made
|
|
284
|
+
end
|
|
285
|
+
it "returns an array of Tweets with retweet details embedded" do
|
|
286
|
+
tweets = @client.retweet!(25938088801)
|
|
287
|
+
expect(tweets).to be_an Array
|
|
288
|
+
expect(tweets.first).to be_a Twitter::Tweet
|
|
289
|
+
expect(tweets.first.text).to eq("As for the Series, I'm for the Giants. Fuck Texas, fuck Nolan Ryan, fuck George Bush.")
|
|
290
|
+
expect(tweets.first.retweeted_tweet.text).to eq("RT @gruber: As for the Series, I'm for the Giants. Fuck Texas, fuck Nolan Ryan, fuck George Bush.")
|
|
291
|
+
expect(tweets.first.retweeted_tweet.id).not_to eq(tweets.first.id)
|
|
292
|
+
end
|
|
293
|
+
context "forbidden" do
|
|
294
|
+
before do
|
|
295
|
+
stub_post("/1.1/statuses/retweet/25938088801.json").to_return(:status => 403, :headers => {:content_type => "application/json; charset=utf-8"})
|
|
296
|
+
end
|
|
297
|
+
it "raises a Forbidden error" do
|
|
298
|
+
expect{@client.retweet!(25938088801)}.to raise_error Twitter::Error::Forbidden
|
|
299
|
+
end
|
|
300
|
+
end
|
|
301
|
+
context "already retweeted" do
|
|
302
|
+
before do
|
|
303
|
+
stub_post("/1.1/statuses/retweet/25938088801.json").to_return(:status => 403, :body => fixture("already_retweeted.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
|
304
|
+
end
|
|
305
|
+
it "raises an AlreadyRetweeted error" do
|
|
306
|
+
expect{@client.retweet!(25938088801)}.to raise_error Twitter::Error::AlreadyRetweeted
|
|
307
|
+
end
|
|
308
|
+
end
|
|
309
|
+
context "with a URI object passed" do
|
|
310
|
+
it "requests the correct resource" do
|
|
311
|
+
tweet = URI.parse("https://twitter.com/sferik/status/25938088801")
|
|
312
|
+
@client.retweet!(tweet)
|
|
313
|
+
expect(a_post("/1.1/statuses/retweet/25938088801.json")).to have_been_made
|
|
314
|
+
end
|
|
315
|
+
end
|
|
316
|
+
context "with a URI string passed" do
|
|
317
|
+
it "requests the correct resource" do
|
|
318
|
+
@client.retweet!("https://twitter.com/sferik/status/25938088801")
|
|
319
|
+
expect(a_post("/1.1/statuses/retweet/25938088801.json")).to have_been_made
|
|
320
|
+
end
|
|
321
|
+
end
|
|
322
|
+
context "with a Tweet passed" do
|
|
323
|
+
it "requests the correct resource" do
|
|
324
|
+
tweet = Twitter::Tweet.new(:id => 25938088801)
|
|
325
|
+
@client.retweet!(tweet)
|
|
326
|
+
expect(a_post("/1.1/statuses/retweet/25938088801.json")).to have_been_made
|
|
327
|
+
end
|
|
328
|
+
end
|
|
329
|
+
end
|
|
330
|
+
|
|
331
|
+
describe "#update_with_media" do
|
|
332
|
+
before do
|
|
333
|
+
stub_post("/1.1/statuses/update_with_media.json").to_return(:body => fixture("status.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
|
334
|
+
end
|
|
335
|
+
context "a gif image" do
|
|
336
|
+
it "requests the correct resource" do
|
|
337
|
+
@client.update_with_media("The problem with your code is that it's doing exactly what you told it to do.", fixture("pbjt.gif"))
|
|
338
|
+
expect(a_post("/1.1/statuses/update_with_media.json")).to have_been_made
|
|
339
|
+
end
|
|
340
|
+
it "returns a Tweet" do
|
|
341
|
+
tweet = @client.update_with_media("The problem with your code is that it's doing exactly what you told it to do.", fixture("pbjt.gif"))
|
|
342
|
+
expect(tweet).to be_a Twitter::Tweet
|
|
343
|
+
expect(tweet.text).to eq("The problem with your code is that it's doing exactly what you told it to do.")
|
|
344
|
+
end
|
|
345
|
+
end
|
|
346
|
+
context "a jpe image" do
|
|
347
|
+
it "requests the correct resource" do
|
|
348
|
+
@client.update_with_media("You always have options", fixture("wildcomet2.jpe"))
|
|
349
|
+
expect(a_post("/1.1/statuses/update_with_media.json")).to have_been_made
|
|
350
|
+
end
|
|
351
|
+
end
|
|
352
|
+
context "a jpeg image" do
|
|
353
|
+
it "requests the correct resource" do
|
|
354
|
+
@client.update_with_media("You always have options", fixture("me.jpeg"))
|
|
355
|
+
expect(a_post("/1.1/statuses/update_with_media.json")).to have_been_made
|
|
356
|
+
end
|
|
357
|
+
end
|
|
358
|
+
context "a png image" do
|
|
359
|
+
it "requests the correct resource" do
|
|
360
|
+
@client.update_with_media("You always have options", fixture("we_concept_bg2.png"))
|
|
361
|
+
expect(a_post("/1.1/statuses/update_with_media.json")).to have_been_made
|
|
362
|
+
end
|
|
363
|
+
end
|
|
364
|
+
context "a Tempfile" do
|
|
365
|
+
it "requests the correct resource" do
|
|
366
|
+
@client.update_with_media("You always have options", Tempfile.new("tmp"))
|
|
367
|
+
expect(a_post("/1.1/statuses/update_with_media.json")).to have_been_made
|
|
368
|
+
end
|
|
369
|
+
end
|
|
370
|
+
context "already posted" do
|
|
371
|
+
before do
|
|
372
|
+
stub_post("/1.1/statuses/update_with_media.json").to_return(:status => 403, :body => fixture("already_posted.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
|
373
|
+
end
|
|
374
|
+
it "raises an AlreadyPosted error" do
|
|
375
|
+
expect{@client.update_with_media("The problem with your code is that it's doing exactly what you told it to do.", fixture("pbjt.gif"))}.to raise_error Twitter::Error::AlreadyPosted
|
|
376
|
+
end
|
|
377
|
+
end
|
|
378
|
+
end
|
|
379
|
+
|
|
380
|
+
describe "#oembed" do
|
|
381
|
+
before do
|
|
382
|
+
stub_get("/1.1/statuses/oembed.json").with(:query => {:id => "25938088801"}).to_return(:body => fixture("oembed.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
|
383
|
+
stub_get("/1.1/statuses/oembed.json").with(:query => {:url => "https://twitter.com/sferik/status/25938088801"}).to_return(:body => fixture("oembed.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
|
384
|
+
end
|
|
385
|
+
it "requests the correct resource" do
|
|
386
|
+
@client.oembed(25938088801)
|
|
387
|
+
expect(a_get("/1.1/statuses/oembed.json").with(:query => {:id => "25938088801"})).to have_been_made
|
|
388
|
+
end
|
|
389
|
+
it "requests the correct resource when a URL is given" do
|
|
390
|
+
@client.oembed("https://twitter.com/sferik/status/25938088801")
|
|
391
|
+
expect(a_get("/1.1/statuses/oembed.json").with(:query => {:url => "https://twitter.com/sferik/status/25938088801"}))
|
|
392
|
+
end
|
|
393
|
+
it "returns an array of OEmbed instances" do
|
|
394
|
+
oembed = @client.oembed(25938088801)
|
|
395
|
+
expect(oembed).to be_a Twitter::OEmbed
|
|
396
|
+
end
|
|
397
|
+
context "with a URI object passed" do
|
|
398
|
+
it "requests the correct resource" do
|
|
399
|
+
tweet = URI.parse("https://twitter.com/sferik/status/25938088801")
|
|
400
|
+
@client.oembed(tweet)
|
|
401
|
+
expect(a_get("/1.1/statuses/oembed.json").with(:query => {:id => "25938088801"})).to have_been_made
|
|
402
|
+
end
|
|
403
|
+
end
|
|
404
|
+
context "with a URI string passed" do
|
|
405
|
+
it "requests the correct resource" do
|
|
406
|
+
@client.oembed("https://twitter.com/sferik/status/25938088801")
|
|
407
|
+
expect(a_get("/1.1/statuses/oembed.json").with(:query => {:id => "25938088801"})).to have_been_made
|
|
408
|
+
end
|
|
409
|
+
end
|
|
410
|
+
context "with a Tweet passed" do
|
|
411
|
+
it "requests the correct resource" do
|
|
412
|
+
tweet = Twitter::Tweet.new(:id => 25938088801)
|
|
413
|
+
@client.oembed(tweet)
|
|
414
|
+
expect(a_get("/1.1/statuses/oembed.json").with(:query => {:id => "25938088801"})).to have_been_made
|
|
415
|
+
end
|
|
416
|
+
end
|
|
417
|
+
end
|
|
418
|
+
|
|
419
|
+
describe "#oembeds" do
|
|
420
|
+
before do
|
|
421
|
+
stub_get("/1.1/statuses/oembed.json").with(:query => {:id => "25938088801"}).to_return(:body => fixture("oembed.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
|
422
|
+
end
|
|
423
|
+
it "requests the correct resource" do
|
|
424
|
+
@client.oembeds(25938088801)
|
|
425
|
+
expect(a_get("/1.1/statuses/oembed.json").with(:query => {:id => "25938088801"})).to have_been_made
|
|
426
|
+
end
|
|
427
|
+
it "requests the correct resource when a URL is given" do
|
|
428
|
+
@client.oembeds("https://twitter.com/sferik/status/25938088801")
|
|
429
|
+
expect(a_get("/1.1/statuses/oembed.json").with(:query => {:id => "25938088801"})).to have_been_made
|
|
430
|
+
end
|
|
431
|
+
it "returns an array of OEmbed instances" do
|
|
432
|
+
oembeds = @client.oembeds(25938088801)
|
|
433
|
+
expect(oembeds).to be_an Array
|
|
434
|
+
expect(oembeds.first).to be_a Twitter::OEmbed
|
|
435
|
+
end
|
|
436
|
+
context "with a URI object passed" do
|
|
437
|
+
it "requests the correct resource" do
|
|
438
|
+
tweet = URI.parse("https://twitter.com/sferik/status/25938088801")
|
|
439
|
+
@client.oembeds(tweet)
|
|
440
|
+
expect(a_get("/1.1/statuses/oembed.json").with(:query => {:id => "25938088801"})).to have_been_made
|
|
441
|
+
end
|
|
442
|
+
end
|
|
443
|
+
context "with a URI string passed" do
|
|
444
|
+
it "requests the correct resource" do
|
|
445
|
+
@client.oembeds("https://twitter.com/sferik/status/25938088801")
|
|
446
|
+
expect(a_get("/1.1/statuses/oembed.json").with(:query => {:id => "25938088801"})).to have_been_made
|
|
447
|
+
end
|
|
448
|
+
end
|
|
449
|
+
context "with a Tweet passed" do
|
|
450
|
+
it "requests the correct resource" do
|
|
451
|
+
tweet = Twitter::Tweet.new(:id => 25938088801)
|
|
452
|
+
@client.oembeds(tweet)
|
|
453
|
+
expect(a_get("/1.1/statuses/oembed.json").with(:query => {:id => "25938088801"})).to have_been_made
|
|
454
|
+
end
|
|
455
|
+
end
|
|
456
|
+
end
|
|
457
|
+
|
|
458
|
+
describe "#retweeters_ids" do
|
|
459
|
+
before do
|
|
460
|
+
stub_get("/1.1/statuses/retweeters/ids.json").with(:query => {:id => "25938088801", :cursor => "-1"}).to_return(:body => fixture("ids_list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
|
461
|
+
end
|
|
462
|
+
it "requests the correct resource" do
|
|
463
|
+
@client.retweeters_ids(25938088801)
|
|
464
|
+
expect(a_get("/1.1/statuses/retweeters/ids.json").with(:query => {:id => "25938088801", :cursor => "-1"})).to have_been_made
|
|
465
|
+
end
|
|
466
|
+
it "returns a collection of up to 100 user IDs belonging to users who have retweeted the tweet specified by the id parameter" do
|
|
467
|
+
retweeters_ids = @client.retweeters_ids(25938088801)
|
|
468
|
+
expect(retweeters_ids).to be_a Twitter::Cursor
|
|
469
|
+
expect(retweeters_ids.first).to eq(20009713)
|
|
470
|
+
end
|
|
471
|
+
context "with each" do
|
|
472
|
+
before do
|
|
473
|
+
stub_get("/1.1/statuses/retweeters/ids.json").with(:query => {:id => "25938088801", :cursor => "1305102810874389703"}).to_return(:body => fixture("ids_list2.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
|
474
|
+
end
|
|
475
|
+
it "requests the correct resource" do
|
|
476
|
+
@client.retweeters_ids(25938088801).each{}
|
|
477
|
+
expect(a_get("/1.1/statuses/retweeters/ids.json").with(:query => {:id => "25938088801", :cursor => "-1"})).to have_been_made
|
|
478
|
+
expect(a_get("/1.1/statuses/retweeters/ids.json").with(:query => {:id => "25938088801", :cursor => "1305102810874389703"})).to have_been_made
|
|
479
|
+
end
|
|
480
|
+
end
|
|
481
|
+
context "with a URI object passed" do
|
|
482
|
+
it "requests the correct resource" do
|
|
483
|
+
tweet = URI.parse("https://twitter.com/sferik/status/25938088801")
|
|
484
|
+
@client.retweeters_ids(tweet)
|
|
485
|
+
expect(a_get("/1.1/statuses/retweeters/ids.json").with(:query => {:id => "25938088801", :cursor => "-1"})).to have_been_made
|
|
486
|
+
end
|
|
487
|
+
end
|
|
488
|
+
context "with a URI string passed" do
|
|
489
|
+
it "requests the correct resource" do
|
|
490
|
+
@client.retweeters_ids("https://twitter.com/sferik/status/25938088801")
|
|
491
|
+
expect(a_get("/1.1/statuses/retweeters/ids.json").with(:query => {:id => "25938088801", :cursor => "-1"})).to have_been_made
|
|
492
|
+
end
|
|
493
|
+
end
|
|
494
|
+
context "with a Tweet passed" do
|
|
495
|
+
it "requests the correct resource" do
|
|
496
|
+
tweet = Twitter::Tweet.new(:id => 25938088801)
|
|
497
|
+
@client.retweeters_ids(tweet)
|
|
498
|
+
expect(a_get("/1.1/statuses/retweeters/ids.json").with(:query => {:id => "25938088801", :cursor => "-1"})).to have_been_made
|
|
499
|
+
end
|
|
500
|
+
end
|
|
501
|
+
end
|
|
502
|
+
|
|
503
|
+
end
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
require 'helper'
|
|
2
2
|
|
|
3
|
-
describe Twitter::API::Undocumented do
|
|
3
|
+
describe Twitter::REST::API::Undocumented 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 "#following_followers_of" do
|
|
@@ -18,15 +18,14 @@ describe Twitter::API::Undocumented do
|
|
|
18
18
|
it "returns an array of numeric IDs for every user following the specified user" do
|
|
19
19
|
following_followers_of = @client.following_followers_of("sferik")
|
|
20
20
|
expect(following_followers_of).to be_a Twitter::Cursor
|
|
21
|
-
expect(following_followers_of.
|
|
22
|
-
expect(following_followers_of.users.first).to be_a Twitter::User
|
|
21
|
+
expect(following_followers_of.first).to be_a Twitter::User
|
|
23
22
|
end
|
|
24
|
-
context "with
|
|
23
|
+
context "with each" do
|
|
25
24
|
before do
|
|
26
25
|
stub_get("/users/following_followers_of.json").with(:query => {:cursor => "1322801608223717003", :screen_name => "sferik"}).to_return(:body => fixture("users_list2.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
|
27
26
|
end
|
|
28
27
|
it "requests the correct resource" do
|
|
29
|
-
@client.following_followers_of("sferik").
|
|
28
|
+
@client.following_followers_of("sferik").each{}
|
|
30
29
|
expect(a_get("/users/following_followers_of.json").with(:query => {:cursor => "-1", :screen_name => "sferik"})).to have_been_made
|
|
31
30
|
expect(a_get("/users/following_followers_of.json").with(:query => {:cursor => "1322801608223717003", :screen_name => "sferik"})).to have_been_made
|
|
32
31
|
end
|
|
@@ -40,12 +39,12 @@ describe Twitter::API::Undocumented do
|
|
|
40
39
|
@client.following_followers_of(7505382)
|
|
41
40
|
expect(a_get("/users/following_followers_of.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("/users/following_followers_of.json").with(:query => {:cursor => "1322801608223717003", :user_id => "7505382"}).to_return(:body => fixture("users_list2.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
|
46
45
|
end
|
|
47
46
|
it "requests the correct resource" do
|
|
48
|
-
@client.following_followers_of(7505382).
|
|
47
|
+
@client.following_followers_of(7505382).each{}
|
|
49
48
|
expect(a_get("/users/following_followers_of.json").with(:query => {:cursor => "-1", :user_id => "7505382"})).to have_been_made
|
|
50
49
|
expect(a_get("/users/following_followers_of.json").with(:query => {:cursor => "1322801608223717003", :user_id => "7505382"})).to have_been_made
|
|
51
50
|
end
|
|
@@ -64,15 +63,14 @@ describe Twitter::API::Undocumented do
|
|
|
64
63
|
it "returns an array of numeric IDs for every user following the specified user" do
|
|
65
64
|
following_followers_of = @client.following_followers_of
|
|
66
65
|
expect(following_followers_of).to be_a Twitter::Cursor
|
|
67
|
-
expect(following_followers_of.
|
|
68
|
-
expect(following_followers_of.users.first).to be_a Twitter::User
|
|
66
|
+
expect(following_followers_of.first).to be_a Twitter::User
|
|
69
67
|
end
|
|
70
|
-
context "with
|
|
68
|
+
context "with each" do
|
|
71
69
|
before do
|
|
72
70
|
stub_get("/users/following_followers_of.json").with(:query => {:cursor => "1322801608223717003", :screen_name => "sferik"}).to_return(:body => fixture("users_list2.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
|
73
71
|
end
|
|
74
72
|
it "requests the correct resource" do
|
|
75
|
-
@client.following_followers_of.
|
|
73
|
+
@client.following_followers_of.each{}
|
|
76
74
|
expect(a_get("/users/following_followers_of.json").with(:query => {:cursor => "-1", :screen_name => "sferik"})).to have_been_made
|
|
77
75
|
expect(a_get("/users/following_followers_of.json").with(:query => {:cursor => "1322801608223717003", :screen_name => "sferik"})).to have_been_made
|
|
78
76
|
end
|
|
@@ -80,38 +78,7 @@ describe Twitter::API::Undocumented do
|
|
|
80
78
|
end
|
|
81
79
|
end
|
|
82
80
|
|
|
83
|
-
describe "#
|
|
84
|
-
before do
|
|
85
|
-
stub_get("/i/statuses/25938088801/activity/summary.json").to_return(:body => fixture("activity_summary.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
|
86
|
-
end
|
|
87
|
-
it "requests the correct resource" do
|
|
88
|
-
@client.status_activity(25938088801)
|
|
89
|
-
expect(a_get("/i/statuses/25938088801/activity/summary.json")).to have_been_made
|
|
90
|
-
end
|
|
91
|
-
it "returns a Tweet" do
|
|
92
|
-
tweet = @client.status_activity(25938088801)
|
|
93
|
-
expect(tweet).to be_a Twitter::Tweet
|
|
94
|
-
expect(tweet.retweeters_count).to eq 1
|
|
95
|
-
end
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
describe "#statuses_activity" do
|
|
99
|
-
before do
|
|
100
|
-
stub_get("/i/statuses/25938088801/activity/summary.json").to_return(:body => fixture("activity_summary.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
|
101
|
-
end
|
|
102
|
-
it "requests the correct resource" do
|
|
103
|
-
@client.statuses_activity(25938088801)
|
|
104
|
-
expect(a_get("/i/statuses/25938088801/activity/summary.json")).to have_been_made
|
|
105
|
-
end
|
|
106
|
-
it "returns an array of Tweets" do
|
|
107
|
-
tweets = @client.statuses_activity(25938088801)
|
|
108
|
-
expect(tweets).to be_an Array
|
|
109
|
-
expect(tweets.first).to be_a Twitter::Tweet
|
|
110
|
-
expect(tweets.first.retweeters_count).to eq 1
|
|
111
|
-
end
|
|
112
|
-
end
|
|
113
|
-
|
|
114
|
-
describe "#statuses_activity" do
|
|
81
|
+
describe "#tweet_count" do
|
|
115
82
|
before do
|
|
116
83
|
stub_request(:get, "https://cdn.api.twitter.com/1/urls/count.json").with(:query => {:url => "http://twitter.com"}).to_return(:body => fixture("count.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
|
117
84
|
end
|
|
@@ -122,7 +89,14 @@ describe Twitter::API::Undocumented do
|
|
|
122
89
|
it "returns a Tweet count" do
|
|
123
90
|
tweet_count = @client.tweet_count("http://twitter.com")
|
|
124
91
|
expect(tweet_count).to be_an Integer
|
|
125
|
-
expect(tweet_count).to eq
|
|
92
|
+
expect(tweet_count).to eq(13845465)
|
|
93
|
+
end
|
|
94
|
+
context "with a URI" do
|
|
95
|
+
it "requests the correct resource" do
|
|
96
|
+
uri = URI.parse("http://twitter.com")
|
|
97
|
+
@client.tweet_count(uri)
|
|
98
|
+
expect(a_request(:get, "https://cdn.api.twitter.com/1/urls/count.json").with(:query => {:url => "http://twitter.com"})).to have_been_made
|
|
99
|
+
end
|
|
126
100
|
end
|
|
127
101
|
end
|
|
128
102
|
|