twitter 5.0.0 → 5.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.yardopts +4 -0
- data/CHANGELOG.md +47 -0
- data/CONTRIBUTING.md +5 -5
- data/README.md +57 -56
- data/Rakefile +26 -5
- data/lib/twitter/arguments.rb +1 -2
- data/lib/twitter/base.rb +15 -18
- data/lib/twitter/basic_user.rb +3 -3
- data/lib/twitter/client.rb +9 -10
- data/lib/twitter/configuration.rb +5 -5
- data/lib/twitter/creatable.rb +0 -1
- data/lib/twitter/cursor.rb +9 -36
- data/lib/twitter/direct_message.rb +1 -1
- data/lib/twitter/entity/uri.rb +2 -2
- data/lib/twitter/enumerable.rb +10 -1
- data/lib/twitter/error/already_favorited.rb +1 -1
- data/lib/twitter/error/already_posted.rb +1 -1
- data/lib/twitter/error/already_retweeted.rb +1 -1
- data/lib/twitter/error/too_many_requests.rb +2 -2
- data/lib/twitter/error.rb +6 -6
- data/lib/twitter/factory.rb +2 -6
- data/lib/twitter/geo/point.rb +3 -5
- data/lib/twitter/geo.rb +1 -1
- data/lib/twitter/geo_factory.rb +1 -5
- data/lib/twitter/geo_results.rb +5 -8
- data/lib/twitter/identity.rb +1 -2
- data/lib/twitter/list.rb +10 -11
- data/lib/twitter/media/photo.rb +1 -2
- data/lib/twitter/media_factory.rb +1 -5
- data/lib/twitter/null_object.rb +4 -6
- data/lib/twitter/oembed.rb +1 -1
- data/lib/twitter/place.rb +17 -6
- data/lib/twitter/profile_banner.rb +1 -3
- data/lib/twitter/rate_limit.rb +1 -3
- data/lib/twitter/relationship.rb +1 -2
- data/lib/twitter/rest/api/direct_messages.rb +15 -15
- data/lib/twitter/rest/api/favorites.rb +15 -15
- data/lib/twitter/rest/api/friends_and_followers.rb +37 -42
- data/lib/twitter/rest/api/help.rb +8 -9
- data/lib/twitter/rest/api/lists.rb +69 -69
- data/lib/twitter/rest/api/oauth.rb +3 -4
- data/lib/twitter/rest/api/places_and_geo.rb +9 -10
- data/lib/twitter/rest/api/saved_searches.rb +8 -8
- data/lib/twitter/rest/api/search.rb +10 -2
- data/lib/twitter/rest/api/spam_reporting.rb +1 -2
- data/lib/twitter/rest/api/suggested_users.rb +4 -5
- data/lib/twitter/rest/api/timelines.rb +17 -18
- data/lib/twitter/rest/api/trends.rb +10 -11
- data/lib/twitter/rest/api/tweets.rb +31 -20
- data/lib/twitter/rest/api/undocumented.rb +6 -7
- data/lib/twitter/rest/api/users.rb +53 -54
- data/lib/twitter/rest/api/utils.rb +28 -34
- data/lib/twitter/rest/client.rb +8 -9
- data/lib/twitter/rest/request/multipart_with_file.rb +7 -5
- data/lib/twitter/rest/response/parse_error_json.rb +0 -2
- data/lib/twitter/rest/response/parse_json.rb +2 -2
- data/lib/twitter/rest/response/raise_error.rb +1 -3
- data/lib/twitter/search_results.rb +38 -56
- data/lib/twitter/settings.rb +2 -2
- data/lib/twitter/size.rb +2 -2
- data/lib/twitter/source_user.rb +1 -1
- data/lib/twitter/streaming/client.rb +69 -18
- data/lib/twitter/streaming/connection.rb +1 -3
- data/lib/twitter/streaming/deleted_tweet.rb +8 -0
- data/lib/twitter/streaming/event.rb +8 -8
- data/lib/twitter/streaming/friend_list.rb +2 -9
- data/lib/twitter/streaming/message_parser.rb +13 -3
- data/lib/twitter/streaming/response.rb +0 -2
- data/lib/twitter/streaming/stall_warning.rb +7 -0
- data/lib/twitter/suggestion.rb +0 -1
- data/lib/twitter/token.rb +2 -3
- data/lib/twitter/trend_results.rb +5 -8
- data/lib/twitter/tweet.rb +17 -18
- data/lib/twitter/user.rb +33 -35
- data/lib/twitter/utils.rb +14 -0
- data/lib/twitter/version.rb +2 -5
- data/lib/twitter.rb +1 -1
- data/spec/fixtures/forbidden.json +1 -0
- data/spec/fixtures/search.json +1 -1
- data/spec/fixtures/search2.json +1 -0
- data/spec/fixtures/track_streaming_user.json +2 -1
- data/spec/helper.rb +6 -2
- data/spec/twitter/base_spec.rb +9 -9
- data/spec/twitter/basic_user_spec.rb +6 -6
- data/spec/twitter/configuration_spec.rb +4 -4
- data/spec/twitter/cursor_spec.rb +13 -51
- data/spec/twitter/direct_message_spec.rb +36 -36
- data/spec/twitter/entity/uri_spec.rb +29 -29
- data/spec/twitter/error_spec.rb +21 -21
- data/spec/twitter/geo/point_spec.rb +9 -9
- data/spec/twitter/geo/polygon_spec.rb +5 -5
- data/spec/twitter/geo_factory_spec.rb +7 -7
- data/spec/twitter/geo_results_spec.rb +11 -11
- data/spec/twitter/geo_spec.rb +5 -5
- data/spec/twitter/identifiable_spec.rb +9 -9
- data/spec/twitter/list_spec.rb +38 -38
- data/spec/twitter/media/photo_spec.rb +58 -58
- data/spec/twitter/media_factory_spec.rb +5 -5
- data/spec/twitter/null_object_spec.rb +6 -6
- data/spec/twitter/oembed_spec.rb +68 -68
- data/spec/twitter/place_spec.rb +91 -62
- data/spec/twitter/profile_banner_spec.rb +3 -3
- data/spec/twitter/rate_limit_spec.rb +18 -18
- data/spec/twitter/relationship_spec.rb +16 -16
- data/spec/twitter/rest/api/direct_messages_spec.rb +61 -61
- data/spec/twitter/rest/api/favorites_spec.rb +93 -93
- data/spec/twitter/rest/api/friends_and_followers_spec.rb +357 -349
- data/spec/twitter/rest/api/geo_spec.rb +33 -33
- data/spec/twitter/rest/api/help_spec.rb +24 -24
- data/spec/twitter/rest/api/lists_spec.rb +487 -487
- data/spec/twitter/rest/api/oauth_spec.rb +30 -30
- data/spec/twitter/rest/api/saved_searches_spec.rb +50 -40
- data/spec/twitter/rest/api/search_spec.rb +27 -26
- data/spec/twitter/rest/api/spam_reporting_spec.rb +9 -9
- data/spec/twitter/rest/api/suggested_users_spec.rb +23 -23
- data/spec/twitter/rest/api/timelines_spec.rb +58 -58
- data/spec/twitter/rest/api/trends_spec.rb +26 -26
- data/spec/twitter/rest/api/tweets_spec.rb +304 -266
- data/spec/twitter/rest/api/undocumented_spec.rb +51 -51
- data/spec/twitter/rest/api/users_spec.rb +360 -360
- data/spec/twitter/rest/client_spec.rb +99 -103
- data/spec/twitter/saved_search_spec.rb +16 -16
- data/spec/twitter/search_results_spec.rb +14 -110
- data/spec/twitter/settings_spec.rb +8 -8
- data/spec/twitter/size_spec.rb +5 -5
- data/spec/twitter/source_user_spec.rb +6 -6
- data/spec/twitter/streaming/client_spec.rb +85 -54
- data/spec/twitter/streaming/deleted_tweet_spec.rb +23 -0
- data/spec/twitter/streaming/event_spec.rb +20 -22
- data/spec/twitter/streaming/friend_list_spec.rb +11 -0
- data/spec/twitter/streaming/message_parser_spec.rb +54 -0
- data/spec/twitter/suggestion_spec.rb +11 -11
- data/spec/twitter/target_user_spec.rb +6 -6
- data/spec/twitter/token_spec.rb +4 -4
- data/spec/twitter/trend_results_spec.rb +30 -30
- data/spec/twitter/trend_spec.rb +21 -21
- data/spec/twitter/tweet_spec.rb +178 -164
- data/spec/twitter/user_spec.rb +190 -190
- data/twitter.gemspec +6 -6
- data.tar.gz.sig +0 -0
- metadata +44 -16
- metadata.gz.sig +0 -0
- data/lib/twitter/core_ext/enumerable.rb +0 -10
- data/lib/twitter/core_ext/kernel.rb +0 -10
- data/spec/twitter_spec.rb +0 -0
|
@@ -3,499 +3,537 @@ require 'helper'
|
|
|
3
3
|
describe Twitter::REST::API::Tweets do
|
|
4
4
|
|
|
5
5
|
before do
|
|
6
|
-
@client = Twitter::REST::Client.new(:consumer_key =>
|
|
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
|
-
describe
|
|
9
|
+
describe '#retweets' do
|
|
10
10
|
before do
|
|
11
|
-
stub_get(
|
|
11
|
+
stub_get('/1.1/statuses/retweets/25938088801.json').to_return(:body => fixture('retweets.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
12
12
|
end
|
|
13
|
-
context
|
|
14
|
-
it
|
|
15
|
-
@client.retweets(
|
|
16
|
-
expect(a_get(
|
|
13
|
+
context 'with a tweet ID passed' do
|
|
14
|
+
it 'requests the correct resource' do
|
|
15
|
+
@client.retweets(25_938_088_801)
|
|
16
|
+
expect(a_get('/1.1/statuses/retweets/25938088801.json')).to have_been_made
|
|
17
17
|
end
|
|
18
|
-
it
|
|
19
|
-
tweets = @client.retweets(
|
|
18
|
+
it 'returns up to 100 of the first retweets of a given tweet' do
|
|
19
|
+
tweets = @client.retweets(25_938_088_801)
|
|
20
20
|
expect(tweets).to be_an Array
|
|
21
21
|
expect(tweets.first).to be_a Twitter::Tweet
|
|
22
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
23
|
end
|
|
24
24
|
end
|
|
25
|
-
context
|
|
26
|
-
it
|
|
27
|
-
tweet = URI.parse(
|
|
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
28
|
@client.retweets(tweet)
|
|
29
|
-
expect(a_get(
|
|
29
|
+
expect(a_get('/1.1/statuses/retweets/25938088801.json')).to have_been_made
|
|
30
30
|
end
|
|
31
31
|
end
|
|
32
|
-
context
|
|
33
|
-
it
|
|
34
|
-
@client.retweets(
|
|
35
|
-
expect(a_get(
|
|
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
36
|
end
|
|
37
37
|
end
|
|
38
|
-
context
|
|
39
|
-
it
|
|
40
|
-
tweet = Twitter::Tweet.new(:id =>
|
|
38
|
+
context 'with a Tweet passed' do
|
|
39
|
+
it 'requests the correct resource' do
|
|
40
|
+
tweet = Twitter::Tweet.new(:id => 25_938_088_801)
|
|
41
41
|
@client.retweets(tweet)
|
|
42
|
-
expect(a_get(
|
|
42
|
+
expect(a_get('/1.1/statuses/retweets/25938088801.json')).to have_been_made
|
|
43
43
|
end
|
|
44
44
|
end
|
|
45
45
|
end
|
|
46
46
|
|
|
47
|
-
describe
|
|
48
|
-
context
|
|
49
|
-
context
|
|
47
|
+
describe '#retweeters_of' do
|
|
48
|
+
context 'with ids_only passed' do
|
|
49
|
+
context 'with a tweet ID passed' do
|
|
50
50
|
before do
|
|
51
|
-
stub_get(
|
|
51
|
+
stub_get('/1.1/statuses/retweets/25938088801.json').to_return(:body => fixture('retweets.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
52
52
|
end
|
|
53
|
-
it
|
|
54
|
-
@client.retweeters_of(
|
|
55
|
-
expect(a_get(
|
|
53
|
+
it 'requests the correct resource' do
|
|
54
|
+
@client.retweeters_of(25_938_088_801, :ids_only => true)
|
|
55
|
+
expect(a_get('/1.1/statuses/retweets/25938088801.json')).to have_been_made
|
|
56
56
|
end
|
|
57
|
-
it
|
|
58
|
-
ids = @client.retweeters_of(
|
|
57
|
+
it 'returns an array of numeric user IDs of retweeters of a Tweet' do
|
|
58
|
+
ids = @client.retweeters_of(25_938_088_801, :ids_only => true)
|
|
59
59
|
expect(ids).to be_an Array
|
|
60
|
-
expect(ids.first).to eq(
|
|
60
|
+
expect(ids.first).to eq(7_505_382)
|
|
61
61
|
end
|
|
62
62
|
end
|
|
63
63
|
end
|
|
64
|
-
context
|
|
64
|
+
context 'without ids_only passed' do
|
|
65
65
|
before do
|
|
66
|
-
stub_get(
|
|
66
|
+
stub_get('/1.1/statuses/retweets/25938088801.json').to_return(:body => fixture('retweets.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
67
67
|
end
|
|
68
|
-
it
|
|
69
|
-
@client.retweeters_of(
|
|
70
|
-
expect(a_get(
|
|
68
|
+
it 'requests the correct resource' do
|
|
69
|
+
@client.retweeters_of(25_938_088_801)
|
|
70
|
+
expect(a_get('/1.1/statuses/retweets/25938088801.json')).to have_been_made
|
|
71
71
|
end
|
|
72
|
-
it
|
|
73
|
-
users = @client.retweeters_of(
|
|
72
|
+
it 'returns an array of user of retweeters of a Tweet' do
|
|
73
|
+
users = @client.retweeters_of(25_938_088_801)
|
|
74
74
|
expect(users).to be_an Array
|
|
75
75
|
expect(users.first).to be_a Twitter::User
|
|
76
|
-
expect(users.first.id).to eq(
|
|
76
|
+
expect(users.first.id).to eq(7_505_382)
|
|
77
77
|
end
|
|
78
|
-
context
|
|
79
|
-
it
|
|
80
|
-
tweet = URI.parse(
|
|
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
81
|
@client.retweeters_of(tweet)
|
|
82
|
-
expect(a_get(
|
|
82
|
+
expect(a_get('/1.1/statuses/retweets/25938088801.json')).to have_been_made
|
|
83
83
|
end
|
|
84
84
|
end
|
|
85
|
-
context
|
|
86
|
-
it
|
|
87
|
-
@client.retweeters_of(
|
|
88
|
-
expect(a_get(
|
|
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
89
|
end
|
|
90
90
|
end
|
|
91
|
-
context
|
|
92
|
-
it
|
|
93
|
-
tweet = Twitter::Tweet.new(:id =>
|
|
91
|
+
context 'with a Tweet passed' do
|
|
92
|
+
it 'requests the correct resource' do
|
|
93
|
+
tweet = Twitter::Tweet.new(:id => 25_938_088_801)
|
|
94
94
|
@client.retweeters_of(tweet)
|
|
95
|
-
expect(a_get(
|
|
95
|
+
expect(a_get('/1.1/statuses/retweets/25938088801.json')).to have_been_made
|
|
96
96
|
end
|
|
97
97
|
end
|
|
98
98
|
end
|
|
99
99
|
end
|
|
100
100
|
|
|
101
|
-
describe
|
|
101
|
+
describe '#status' do
|
|
102
102
|
before do
|
|
103
|
-
stub_get(
|
|
103
|
+
stub_get('/1.1/statuses/show/25938088801.json').to_return(:body => fixture('status.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
104
104
|
end
|
|
105
|
-
it
|
|
106
|
-
@client.status(
|
|
107
|
-
expect(a_get(
|
|
105
|
+
it 'requests the correct resource' do
|
|
106
|
+
@client.status(25_938_088_801)
|
|
107
|
+
expect(a_get('/1.1/statuses/show/25938088801.json')).to have_been_made
|
|
108
108
|
end
|
|
109
|
-
it
|
|
110
|
-
tweet = @client.status(
|
|
109
|
+
it 'returns a Tweet' do
|
|
110
|
+
tweet = @client.status(25_938_088_801)
|
|
111
111
|
expect(tweet).to be_a Twitter::Tweet
|
|
112
112
|
expect(tweet.text).to eq("The problem with your code is that it's doing exactly what you told it to do.")
|
|
113
113
|
end
|
|
114
|
-
context
|
|
115
|
-
it
|
|
116
|
-
tweet = URI.parse(
|
|
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
117
|
@client.status(tweet)
|
|
118
|
-
expect(a_get(
|
|
118
|
+
expect(a_get('/1.1/statuses/show/25938088801.json')).to have_been_made
|
|
119
119
|
end
|
|
120
120
|
end
|
|
121
|
-
context
|
|
122
|
-
it
|
|
123
|
-
@client.status(
|
|
124
|
-
expect(a_get(
|
|
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
125
|
end
|
|
126
126
|
end
|
|
127
|
-
context
|
|
128
|
-
it
|
|
129
|
-
tweet = Twitter::Tweet.new(:id =>
|
|
127
|
+
context 'with a Tweet passed' do
|
|
128
|
+
it 'requests the correct resource' do
|
|
129
|
+
tweet = Twitter::Tweet.new(:id => 25_938_088_801)
|
|
130
130
|
@client.status(tweet)
|
|
131
|
-
expect(a_get(
|
|
131
|
+
expect(a_get('/1.1/statuses/show/25938088801.json')).to have_been_made
|
|
132
132
|
end
|
|
133
133
|
end
|
|
134
134
|
end
|
|
135
135
|
|
|
136
|
-
describe
|
|
136
|
+
describe '#statuses' do
|
|
137
137
|
before do
|
|
138
|
-
stub_get(
|
|
138
|
+
stub_get('/1.1/statuses/show/25938088801.json').to_return(:body => fixture('status.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
139
139
|
end
|
|
140
|
-
it
|
|
141
|
-
@client.statuses(
|
|
142
|
-
expect(a_get(
|
|
140
|
+
it 'requests the correct resource' do
|
|
141
|
+
@client.statuses(25_938_088_801)
|
|
142
|
+
expect(a_get('/1.1/statuses/show/25938088801.json')).to have_been_made
|
|
143
143
|
end
|
|
144
|
-
it
|
|
145
|
-
tweets = @client.statuses(
|
|
144
|
+
it 'returns an array of Tweets' do
|
|
145
|
+
tweets = @client.statuses(25_938_088_801)
|
|
146
146
|
expect(tweets).to be_an Array
|
|
147
147
|
expect(tweets.first).to be_a Twitter::Tweet
|
|
148
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
149
|
end
|
|
150
|
-
context
|
|
151
|
-
it
|
|
152
|
-
tweet = URI.parse(
|
|
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
153
|
@client.statuses(tweet)
|
|
154
|
-
expect(a_get(
|
|
154
|
+
expect(a_get('/1.1/statuses/show/25938088801.json')).to have_been_made
|
|
155
155
|
end
|
|
156
156
|
end
|
|
157
|
-
context
|
|
158
|
-
it
|
|
159
|
-
@client.statuses(
|
|
160
|
-
expect(a_get(
|
|
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
161
|
end
|
|
162
162
|
end
|
|
163
|
-
context
|
|
164
|
-
it
|
|
165
|
-
tweet = Twitter::Tweet.new(:id =>
|
|
163
|
+
context 'with a Tweet passed' do
|
|
164
|
+
it 'requests the correct resource' do
|
|
165
|
+
tweet = Twitter::Tweet.new(:id => 25_938_088_801)
|
|
166
166
|
@client.statuses(tweet)
|
|
167
|
-
expect(a_get(
|
|
167
|
+
expect(a_get('/1.1/statuses/show/25938088801.json')).to have_been_made
|
|
168
168
|
end
|
|
169
169
|
end
|
|
170
170
|
end
|
|
171
171
|
|
|
172
|
-
describe
|
|
172
|
+
describe '#destroy_status' do
|
|
173
173
|
before do
|
|
174
|
-
stub_post(
|
|
174
|
+
stub_post('/1.1/statuses/destroy/25938088801.json').to_return(:body => fixture('status.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
175
175
|
end
|
|
176
|
-
it
|
|
177
|
-
@client.destroy_status(
|
|
178
|
-
expect(a_post(
|
|
176
|
+
it 'requests the correct resource' do
|
|
177
|
+
@client.destroy_status(25_938_088_801)
|
|
178
|
+
expect(a_post('/1.1/statuses/destroy/25938088801.json')).to have_been_made
|
|
179
179
|
end
|
|
180
|
-
it
|
|
181
|
-
tweets = @client.destroy_status(
|
|
180
|
+
it 'returns an array of Tweets' do
|
|
181
|
+
tweets = @client.destroy_status(25_938_088_801)
|
|
182
182
|
expect(tweets).to be_an Array
|
|
183
183
|
expect(tweets.first).to be_a Twitter::Tweet
|
|
184
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
185
|
end
|
|
186
|
-
context
|
|
187
|
-
it
|
|
188
|
-
tweet = URI.parse(
|
|
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
189
|
@client.destroy_status(tweet)
|
|
190
|
-
expect(a_post(
|
|
190
|
+
expect(a_post('/1.1/statuses/destroy/25938088801.json')).to have_been_made
|
|
191
191
|
end
|
|
192
192
|
end
|
|
193
|
-
context
|
|
194
|
-
it
|
|
195
|
-
@client.destroy_status(
|
|
196
|
-
expect(a_post(
|
|
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
197
|
end
|
|
198
198
|
end
|
|
199
|
-
context
|
|
200
|
-
it
|
|
201
|
-
tweet = Twitter::Tweet.new(:id =>
|
|
199
|
+
context 'with a Tweet passed' do
|
|
200
|
+
it 'requests the correct resource' do
|
|
201
|
+
tweet = Twitter::Tweet.new(:id => 25_938_088_801)
|
|
202
202
|
@client.destroy_status(tweet)
|
|
203
|
-
expect(a_post(
|
|
203
|
+
expect(a_post('/1.1/statuses/destroy/25938088801.json')).to have_been_made
|
|
204
204
|
end
|
|
205
205
|
end
|
|
206
206
|
end
|
|
207
207
|
|
|
208
|
-
describe
|
|
208
|
+
describe '#update' do
|
|
209
209
|
before do
|
|
210
|
-
stub_post(
|
|
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
211
|
end
|
|
212
|
-
it
|
|
212
|
+
it 'requests the correct resource' do
|
|
213
213
|
@client.update("The problem with your code is that it's doing exactly what you told it to do.")
|
|
214
|
-
expect(a_post(
|
|
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
215
|
end
|
|
216
|
-
it
|
|
216
|
+
it 'returns a Tweet' do
|
|
217
217
|
tweet = @client.update("The problem with your code is that it's doing exactly what you told it to do.")
|
|
218
218
|
expect(tweet).to be_a Twitter::Tweet
|
|
219
219
|
expect(tweet.text).to eq("The problem with your code is that it's doing exactly what you told it to do.")
|
|
220
220
|
end
|
|
221
|
-
context
|
|
221
|
+
context 'already posted' do
|
|
222
222
|
before do
|
|
223
|
-
stub_post(
|
|
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
224
|
end
|
|
225
|
-
it
|
|
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
|
|
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
|
+
context 'with an in-reply-to status' do
|
|
230
|
+
before do
|
|
231
|
+
@tweet = Twitter::Tweet.new(:id => 1)
|
|
232
|
+
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.", :in_reply_to_status_id => '1'}).to_return(:body => fixture('status.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
233
|
+
end
|
|
234
|
+
it 'requests the correct resource' do
|
|
235
|
+
@client.update("The problem with your code is that it's doing exactly what you told it to do.", :in_reply_to_status => @tweet)
|
|
236
|
+
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.", :in_reply_to_status_id => '1'})).to have_been_made
|
|
237
|
+
end
|
|
238
|
+
end
|
|
239
|
+
context 'with an in-reply-to status ID' do
|
|
240
|
+
before do
|
|
241
|
+
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.", :in_reply_to_status_id => '1'}).to_return(:body => fixture('status.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
242
|
+
end
|
|
243
|
+
it 'requests the correct resource' do
|
|
244
|
+
@client.update("The problem with your code is that it's doing exactly what you told it to do.", :in_reply_to_status_id => 1)
|
|
245
|
+
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.", :in_reply_to_status_id => '1'})).to have_been_made
|
|
246
|
+
end
|
|
247
|
+
end
|
|
248
|
+
context 'with a place' do
|
|
249
|
+
before do
|
|
250
|
+
@place = Twitter::Place.new(:woeid => 'df51dec6f4ee2b2c')
|
|
251
|
+
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.", :place_id => 'df51dec6f4ee2b2c'}).to_return(:body => fixture('status.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
252
|
+
end
|
|
253
|
+
it 'requests the correct resource' do
|
|
254
|
+
@client.update("The problem with your code is that it's doing exactly what you told it to do.", :place => @place)
|
|
255
|
+
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.", :place_id => 'df51dec6f4ee2b2c'})).to have_been_made
|
|
256
|
+
end
|
|
257
|
+
end
|
|
258
|
+
context 'with a place ID' do
|
|
259
|
+
before do
|
|
260
|
+
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.", :place_id => 'df51dec6f4ee2b2c'}).to_return(:body => fixture('status.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
261
|
+
end
|
|
262
|
+
it 'requests the correct resource' do
|
|
263
|
+
@client.update("The problem with your code is that it's doing exactly what you told it to do.", :place_id => 'df51dec6f4ee2b2c')
|
|
264
|
+
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.", :place_id => 'df51dec6f4ee2b2c'})).to have_been_made
|
|
227
265
|
end
|
|
228
266
|
end
|
|
229
267
|
end
|
|
230
268
|
|
|
231
|
-
describe
|
|
269
|
+
describe '#retweet' do
|
|
232
270
|
before do
|
|
233
|
-
stub_post(
|
|
271
|
+
stub_post('/1.1/statuses/retweet/25938088801.json').to_return(:body => fixture('retweet.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
234
272
|
end
|
|
235
|
-
it
|
|
236
|
-
@client.retweet(
|
|
237
|
-
expect(a_post(
|
|
273
|
+
it 'requests the correct resource' do
|
|
274
|
+
@client.retweet(25_938_088_801)
|
|
275
|
+
expect(a_post('/1.1/statuses/retweet/25938088801.json')).to have_been_made
|
|
238
276
|
end
|
|
239
|
-
it
|
|
240
|
-
tweets = @client.retweet(
|
|
277
|
+
it 'returns an array of Tweets with retweet details embedded' do
|
|
278
|
+
tweets = @client.retweet(25_938_088_801)
|
|
241
279
|
expect(tweets).to be_an Array
|
|
242
280
|
expect(tweets.first).to be_a Twitter::Tweet
|
|
243
281
|
expect(tweets.first.text).to eq("As for the Series, I'm for the Giants. Fuck Texas, fuck Nolan Ryan, fuck George Bush.")
|
|
244
282
|
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
283
|
expect(tweets.first.retweeted_tweet.id).not_to eq(tweets.first.id)
|
|
246
284
|
end
|
|
247
|
-
context
|
|
285
|
+
context 'already retweeted' do
|
|
248
286
|
before do
|
|
249
|
-
stub_post(
|
|
287
|
+
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
288
|
end
|
|
251
|
-
it
|
|
252
|
-
expect{@client.retweet(
|
|
289
|
+
it 'does not raise an error' do
|
|
290
|
+
expect { @client.retweet(25_938_088_801) }.not_to raise_error
|
|
253
291
|
end
|
|
254
292
|
end
|
|
255
|
-
context
|
|
256
|
-
it
|
|
257
|
-
tweet = URI.parse(
|
|
293
|
+
context 'with a URI object passed' do
|
|
294
|
+
it 'requests the correct resource' do
|
|
295
|
+
tweet = URI.parse('https://twitter.com/sferik/status/25938088801')
|
|
258
296
|
@client.retweet(tweet)
|
|
259
|
-
expect(a_post(
|
|
297
|
+
expect(a_post('/1.1/statuses/retweet/25938088801.json')).to have_been_made
|
|
260
298
|
end
|
|
261
299
|
end
|
|
262
|
-
context
|
|
263
|
-
it
|
|
264
|
-
@client.retweet(
|
|
265
|
-
expect(a_post(
|
|
300
|
+
context 'with a URI string passed' do
|
|
301
|
+
it 'requests the correct resource' do
|
|
302
|
+
@client.retweet('https://twitter.com/sferik/status/25938088801')
|
|
303
|
+
expect(a_post('/1.1/statuses/retweet/25938088801.json')).to have_been_made
|
|
266
304
|
end
|
|
267
305
|
end
|
|
268
|
-
context
|
|
269
|
-
it
|
|
270
|
-
tweet = Twitter::Tweet.new(:id =>
|
|
306
|
+
context 'with a Tweet passed' do
|
|
307
|
+
it 'requests the correct resource' do
|
|
308
|
+
tweet = Twitter::Tweet.new(:id => 25_938_088_801)
|
|
271
309
|
@client.retweet(tweet)
|
|
272
|
-
expect(a_post(
|
|
310
|
+
expect(a_post('/1.1/statuses/retweet/25938088801.json')).to have_been_made
|
|
273
311
|
end
|
|
274
312
|
end
|
|
275
313
|
end
|
|
276
314
|
|
|
277
|
-
describe
|
|
315
|
+
describe '#retweet!' do
|
|
278
316
|
before do
|
|
279
|
-
stub_post(
|
|
317
|
+
stub_post('/1.1/statuses/retweet/25938088801.json').to_return(:body => fixture('retweet.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
280
318
|
end
|
|
281
|
-
it
|
|
282
|
-
@client.retweet!(
|
|
283
|
-
expect(a_post(
|
|
319
|
+
it 'requests the correct resource' do
|
|
320
|
+
@client.retweet!(25_938_088_801)
|
|
321
|
+
expect(a_post('/1.1/statuses/retweet/25938088801.json')).to have_been_made
|
|
284
322
|
end
|
|
285
|
-
it
|
|
286
|
-
tweets = @client.retweet!(
|
|
323
|
+
it 'returns an array of Tweets with retweet details embedded' do
|
|
324
|
+
tweets = @client.retweet!(25_938_088_801)
|
|
287
325
|
expect(tweets).to be_an Array
|
|
288
326
|
expect(tweets.first).to be_a Twitter::Tweet
|
|
289
327
|
expect(tweets.first.text).to eq("As for the Series, I'm for the Giants. Fuck Texas, fuck Nolan Ryan, fuck George Bush.")
|
|
290
328
|
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
329
|
expect(tweets.first.retweeted_tweet.id).not_to eq(tweets.first.id)
|
|
292
330
|
end
|
|
293
|
-
context
|
|
331
|
+
context 'forbidden' do
|
|
294
332
|
before do
|
|
295
|
-
stub_post(
|
|
333
|
+
stub_post('/1.1/statuses/retweet/25938088801.json').to_return(:status => 403, :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
296
334
|
end
|
|
297
|
-
it
|
|
298
|
-
expect{@client.retweet!(
|
|
335
|
+
it 'raises a Forbidden error' do
|
|
336
|
+
expect { @client.retweet!(25_938_088_801) }.to raise_error Twitter::Error::Forbidden
|
|
299
337
|
end
|
|
300
338
|
end
|
|
301
|
-
context
|
|
339
|
+
context 'already retweeted' do
|
|
302
340
|
before do
|
|
303
|
-
stub_post(
|
|
341
|
+
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
342
|
end
|
|
305
|
-
it
|
|
306
|
-
expect{@client.retweet!(
|
|
343
|
+
it 'raises an AlreadyRetweeted error' do
|
|
344
|
+
expect { @client.retweet!(25_938_088_801) }.to raise_error Twitter::Error::AlreadyRetweeted
|
|
307
345
|
end
|
|
308
346
|
end
|
|
309
|
-
context
|
|
310
|
-
it
|
|
311
|
-
tweet = URI.parse(
|
|
347
|
+
context 'with a URI object passed' do
|
|
348
|
+
it 'requests the correct resource' do
|
|
349
|
+
tweet = URI.parse('https://twitter.com/sferik/status/25938088801')
|
|
312
350
|
@client.retweet!(tweet)
|
|
313
|
-
expect(a_post(
|
|
351
|
+
expect(a_post('/1.1/statuses/retweet/25938088801.json')).to have_been_made
|
|
314
352
|
end
|
|
315
353
|
end
|
|
316
|
-
context
|
|
317
|
-
it
|
|
318
|
-
@client.retweet!(
|
|
319
|
-
expect(a_post(
|
|
354
|
+
context 'with a URI string passed' do
|
|
355
|
+
it 'requests the correct resource' do
|
|
356
|
+
@client.retweet!('https://twitter.com/sferik/status/25938088801')
|
|
357
|
+
expect(a_post('/1.1/statuses/retweet/25938088801.json')).to have_been_made
|
|
320
358
|
end
|
|
321
359
|
end
|
|
322
|
-
context
|
|
323
|
-
it
|
|
324
|
-
tweet = Twitter::Tweet.new(:id =>
|
|
360
|
+
context 'with a Tweet passed' do
|
|
361
|
+
it 'requests the correct resource' do
|
|
362
|
+
tweet = Twitter::Tweet.new(:id => 25_938_088_801)
|
|
325
363
|
@client.retweet!(tweet)
|
|
326
|
-
expect(a_post(
|
|
364
|
+
expect(a_post('/1.1/statuses/retweet/25938088801.json')).to have_been_made
|
|
327
365
|
end
|
|
328
366
|
end
|
|
329
367
|
end
|
|
330
368
|
|
|
331
|
-
describe
|
|
369
|
+
describe '#update_with_media' do
|
|
332
370
|
before do
|
|
333
|
-
stub_post(
|
|
371
|
+
stub_post('/1.1/statuses/update_with_media.json').to_return(:body => fixture('status.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
334
372
|
end
|
|
335
|
-
context
|
|
336
|
-
it
|
|
337
|
-
@client.update_with_media("The problem with your code is that it's doing exactly what you told it to do.", fixture(
|
|
338
|
-
expect(a_post(
|
|
373
|
+
context 'a gif image' do
|
|
374
|
+
it 'requests the correct resource' do
|
|
375
|
+
@client.update_with_media("The problem with your code is that it's doing exactly what you told it to do.", fixture('pbjt.gif'))
|
|
376
|
+
expect(a_post('/1.1/statuses/update_with_media.json')).to have_been_made
|
|
339
377
|
end
|
|
340
|
-
it
|
|
341
|
-
tweet = @client.update_with_media("The problem with your code is that it's doing exactly what you told it to do.", fixture(
|
|
378
|
+
it 'returns a Tweet' do
|
|
379
|
+
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
380
|
expect(tweet).to be_a Twitter::Tweet
|
|
343
381
|
expect(tweet.text).to eq("The problem with your code is that it's doing exactly what you told it to do.")
|
|
344
382
|
end
|
|
345
383
|
end
|
|
346
|
-
context
|
|
347
|
-
it
|
|
348
|
-
@client.update_with_media(
|
|
349
|
-
expect(a_post(
|
|
384
|
+
context 'a jpe image' do
|
|
385
|
+
it 'requests the correct resource' do
|
|
386
|
+
@client.update_with_media('You always have options', fixture('wildcomet2.jpe'))
|
|
387
|
+
expect(a_post('/1.1/statuses/update_with_media.json')).to have_been_made
|
|
350
388
|
end
|
|
351
389
|
end
|
|
352
|
-
context
|
|
353
|
-
it
|
|
354
|
-
@client.update_with_media(
|
|
355
|
-
expect(a_post(
|
|
390
|
+
context 'a jpeg image' do
|
|
391
|
+
it 'requests the correct resource' do
|
|
392
|
+
@client.update_with_media('You always have options', fixture('me.jpeg'))
|
|
393
|
+
expect(a_post('/1.1/statuses/update_with_media.json')).to have_been_made
|
|
356
394
|
end
|
|
357
395
|
end
|
|
358
|
-
context
|
|
359
|
-
it
|
|
360
|
-
@client.update_with_media(
|
|
361
|
-
expect(a_post(
|
|
396
|
+
context 'a png image' do
|
|
397
|
+
it 'requests the correct resource' do
|
|
398
|
+
@client.update_with_media('You always have options', fixture('we_concept_bg2.png'))
|
|
399
|
+
expect(a_post('/1.1/statuses/update_with_media.json')).to have_been_made
|
|
362
400
|
end
|
|
363
401
|
end
|
|
364
|
-
context
|
|
365
|
-
it
|
|
366
|
-
@client.update_with_media(
|
|
367
|
-
expect(a_post(
|
|
402
|
+
context 'a Tempfile' do
|
|
403
|
+
it 'requests the correct resource' do
|
|
404
|
+
@client.update_with_media('You always have options', Tempfile.new('tmp'))
|
|
405
|
+
expect(a_post('/1.1/statuses/update_with_media.json')).to have_been_made
|
|
368
406
|
end
|
|
369
407
|
end
|
|
370
|
-
context
|
|
408
|
+
context 'already posted' do
|
|
371
409
|
before do
|
|
372
|
-
stub_post(
|
|
410
|
+
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
411
|
end
|
|
374
|
-
it
|
|
375
|
-
expect{@client.update_with_media("The problem with your code is that it's doing exactly what you told it to do.", fixture(
|
|
412
|
+
it 'raises an AlreadyPosted error' do
|
|
413
|
+
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
414
|
end
|
|
377
415
|
end
|
|
378
416
|
end
|
|
379
417
|
|
|
380
|
-
describe
|
|
418
|
+
describe '#oembed' do
|
|
381
419
|
before do
|
|
382
|
-
stub_get(
|
|
383
|
-
stub_get(
|
|
420
|
+
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'})
|
|
421
|
+
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
422
|
end
|
|
385
|
-
it
|
|
386
|
-
@client.oembed(
|
|
387
|
-
expect(a_get(
|
|
423
|
+
it 'requests the correct resource' do
|
|
424
|
+
@client.oembed(25_938_088_801)
|
|
425
|
+
expect(a_get('/1.1/statuses/oembed.json').with(:query => {:id => '25938088801'})).to have_been_made
|
|
388
426
|
end
|
|
389
|
-
it
|
|
390
|
-
@client.oembed(
|
|
391
|
-
expect(a_get(
|
|
427
|
+
it 'requests the correct resource when a URL is given' do
|
|
428
|
+
@client.oembed('https://twitter.com/sferik/status/25938088801')
|
|
429
|
+
expect(a_get('/1.1/statuses/oembed.json').with(:query => {:url => 'https://twitter.com/sferik/status/25938088801'}))
|
|
392
430
|
end
|
|
393
|
-
it
|
|
394
|
-
oembed = @client.oembed(
|
|
431
|
+
it 'returns an array of OEmbed instances' do
|
|
432
|
+
oembed = @client.oembed(25_938_088_801)
|
|
395
433
|
expect(oembed).to be_a Twitter::OEmbed
|
|
396
434
|
end
|
|
397
|
-
context
|
|
398
|
-
it
|
|
399
|
-
tweet = URI.parse(
|
|
435
|
+
context 'with a URI object passed' do
|
|
436
|
+
it 'requests the correct resource' do
|
|
437
|
+
tweet = URI.parse('https://twitter.com/sferik/status/25938088801')
|
|
400
438
|
@client.oembed(tweet)
|
|
401
|
-
expect(a_get(
|
|
439
|
+
expect(a_get('/1.1/statuses/oembed.json').with(:query => {:id => '25938088801'})).to have_been_made
|
|
402
440
|
end
|
|
403
441
|
end
|
|
404
|
-
context
|
|
405
|
-
it
|
|
406
|
-
@client.oembed(
|
|
407
|
-
expect(a_get(
|
|
442
|
+
context 'with a URI string passed' do
|
|
443
|
+
it 'requests the correct resource' do
|
|
444
|
+
@client.oembed('https://twitter.com/sferik/status/25938088801')
|
|
445
|
+
expect(a_get('/1.1/statuses/oembed.json').with(:query => {:id => '25938088801'})).to have_been_made
|
|
408
446
|
end
|
|
409
447
|
end
|
|
410
|
-
context
|
|
411
|
-
it
|
|
412
|
-
tweet = Twitter::Tweet.new(:id =>
|
|
448
|
+
context 'with a Tweet passed' do
|
|
449
|
+
it 'requests the correct resource' do
|
|
450
|
+
tweet = Twitter::Tweet.new(:id => 25_938_088_801)
|
|
413
451
|
@client.oembed(tweet)
|
|
414
|
-
expect(a_get(
|
|
452
|
+
expect(a_get('/1.1/statuses/oembed.json').with(:query => {:id => '25938088801'})).to have_been_made
|
|
415
453
|
end
|
|
416
454
|
end
|
|
417
455
|
end
|
|
418
456
|
|
|
419
|
-
describe
|
|
457
|
+
describe '#oembeds' do
|
|
420
458
|
before do
|
|
421
|
-
stub_get(
|
|
459
|
+
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
460
|
end
|
|
423
|
-
it
|
|
424
|
-
@client.oembeds(
|
|
425
|
-
expect(a_get(
|
|
461
|
+
it 'requests the correct resource' do
|
|
462
|
+
@client.oembeds(25_938_088_801)
|
|
463
|
+
expect(a_get('/1.1/statuses/oembed.json').with(:query => {:id => '25938088801'})).to have_been_made
|
|
426
464
|
end
|
|
427
|
-
it
|
|
428
|
-
@client.oembeds(
|
|
429
|
-
expect(a_get(
|
|
465
|
+
it 'requests the correct resource when a URL is given' do
|
|
466
|
+
@client.oembeds('https://twitter.com/sferik/status/25938088801')
|
|
467
|
+
expect(a_get('/1.1/statuses/oembed.json').with(:query => {:id => '25938088801'})).to have_been_made
|
|
430
468
|
end
|
|
431
|
-
it
|
|
432
|
-
oembeds = @client.oembeds(
|
|
469
|
+
it 'returns an array of OEmbed instances' do
|
|
470
|
+
oembeds = @client.oembeds(25_938_088_801)
|
|
433
471
|
expect(oembeds).to be_an Array
|
|
434
472
|
expect(oembeds.first).to be_a Twitter::OEmbed
|
|
435
473
|
end
|
|
436
|
-
context
|
|
437
|
-
it
|
|
438
|
-
tweet = URI.parse(
|
|
474
|
+
context 'with a URI object passed' do
|
|
475
|
+
it 'requests the correct resource' do
|
|
476
|
+
tweet = URI.parse('https://twitter.com/sferik/status/25938088801')
|
|
439
477
|
@client.oembeds(tweet)
|
|
440
|
-
expect(a_get(
|
|
478
|
+
expect(a_get('/1.1/statuses/oembed.json').with(:query => {:id => '25938088801'})).to have_been_made
|
|
441
479
|
end
|
|
442
480
|
end
|
|
443
|
-
context
|
|
444
|
-
it
|
|
445
|
-
@client.oembeds(
|
|
446
|
-
expect(a_get(
|
|
481
|
+
context 'with a URI string passed' do
|
|
482
|
+
it 'requests the correct resource' do
|
|
483
|
+
@client.oembeds('https://twitter.com/sferik/status/25938088801')
|
|
484
|
+
expect(a_get('/1.1/statuses/oembed.json').with(:query => {:id => '25938088801'})).to have_been_made
|
|
447
485
|
end
|
|
448
486
|
end
|
|
449
|
-
context
|
|
450
|
-
it
|
|
451
|
-
tweet = Twitter::Tweet.new(:id =>
|
|
487
|
+
context 'with a Tweet passed' do
|
|
488
|
+
it 'requests the correct resource' do
|
|
489
|
+
tweet = Twitter::Tweet.new(:id => 25_938_088_801)
|
|
452
490
|
@client.oembeds(tweet)
|
|
453
|
-
expect(a_get(
|
|
491
|
+
expect(a_get('/1.1/statuses/oembed.json').with(:query => {:id => '25938088801'})).to have_been_made
|
|
454
492
|
end
|
|
455
493
|
end
|
|
456
494
|
end
|
|
457
495
|
|
|
458
|
-
describe
|
|
496
|
+
describe '#retweeters_ids' do
|
|
459
497
|
before do
|
|
460
|
-
stub_get(
|
|
498
|
+
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
499
|
end
|
|
462
|
-
it
|
|
463
|
-
@client.retweeters_ids(
|
|
464
|
-
expect(a_get(
|
|
500
|
+
it 'requests the correct resource' do
|
|
501
|
+
@client.retweeters_ids(25_938_088_801)
|
|
502
|
+
expect(a_get('/1.1/statuses/retweeters/ids.json').with(:query => {:id => '25938088801', :cursor => '-1'})).to have_been_made
|
|
465
503
|
end
|
|
466
|
-
it
|
|
467
|
-
retweeters_ids = @client.retweeters_ids(
|
|
504
|
+
it 'returns a collection of up to 100 user IDs belonging to users who have retweeted the tweet specified by the id parameter' do
|
|
505
|
+
retweeters_ids = @client.retweeters_ids(25_938_088_801)
|
|
468
506
|
expect(retweeters_ids).to be_a Twitter::Cursor
|
|
469
|
-
expect(retweeters_ids.first).to eq(
|
|
507
|
+
expect(retweeters_ids.first).to eq(20_009_713)
|
|
470
508
|
end
|
|
471
|
-
context
|
|
509
|
+
context 'with each' do
|
|
472
510
|
before do
|
|
473
|
-
stub_get(
|
|
511
|
+
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
512
|
end
|
|
475
|
-
it
|
|
476
|
-
@client.retweeters_ids(
|
|
477
|
-
expect(a_get(
|
|
478
|
-
expect(a_get(
|
|
513
|
+
it 'requests the correct resource' do
|
|
514
|
+
@client.retweeters_ids(25_938_088_801).each {}
|
|
515
|
+
expect(a_get('/1.1/statuses/retweeters/ids.json').with(:query => {:id => '25938088801', :cursor => '-1'})).to have_been_made
|
|
516
|
+
expect(a_get('/1.1/statuses/retweeters/ids.json').with(:query => {:id => '25938088801', :cursor => '1305102810874389703'})).to have_been_made
|
|
479
517
|
end
|
|
480
518
|
end
|
|
481
|
-
context
|
|
482
|
-
it
|
|
483
|
-
tweet = URI.parse(
|
|
519
|
+
context 'with a URI object passed' do
|
|
520
|
+
it 'requests the correct resource' do
|
|
521
|
+
tweet = URI.parse('https://twitter.com/sferik/status/25938088801')
|
|
484
522
|
@client.retweeters_ids(tweet)
|
|
485
|
-
expect(a_get(
|
|
523
|
+
expect(a_get('/1.1/statuses/retweeters/ids.json').with(:query => {:id => '25938088801', :cursor => '-1'})).to have_been_made
|
|
486
524
|
end
|
|
487
525
|
end
|
|
488
|
-
context
|
|
489
|
-
it
|
|
490
|
-
@client.retweeters_ids(
|
|
491
|
-
expect(a_get(
|
|
526
|
+
context 'with a URI string passed' do
|
|
527
|
+
it 'requests the correct resource' do
|
|
528
|
+
@client.retweeters_ids('https://twitter.com/sferik/status/25938088801')
|
|
529
|
+
expect(a_get('/1.1/statuses/retweeters/ids.json').with(:query => {:id => '25938088801', :cursor => '-1'})).to have_been_made
|
|
492
530
|
end
|
|
493
531
|
end
|
|
494
|
-
context
|
|
495
|
-
it
|
|
496
|
-
tweet = Twitter::Tweet.new(:id =>
|
|
532
|
+
context 'with a Tweet passed' do
|
|
533
|
+
it 'requests the correct resource' do
|
|
534
|
+
tweet = Twitter::Tweet.new(:id => 25_938_088_801)
|
|
497
535
|
@client.retweeters_ids(tweet)
|
|
498
|
-
expect(a_get(
|
|
536
|
+
expect(a_get('/1.1/statuses/retweeters/ids.json').with(:query => {:id => '25938088801', :cursor => '-1'})).to have_been_made
|
|
499
537
|
end
|
|
500
538
|
end
|
|
501
539
|
end
|