twitter 5.1.0 → 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/.yardopts +2 -0
- data/CHANGELOG.md +14 -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/already_favorited.rb +1 -1
- data/lib/twitter/error/already_posted.rb +1 -1
- data/lib/twitter/error/already_retweeted.rb +1 -1
- data/lib/twitter/error/too_many_requests.rb +2 -2
- data/lib/twitter/error.rb +4 -6
- data/lib/twitter/factory.rb +2 -6
- data/lib/twitter/geo/point.rb +3 -5
- data/lib/twitter/geo.rb +1 -1
- data/lib/twitter/geo_factory.rb +1 -5
- data/lib/twitter/geo_results.rb +5 -8
- data/lib/twitter/identity.rb +1 -2
- data/lib/twitter/list.rb +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 +17 -6
- data/lib/twitter/profile_banner.rb +1 -3
- data/lib/twitter/rate_limit.rb +1 -3
- data/lib/twitter/relationship.rb +1 -2
- data/lib/twitter/rest/api/direct_messages.rb +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 +1 -4
- 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
- data.tar.gz.sig +0 -0
- metadata +21 -4
- metadata.gz.sig +2 -3
|
@@ -3,99 +3,99 @@ require 'helper'
|
|
|
3
3
|
describe Twitter::REST::API::Undocumented 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 '#following_followers_of' do
|
|
10
|
+
context 'with a screen_name passed' do
|
|
11
11
|
before do
|
|
12
|
-
stub_get(
|
|
12
|
+
stub_get('/users/following_followers_of.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'}).to_return(:body => fixture('users_list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
13
13
|
end
|
|
14
|
-
it
|
|
15
|
-
@client.following_followers_of(
|
|
16
|
-
expect(a_get(
|
|
14
|
+
it 'requests the correct resource' do
|
|
15
|
+
@client.following_followers_of('sferik')
|
|
16
|
+
expect(a_get('/users/following_followers_of.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'})).to have_been_made
|
|
17
17
|
end
|
|
18
|
-
it
|
|
19
|
-
following_followers_of = @client.following_followers_of(
|
|
18
|
+
it 'returns an array of numeric IDs for every user following the specified user' do
|
|
19
|
+
following_followers_of = @client.following_followers_of('sferik')
|
|
20
20
|
expect(following_followers_of).to be_a Twitter::Cursor
|
|
21
21
|
expect(following_followers_of.first).to be_a Twitter::User
|
|
22
22
|
end
|
|
23
|
-
context
|
|
23
|
+
context 'with each' do
|
|
24
24
|
before do
|
|
25
|
-
stub_get(
|
|
25
|
+
stub_get('/users/following_followers_of.json').with(:query => {:cursor => '1322801608223717003', :screen_name => 'sferik'}).to_return(:body => fixture('users_list2.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
26
26
|
end
|
|
27
|
-
it
|
|
28
|
-
@client.following_followers_of(
|
|
29
|
-
expect(a_get(
|
|
30
|
-
expect(a_get(
|
|
27
|
+
it 'requests the correct resource' do
|
|
28
|
+
@client.following_followers_of('sferik').each {}
|
|
29
|
+
expect(a_get('/users/following_followers_of.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'})).to have_been_made
|
|
30
|
+
expect(a_get('/users/following_followers_of.json').with(:query => {:cursor => '1322801608223717003', :screen_name => 'sferik'})).to have_been_made
|
|
31
31
|
end
|
|
32
32
|
end
|
|
33
33
|
end
|
|
34
|
-
context
|
|
34
|
+
context 'with a user ID passed' do
|
|
35
35
|
before do
|
|
36
|
-
stub_get(
|
|
36
|
+
stub_get('/users/following_followers_of.json').with(:query => {:cursor => '-1', :user_id => '7505382'}).to_return(:body => fixture('users_list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
37
37
|
end
|
|
38
|
-
it
|
|
39
|
-
@client.following_followers_of(
|
|
40
|
-
expect(a_get(
|
|
38
|
+
it 'requests the correct resource' do
|
|
39
|
+
@client.following_followers_of(7_505_382)
|
|
40
|
+
expect(a_get('/users/following_followers_of.json').with(:query => {:cursor => '-1', :user_id => '7505382'})).to have_been_made
|
|
41
41
|
end
|
|
42
|
-
context
|
|
42
|
+
context 'with each' do
|
|
43
43
|
before do
|
|
44
|
-
stub_get(
|
|
44
|
+
stub_get('/users/following_followers_of.json').with(:query => {:cursor => '1322801608223717003', :user_id => '7505382'}).to_return(:body => fixture('users_list2.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
45
45
|
end
|
|
46
|
-
it
|
|
47
|
-
@client.following_followers_of(
|
|
48
|
-
expect(a_get(
|
|
49
|
-
expect(a_get(
|
|
46
|
+
it 'requests the correct resource' do
|
|
47
|
+
@client.following_followers_of(7_505_382).each {}
|
|
48
|
+
expect(a_get('/users/following_followers_of.json').with(:query => {:cursor => '-1', :user_id => '7505382'})).to have_been_made
|
|
49
|
+
expect(a_get('/users/following_followers_of.json').with(:query => {:cursor => '1322801608223717003', :user_id => '7505382'})).to have_been_made
|
|
50
50
|
end
|
|
51
51
|
end
|
|
52
52
|
end
|
|
53
|
-
context
|
|
53
|
+
context 'without arguments passed' do
|
|
54
54
|
before do
|
|
55
|
-
stub_get(
|
|
56
|
-
stub_get(
|
|
55
|
+
stub_get('/1.1/account/verify_credentials.json').to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
56
|
+
stub_get('/users/following_followers_of.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'}).to_return(:body => fixture('users_list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
57
57
|
end
|
|
58
|
-
it
|
|
58
|
+
it 'requests the correct resource' do
|
|
59
59
|
@client.following_followers_of
|
|
60
|
-
expect(a_get(
|
|
61
|
-
expect(a_get(
|
|
60
|
+
expect(a_get('/1.1/account/verify_credentials.json')).to have_been_made
|
|
61
|
+
expect(a_get('/users/following_followers_of.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'})).to have_been_made
|
|
62
62
|
end
|
|
63
|
-
it
|
|
63
|
+
it 'returns an array of numeric IDs for every user following the specified user' do
|
|
64
64
|
following_followers_of = @client.following_followers_of
|
|
65
65
|
expect(following_followers_of).to be_a Twitter::Cursor
|
|
66
66
|
expect(following_followers_of.first).to be_a Twitter::User
|
|
67
67
|
end
|
|
68
|
-
context
|
|
68
|
+
context 'with each' do
|
|
69
69
|
before do
|
|
70
|
-
stub_get(
|
|
70
|
+
stub_get('/users/following_followers_of.json').with(:query => {:cursor => '1322801608223717003', :screen_name => 'sferik'}).to_return(:body => fixture('users_list2.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
71
71
|
end
|
|
72
|
-
it
|
|
73
|
-
@client.following_followers_of.each{}
|
|
74
|
-
expect(a_get(
|
|
75
|
-
expect(a_get(
|
|
72
|
+
it 'requests the correct resource' do
|
|
73
|
+
@client.following_followers_of.each {}
|
|
74
|
+
expect(a_get('/users/following_followers_of.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'})).to have_been_made
|
|
75
|
+
expect(a_get('/users/following_followers_of.json').with(:query => {:cursor => '1322801608223717003', :screen_name => 'sferik'})).to have_been_made
|
|
76
76
|
end
|
|
77
77
|
end
|
|
78
78
|
end
|
|
79
79
|
end
|
|
80
80
|
|
|
81
|
-
describe
|
|
81
|
+
describe '#tweet_count' do
|
|
82
82
|
before do
|
|
83
|
-
stub_request(:get,
|
|
83
|
+
stub_request(:get, 'https://cdn.api.twitter.com/1/urls/count.json').with(:query => {:url => 'http://twitter.com'}).to_return(:body => fixture('count.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
84
84
|
end
|
|
85
|
-
it
|
|
86
|
-
@client.tweet_count(
|
|
87
|
-
expect(a_request(:get,
|
|
85
|
+
it 'requests the correct resource' do
|
|
86
|
+
@client.tweet_count('http://twitter.com')
|
|
87
|
+
expect(a_request(:get, 'https://cdn.api.twitter.com/1/urls/count.json').with(:query => {:url => 'http://twitter.com'})).to have_been_made
|
|
88
88
|
end
|
|
89
|
-
it
|
|
90
|
-
tweet_count = @client.tweet_count(
|
|
89
|
+
it 'returns a Tweet count' do
|
|
90
|
+
tweet_count = @client.tweet_count('http://twitter.com')
|
|
91
91
|
expect(tweet_count).to be_an Integer
|
|
92
|
-
expect(tweet_count).to eq(
|
|
92
|
+
expect(tweet_count).to eq(13_845_465)
|
|
93
93
|
end
|
|
94
|
-
context
|
|
95
|
-
it
|
|
96
|
-
uri = URI.parse(
|
|
94
|
+
context 'with a URI' do
|
|
95
|
+
it 'requests the correct resource' do
|
|
96
|
+
uri = URI.parse('http://twitter.com')
|
|
97
97
|
@client.tweet_count(uri)
|
|
98
|
-
expect(a_request(:get,
|
|
98
|
+
expect(a_request(:get, 'https://cdn.api.twitter.com/1/urls/count.json').with(:query => {:url => 'http://twitter.com'})).to have_been_made
|
|
99
99
|
end
|
|
100
100
|
end
|
|
101
101
|
end
|