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,64 +3,64 @@ require 'helper'
|
|
|
3
3
|
describe Twitter::REST::API::OAuth 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')
|
|
7
7
|
end
|
|
8
8
|
|
|
9
|
-
describe
|
|
9
|
+
describe '#token' do
|
|
10
10
|
before do
|
|
11
11
|
# WebMock treats Basic Auth differently so we have to chack against the full URL with credentials.
|
|
12
|
-
@oauth2_token_url =
|
|
13
|
-
stub_request(:post, @oauth2_token_url).with(:body =>
|
|
12
|
+
@oauth2_token_url = 'https://CK:CS@api.twitter.com/oauth2/token'
|
|
13
|
+
stub_request(:post, @oauth2_token_url).with(:body => 'grant_type=client_credentials').to_return(:body => fixture('bearer_token.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
14
14
|
end
|
|
15
|
-
it
|
|
15
|
+
it 'requests the correct resource' do
|
|
16
16
|
@client.token
|
|
17
|
-
expect(a_request(:post, @oauth2_token_url).with(:body => {:grant_type =>
|
|
17
|
+
expect(a_request(:post, @oauth2_token_url).with(:body => {:grant_type => 'client_credentials'})).to have_been_made
|
|
18
18
|
end
|
|
19
|
-
it
|
|
19
|
+
it 'requests with the correct headers' do
|
|
20
20
|
@client.token
|
|
21
|
-
expect(a_request(:post, @oauth2_token_url).with(:headers => {:content_type =>
|
|
21
|
+
expect(a_request(:post, @oauth2_token_url).with(:headers => {:content_type => 'application/x-www-form-urlencoded; charset=UTF-8', :accept => '*/*'})).to have_been_made
|
|
22
22
|
end
|
|
23
|
-
it
|
|
23
|
+
it 'returns the bearer token' do
|
|
24
24
|
bearer_token = @client.token
|
|
25
|
-
expect(bearer_token.access_token).to eq(
|
|
26
|
-
expect(bearer_token.token_type).to eq(
|
|
25
|
+
expect(bearer_token.access_token).to eq('AAAA%2FAAA%3DAAAAAAAA')
|
|
26
|
+
expect(bearer_token.token_type).to eq('bearer')
|
|
27
27
|
end
|
|
28
28
|
end
|
|
29
29
|
|
|
30
|
-
describe
|
|
30
|
+
describe '#invalidate_token' do
|
|
31
31
|
before do
|
|
32
|
-
stub_post(
|
|
33
|
-
@client.bearer_token =
|
|
32
|
+
stub_post('/oauth2/invalidate_token').with(:body => {:access_token => 'AAAA%2FAAA%3DAAAAAAAA'}).to_return(:body => '{"access_token":"AAAA%2FAAA%3DAAAAAAAA"}', :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
33
|
+
@client.bearer_token = 'AAAA%2FAAA%3DAAAAAAAA'
|
|
34
34
|
end
|
|
35
|
-
it
|
|
36
|
-
@client.invalidate_token(
|
|
37
|
-
expect(a_post(
|
|
35
|
+
it 'requests the correct resource' do
|
|
36
|
+
@client.invalidate_token('AAAA%2FAAA%3DAAAAAAAA')
|
|
37
|
+
expect(a_post('/oauth2/invalidate_token').with(:body => {:access_token => 'AAAA%2FAAA%3DAAAAAAAA'})).to have_been_made
|
|
38
38
|
end
|
|
39
|
-
it
|
|
40
|
-
token = @client.invalidate_token(
|
|
41
|
-
expect(token.access_token).to eq(
|
|
39
|
+
it 'returns the invalidated token' do
|
|
40
|
+
token = @client.invalidate_token('AAAA%2FAAA%3DAAAAAAAA')
|
|
41
|
+
expect(token.access_token).to eq('AAAA%2FAAA%3DAAAAAAAA')
|
|
42
42
|
expect(token.token_type).to be_nil
|
|
43
43
|
end
|
|
44
|
-
context
|
|
45
|
-
it
|
|
46
|
-
token = Twitter::Token.new(:access_token =>
|
|
44
|
+
context 'with a token' do
|
|
45
|
+
it 'requests the correct resource' do
|
|
46
|
+
token = Twitter::Token.new(:access_token => 'AAAA%2FAAA%3DAAAAAAAA')
|
|
47
47
|
@client.invalidate_token(token)
|
|
48
|
-
expect(a_post(
|
|
48
|
+
expect(a_post('/oauth2/invalidate_token').with(:body => {:access_token => 'AAAA%2FAAA%3DAAAAAAAA'})).to have_been_made
|
|
49
49
|
end
|
|
50
50
|
end
|
|
51
51
|
end
|
|
52
52
|
|
|
53
|
-
describe
|
|
53
|
+
describe '#reverse_token' do
|
|
54
54
|
before do
|
|
55
55
|
# WebMock treats Basic Auth differently so we have to chack against the full URL with credentials.
|
|
56
|
-
@oauth_request_token_url =
|
|
57
|
-
stub_request(:post, @oauth_request_token_url).to_return(:body => fixture('request_token.txt'), :headers => {:content_type =>
|
|
56
|
+
@oauth_request_token_url = 'https://api.twitter.com/oauth/request_token?x_auth_mode=reverse_auth'
|
|
57
|
+
stub_request(:post, @oauth_request_token_url).to_return(:body => fixture('request_token.txt'), :headers => {:content_type => 'text/html; charset=utf-8'})
|
|
58
58
|
end
|
|
59
|
-
it
|
|
59
|
+
it 'requests the correct resource' do
|
|
60
60
|
@client.reverse_token
|
|
61
|
-
expect(a_request(:post, @oauth_request_token_url).with(:params => {:x_auth_mode =>
|
|
61
|
+
expect(a_request(:post, @oauth_request_token_url).with(:params => {:x_auth_mode => 'reverse_auth'})).to have_been_made
|
|
62
62
|
end
|
|
63
|
-
it
|
|
63
|
+
it 'requests the correct resource' do
|
|
64
64
|
expect(@client.reverse_token).to eql fixture('request_token.txt').read
|
|
65
65
|
end
|
|
66
66
|
end
|
|
@@ -3,85 +3,85 @@ require 'helper'
|
|
|
3
3
|
describe Twitter::REST::API::SavedSearches 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 '#saved_searches' do
|
|
10
|
+
context 'with ids passed' do
|
|
11
11
|
before do
|
|
12
|
-
stub_get(
|
|
12
|
+
stub_get('/1.1/saved_searches/show/16129012.json').to_return(:body => fixture('saved_search.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
13
13
|
end
|
|
14
|
-
it
|
|
15
|
-
@client.saved_searches(
|
|
16
|
-
expect(a_get(
|
|
14
|
+
it 'requests the correct resource' do
|
|
15
|
+
@client.saved_searches(16_129_012)
|
|
16
|
+
expect(a_get('/1.1/saved_searches/show/16129012.json')).to have_been_made
|
|
17
17
|
end
|
|
18
|
-
it
|
|
19
|
-
saved_searches = @client.saved_searches(
|
|
18
|
+
it 'returns an array of saved searches' do
|
|
19
|
+
saved_searches = @client.saved_searches(16_129_012)
|
|
20
20
|
expect(saved_searches).to be_an Array
|
|
21
21
|
expect(saved_searches.first).to be_a Twitter::SavedSearch
|
|
22
|
-
expect(saved_searches.first.name).to eq(
|
|
22
|
+
expect(saved_searches.first.name).to eq('twitter')
|
|
23
23
|
end
|
|
24
24
|
end
|
|
25
|
-
context
|
|
25
|
+
context 'without ids passed' do
|
|
26
26
|
before do
|
|
27
|
-
stub_get(
|
|
27
|
+
stub_get('/1.1/saved_searches/list.json').to_return(:body => fixture('saved_searches.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
28
28
|
end
|
|
29
|
-
it
|
|
29
|
+
it 'requests the correct resource' do
|
|
30
30
|
@client.saved_searches
|
|
31
|
-
expect(a_get(
|
|
31
|
+
expect(a_get('/1.1/saved_searches/list.json')).to have_been_made
|
|
32
32
|
end
|
|
33
|
-
it
|
|
33
|
+
it 'returns the saved search queries for the authenticated user' do
|
|
34
34
|
saved_searches = @client.saved_searches
|
|
35
35
|
expect(saved_searches).to be_an Array
|
|
36
36
|
expect(saved_searches.first).to be_a Twitter::SavedSearch
|
|
37
|
-
expect(saved_searches.first.name).to eq(
|
|
37
|
+
expect(saved_searches.first.name).to eq('twitter')
|
|
38
38
|
end
|
|
39
39
|
end
|
|
40
40
|
end
|
|
41
41
|
|
|
42
|
-
describe
|
|
42
|
+
describe '#saved_search' do
|
|
43
43
|
before do
|
|
44
|
-
stub_get(
|
|
44
|
+
stub_get('/1.1/saved_searches/show/16129012.json').to_return(:body => fixture('saved_search.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
45
45
|
end
|
|
46
|
-
it
|
|
47
|
-
@client.saved_search(
|
|
48
|
-
expect(a_get(
|
|
46
|
+
it 'requests the correct resource' do
|
|
47
|
+
@client.saved_search(16_129_012)
|
|
48
|
+
expect(a_get('/1.1/saved_searches/show/16129012.json')).to have_been_made
|
|
49
49
|
end
|
|
50
|
-
it
|
|
51
|
-
saved_search = @client.saved_search(
|
|
50
|
+
it 'returns a saved search' do
|
|
51
|
+
saved_search = @client.saved_search(16_129_012)
|
|
52
52
|
expect(saved_search).to be_a Twitter::SavedSearch
|
|
53
|
-
expect(saved_search.name).to eq(
|
|
53
|
+
expect(saved_search.name).to eq('twitter')
|
|
54
54
|
end
|
|
55
55
|
end
|
|
56
56
|
|
|
57
|
-
describe
|
|
57
|
+
describe '#create_saved_search' do
|
|
58
58
|
before do
|
|
59
|
-
stub_post(
|
|
59
|
+
stub_post('/1.1/saved_searches/create.json').with(:body => {:query => 'twitter'}).to_return(:body => fixture('saved_search.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
60
60
|
end
|
|
61
|
-
it
|
|
62
|
-
@client.create_saved_search(
|
|
63
|
-
expect(a_post(
|
|
61
|
+
it 'requests the correct resource' do
|
|
62
|
+
@client.create_saved_search('twitter')
|
|
63
|
+
expect(a_post('/1.1/saved_searches/create.json').with(:body => {:query => 'twitter'})).to have_been_made
|
|
64
64
|
end
|
|
65
|
-
it
|
|
66
|
-
saved_search = @client.create_saved_search(
|
|
65
|
+
it 'returns the created saved search' do
|
|
66
|
+
saved_search = @client.create_saved_search('twitter')
|
|
67
67
|
expect(saved_search).to be_a Twitter::SavedSearch
|
|
68
|
-
expect(saved_search.name).to eq(
|
|
68
|
+
expect(saved_search.name).to eq('twitter')
|
|
69
69
|
end
|
|
70
70
|
end
|
|
71
71
|
|
|
72
|
-
describe
|
|
72
|
+
describe '#destroy_saved_search' do
|
|
73
73
|
before do
|
|
74
|
-
stub_post(
|
|
74
|
+
stub_post('/1.1/saved_searches/destroy/16129012.json').to_return(:body => fixture('saved_search.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
75
75
|
end
|
|
76
|
-
it
|
|
77
|
-
@client.destroy_saved_search(
|
|
78
|
-
expect(a_post(
|
|
76
|
+
it 'requests the correct resource' do
|
|
77
|
+
@client.destroy_saved_search(16_129_012)
|
|
78
|
+
expect(a_post('/1.1/saved_searches/destroy/16129012.json')).to have_been_made
|
|
79
79
|
end
|
|
80
|
-
it
|
|
81
|
-
saved_searches = @client.destroy_saved_search(
|
|
80
|
+
it 'returns an array of deleted saved searches' do
|
|
81
|
+
saved_searches = @client.destroy_saved_search(16_129_012)
|
|
82
82
|
expect(saved_searches).to be_an Array
|
|
83
83
|
expect(saved_searches.first).to be_a Twitter::SavedSearch
|
|
84
|
-
expect(saved_searches.first.name).to eq(
|
|
84
|
+
expect(saved_searches.first.name).to eq('twitter')
|
|
85
85
|
end
|
|
86
86
|
end
|
|
87
87
|
|
|
@@ -3,35 +3,35 @@ require 'helper'
|
|
|
3
3
|
describe Twitter::REST::API::Search 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 '#search' do
|
|
10
10
|
before do
|
|
11
|
-
stub_get(
|
|
11
|
+
stub_get('/1.1/search/tweets.json').with(:query => {:q => 'twitter'}).to_return(:body => fixture('search.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
12
12
|
end
|
|
13
|
-
it
|
|
14
|
-
@client.search(
|
|
15
|
-
expect(a_get(
|
|
13
|
+
it 'requests the correct resource' do
|
|
14
|
+
@client.search('twitter')
|
|
15
|
+
expect(a_get('/1.1/search/tweets.json').with(:query => {:q => 'twitter'})).to have_been_made
|
|
16
16
|
end
|
|
17
|
-
it
|
|
18
|
-
search = @client.search(
|
|
17
|
+
it 'returns recent Tweets related to a query with images and videos embedded' do
|
|
18
|
+
search = @client.search('twitter')
|
|
19
19
|
expect(search).to be_a Twitter::SearchResults
|
|
20
20
|
expect(search.first).to be_a Twitter::Tweet
|
|
21
|
-
expect(search.first.text).to eq(
|
|
21
|
+
expect(search.first.text).to eq('Bubble Mailer #freebandnames')
|
|
22
22
|
end
|
|
23
|
-
it
|
|
24
|
-
search = @client.search(
|
|
25
|
-
expect(search.max_id).to eq(
|
|
23
|
+
it 'returns the max_id value for a search result' do
|
|
24
|
+
search = @client.search('twitter')
|
|
25
|
+
expect(search.max_id).to eq(250_126_199_840_518_145)
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
-
context
|
|
28
|
+
context 'when search API responds a malformed result' do
|
|
29
29
|
before do
|
|
30
|
-
stub_get(
|
|
30
|
+
stub_get('/1.1/search/tweets.json').with(:query => {:q => 'twitter'}).to_return(:body => fixture('search_malformed.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
31
31
|
end
|
|
32
32
|
|
|
33
|
-
it
|
|
34
|
-
search = @client.search(
|
|
33
|
+
it 'returns an empty array' do
|
|
34
|
+
search = @client.search('twitter')
|
|
35
35
|
expect(search.to_a).to be_an Array
|
|
36
36
|
expect(search.to_a).to be_empty
|
|
37
37
|
end
|
|
@@ -3,22 +3,22 @@ require 'helper'
|
|
|
3
3
|
describe Twitter::REST::API::SpamReporting 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 '#report_spam' do
|
|
10
10
|
before do
|
|
11
|
-
stub_post(
|
|
11
|
+
stub_post('/1.1/users/report_spam.json').with(:body => {:screen_name => 'sferik'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
12
12
|
end
|
|
13
|
-
it
|
|
14
|
-
@client.report_spam(
|
|
15
|
-
expect(a_post(
|
|
13
|
+
it 'requests the correct resource' do
|
|
14
|
+
@client.report_spam('sferik')
|
|
15
|
+
expect(a_post('/1.1/users/report_spam.json').with(:body => {:screen_name => 'sferik'})).to have_been_made
|
|
16
16
|
end
|
|
17
|
-
it
|
|
18
|
-
users = @client.report_spam(
|
|
17
|
+
it 'returns an array of users' do
|
|
18
|
+
users = @client.report_spam('sferik')
|
|
19
19
|
expect(users).to be_an Array
|
|
20
20
|
expect(users.first).to be_a Twitter::User
|
|
21
|
-
expect(users.first.id).to eq(
|
|
21
|
+
expect(users.first.id).to eq(7_505_382)
|
|
22
22
|
end
|
|
23
23
|
end
|
|
24
24
|
|
|
@@ -3,53 +3,53 @@ require 'helper'
|
|
|
3
3
|
describe Twitter::REST::API::SuggestedUsers 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 '#suggestions' do
|
|
10
|
+
context 'with a category slug passed' do
|
|
11
11
|
before do
|
|
12
|
-
stub_get(
|
|
12
|
+
stub_get('/1.1/users/suggestions/art-design.json').to_return(:body => fixture('category.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
13
13
|
end
|
|
14
|
-
it
|
|
15
|
-
@client.suggestions(
|
|
16
|
-
expect(a_get(
|
|
14
|
+
it 'requests the correct resource' do
|
|
15
|
+
@client.suggestions('art-design')
|
|
16
|
+
expect(a_get('/1.1/users/suggestions/art-design.json')).to have_been_made
|
|
17
17
|
end
|
|
18
|
-
it
|
|
19
|
-
suggestion = @client.suggestions(
|
|
18
|
+
it 'returns the users in a given category of the Twitter suggested user list' do
|
|
19
|
+
suggestion = @client.suggestions('art-design')
|
|
20
20
|
expect(suggestion).to be_a Twitter::Suggestion
|
|
21
|
-
expect(suggestion.name).to eq(
|
|
21
|
+
expect(suggestion.name).to eq('Art & Design')
|
|
22
22
|
expect(suggestion.users).to be_an Array
|
|
23
23
|
expect(suggestion.users.first).to be_a Twitter::User
|
|
24
24
|
end
|
|
25
25
|
end
|
|
26
|
-
context
|
|
26
|
+
context 'without arguments passed' do
|
|
27
27
|
before do
|
|
28
|
-
stub_get(
|
|
28
|
+
stub_get('/1.1/users/suggestions.json').to_return(:body => fixture('suggestions.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
29
29
|
end
|
|
30
|
-
it
|
|
30
|
+
it 'requests the correct resource' do
|
|
31
31
|
@client.suggestions
|
|
32
|
-
expect(a_get(
|
|
32
|
+
expect(a_get('/1.1/users/suggestions.json')).to have_been_made
|
|
33
33
|
end
|
|
34
|
-
it
|
|
34
|
+
it 'returns the list of suggested user categories' do
|
|
35
35
|
suggestions = @client.suggestions
|
|
36
36
|
expect(suggestions).to be_an Array
|
|
37
37
|
expect(suggestions.first).to be_a Twitter::Suggestion
|
|
38
|
-
expect(suggestions.first.name).to eq(
|
|
38
|
+
expect(suggestions.first.name).to eq('Art & Design')
|
|
39
39
|
end
|
|
40
40
|
end
|
|
41
41
|
end
|
|
42
42
|
|
|
43
|
-
describe
|
|
43
|
+
describe '#suggest_users' do
|
|
44
44
|
before do
|
|
45
|
-
stub_get(
|
|
45
|
+
stub_get('/1.1/users/suggestions/art-design/members.json').to_return(:body => fixture('members.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
46
46
|
end
|
|
47
|
-
it
|
|
48
|
-
@client.suggest_users(
|
|
49
|
-
expect(a_get(
|
|
47
|
+
it 'requests the correct resource' do
|
|
48
|
+
@client.suggest_users('art-design')
|
|
49
|
+
expect(a_get('/1.1/users/suggestions/art-design/members.json')).to have_been_made
|
|
50
50
|
end
|
|
51
|
-
it
|
|
52
|
-
suggest_users = @client.suggest_users(
|
|
51
|
+
it 'returns users in a given category of the Twitter suggested user list and return their most recent status if they are not a protected user' do
|
|
52
|
+
suggest_users = @client.suggest_users('art-design')
|
|
53
53
|
expect(suggest_users).to be_an Array
|
|
54
54
|
expect(suggest_users.first).to be_a Twitter::User
|
|
55
55
|
expect(suggest_users.first.id).to eq(13)
|
|
@@ -3,135 +3,135 @@ require 'helper'
|
|
|
3
3
|
describe Twitter::REST::API::Timelines 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 '#mentions_timeline' do
|
|
10
10
|
before do
|
|
11
|
-
stub_get(
|
|
11
|
+
stub_get('/1.1/statuses/mentions_timeline.json').to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
12
12
|
end
|
|
13
|
-
it
|
|
13
|
+
it 'requests the correct resource' do
|
|
14
14
|
@client.mentions_timeline
|
|
15
|
-
expect(a_get(
|
|
15
|
+
expect(a_get('/1.1/statuses/mentions_timeline.json')).to have_been_made
|
|
16
16
|
end
|
|
17
|
-
it
|
|
17
|
+
it 'returns the 20 most recent mentions (status containing @username) for the authenticating user' do
|
|
18
18
|
tweets = @client.mentions_timeline
|
|
19
19
|
expect(tweets).to be_an Array
|
|
20
20
|
expect(tweets.first).to be_a Twitter::Tweet
|
|
21
|
-
expect(tweets.first.text).to eq(
|
|
21
|
+
expect(tweets.first.text).to eq('Happy Birthday @imdane. Watch out for those @rally pranksters!')
|
|
22
22
|
end
|
|
23
23
|
end
|
|
24
24
|
|
|
25
|
-
describe
|
|
26
|
-
context
|
|
25
|
+
describe '#user_timeline' do
|
|
26
|
+
context 'with a screen name passed' do
|
|
27
27
|
before do
|
|
28
|
-
stub_get(
|
|
28
|
+
stub_get('/1.1/statuses/user_timeline.json').with(:query => {:screen_name => 'sferik'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
29
29
|
end
|
|
30
|
-
it
|
|
31
|
-
@client.user_timeline(
|
|
32
|
-
expect(a_get(
|
|
30
|
+
it 'requests the correct resource' do
|
|
31
|
+
@client.user_timeline('sferik')
|
|
32
|
+
expect(a_get('/1.1/statuses/user_timeline.json').with(:query => {:screen_name => 'sferik'})).to have_been_made
|
|
33
33
|
end
|
|
34
|
-
it
|
|
35
|
-
tweets = @client.user_timeline(
|
|
34
|
+
it 'returns the 20 most recent Tweets posted by the user specified by screen name or user id' do
|
|
35
|
+
tweets = @client.user_timeline('sferik')
|
|
36
36
|
expect(tweets).to be_an Array
|
|
37
37
|
expect(tweets.first).to be_a Twitter::Tweet
|
|
38
|
-
expect(tweets.first.text).to eq(
|
|
38
|
+
expect(tweets.first.text).to eq('Happy Birthday @imdane. Watch out for those @rally pranksters!')
|
|
39
39
|
end
|
|
40
40
|
end
|
|
41
|
-
context
|
|
41
|
+
context 'without a screen name passed' do
|
|
42
42
|
before do
|
|
43
|
-
stub_get(
|
|
43
|
+
stub_get('/1.1/statuses/user_timeline.json').to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
44
44
|
end
|
|
45
|
-
it
|
|
45
|
+
it 'requests the correct resource' do
|
|
46
46
|
@client.user_timeline
|
|
47
|
-
expect(a_get(
|
|
47
|
+
expect(a_get('/1.1/statuses/user_timeline.json')).to have_been_made
|
|
48
48
|
end
|
|
49
49
|
end
|
|
50
50
|
end
|
|
51
51
|
|
|
52
|
-
describe
|
|
52
|
+
describe '#retweeted_by_user' do
|
|
53
53
|
before do
|
|
54
|
-
stub_get(
|
|
55
|
-
stub_get(
|
|
54
|
+
stub_get('/1.1/statuses/user_timeline.json').with(:query => {:include_rts => 'true', :screen_name => 'sferik', :count => '200'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
55
|
+
stub_get('/1.1/statuses/user_timeline.json').with(:query => {:include_rts => 'true', :screen_name => 'sferik', :count => '200', :max_id => '244102729860009983'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
56
56
|
end
|
|
57
|
-
it
|
|
58
|
-
@client.retweeted_by_user(
|
|
59
|
-
expect(a_get(
|
|
60
|
-
expect(a_get(
|
|
57
|
+
it 'requests the correct resource' do
|
|
58
|
+
@client.retweeted_by_user('sferik')
|
|
59
|
+
expect(a_get('/1.1/statuses/user_timeline.json').with(:query => {:include_rts => 'true', :screen_name => 'sferik', :count => '200'})).to have_been_made
|
|
60
|
+
expect(a_get('/1.1/statuses/user_timeline.json').with(:query => {:include_rts => 'true', :screen_name => 'sferik', :count => '200', :max_id => '244102729860009983'})).to have_been_made.times(3)
|
|
61
61
|
end
|
|
62
|
-
it
|
|
63
|
-
tweets = @client.retweeted_by_user(
|
|
62
|
+
it 'returns the 20 most recent retweets posted by the authenticating user' do
|
|
63
|
+
tweets = @client.retweeted_by_user('sferik')
|
|
64
64
|
expect(tweets).to be_an Array
|
|
65
65
|
expect(tweets.first).to be_a Twitter::Tweet
|
|
66
|
-
expect(tweets.first.text).to eq(
|
|
66
|
+
expect(tweets.first.text).to eq('RT @olivercameron: Mosaic looks cool: http://t.co/A8013C9k')
|
|
67
67
|
end
|
|
68
68
|
end
|
|
69
69
|
|
|
70
|
-
describe
|
|
70
|
+
describe '#retweeted_by_me' do
|
|
71
71
|
before do
|
|
72
|
-
stub_get(
|
|
73
|
-
stub_get(
|
|
72
|
+
stub_get('/1.1/statuses/user_timeline.json').with(:query => {:include_rts => 'true', :count => '200'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
73
|
+
stub_get('/1.1/statuses/user_timeline.json').with(:query => {:include_rts => 'true', :count => '200', :max_id => '244102729860009983'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
74
74
|
end
|
|
75
|
-
it
|
|
75
|
+
it 'requests the correct resource' do
|
|
76
76
|
@client.retweeted_by_me
|
|
77
|
-
expect(a_get(
|
|
78
|
-
expect(a_get(
|
|
77
|
+
expect(a_get('/1.1/statuses/user_timeline.json').with(:query => {:include_rts => 'true', :count => '200'})).to have_been_made
|
|
78
|
+
expect(a_get('/1.1/statuses/user_timeline.json').with(:query => {:include_rts => 'true', :count => '200', :max_id => '244102729860009983'})).to have_been_made.times(3)
|
|
79
79
|
end
|
|
80
|
-
it
|
|
80
|
+
it 'returns the 20 most recent retweets posted by the authenticating user' do
|
|
81
81
|
tweets = @client.retweeted_by_me
|
|
82
82
|
expect(tweets).to be_an Array
|
|
83
83
|
expect(tweets.first).to be_a Twitter::Tweet
|
|
84
|
-
expect(tweets.first.text).to eq(
|
|
84
|
+
expect(tweets.first.text).to eq('RT @olivercameron: Mosaic looks cool: http://t.co/A8013C9k')
|
|
85
85
|
end
|
|
86
86
|
end
|
|
87
87
|
|
|
88
|
-
describe
|
|
88
|
+
describe '#home_timeline' do
|
|
89
89
|
before do
|
|
90
|
-
stub_get(
|
|
90
|
+
stub_get('/1.1/statuses/home_timeline.json').to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
91
91
|
end
|
|
92
|
-
it
|
|
92
|
+
it 'requests the correct resource' do
|
|
93
93
|
@client.home_timeline
|
|
94
|
-
expect(a_get(
|
|
94
|
+
expect(a_get('/1.1/statuses/home_timeline.json')).to have_been_made
|
|
95
95
|
end
|
|
96
|
-
it
|
|
96
|
+
it 'returns the 20 most recent Tweets, including retweets if they exist, posted by the authenticating user and the users they follow' do
|
|
97
97
|
tweets = @client.home_timeline
|
|
98
98
|
expect(tweets).to be_an Array
|
|
99
99
|
expect(tweets.first).to be_a Twitter::Tweet
|
|
100
|
-
expect(tweets.first.text).to eq(
|
|
100
|
+
expect(tweets.first.text).to eq('Happy Birthday @imdane. Watch out for those @rally pranksters!')
|
|
101
101
|
end
|
|
102
102
|
end
|
|
103
103
|
|
|
104
|
-
describe
|
|
104
|
+
describe '#retweeted_to_me' do
|
|
105
105
|
before do
|
|
106
|
-
stub_get(
|
|
107
|
-
stub_get(
|
|
106
|
+
stub_get('/1.1/statuses/home_timeline.json').with(:query => {:include_rts => 'true', :count => '200'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
107
|
+
stub_get('/1.1/statuses/home_timeline.json').with(:query => {:include_rts => 'true', :count => '200', :max_id => '244102729860009983'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
108
108
|
end
|
|
109
|
-
it
|
|
109
|
+
it 'requests the correct resource' do
|
|
110
110
|
@client.retweeted_to_me
|
|
111
|
-
expect(stub_get(
|
|
112
|
-
expect(stub_get(
|
|
111
|
+
expect(stub_get('/1.1/statuses/home_timeline.json').with(:query => {:include_rts => 'true', :count => '200'})).to have_been_made
|
|
112
|
+
expect(stub_get('/1.1/statuses/home_timeline.json').with(:query => {:include_rts => 'true', :count => '200', :max_id => '244102729860009983'})).to have_been_made.times(3)
|
|
113
113
|
end
|
|
114
|
-
it
|
|
114
|
+
it 'returns the 20 most recent retweets posted by users the authenticating user follow' do
|
|
115
115
|
tweets = @client.retweeted_to_me
|
|
116
116
|
expect(tweets).to be_an Array
|
|
117
117
|
expect(tweets.first).to be_a Twitter::Tweet
|
|
118
|
-
expect(tweets.first.text).to eq(
|
|
118
|
+
expect(tweets.first.text).to eq('RT @olivercameron: Mosaic looks cool: http://t.co/A8013C9k')
|
|
119
119
|
end
|
|
120
120
|
end
|
|
121
121
|
|
|
122
|
-
describe
|
|
122
|
+
describe '#retweets_of_me' do
|
|
123
123
|
before do
|
|
124
|
-
stub_get(
|
|
124
|
+
stub_get('/1.1/statuses/retweets_of_me.json').to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
125
125
|
end
|
|
126
|
-
it
|
|
126
|
+
it 'requests the correct resource' do
|
|
127
127
|
@client.retweets_of_me
|
|
128
|
-
expect(a_get(
|
|
128
|
+
expect(a_get('/1.1/statuses/retweets_of_me.json')).to have_been_made
|
|
129
129
|
end
|
|
130
|
-
it
|
|
130
|
+
it 'returns the 20 most recent tweets of the authenticated user that have been retweeted by others' do
|
|
131
131
|
tweets = @client.retweets_of_me
|
|
132
132
|
expect(tweets).to be_an Array
|
|
133
133
|
expect(tweets.first).to be_a Twitter::Tweet
|
|
134
|
-
expect(tweets.first.text).to eq(
|
|
134
|
+
expect(tweets.first.text).to eq('Happy Birthday @imdane. Watch out for those @rally pranksters!')
|
|
135
135
|
end
|
|
136
136
|
end
|
|
137
137
|
|