twitter 5.1.1 → 5.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data.tar.gz.sig +0 -0
- data/.yardopts +2 -0
- data/CHANGELOG.md +10 -1
- data/CONTRIBUTING.md +2 -2
- data/README.md +30 -20
- data/Rakefile +26 -5
- data/lib/twitter/arguments.rb +0 -1
- data/lib/twitter/base.rb +13 -16
- data/lib/twitter/basic_user.rb +3 -3
- data/lib/twitter/client.rb +7 -8
- data/lib/twitter/configuration.rb +5 -5
- data/lib/twitter/core_ext/enumerable.rb +0 -2
- data/lib/twitter/core_ext/kernel.rb +0 -2
- data/lib/twitter/creatable.rb +0 -1
- data/lib/twitter/cursor.rb +7 -10
- data/lib/twitter/direct_message.rb +1 -1
- data/lib/twitter/entity/uri.rb +2 -2
- data/lib/twitter/enumerable.rb +1 -2
- data/lib/twitter/error.rb +4 -6
- 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/factory.rb +2 -6
- data/lib/twitter/geo.rb +1 -1
- data/lib/twitter/geo/point.rb +3 -5
- 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 +4 -5
- 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 +4 -5
- 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 +13 -14
- data/lib/twitter/rest/api/favorites.rb +10 -11
- data/lib/twitter/rest/api/friends_and_followers.rb +36 -36
- data/lib/twitter/rest/api/help.rb +8 -9
- data/lib/twitter/rest/api/lists.rb +62 -63
- 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 +5 -6
- data/lib/twitter/rest/api/search.rb +2 -3
- 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 +15 -16
- data/lib/twitter/rest/api/undocumented.rb +6 -7
- data/lib/twitter/rest/api/users.rb +51 -52
- data/lib/twitter/rest/api/utils.rb +23 -30
- data/lib/twitter/rest/client.rb +8 -9
- data/lib/twitter/rest/request/multipart_with_file.rb +0 -1
- data/lib/twitter/rest/response/parse_error_json.rb +0 -2
- data/lib/twitter/rest/response/parse_json.rb +0 -2
- data/lib/twitter/rest/response/raise_error.rb +1 -3
- data/lib/twitter/search_results.rb +12 -15
- 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 +71 -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 -7
- 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 +16 -24
- data/lib/twitter/user.rb +30 -32
- data/lib/twitter/version.rb +2 -5
- 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 +27 -27
- data/spec/twitter/direct_message_spec.rb +36 -36
- data/spec/twitter/entity/uri_spec.rb +27 -27
- 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 +54 -54
- data/spec/twitter/media_factory_spec.rb +5 -5
- data/spec/twitter/null_object_spec.rb +6 -6
- data/spec/twitter/oembed_spec.rb +65 -65
- data/spec/twitter/place_spec.rb +89 -60
- 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 +349 -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 +40 -40
- data/spec/twitter/rest/api/search_spec.rb +16 -16
- 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 +284 -284
- 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 +44 -44
- 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 +53 -49
- 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 +20 -20
- data/spec/twitter/tweet_spec.rb +170 -173
- data/spec/twitter/user_spec.rb +179 -179
- data/twitter.gemspec +2 -2
- metadata +21 -4
- metadata.gz.sig +2 -1
|
@@ -3,65 +3,65 @@ require 'helper'
|
|
|
3
3
|
describe Twitter::REST::API::Trends 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
|
|
10
|
-
context
|
|
9
|
+
describe '#trends' do
|
|
10
|
+
context 'with woeid passed' do
|
|
11
11
|
before do
|
|
12
|
-
stub_get(
|
|
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
13
|
end
|
|
14
|
-
it
|
|
15
|
-
@client.trends(
|
|
16
|
-
expect(a_get(
|
|
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
17
|
end
|
|
18
|
-
it
|
|
19
|
-
matching_trends = @client.trends(
|
|
18
|
+
it 'returns the top 10 trending topics for a specific WOEID' do
|
|
19
|
+
matching_trends = @client.trends(2_487_956)
|
|
20
20
|
expect(matching_trends).to be_a Twitter::TrendResults
|
|
21
21
|
expect(matching_trends.first).to be_a Twitter::Trend
|
|
22
|
-
expect(matching_trends.first.name).to eq(
|
|
22
|
+
expect(matching_trends.first.name).to eq('#sevenwordsaftersex')
|
|
23
23
|
end
|
|
24
24
|
end
|
|
25
|
-
context
|
|
25
|
+
context 'without arguments passed' do
|
|
26
26
|
before do
|
|
27
|
-
stub_get(
|
|
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
28
|
end
|
|
29
|
-
it
|
|
29
|
+
it 'requests the correct resource' do
|
|
30
30
|
@client.trends
|
|
31
|
-
expect(a_get(
|
|
31
|
+
expect(a_get('/1.1/trends/place.json').with(:query => {:id => '1'})).to have_been_made
|
|
32
32
|
end
|
|
33
33
|
end
|
|
34
34
|
end
|
|
35
35
|
|
|
36
|
-
describe
|
|
36
|
+
describe '#trends_available' do
|
|
37
37
|
before do
|
|
38
|
-
stub_get(
|
|
38
|
+
stub_get('/1.1/trends/available.json').to_return(:body => fixture('locations.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
39
39
|
end
|
|
40
|
-
it
|
|
40
|
+
it 'requests the correct resource' do
|
|
41
41
|
@client.trends_available
|
|
42
|
-
expect(a_get(
|
|
42
|
+
expect(a_get('/1.1/trends/available.json')).to have_been_made
|
|
43
43
|
end
|
|
44
|
-
it
|
|
44
|
+
it 'returns the locations that Twitter has trending topic information for' do
|
|
45
45
|
locations = @client.trends_available
|
|
46
46
|
expect(locations).to be_an Array
|
|
47
47
|
expect(locations.first).to be_a Twitter::Place
|
|
48
|
-
expect(locations.first.name).to eq(
|
|
48
|
+
expect(locations.first.name).to eq('Ireland')
|
|
49
49
|
end
|
|
50
50
|
end
|
|
51
51
|
|
|
52
|
-
describe
|
|
52
|
+
describe '#trends_closest' do
|
|
53
53
|
before do
|
|
54
|
-
stub_get(
|
|
54
|
+
stub_get('/1.1/trends/closest.json').to_return(:body => fixture('locations.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
55
55
|
end
|
|
56
|
-
it
|
|
56
|
+
it 'requests the correct resource' do
|
|
57
57
|
@client.trends_closest
|
|
58
|
-
expect(a_get(
|
|
58
|
+
expect(a_get('/1.1/trends/closest.json')).to have_been_made
|
|
59
59
|
end
|
|
60
|
-
it
|
|
60
|
+
it 'returns the locations that Twitter has trending topic information for' do
|
|
61
61
|
locations = @client.trends_closest
|
|
62
62
|
expect(locations).to be_an Array
|
|
63
63
|
expect(locations.first).to be_a Twitter::Place
|
|
64
|
-
expect(locations.first.name).to eq(
|
|
64
|
+
expect(locations.first.name).to eq('Ireland')
|
|
65
65
|
end
|
|
66
66
|
end
|
|
67
67
|
|
|
@@ -3,537 +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
227
|
end
|
|
228
228
|
end
|
|
229
|
-
context
|
|
229
|
+
context 'with an in-reply-to status' do
|
|
230
230
|
before do
|
|
231
231
|
@tweet = Twitter::Tweet.new(:id => 1)
|
|
232
|
-
stub_post(
|
|
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
233
|
end
|
|
234
|
-
it
|
|
234
|
+
it 'requests the correct resource' do
|
|
235
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(
|
|
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
237
|
end
|
|
238
238
|
end
|
|
239
|
-
context
|
|
239
|
+
context 'with an in-reply-to status ID' do
|
|
240
240
|
before do
|
|
241
|
-
stub_post(
|
|
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
242
|
end
|
|
243
|
-
it
|
|
243
|
+
it 'requests the correct resource' do
|
|
244
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(
|
|
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
246
|
end
|
|
247
247
|
end
|
|
248
|
-
context
|
|
248
|
+
context 'with a place' do
|
|
249
249
|
before do
|
|
250
|
-
@place = Twitter::Place.new(:woeid =>
|
|
251
|
-
stub_post(
|
|
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
252
|
end
|
|
253
|
-
it
|
|
253
|
+
it 'requests the correct resource' do
|
|
254
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(
|
|
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
256
|
end
|
|
257
257
|
end
|
|
258
|
-
context
|
|
258
|
+
context 'with a place ID' do
|
|
259
259
|
before do
|
|
260
|
-
stub_post(
|
|
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
261
|
end
|
|
262
|
-
it
|
|
263
|
-
@client.update("The problem with your code is that it's doing exactly what you told it to do.", :place_id =>
|
|
264
|
-
expect(a_post(
|
|
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
|
|
265
265
|
end
|
|
266
266
|
end
|
|
267
267
|
end
|
|
268
268
|
|
|
269
|
-
describe
|
|
269
|
+
describe '#retweet' do
|
|
270
270
|
before do
|
|
271
|
-
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'})
|
|
272
272
|
end
|
|
273
|
-
it
|
|
274
|
-
@client.retweet(
|
|
275
|
-
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
|
|
276
276
|
end
|
|
277
|
-
it
|
|
278
|
-
tweets = @client.retweet(
|
|
277
|
+
it 'returns an array of Tweets with retweet details embedded' do
|
|
278
|
+
tweets = @client.retweet(25_938_088_801)
|
|
279
279
|
expect(tweets).to be_an Array
|
|
280
280
|
expect(tweets.first).to be_a Twitter::Tweet
|
|
281
281
|
expect(tweets.first.text).to eq("As for the Series, I'm for the Giants. Fuck Texas, fuck Nolan Ryan, fuck George Bush.")
|
|
282
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.")
|
|
283
283
|
expect(tweets.first.retweeted_tweet.id).not_to eq(tweets.first.id)
|
|
284
284
|
end
|
|
285
|
-
context
|
|
285
|
+
context 'already retweeted' do
|
|
286
286
|
before do
|
|
287
|
-
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'})
|
|
288
288
|
end
|
|
289
|
-
it
|
|
290
|
-
expect{@client.retweet(
|
|
289
|
+
it 'does not raise an error' do
|
|
290
|
+
expect { @client.retweet(25_938_088_801) }.not_to raise_error
|
|
291
291
|
end
|
|
292
292
|
end
|
|
293
|
-
context
|
|
294
|
-
it
|
|
295
|
-
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')
|
|
296
296
|
@client.retweet(tweet)
|
|
297
|
-
expect(a_post(
|
|
297
|
+
expect(a_post('/1.1/statuses/retweet/25938088801.json')).to have_been_made
|
|
298
298
|
end
|
|
299
299
|
end
|
|
300
|
-
context
|
|
301
|
-
it
|
|
302
|
-
@client.retweet(
|
|
303
|
-
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
|
|
304
304
|
end
|
|
305
305
|
end
|
|
306
|
-
context
|
|
307
|
-
it
|
|
308
|
-
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)
|
|
309
309
|
@client.retweet(tweet)
|
|
310
|
-
expect(a_post(
|
|
310
|
+
expect(a_post('/1.1/statuses/retweet/25938088801.json')).to have_been_made
|
|
311
311
|
end
|
|
312
312
|
end
|
|
313
313
|
end
|
|
314
314
|
|
|
315
|
-
describe
|
|
315
|
+
describe '#retweet!' do
|
|
316
316
|
before do
|
|
317
|
-
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'})
|
|
318
318
|
end
|
|
319
|
-
it
|
|
320
|
-
@client.retweet!(
|
|
321
|
-
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
|
|
322
322
|
end
|
|
323
|
-
it
|
|
324
|
-
tweets = @client.retweet!(
|
|
323
|
+
it 'returns an array of Tweets with retweet details embedded' do
|
|
324
|
+
tweets = @client.retweet!(25_938_088_801)
|
|
325
325
|
expect(tweets).to be_an Array
|
|
326
326
|
expect(tweets.first).to be_a Twitter::Tweet
|
|
327
327
|
expect(tweets.first.text).to eq("As for the Series, I'm for the Giants. Fuck Texas, fuck Nolan Ryan, fuck George Bush.")
|
|
328
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.")
|
|
329
329
|
expect(tweets.first.retweeted_tweet.id).not_to eq(tweets.first.id)
|
|
330
330
|
end
|
|
331
|
-
context
|
|
331
|
+
context 'forbidden' do
|
|
332
332
|
before do
|
|
333
|
-
stub_post(
|
|
333
|
+
stub_post('/1.1/statuses/retweet/25938088801.json').to_return(:status => 403, :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
334
334
|
end
|
|
335
|
-
it
|
|
336
|
-
expect{@client.retweet!(
|
|
335
|
+
it 'raises a Forbidden error' do
|
|
336
|
+
expect { @client.retweet!(25_938_088_801) }.to raise_error Twitter::Error::Forbidden
|
|
337
337
|
end
|
|
338
338
|
end
|
|
339
|
-
context
|
|
339
|
+
context 'already retweeted' do
|
|
340
340
|
before do
|
|
341
|
-
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'})
|
|
342
342
|
end
|
|
343
|
-
it
|
|
344
|
-
expect{@client.retweet!(
|
|
343
|
+
it 'raises an AlreadyRetweeted error' do
|
|
344
|
+
expect { @client.retweet!(25_938_088_801) }.to raise_error Twitter::Error::AlreadyRetweeted
|
|
345
345
|
end
|
|
346
346
|
end
|
|
347
|
-
context
|
|
348
|
-
it
|
|
349
|
-
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')
|
|
350
350
|
@client.retweet!(tweet)
|
|
351
|
-
expect(a_post(
|
|
351
|
+
expect(a_post('/1.1/statuses/retweet/25938088801.json')).to have_been_made
|
|
352
352
|
end
|
|
353
353
|
end
|
|
354
|
-
context
|
|
355
|
-
it
|
|
356
|
-
@client.retweet!(
|
|
357
|
-
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
|
|
358
358
|
end
|
|
359
359
|
end
|
|
360
|
-
context
|
|
361
|
-
it
|
|
362
|
-
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)
|
|
363
363
|
@client.retweet!(tweet)
|
|
364
|
-
expect(a_post(
|
|
364
|
+
expect(a_post('/1.1/statuses/retweet/25938088801.json')).to have_been_made
|
|
365
365
|
end
|
|
366
366
|
end
|
|
367
367
|
end
|
|
368
368
|
|
|
369
|
-
describe
|
|
369
|
+
describe '#update_with_media' do
|
|
370
370
|
before do
|
|
371
|
-
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'})
|
|
372
372
|
end
|
|
373
|
-
context
|
|
374
|
-
it
|
|
375
|
-
@client.update_with_media("The problem with your code is that it's doing exactly what you told it to do.", fixture(
|
|
376
|
-
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
|
|
377
377
|
end
|
|
378
|
-
it
|
|
379
|
-
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'))
|
|
380
380
|
expect(tweet).to be_a Twitter::Tweet
|
|
381
381
|
expect(tweet.text).to eq("The problem with your code is that it's doing exactly what you told it to do.")
|
|
382
382
|
end
|
|
383
383
|
end
|
|
384
|
-
context
|
|
385
|
-
it
|
|
386
|
-
@client.update_with_media(
|
|
387
|
-
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
|
|
388
388
|
end
|
|
389
389
|
end
|
|
390
|
-
context
|
|
391
|
-
it
|
|
392
|
-
@client.update_with_media(
|
|
393
|
-
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
|
|
394
394
|
end
|
|
395
395
|
end
|
|
396
|
-
context
|
|
397
|
-
it
|
|
398
|
-
@client.update_with_media(
|
|
399
|
-
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
|
|
400
400
|
end
|
|
401
401
|
end
|
|
402
|
-
context
|
|
403
|
-
it
|
|
404
|
-
@client.update_with_media(
|
|
405
|
-
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
|
|
406
406
|
end
|
|
407
407
|
end
|
|
408
|
-
context
|
|
408
|
+
context 'already posted' do
|
|
409
409
|
before do
|
|
410
|
-
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'})
|
|
411
411
|
end
|
|
412
|
-
it
|
|
413
|
-
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
|
|
414
414
|
end
|
|
415
415
|
end
|
|
416
416
|
end
|
|
417
417
|
|
|
418
|
-
describe
|
|
418
|
+
describe '#oembed' do
|
|
419
419
|
before do
|
|
420
|
-
stub_get(
|
|
421
|
-
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'})
|
|
422
422
|
end
|
|
423
|
-
it
|
|
424
|
-
@client.oembed(
|
|
425
|
-
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
|
|
426
426
|
end
|
|
427
|
-
it
|
|
428
|
-
@client.oembed(
|
|
429
|
-
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'}))
|
|
430
430
|
end
|
|
431
|
-
it
|
|
432
|
-
oembed = @client.oembed(
|
|
431
|
+
it 'returns an array of OEmbed instances' do
|
|
432
|
+
oembed = @client.oembed(25_938_088_801)
|
|
433
433
|
expect(oembed).to be_a Twitter::OEmbed
|
|
434
434
|
end
|
|
435
|
-
context
|
|
436
|
-
it
|
|
437
|
-
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')
|
|
438
438
|
@client.oembed(tweet)
|
|
439
|
-
expect(a_get(
|
|
439
|
+
expect(a_get('/1.1/statuses/oembed.json').with(:query => {:id => '25938088801'})).to have_been_made
|
|
440
440
|
end
|
|
441
441
|
end
|
|
442
|
-
context
|
|
443
|
-
it
|
|
444
|
-
@client.oembed(
|
|
445
|
-
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
|
|
446
446
|
end
|
|
447
447
|
end
|
|
448
|
-
context
|
|
449
|
-
it
|
|
450
|
-
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)
|
|
451
451
|
@client.oembed(tweet)
|
|
452
|
-
expect(a_get(
|
|
452
|
+
expect(a_get('/1.1/statuses/oembed.json').with(:query => {:id => '25938088801'})).to have_been_made
|
|
453
453
|
end
|
|
454
454
|
end
|
|
455
455
|
end
|
|
456
456
|
|
|
457
|
-
describe
|
|
457
|
+
describe '#oembeds' do
|
|
458
458
|
before do
|
|
459
|
-
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'})
|
|
460
460
|
end
|
|
461
|
-
it
|
|
462
|
-
@client.oembeds(
|
|
463
|
-
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
|
|
464
464
|
end
|
|
465
|
-
it
|
|
466
|
-
@client.oembeds(
|
|
467
|
-
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
|
|
468
468
|
end
|
|
469
|
-
it
|
|
470
|
-
oembeds = @client.oembeds(
|
|
469
|
+
it 'returns an array of OEmbed instances' do
|
|
470
|
+
oembeds = @client.oembeds(25_938_088_801)
|
|
471
471
|
expect(oembeds).to be_an Array
|
|
472
472
|
expect(oembeds.first).to be_a Twitter::OEmbed
|
|
473
473
|
end
|
|
474
|
-
context
|
|
475
|
-
it
|
|
476
|
-
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')
|
|
477
477
|
@client.oembeds(tweet)
|
|
478
|
-
expect(a_get(
|
|
478
|
+
expect(a_get('/1.1/statuses/oembed.json').with(:query => {:id => '25938088801'})).to have_been_made
|
|
479
479
|
end
|
|
480
480
|
end
|
|
481
|
-
context
|
|
482
|
-
it
|
|
483
|
-
@client.oembeds(
|
|
484
|
-
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
|
|
485
485
|
end
|
|
486
486
|
end
|
|
487
|
-
context
|
|
488
|
-
it
|
|
489
|
-
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)
|
|
490
490
|
@client.oembeds(tweet)
|
|
491
|
-
expect(a_get(
|
|
491
|
+
expect(a_get('/1.1/statuses/oembed.json').with(:query => {:id => '25938088801'})).to have_been_made
|
|
492
492
|
end
|
|
493
493
|
end
|
|
494
494
|
end
|
|
495
495
|
|
|
496
|
-
describe
|
|
496
|
+
describe '#retweeters_ids' do
|
|
497
497
|
before do
|
|
498
|
-
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'})
|
|
499
499
|
end
|
|
500
|
-
it
|
|
501
|
-
@client.retweeters_ids(
|
|
502
|
-
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
|
|
503
503
|
end
|
|
504
|
-
it
|
|
505
|
-
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)
|
|
506
506
|
expect(retweeters_ids).to be_a Twitter::Cursor
|
|
507
|
-
expect(retweeters_ids.first).to eq(
|
|
507
|
+
expect(retweeters_ids.first).to eq(20_009_713)
|
|
508
508
|
end
|
|
509
|
-
context
|
|
509
|
+
context 'with each' do
|
|
510
510
|
before do
|
|
511
|
-
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'})
|
|
512
512
|
end
|
|
513
|
-
it
|
|
514
|
-
@client.retweeters_ids(
|
|
515
|
-
expect(a_get(
|
|
516
|
-
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
|
|
517
517
|
end
|
|
518
518
|
end
|
|
519
|
-
context
|
|
520
|
-
it
|
|
521
|
-
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')
|
|
522
522
|
@client.retweeters_ids(tweet)
|
|
523
|
-
expect(a_get(
|
|
523
|
+
expect(a_get('/1.1/statuses/retweeters/ids.json').with(:query => {:id => '25938088801', :cursor => '-1'})).to have_been_made
|
|
524
524
|
end
|
|
525
525
|
end
|
|
526
|
-
context
|
|
527
|
-
it
|
|
528
|
-
@client.retweeters_ids(
|
|
529
|
-
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
|
|
530
530
|
end
|
|
531
531
|
end
|
|
532
|
-
context
|
|
533
|
-
it
|
|
534
|
-
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)
|
|
535
535
|
@client.retweeters_ids(tweet)
|
|
536
|
-
expect(a_get(
|
|
536
|
+
expect(a_get('/1.1/statuses/retweeters/ids.json').with(:query => {:id => '25938088801', :cursor => '-1'})).to have_been_made
|
|
537
537
|
end
|
|
538
538
|
end
|
|
539
539
|
end
|