twitter 5.11.0 → 5.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -1
- data/README.md +7 -5
- data/lib/twitter/arguments.rb +1 -0
- data/lib/twitter/base.rb +4 -5
- data/lib/twitter/basic_user.rb +1 -0
- data/lib/twitter/client.rb +10 -9
- data/lib/twitter/configuration.rb +4 -2
- data/lib/twitter/cursor.rb +3 -2
- data/lib/twitter/direct_message.rb +1 -0
- data/lib/twitter/entity.rb +1 -0
- data/lib/twitter/entity/hashtag.rb +1 -0
- data/lib/twitter/entity/symbol.rb +1 -0
- data/lib/twitter/entity/user_mention.rb +4 -1
- data/lib/twitter/error.rb +22 -19
- data/lib/twitter/geo.rb +1 -0
- data/lib/twitter/geo_results.rb +3 -2
- data/lib/twitter/identity.rb +1 -0
- data/lib/twitter/language.rb +1 -0
- data/lib/twitter/list.rb +12 -5
- data/lib/twitter/media/photo.rb +1 -0
- data/lib/twitter/metadata.rb +1 -0
- data/lib/twitter/null_object.rb +22 -0
- data/lib/twitter/oembed.rb +5 -2
- data/lib/twitter/place.rb +4 -1
- data/lib/twitter/profile.rb +1 -1
- data/lib/twitter/rest/client.rb +4 -4
- data/lib/twitter/rest/favorites.rb +4 -3
- data/lib/twitter/rest/lists.rb +18 -3
- data/lib/twitter/rest/request/multipart_with_file.rb +1 -1
- data/lib/twitter/rest/response/parse_json.rb +1 -1
- data/lib/twitter/rest/response/raise_error.rb +4 -5
- data/lib/twitter/rest/tweets.rb +2 -1
- data/lib/twitter/rest/users.rb +10 -7
- data/lib/twitter/saved_search.rb +1 -0
- data/lib/twitter/search_results.rb +3 -2
- data/lib/twitter/settings.rb +7 -3
- data/lib/twitter/size.rb +4 -1
- data/lib/twitter/streaming/deleted_tweet.rb +1 -0
- data/lib/twitter/streaming/event.rb +2 -2
- data/lib/twitter/streaming/message_parser.rb +1 -1
- data/lib/twitter/suggestion.rb +4 -1
- data/lib/twitter/token.rb +1 -0
- data/lib/twitter/trend.rb +1 -0
- data/lib/twitter/trend_results.rb +3 -2
- data/lib/twitter/tweet.rb +9 -6
- data/lib/twitter/user.rb +15 -13
- data/lib/twitter/utils.rb +2 -6
- data/lib/twitter/version.rb +1 -1
- data/twitter.gemspec +6 -9
- metadata +6 -259
- data/Rakefile +0 -37
- data/spec/fixtures/already_favorited.json +0 -1
- data/spec/fixtures/already_posted.json +0 -1
- data/spec/fixtures/already_retweeted.json +0 -1
- data/spec/fixtures/bearer_token.json +0 -1
- data/spec/fixtures/category.json +0 -1
- data/spec/fixtures/configuration.json +0 -1
- data/spec/fixtures/contributees.json +0 -1
- data/spec/fixtures/count.json +0 -1
- data/spec/fixtures/direct_message.json +0 -1
- data/spec/fixtures/direct_messages.json +0 -1
- data/spec/fixtures/empty.json +0 -0
- data/spec/fixtures/followers_list.json +0 -1
- data/spec/fixtures/followers_list2.json +0 -1
- data/spec/fixtures/following.json +0 -1
- data/spec/fixtures/forbidden.json +0 -1
- data/spec/fixtures/friends_list.json +0 -1
- data/spec/fixtures/friends_list2.json +0 -1
- data/spec/fixtures/friendships.json +0 -1
- data/spec/fixtures/ids.json +0 -1
- data/spec/fixtures/ids_list.json +0 -1
- data/spec/fixtures/ids_list2.json +0 -1
- data/spec/fixtures/languages.json +0 -1
- data/spec/fixtures/list.json +0 -1
- data/spec/fixtures/lists.json +0 -1
- data/spec/fixtures/locations.json +0 -1
- data/spec/fixtures/matching_trends.json +0 -1
- data/spec/fixtures/me.jpeg +0 -0
- data/spec/fixtures/members.json +0 -1
- data/spec/fixtures/memberships.json +0 -1
- data/spec/fixtures/memberships2.json +0 -1
- data/spec/fixtures/not_following.json +0 -1
- data/spec/fixtures/not_found.json +0 -1
- data/spec/fixtures/oembed.json +0 -1
- data/spec/fixtures/ownerships.json +0 -1
- data/spec/fixtures/pbjt.gif +0 -0
- data/spec/fixtures/pengwynn.json +0 -1
- data/spec/fixtures/place.json +0 -1
- data/spec/fixtures/places.json +0 -1
- data/spec/fixtures/privacy.json +0 -1
- data/spec/fixtures/profile_banner.json +0 -1
- data/spec/fixtures/request_token.txt +0 -6
- data/spec/fixtures/retweet.json +0 -1
- data/spec/fixtures/retweets.json +0 -1
- data/spec/fixtures/saved_search.json +0 -1
- data/spec/fixtures/saved_searches.json +0 -1
- data/spec/fixtures/search.json +0 -1
- data/spec/fixtures/search2.json +0 -1
- data/spec/fixtures/search_malformed.json +0 -1
- data/spec/fixtures/settings.json +0 -1
- data/spec/fixtures/sferik.json +0 -1
- data/spec/fixtures/status.json +0 -1
- data/spec/fixtures/statuses.json +0 -1
- data/spec/fixtures/subscriptions.json +0 -1
- data/spec/fixtures/subscriptions2.json +0 -1
- data/spec/fixtures/suggestions.json +0 -1
- data/spec/fixtures/tos.json +0 -1
- data/spec/fixtures/track_streaming.json +0 -3
- data/spec/fixtures/track_streaming_user.json +0 -6
- data/spec/fixtures/upload.json +0 -1
- data/spec/fixtures/user_search.json +0 -1
- data/spec/fixtures/user_timeline.json +0 -1
- data/spec/fixtures/users.json +0 -1
- data/spec/fixtures/users_list.json +0 -1
- data/spec/fixtures/users_list2.json +0 -1
- data/spec/fixtures/we_concept_bg2.png +0 -0
- data/spec/fixtures/wildcomet2.jpe +0 -0
- data/spec/helper.rb +0 -68
- data/spec/twitter/base_spec.rb +0 -39
- data/spec/twitter/basic_user_spec.rb +0 -23
- data/spec/twitter/configuration_spec.rb +0 -17
- data/spec/twitter/cursor_spec.rb +0 -30
- data/spec/twitter/direct_message_spec.rb +0 -232
- data/spec/twitter/entity/uri_spec.rb +0 -75
- data/spec/twitter/error_spec.rb +0 -52
- data/spec/twitter/geo/point_spec.rb +0 -41
- data/spec/twitter/geo/polygon_spec.rb +0 -29
- data/spec/twitter/geo_factory_spec.rb +0 -19
- data/spec/twitter/geo_results_spec.rb +0 -35
- data/spec/twitter/geo_spec.rb +0 -29
- data/spec/twitter/identifiable_spec.rb +0 -29
- data/spec/twitter/list_spec.rb +0 -88
- data/spec/twitter/media/photo_spec.rb +0 -151
- data/spec/twitter/media_factory_spec.rb +0 -15
- data/spec/twitter/oembed_spec.rb +0 -170
- data/spec/twitter/place_spec.rb +0 -168
- data/spec/twitter/profile_banner_spec.rb +0 -13
- data/spec/twitter/rate_limit_spec.rb +0 -59
- data/spec/twitter/relationship_spec.rb +0 -49
- data/spec/twitter/rest/client_spec.rb +0 -217
- data/spec/twitter/rest/direct_messages_spec.rb +0 -133
- data/spec/twitter/rest/favorites_spec.rb +0 -188
- data/spec/twitter/rest/friends_and_followers_spec.rb +0 -667
- data/spec/twitter/rest/geo_spec.rb +0 -68
- data/spec/twitter/rest/help_spec.rb +0 -68
- data/spec/twitter/rest/lists_spec.rb +0 -910
- data/spec/twitter/rest/media_spec.rb +0 -54
- data/spec/twitter/rest/oauth_spec.rb +0 -63
- data/spec/twitter/rest/saved_searches_spec.rb +0 -98
- data/spec/twitter/rest/search_spec.rb +0 -42
- data/spec/twitter/rest/spam_reporting_spec.rb +0 -25
- data/spec/twitter/rest/suggested_users_spec.rb +0 -59
- data/spec/twitter/rest/timelines_spec.rb +0 -138
- data/spec/twitter/rest/trends_spec.rb +0 -68
- data/spec/twitter/rest/tweets_spec.rb +0 -614
- data/spec/twitter/rest/undocumented_spec.rb +0 -103
- data/spec/twitter/rest/users_spec.rb +0 -797
- data/spec/twitter/saved_search_spec.rb +0 -45
- data/spec/twitter/search_results_spec.rb +0 -30
- data/spec/twitter/settings_spec.rb +0 -27
- data/spec/twitter/size_spec.rb +0 -28
- data/spec/twitter/source_user_spec.rb +0 -23
- data/spec/twitter/streaming/client_spec.rb +0 -123
- data/spec/twitter/streaming/connection_spec.rb +0 -32
- data/spec/twitter/streaming/deleted_tweet_spec.rb +0 -23
- data/spec/twitter/streaming/event_spec.rb +0 -43
- data/spec/twitter/streaming/friend_list_spec.rb +0 -11
- data/spec/twitter/streaming/message_parser_spec.rb +0 -54
- data/spec/twitter/streaming/response_spec.rb +0 -21
- data/spec/twitter/suggestion_spec.rb +0 -40
- data/spec/twitter/target_user_spec.rb +0 -23
- data/spec/twitter/token_spec.rb +0 -16
- data/spec/twitter/trend_results_spec.rb +0 -89
- data/spec/twitter/trend_spec.rb +0 -51
- data/spec/twitter/tweet_spec.rb +0 -456
- data/spec/twitter/user_spec.rb +0 -447
- data/spec/twitter/utils_spec.rb +0 -34
@@ -1,68 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
describe Twitter::REST::Trends 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 '#trends' do
|
10
|
-
context 'with woeid passed' do
|
11
|
-
before do
|
12
|
-
stub_get('/1.1/trends/place.json').with(:query => {:id => '2487956'}).to_return(:body => fixture('matching_trends.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
13
|
-
end
|
14
|
-
it 'requests the correct resource' do
|
15
|
-
@client.trends(2_487_956)
|
16
|
-
expect(a_get('/1.1/trends/place.json').with(:query => {:id => '2487956'})).to have_been_made
|
17
|
-
end
|
18
|
-
it 'returns the top 10 trending topics for a specific WOEID' do
|
19
|
-
matching_trends = @client.trends(2_487_956)
|
20
|
-
expect(matching_trends).to be_a Twitter::TrendResults
|
21
|
-
expect(matching_trends.first).to be_a Twitter::Trend
|
22
|
-
expect(matching_trends.first.name).to eq('#sevenwordsaftersex')
|
23
|
-
end
|
24
|
-
end
|
25
|
-
context 'without arguments passed' do
|
26
|
-
before do
|
27
|
-
stub_get('/1.1/trends/place.json').with(:query => {:id => '1'}).to_return(:body => fixture('matching_trends.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
28
|
-
end
|
29
|
-
it 'requests the correct resource' do
|
30
|
-
@client.trends
|
31
|
-
expect(a_get('/1.1/trends/place.json').with(:query => {:id => '1'})).to have_been_made
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
describe '#trends_available' do
|
37
|
-
before do
|
38
|
-
stub_get('/1.1/trends/available.json').to_return(:body => fixture('locations.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
39
|
-
end
|
40
|
-
it 'requests the correct resource' do
|
41
|
-
@client.trends_available
|
42
|
-
expect(a_get('/1.1/trends/available.json')).to have_been_made
|
43
|
-
end
|
44
|
-
it 'returns the locations that Twitter has trending topic information for' do
|
45
|
-
locations = @client.trends_available
|
46
|
-
expect(locations).to be_an Array
|
47
|
-
expect(locations.first).to be_a Twitter::Place
|
48
|
-
expect(locations.first.name).to eq('Ireland')
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
describe '#trends_closest' do
|
53
|
-
before do
|
54
|
-
stub_get('/1.1/trends/closest.json').to_return(:body => fixture('locations.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
55
|
-
end
|
56
|
-
it 'requests the correct resource' do
|
57
|
-
@client.trends_closest
|
58
|
-
expect(a_get('/1.1/trends/closest.json')).to have_been_made
|
59
|
-
end
|
60
|
-
it 'returns the locations that Twitter has trending topic information for' do
|
61
|
-
locations = @client.trends_closest
|
62
|
-
expect(locations).to be_an Array
|
63
|
-
expect(locations.first).to be_a Twitter::Place
|
64
|
-
expect(locations.first.name).to eq('Ireland')
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
end
|
@@ -1,614 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
require 'helper'
|
3
|
-
|
4
|
-
describe Twitter::REST::Tweets do
|
5
|
-
|
6
|
-
before do
|
7
|
-
@client = Twitter::REST::Client.new(:consumer_key => 'CK', :consumer_secret => 'CS', :access_token => 'AT', :access_token_secret => 'AS')
|
8
|
-
end
|
9
|
-
|
10
|
-
describe '#retweets' do
|
11
|
-
before do
|
12
|
-
stub_get('/1.1/statuses/retweets/25938088801.json').to_return(:body => fixture('retweets.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
13
|
-
end
|
14
|
-
context 'with a tweet ID passed' do
|
15
|
-
it 'requests the correct resource' do
|
16
|
-
@client.retweets(25_938_088_801)
|
17
|
-
expect(a_get('/1.1/statuses/retweets/25938088801.json')).to have_been_made
|
18
|
-
end
|
19
|
-
it 'returns up to 100 of the first retweets of a given tweet' do
|
20
|
-
tweets = @client.retweets(25_938_088_801)
|
21
|
-
expect(tweets).to be_an Array
|
22
|
-
expect(tweets.first).to be_a Twitter::Tweet
|
23
|
-
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.")
|
24
|
-
end
|
25
|
-
end
|
26
|
-
context 'with a URI object passed' do
|
27
|
-
it 'requests the correct resource' do
|
28
|
-
tweet = URI.parse('https://twitter.com/sferik/status/25938088801')
|
29
|
-
@client.retweets(tweet)
|
30
|
-
expect(a_get('/1.1/statuses/retweets/25938088801.json')).to have_been_made
|
31
|
-
end
|
32
|
-
end
|
33
|
-
context 'with a URI string passed' do
|
34
|
-
it 'requests the correct resource' do
|
35
|
-
@client.retweets('https://twitter.com/sferik/status/25938088801')
|
36
|
-
expect(a_get('/1.1/statuses/retweets/25938088801.json')).to have_been_made
|
37
|
-
end
|
38
|
-
end
|
39
|
-
context 'with a Tweet passed' do
|
40
|
-
it 'requests the correct resource' do
|
41
|
-
tweet = Twitter::Tweet.new(:id => 25_938_088_801)
|
42
|
-
@client.retweets(tweet)
|
43
|
-
expect(a_get('/1.1/statuses/retweets/25938088801.json')).to have_been_made
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
describe '#retweeters_of' do
|
49
|
-
context 'with ids_only passed' do
|
50
|
-
context 'with a tweet ID passed' do
|
51
|
-
before do
|
52
|
-
stub_get('/1.1/statuses/retweets/25938088801.json').to_return(:body => fixture('retweets.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
53
|
-
end
|
54
|
-
it 'requests the correct resource' do
|
55
|
-
@client.retweeters_of(25_938_088_801, :ids_only => true)
|
56
|
-
expect(a_get('/1.1/statuses/retweets/25938088801.json')).to have_been_made
|
57
|
-
end
|
58
|
-
it 'returns an array of numeric user IDs of retweeters of a Tweet' do
|
59
|
-
ids = @client.retweeters_of(25_938_088_801, :ids_only => true)
|
60
|
-
expect(ids).to be_an Array
|
61
|
-
expect(ids.first).to eq(7_505_382)
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
context 'without ids_only passed' do
|
66
|
-
before do
|
67
|
-
stub_get('/1.1/statuses/retweets/25938088801.json').to_return(:body => fixture('retweets.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
68
|
-
end
|
69
|
-
it 'requests the correct resource' do
|
70
|
-
@client.retweeters_of(25_938_088_801)
|
71
|
-
expect(a_get('/1.1/statuses/retweets/25938088801.json')).to have_been_made
|
72
|
-
end
|
73
|
-
it 'returns an array of user of retweeters of a Tweet' do
|
74
|
-
users = @client.retweeters_of(25_938_088_801)
|
75
|
-
expect(users).to be_an Array
|
76
|
-
expect(users.first).to be_a Twitter::User
|
77
|
-
expect(users.first.id).to eq(7_505_382)
|
78
|
-
end
|
79
|
-
context 'with a URI object passed' do
|
80
|
-
it 'requests the correct resource' do
|
81
|
-
tweet = URI.parse('https://twitter.com/sferik/status/25938088801')
|
82
|
-
@client.retweeters_of(tweet)
|
83
|
-
expect(a_get('/1.1/statuses/retweets/25938088801.json')).to have_been_made
|
84
|
-
end
|
85
|
-
end
|
86
|
-
context 'with a URI string passed' do
|
87
|
-
it 'requests the correct resource' do
|
88
|
-
@client.retweeters_of('https://twitter.com/sferik/status/25938088801')
|
89
|
-
expect(a_get('/1.1/statuses/retweets/25938088801.json')).to have_been_made
|
90
|
-
end
|
91
|
-
end
|
92
|
-
context 'with a Tweet passed' do
|
93
|
-
it 'requests the correct resource' do
|
94
|
-
tweet = Twitter::Tweet.new(:id => 25_938_088_801)
|
95
|
-
@client.retweeters_of(tweet)
|
96
|
-
expect(a_get('/1.1/statuses/retweets/25938088801.json')).to have_been_made
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
describe '#status' do
|
103
|
-
before do
|
104
|
-
stub_get('/1.1/statuses/show/25938088801.json').to_return(:body => fixture('status.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
105
|
-
end
|
106
|
-
it 'requests the correct resource' do
|
107
|
-
@client.status(25_938_088_801)
|
108
|
-
expect(a_get('/1.1/statuses/show/25938088801.json')).to have_been_made
|
109
|
-
end
|
110
|
-
it 'returns a Tweet' do
|
111
|
-
tweet = @client.status(25_938_088_801)
|
112
|
-
expect(tweet).to be_a Twitter::Tweet
|
113
|
-
expect(tweet.text).to eq("\"I hope you'll keep...building bonds of friendship that will enrich your lives & enrich our world\" —FLOTUS in China, http://t.co/fxmuQN9JL9")
|
114
|
-
end
|
115
|
-
context 'with a URI object passed' do
|
116
|
-
it 'requests the correct resource' do
|
117
|
-
tweet = URI.parse('https://twitter.com/sferik/status/25938088801')
|
118
|
-
@client.status(tweet)
|
119
|
-
expect(a_get('/1.1/statuses/show/25938088801.json')).to have_been_made
|
120
|
-
end
|
121
|
-
end
|
122
|
-
context 'with a URI string passed' do
|
123
|
-
it 'requests the correct resource' do
|
124
|
-
@client.status('https://twitter.com/sferik/status/25938088801')
|
125
|
-
expect(a_get('/1.1/statuses/show/25938088801.json')).to have_been_made
|
126
|
-
end
|
127
|
-
end
|
128
|
-
context 'with a Tweet passed' do
|
129
|
-
it 'requests the correct resource' do
|
130
|
-
tweet = Twitter::Tweet.new(:id => 25_938_088_801)
|
131
|
-
@client.status(tweet)
|
132
|
-
expect(a_get('/1.1/statuses/show/25938088801.json')).to have_been_made
|
133
|
-
end
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
describe '#statuses' do
|
138
|
-
before do
|
139
|
-
stub_post('/1.1/statuses/lookup.json').with(:body => {:id => '25938088801,91151181040201728'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
140
|
-
end
|
141
|
-
it 'requests the correct resource' do
|
142
|
-
@client.statuses(25_938_088_801, 91_151_181_040_201_728)
|
143
|
-
expect(a_post('/1.1/statuses/lookup.json').with(:body => {:id => '25938088801,91151181040201728'})).to have_been_made
|
144
|
-
end
|
145
|
-
it 'returns an array of Tweets' do
|
146
|
-
tweets = @client.statuses(25_938_088_801, 91_151_181_040_201_728)
|
147
|
-
expect(tweets).to be_an Array
|
148
|
-
expect(tweets.first).to be_a Twitter::Tweet
|
149
|
-
expect(tweets.first.text).to eq('Happy Birthday @imdane. Watch out for those @rally pranksters!')
|
150
|
-
end
|
151
|
-
context 'with URI objects passed' do
|
152
|
-
it 'requests the correct resource' do
|
153
|
-
@client.statuses(URI.parse('https://twitter.com/sferik/status/25938088801'), URI.parse('https://twitter.com/sferik/status/91151181040201728'))
|
154
|
-
expect(a_post('/1.1/statuses/lookup.json').with(:body => {:id => '25938088801,91151181040201728'})).to have_been_made
|
155
|
-
end
|
156
|
-
end
|
157
|
-
context 'with URI strings passed' do
|
158
|
-
it 'requests the correct resource' do
|
159
|
-
@client.statuses('https://twitter.com/sferik/status/25938088801', 'https://twitter.com/sferik/status/91151181040201728')
|
160
|
-
expect(a_post('/1.1/statuses/lookup.json').with(:body => {:id => '25938088801,91151181040201728'})).to have_been_made
|
161
|
-
end
|
162
|
-
end
|
163
|
-
context 'with Tweets passed' do
|
164
|
-
it 'requests the correct resource' do
|
165
|
-
@client.statuses(Twitter::Tweet.new(:id => 25_938_088_801), Twitter::Tweet.new(:id => 91_151_181_040_201_728))
|
166
|
-
expect(a_post('/1.1/statuses/lookup.json').with(:body => {:id => '25938088801,91151181040201728'})).to have_been_made
|
167
|
-
end
|
168
|
-
end
|
169
|
-
end
|
170
|
-
|
171
|
-
describe '#destroy_status' do
|
172
|
-
before do
|
173
|
-
stub_post('/1.1/statuses/destroy/25938088801.json').to_return(:body => fixture('status.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
174
|
-
end
|
175
|
-
it 'requests the correct resource' do
|
176
|
-
@client.destroy_status(25_938_088_801)
|
177
|
-
expect(a_post('/1.1/statuses/destroy/25938088801.json')).to have_been_made
|
178
|
-
end
|
179
|
-
it 'returns an array of Tweets' do
|
180
|
-
tweets = @client.destroy_status(25_938_088_801)
|
181
|
-
expect(tweets).to be_an Array
|
182
|
-
expect(tweets.first).to be_a Twitter::Tweet
|
183
|
-
expect(tweets.first.text).to eq("\"I hope you'll keep...building bonds of friendship that will enrich your lives & enrich our world\" —FLOTUS in China, http://t.co/fxmuQN9JL9")
|
184
|
-
end
|
185
|
-
context 'with a URI object passed' do
|
186
|
-
it 'requests the correct resource' do
|
187
|
-
tweet = URI.parse('https://twitter.com/sferik/status/25938088801')
|
188
|
-
@client.destroy_status(tweet)
|
189
|
-
expect(a_post('/1.1/statuses/destroy/25938088801.json')).to have_been_made
|
190
|
-
end
|
191
|
-
end
|
192
|
-
context 'with a URI string passed' do
|
193
|
-
it 'requests the correct resource' do
|
194
|
-
@client.destroy_status('https://twitter.com/sferik/status/25938088801')
|
195
|
-
expect(a_post('/1.1/statuses/destroy/25938088801.json')).to have_been_made
|
196
|
-
end
|
197
|
-
end
|
198
|
-
context 'with a Tweet passed' do
|
199
|
-
it 'requests the correct resource' do
|
200
|
-
tweet = Twitter::Tweet.new(:id => 25_938_088_801)
|
201
|
-
@client.destroy_status(tweet)
|
202
|
-
expect(a_post('/1.1/statuses/destroy/25938088801.json')).to have_been_made
|
203
|
-
end
|
204
|
-
end
|
205
|
-
end
|
206
|
-
|
207
|
-
describe '#update' do
|
208
|
-
before do
|
209
|
-
stub_post('/1.1/statuses/update.json').with(:body => {:status => "\"I hope you'll keep...building bonds of friendship that will enrich your lives & enrich our world\" —FLOTUS in China, http://t.co/fxmuQN9JL9"}).to_return(:body => fixture('status.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
210
|
-
end
|
211
|
-
it 'requests the correct resource' do
|
212
|
-
@client.update("\"I hope you'll keep...building bonds of friendship that will enrich your lives & enrich our world\" —FLOTUS in China, http://t.co/fxmuQN9JL9")
|
213
|
-
expect(a_post('/1.1/statuses/update.json').with(:body => {:status => "\"I hope you'll keep...building bonds of friendship that will enrich your lives & enrich our world\" —FLOTUS in China, http://t.co/fxmuQN9JL9"})).to have_been_made
|
214
|
-
end
|
215
|
-
it 'returns a Tweet' do
|
216
|
-
tweet = @client.update("\"I hope you'll keep...building bonds of friendship that will enrich your lives & enrich our world\" —FLOTUS in China, http://t.co/fxmuQN9JL9")
|
217
|
-
expect(tweet).to be_a Twitter::Tweet
|
218
|
-
expect(tweet.text).to eq("\"I hope you'll keep...building bonds of friendship that will enrich your lives & enrich our world\" —FLOTUS in China, http://t.co/fxmuQN9JL9")
|
219
|
-
end
|
220
|
-
context 'already posted' do
|
221
|
-
before do
|
222
|
-
stub_post('/1.1/statuses/update.json').to_return(:status => 403, :body => fixture('already_posted.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
223
|
-
stub_get('/1.1/statuses/user_timeline.json').with(:query => {:count => 1}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
224
|
-
end
|
225
|
-
it 'requests the correct resources' do
|
226
|
-
@client.update("\"I hope you'll keep...building bonds of friendship that will enrich your lives & enrich our world\" —FLOTUS in China, http://t.co/fxmuQN9JL9")
|
227
|
-
expect(a_post('/1.1/statuses/update.json').with(:body => {:status => "\"I hope you'll keep...building bonds of friendship that will enrich your lives & enrich our world\" —FLOTUS in China, http://t.co/fxmuQN9JL9"})).to have_been_made
|
228
|
-
expect(a_get('/1.1/statuses/user_timeline.json').with(:query => {:count => 1})).to have_been_made
|
229
|
-
end
|
230
|
-
it 'returns a Tweet' do
|
231
|
-
tweet = @client.update("\"I hope you'll keep...building bonds of friendship that will enrich your lives & enrich our world\" —FLOTUS in China, http://t.co/fxmuQN9JL9")
|
232
|
-
expect(tweet).to be_a Twitter::Tweet
|
233
|
-
expect(tweet.text).to eq('Happy Birthday @imdane. Watch out for those @rally pranksters!')
|
234
|
-
end
|
235
|
-
end
|
236
|
-
context 'with an in-reply-to status' do
|
237
|
-
before do
|
238
|
-
@tweet = Twitter::Tweet.new(:id => 1)
|
239
|
-
stub_post('/1.1/statuses/update.json').with(:body => {:status => "\"I hope you'll keep...building bonds of friendship that will enrich your lives & enrich our world\" —FLOTUS in China, http://t.co/fxmuQN9JL9", :in_reply_to_status_id => '1'}).to_return(:body => fixture('status.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
240
|
-
end
|
241
|
-
it 'requests the correct resource' do
|
242
|
-
@client.update("\"I hope you'll keep...building bonds of friendship that will enrich your lives & enrich our world\" —FLOTUS in China, http://t.co/fxmuQN9JL9", :in_reply_to_status => @tweet)
|
243
|
-
expect(a_post('/1.1/statuses/update.json').with(:body => {:status => "\"I hope you'll keep...building bonds of friendship that will enrich your lives & enrich our world\" —FLOTUS in China, http://t.co/fxmuQN9JL9", :in_reply_to_status_id => '1'})).to have_been_made
|
244
|
-
end
|
245
|
-
end
|
246
|
-
context 'with an in-reply-to status ID' do
|
247
|
-
before do
|
248
|
-
stub_post('/1.1/statuses/update.json').with(:body => {:status => "\"I hope you'll keep...building bonds of friendship that will enrich your lives & enrich our world\" —FLOTUS in China, http://t.co/fxmuQN9JL9", :in_reply_to_status_id => '1'}).to_return(:body => fixture('status.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
249
|
-
end
|
250
|
-
it 'requests the correct resource' do
|
251
|
-
@client.update("\"I hope you'll keep...building bonds of friendship that will enrich your lives & enrich our world\" —FLOTUS in China, http://t.co/fxmuQN9JL9", :in_reply_to_status_id => 1)
|
252
|
-
expect(a_post('/1.1/statuses/update.json').with(:body => {:status => "\"I hope you'll keep...building bonds of friendship that will enrich your lives & enrich our world\" —FLOTUS in China, http://t.co/fxmuQN9JL9", :in_reply_to_status_id => '1'})).to have_been_made
|
253
|
-
end
|
254
|
-
end
|
255
|
-
context 'with a place' do
|
256
|
-
before do
|
257
|
-
@place = Twitter::Place.new(:woeid => 'df51dec6f4ee2b2c')
|
258
|
-
stub_post('/1.1/statuses/update.json').with(:body => {:status => "\"I hope you'll keep...building bonds of friendship that will enrich your lives & enrich our world\" —FLOTUS in China, http://t.co/fxmuQN9JL9", :place_id => 'df51dec6f4ee2b2c'}).to_return(:body => fixture('status.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
259
|
-
end
|
260
|
-
it 'requests the correct resource' do
|
261
|
-
@client.update("\"I hope you'll keep...building bonds of friendship that will enrich your lives & enrich our world\" —FLOTUS in China, http://t.co/fxmuQN9JL9", :place => @place)
|
262
|
-
expect(a_post('/1.1/statuses/update.json').with(:body => {:status => "\"I hope you'll keep...building bonds of friendship that will enrich your lives & enrich our world\" —FLOTUS in China, http://t.co/fxmuQN9JL9", :place_id => 'df51dec6f4ee2b2c'})).to have_been_made
|
263
|
-
end
|
264
|
-
end
|
265
|
-
context 'with a place ID' do
|
266
|
-
before do
|
267
|
-
stub_post('/1.1/statuses/update.json').with(:body => {:status => "\"I hope you'll keep...building bonds of friendship that will enrich your lives & enrich our world\" —FLOTUS in China, http://t.co/fxmuQN9JL9", :place_id => 'df51dec6f4ee2b2c'}).to_return(:body => fixture('status.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
268
|
-
end
|
269
|
-
it 'requests the correct resource' do
|
270
|
-
@client.update("\"I hope you'll keep...building bonds of friendship that will enrich your lives & enrich our world\" —FLOTUS in China, http://t.co/fxmuQN9JL9", :place_id => 'df51dec6f4ee2b2c')
|
271
|
-
expect(a_post('/1.1/statuses/update.json').with(:body => {:status => "\"I hope you'll keep...building bonds of friendship that will enrich your lives & enrich our world\" —FLOTUS in China, http://t.co/fxmuQN9JL9", :place_id => 'df51dec6f4ee2b2c'})).to have_been_made
|
272
|
-
end
|
273
|
-
end
|
274
|
-
end
|
275
|
-
|
276
|
-
describe '#update!' do
|
277
|
-
before do
|
278
|
-
stub_post('/1.1/statuses/update.json').with(:body => {:status => "\"I hope you'll keep...building bonds of friendship that will enrich your lives & enrich our world\" —FLOTUS in China, http://t.co/fxmuQN9JL9"}).to_return(:body => fixture('status.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
279
|
-
end
|
280
|
-
it 'requests the correct resource' do
|
281
|
-
@client.update!("\"I hope you'll keep...building bonds of friendship that will enrich your lives & enrich our world\" —FLOTUS in China, http://t.co/fxmuQN9JL9")
|
282
|
-
expect(a_post('/1.1/statuses/update.json').with(:body => {:status => "\"I hope you'll keep...building bonds of friendship that will enrich your lives & enrich our world\" —FLOTUS in China, http://t.co/fxmuQN9JL9"})).to have_been_made
|
283
|
-
end
|
284
|
-
it 'returns a Tweet' do
|
285
|
-
tweet = @client.update!("\"I hope you'll keep...building bonds of friendship that will enrich your lives & enrich our world\" —FLOTUS in China, http://t.co/fxmuQN9JL9")
|
286
|
-
expect(tweet).to be_a Twitter::Tweet
|
287
|
-
expect(tweet.text).to eq("\"I hope you'll keep...building bonds of friendship that will enrich your lives & enrich our world\" —FLOTUS in China, http://t.co/fxmuQN9JL9")
|
288
|
-
end
|
289
|
-
context 'already posted' do
|
290
|
-
before do
|
291
|
-
stub_post('/1.1/statuses/update.json').to_return(:status => 403, :body => fixture('already_posted.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
292
|
-
end
|
293
|
-
it 'raises an DuplicateStatus error' do
|
294
|
-
expect { @client.update!("\"I hope you'll keep...building bonds of friendship that will enrich your lives & enrich our world\" —FLOTUS in China, http://t.co/fxmuQN9JL9") }.to raise_error(Twitter::Error::DuplicateStatus)
|
295
|
-
end
|
296
|
-
end
|
297
|
-
context 'with an in-reply-to status' do
|
298
|
-
before do
|
299
|
-
@tweet = Twitter::Tweet.new(:id => 1)
|
300
|
-
stub_post('/1.1/statuses/update.json').with(:body => {:status => "\"I hope you'll keep...building bonds of friendship that will enrich your lives & enrich our world\" —FLOTUS in China, http://t.co/fxmuQN9JL9", :in_reply_to_status_id => '1'}).to_return(:body => fixture('status.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
301
|
-
end
|
302
|
-
it 'requests the correct resource' do
|
303
|
-
@client.update!("\"I hope you'll keep...building bonds of friendship that will enrich your lives & enrich our world\" —FLOTUS in China, http://t.co/fxmuQN9JL9", :in_reply_to_status => @tweet)
|
304
|
-
expect(a_post('/1.1/statuses/update.json').with(:body => {:status => "\"I hope you'll keep...building bonds of friendship that will enrich your lives & enrich our world\" —FLOTUS in China, http://t.co/fxmuQN9JL9", :in_reply_to_status_id => '1'})).to have_been_made
|
305
|
-
end
|
306
|
-
end
|
307
|
-
context 'with an in-reply-to status ID' do
|
308
|
-
before do
|
309
|
-
stub_post('/1.1/statuses/update.json').with(:body => {:status => "\"I hope you'll keep...building bonds of friendship that will enrich your lives & enrich our world\" —FLOTUS in China, http://t.co/fxmuQN9JL9", :in_reply_to_status_id => '1'}).to_return(:body => fixture('status.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
310
|
-
end
|
311
|
-
it 'requests the correct resource' do
|
312
|
-
@client.update!("\"I hope you'll keep...building bonds of friendship that will enrich your lives & enrich our world\" —FLOTUS in China, http://t.co/fxmuQN9JL9", :in_reply_to_status_id => 1)
|
313
|
-
expect(a_post('/1.1/statuses/update.json').with(:body => {:status => "\"I hope you'll keep...building bonds of friendship that will enrich your lives & enrich our world\" —FLOTUS in China, http://t.co/fxmuQN9JL9", :in_reply_to_status_id => '1'})).to have_been_made
|
314
|
-
end
|
315
|
-
end
|
316
|
-
context 'with a place' do
|
317
|
-
before do
|
318
|
-
@place = Twitter::Place.new(:woeid => 'df51dec6f4ee2b2c')
|
319
|
-
stub_post('/1.1/statuses/update.json').with(:body => {:status => "\"I hope you'll keep...building bonds of friendship that will enrich your lives & enrich our world\" —FLOTUS in China, http://t.co/fxmuQN9JL9", :place_id => 'df51dec6f4ee2b2c'}).to_return(:body => fixture('status.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
320
|
-
end
|
321
|
-
it 'requests the correct resource' do
|
322
|
-
@client.update!("\"I hope you'll keep...building bonds of friendship that will enrich your lives & enrich our world\" —FLOTUS in China, http://t.co/fxmuQN9JL9", :place => @place)
|
323
|
-
expect(a_post('/1.1/statuses/update.json').with(:body => {:status => "\"I hope you'll keep...building bonds of friendship that will enrich your lives & enrich our world\" —FLOTUS in China, http://t.co/fxmuQN9JL9", :place_id => 'df51dec6f4ee2b2c'})).to have_been_made
|
324
|
-
end
|
325
|
-
end
|
326
|
-
context 'with a place ID' do
|
327
|
-
before do
|
328
|
-
stub_post('/1.1/statuses/update.json').with(:body => {:status => "\"I hope you'll keep...building bonds of friendship that will enrich your lives & enrich our world\" —FLOTUS in China, http://t.co/fxmuQN9JL9", :place_id => 'df51dec6f4ee2b2c'}).to_return(:body => fixture('status.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
329
|
-
end
|
330
|
-
it 'requests the correct resource' do
|
331
|
-
@client.update!("\"I hope you'll keep...building bonds of friendship that will enrich your lives & enrich our world\" —FLOTUS in China, http://t.co/fxmuQN9JL9", :place_id => 'df51dec6f4ee2b2c')
|
332
|
-
expect(a_post('/1.1/statuses/update.json').with(:body => {:status => "\"I hope you'll keep...building bonds of friendship that will enrich your lives & enrich our world\" —FLOTUS in China, http://t.co/fxmuQN9JL9", :place_id => 'df51dec6f4ee2b2c'})).to have_been_made
|
333
|
-
end
|
334
|
-
end
|
335
|
-
end
|
336
|
-
|
337
|
-
describe '#retweet' do
|
338
|
-
before do
|
339
|
-
stub_post('/1.1/statuses/retweet/25938088801.json').to_return(:body => fixture('retweet.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
340
|
-
end
|
341
|
-
it 'requests the correct resource' do
|
342
|
-
@client.retweet(25_938_088_801)
|
343
|
-
expect(a_post('/1.1/statuses/retweet/25938088801.json')).to have_been_made
|
344
|
-
end
|
345
|
-
it 'returns an array of Tweets with retweet details embedded' do
|
346
|
-
tweets = @client.retweet(25_938_088_801)
|
347
|
-
expect(tweets).to be_an Array
|
348
|
-
expect(tweets.first).to be_a Twitter::Tweet
|
349
|
-
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.")
|
350
|
-
expect(tweets.first.retweeted_tweet.text).to eq("As for the Series, I'm for the Giants. Fuck Texas, fuck Nolan Ryan, fuck George Bush.")
|
351
|
-
expect(tweets.first.retweeted_tweet.id).not_to eq(tweets.first.id)
|
352
|
-
end
|
353
|
-
context 'already retweeted' do
|
354
|
-
before do
|
355
|
-
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'})
|
356
|
-
end
|
357
|
-
it 'does not raise an error' do
|
358
|
-
expect { @client.retweet(25_938_088_801) }.not_to raise_error
|
359
|
-
end
|
360
|
-
end
|
361
|
-
context 'with a URI object passed' do
|
362
|
-
it 'requests the correct resource' do
|
363
|
-
tweet = URI.parse('https://twitter.com/sferik/status/25938088801')
|
364
|
-
@client.retweet(tweet)
|
365
|
-
expect(a_post('/1.1/statuses/retweet/25938088801.json')).to have_been_made
|
366
|
-
end
|
367
|
-
end
|
368
|
-
context 'with a URI string passed' do
|
369
|
-
it 'requests the correct resource' do
|
370
|
-
@client.retweet('https://twitter.com/sferik/status/25938088801')
|
371
|
-
expect(a_post('/1.1/statuses/retweet/25938088801.json')).to have_been_made
|
372
|
-
end
|
373
|
-
end
|
374
|
-
context 'with a Tweet passed' do
|
375
|
-
it 'requests the correct resource' do
|
376
|
-
tweet = Twitter::Tweet.new(:id => 25_938_088_801)
|
377
|
-
@client.retweet(tweet)
|
378
|
-
expect(a_post('/1.1/statuses/retweet/25938088801.json')).to have_been_made
|
379
|
-
end
|
380
|
-
end
|
381
|
-
end
|
382
|
-
|
383
|
-
describe '#retweet!' do
|
384
|
-
before do
|
385
|
-
stub_post('/1.1/statuses/retweet/25938088801.json').to_return(:body => fixture('retweet.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
386
|
-
end
|
387
|
-
it 'requests the correct resource' do
|
388
|
-
@client.retweet!(25_938_088_801)
|
389
|
-
expect(a_post('/1.1/statuses/retweet/25938088801.json')).to have_been_made
|
390
|
-
end
|
391
|
-
it 'returns an array of Tweets with retweet details embedded' do
|
392
|
-
tweets = @client.retweet!(25_938_088_801)
|
393
|
-
expect(tweets).to be_an Array
|
394
|
-
expect(tweets.first).to be_a Twitter::Tweet
|
395
|
-
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.")
|
396
|
-
expect(tweets.first.retweeted_tweet.text).to eq("As for the Series, I'm for the Giants. Fuck Texas, fuck Nolan Ryan, fuck George Bush.")
|
397
|
-
expect(tweets.first.retweeted_tweet.id).not_to eq(tweets.first.id)
|
398
|
-
end
|
399
|
-
context 'forbidden' do
|
400
|
-
before do
|
401
|
-
stub_post('/1.1/statuses/retweet/25938088801.json').to_return(:status => 403, :headers => {:content_type => 'application/json; charset=utf-8'})
|
402
|
-
end
|
403
|
-
it 'raises a Forbidden error' do
|
404
|
-
expect { @client.retweet!(25_938_088_801) }.to raise_error(Twitter::Error::Forbidden)
|
405
|
-
end
|
406
|
-
end
|
407
|
-
context 'already retweeted' do
|
408
|
-
before do
|
409
|
-
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'})
|
410
|
-
end
|
411
|
-
it 'raises an AlreadyRetweeted error' do
|
412
|
-
expect { @client.retweet!(25_938_088_801) }.to raise_error(Twitter::Error::AlreadyRetweeted)
|
413
|
-
end
|
414
|
-
end
|
415
|
-
context 'with a URI object passed' do
|
416
|
-
it 'requests the correct resource' do
|
417
|
-
tweet = URI.parse('https://twitter.com/sferik/status/25938088801')
|
418
|
-
@client.retweet!(tweet)
|
419
|
-
expect(a_post('/1.1/statuses/retweet/25938088801.json')).to have_been_made
|
420
|
-
end
|
421
|
-
end
|
422
|
-
context 'with a URI string passed' do
|
423
|
-
it 'requests the correct resource' do
|
424
|
-
@client.retweet!('https://twitter.com/sferik/status/25938088801')
|
425
|
-
expect(a_post('/1.1/statuses/retweet/25938088801.json')).to have_been_made
|
426
|
-
end
|
427
|
-
end
|
428
|
-
context 'with a Tweet passed' do
|
429
|
-
it 'requests the correct resource' do
|
430
|
-
tweet = Twitter::Tweet.new(:id => 25_938_088_801)
|
431
|
-
@client.retweet!(tweet)
|
432
|
-
expect(a_post('/1.1/statuses/retweet/25938088801.json')).to have_been_made
|
433
|
-
end
|
434
|
-
end
|
435
|
-
end
|
436
|
-
|
437
|
-
describe '#update_with_media' do
|
438
|
-
before do
|
439
|
-
stub_post('/1.1/statuses/update_with_media.json').to_return(:body => fixture('status.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
440
|
-
end
|
441
|
-
context 'a gif image' do
|
442
|
-
it 'requests the correct resource' do
|
443
|
-
@client.update_with_media("\"I hope you'll keep...building bonds of friendship that will enrich your lives & enrich our world\" —FLOTUS in China, http://t.co/fxmuQN9JL9", fixture('pbjt.gif'))
|
444
|
-
expect(a_post('/1.1/statuses/update_with_media.json')).to have_been_made
|
445
|
-
end
|
446
|
-
it 'returns a Tweet' do
|
447
|
-
tweet = @client.update_with_media("\"I hope you'll keep...building bonds of friendship that will enrich your lives & enrich our world\" —FLOTUS in China, http://t.co/fxmuQN9JL9", fixture('pbjt.gif'))
|
448
|
-
expect(tweet).to be_a Twitter::Tweet
|
449
|
-
expect(tweet.text).to eq("\"I hope you'll keep...building bonds of friendship that will enrich your lives & enrich our world\" —FLOTUS in China, http://t.co/fxmuQN9JL9")
|
450
|
-
end
|
451
|
-
end
|
452
|
-
context 'a jpe image' do
|
453
|
-
it 'requests the correct resource' do
|
454
|
-
@client.update_with_media('You always have options', fixture('wildcomet2.jpe'))
|
455
|
-
expect(a_post('/1.1/statuses/update_with_media.json')).to have_been_made
|
456
|
-
end
|
457
|
-
end
|
458
|
-
context 'a jpeg image' do
|
459
|
-
it 'requests the correct resource' do
|
460
|
-
@client.update_with_media('You always have options', fixture('me.jpeg'))
|
461
|
-
expect(a_post('/1.1/statuses/update_with_media.json')).to have_been_made
|
462
|
-
end
|
463
|
-
end
|
464
|
-
context 'a png image' do
|
465
|
-
it 'requests the correct resource' do
|
466
|
-
@client.update_with_media('You always have options', fixture('we_concept_bg2.png'))
|
467
|
-
expect(a_post('/1.1/statuses/update_with_media.json')).to have_been_made
|
468
|
-
end
|
469
|
-
end
|
470
|
-
context 'a Tempfile' do
|
471
|
-
it 'requests the correct resource' do
|
472
|
-
@client.update_with_media('You always have options', Tempfile.new('tmp'))
|
473
|
-
expect(a_post('/1.1/statuses/update_with_media.json')).to have_been_made
|
474
|
-
end
|
475
|
-
end
|
476
|
-
context 'A non IO object' do
|
477
|
-
it 'raises an error' do
|
478
|
-
expect { @client.update_with_media('You always have options', 'Unacceptable IO') }.to raise_error(Twitter::Error::UnacceptableIO)
|
479
|
-
end
|
480
|
-
end
|
481
|
-
context 'already posted' do
|
482
|
-
before do
|
483
|
-
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'})
|
484
|
-
end
|
485
|
-
it 'raises an DuplicateStatus error' do
|
486
|
-
expect { @client.update_with_media("\"I hope you'll keep...building bonds of friendship that will enrich your lives & enrich our world\" —FLOTUS in China, http://t.co/fxmuQN9JL9", fixture('pbjt.gif')) }.to raise_error(Twitter::Error::DuplicateStatus)
|
487
|
-
end
|
488
|
-
end
|
489
|
-
end
|
490
|
-
|
491
|
-
describe '#oembed' do
|
492
|
-
before do
|
493
|
-
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'})
|
494
|
-
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'})
|
495
|
-
end
|
496
|
-
it 'requests the correct resource' do
|
497
|
-
@client.oembed(25_938_088_801)
|
498
|
-
expect(a_get('/1.1/statuses/oembed.json').with(:query => {:id => '25938088801'})).to have_been_made
|
499
|
-
end
|
500
|
-
it 'requests the correct resource when a URL is given' do
|
501
|
-
@client.oembed('https://twitter.com/sferik/status/25938088801')
|
502
|
-
expect(a_get('/1.1/statuses/oembed.json').with(:query => {:url => 'https://twitter.com/sferik/status/25938088801'}))
|
503
|
-
end
|
504
|
-
it 'returns an array of OEmbed instances' do
|
505
|
-
oembed = @client.oembed(25_938_088_801)
|
506
|
-
expect(oembed).to be_a Twitter::OEmbed
|
507
|
-
end
|
508
|
-
context 'with a URI object passed' do
|
509
|
-
it 'requests the correct resource' do
|
510
|
-
tweet = URI.parse('https://twitter.com/sferik/status/25938088801')
|
511
|
-
@client.oembed(tweet)
|
512
|
-
expect(a_get('/1.1/statuses/oembed.json').with(:query => {:id => '25938088801'})).to have_been_made
|
513
|
-
end
|
514
|
-
end
|
515
|
-
context 'with a URI string passed' do
|
516
|
-
it 'requests the correct resource' do
|
517
|
-
@client.oembed('https://twitter.com/sferik/status/25938088801')
|
518
|
-
expect(a_get('/1.1/statuses/oembed.json').with(:query => {:id => '25938088801'})).to have_been_made
|
519
|
-
end
|
520
|
-
end
|
521
|
-
context 'with a Tweet passed' do
|
522
|
-
it 'requests the correct resource' do
|
523
|
-
tweet = Twitter::Tweet.new(:id => 25_938_088_801)
|
524
|
-
@client.oembed(tweet)
|
525
|
-
expect(a_get('/1.1/statuses/oembed.json').with(:query => {:id => '25938088801'})).to have_been_made
|
526
|
-
end
|
527
|
-
end
|
528
|
-
end
|
529
|
-
|
530
|
-
describe '#oembeds' do
|
531
|
-
before do
|
532
|
-
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'})
|
533
|
-
end
|
534
|
-
it 'requests the correct resource' do
|
535
|
-
@client.oembeds(25_938_088_801)
|
536
|
-
expect(a_get('/1.1/statuses/oembed.json').with(:query => {:id => '25938088801'})).to have_been_made
|
537
|
-
end
|
538
|
-
it 'requests the correct resource when a URL is given' do
|
539
|
-
@client.oembeds('https://twitter.com/sferik/status/25938088801')
|
540
|
-
expect(a_get('/1.1/statuses/oembed.json').with(:query => {:id => '25938088801'})).to have_been_made
|
541
|
-
end
|
542
|
-
it 'returns an array of OEmbed instances' do
|
543
|
-
oembeds = @client.oembeds(25_938_088_801)
|
544
|
-
expect(oembeds).to be_an Array
|
545
|
-
expect(oembeds.first).to be_a Twitter::OEmbed
|
546
|
-
end
|
547
|
-
context 'with a URI object passed' do
|
548
|
-
it 'requests the correct resource' do
|
549
|
-
tweet = URI.parse('https://twitter.com/sferik/status/25938088801')
|
550
|
-
@client.oembeds(tweet)
|
551
|
-
expect(a_get('/1.1/statuses/oembed.json').with(:query => {:id => '25938088801'})).to have_been_made
|
552
|
-
end
|
553
|
-
end
|
554
|
-
context 'with a URI string passed' do
|
555
|
-
it 'requests the correct resource' do
|
556
|
-
@client.oembeds('https://twitter.com/sferik/status/25938088801')
|
557
|
-
expect(a_get('/1.1/statuses/oembed.json').with(:query => {:id => '25938088801'})).to have_been_made
|
558
|
-
end
|
559
|
-
end
|
560
|
-
context 'with a Tweet passed' do
|
561
|
-
it 'requests the correct resource' do
|
562
|
-
tweet = Twitter::Tweet.new(:id => 25_938_088_801)
|
563
|
-
@client.oembeds(tweet)
|
564
|
-
expect(a_get('/1.1/statuses/oembed.json').with(:query => {:id => '25938088801'})).to have_been_made
|
565
|
-
end
|
566
|
-
end
|
567
|
-
end
|
568
|
-
|
569
|
-
describe '#retweeters_ids' do
|
570
|
-
before do
|
571
|
-
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'})
|
572
|
-
end
|
573
|
-
it 'requests the correct resource' do
|
574
|
-
@client.retweeters_ids(25_938_088_801)
|
575
|
-
expect(a_get('/1.1/statuses/retweeters/ids.json').with(:query => {:id => '25938088801', :cursor => '-1'})).to have_been_made
|
576
|
-
end
|
577
|
-
it 'returns a collection of up to 100 user IDs belonging to users who have retweeted the tweet specified by the id parameter' do
|
578
|
-
retweeters_ids = @client.retweeters_ids(25_938_088_801)
|
579
|
-
expect(retweeters_ids).to be_a Twitter::Cursor
|
580
|
-
expect(retweeters_ids.first).to eq(20_009_713)
|
581
|
-
end
|
582
|
-
context 'with each' do
|
583
|
-
before do
|
584
|
-
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'})
|
585
|
-
end
|
586
|
-
it 'requests the correct resource' do
|
587
|
-
@client.retweeters_ids(25_938_088_801).each {}
|
588
|
-
expect(a_get('/1.1/statuses/retweeters/ids.json').with(:query => {:id => '25938088801', :cursor => '-1'})).to have_been_made
|
589
|
-
expect(a_get('/1.1/statuses/retweeters/ids.json').with(:query => {:id => '25938088801', :cursor => '1305102810874389703'})).to have_been_made
|
590
|
-
end
|
591
|
-
end
|
592
|
-
context 'with a URI object passed' do
|
593
|
-
it 'requests the correct resource' do
|
594
|
-
tweet = URI.parse('https://twitter.com/sferik/status/25938088801')
|
595
|
-
@client.retweeters_ids(tweet)
|
596
|
-
expect(a_get('/1.1/statuses/retweeters/ids.json').with(:query => {:id => '25938088801', :cursor => '-1'})).to have_been_made
|
597
|
-
end
|
598
|
-
end
|
599
|
-
context 'with a URI string passed' do
|
600
|
-
it 'requests the correct resource' do
|
601
|
-
@client.retweeters_ids('https://twitter.com/sferik/status/25938088801')
|
602
|
-
expect(a_get('/1.1/statuses/retweeters/ids.json').with(:query => {:id => '25938088801', :cursor => '-1'})).to have_been_made
|
603
|
-
end
|
604
|
-
end
|
605
|
-
context 'with a Tweet passed' do
|
606
|
-
it 'requests the correct resource' do
|
607
|
-
tweet = Twitter::Tweet.new(:id => 25_938_088_801)
|
608
|
-
@client.retweeters_ids(tweet)
|
609
|
-
expect(a_get('/1.1/statuses/retweeters/ids.json').with(:query => {:id => '25938088801', :cursor => '-1'})).to have_been_made
|
610
|
-
end
|
611
|
-
end
|
612
|
-
end
|
613
|
-
|
614
|
-
end
|