twitter 5.0.0 → 5.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.yardopts +4 -0
- data/CHANGELOG.md +47 -0
- data/CONTRIBUTING.md +5 -5
- data/README.md +57 -56
- data/Rakefile +26 -5
- data/lib/twitter/arguments.rb +1 -2
- data/lib/twitter/base.rb +15 -18
- data/lib/twitter/basic_user.rb +3 -3
- data/lib/twitter/client.rb +9 -10
- data/lib/twitter/configuration.rb +5 -5
- data/lib/twitter/creatable.rb +0 -1
- data/lib/twitter/cursor.rb +9 -36
- data/lib/twitter/direct_message.rb +1 -1
- data/lib/twitter/entity/uri.rb +2 -2
- data/lib/twitter/enumerable.rb +10 -1
- data/lib/twitter/error/already_favorited.rb +1 -1
- data/lib/twitter/error/already_posted.rb +1 -1
- data/lib/twitter/error/already_retweeted.rb +1 -1
- data/lib/twitter/error/too_many_requests.rb +2 -2
- data/lib/twitter/error.rb +6 -6
- data/lib/twitter/factory.rb +2 -6
- data/lib/twitter/geo/point.rb +3 -5
- data/lib/twitter/geo.rb +1 -1
- data/lib/twitter/geo_factory.rb +1 -5
- data/lib/twitter/geo_results.rb +5 -8
- data/lib/twitter/identity.rb +1 -2
- data/lib/twitter/list.rb +10 -11
- data/lib/twitter/media/photo.rb +1 -2
- data/lib/twitter/media_factory.rb +1 -5
- data/lib/twitter/null_object.rb +4 -6
- data/lib/twitter/oembed.rb +1 -1
- data/lib/twitter/place.rb +17 -6
- data/lib/twitter/profile_banner.rb +1 -3
- data/lib/twitter/rate_limit.rb +1 -3
- data/lib/twitter/relationship.rb +1 -2
- data/lib/twitter/rest/api/direct_messages.rb +15 -15
- data/lib/twitter/rest/api/favorites.rb +15 -15
- data/lib/twitter/rest/api/friends_and_followers.rb +37 -42
- data/lib/twitter/rest/api/help.rb +8 -9
- data/lib/twitter/rest/api/lists.rb +69 -69
- data/lib/twitter/rest/api/oauth.rb +3 -4
- data/lib/twitter/rest/api/places_and_geo.rb +9 -10
- data/lib/twitter/rest/api/saved_searches.rb +8 -8
- data/lib/twitter/rest/api/search.rb +10 -2
- data/lib/twitter/rest/api/spam_reporting.rb +1 -2
- data/lib/twitter/rest/api/suggested_users.rb +4 -5
- data/lib/twitter/rest/api/timelines.rb +17 -18
- data/lib/twitter/rest/api/trends.rb +10 -11
- data/lib/twitter/rest/api/tweets.rb +31 -20
- data/lib/twitter/rest/api/undocumented.rb +6 -7
- data/lib/twitter/rest/api/users.rb +53 -54
- data/lib/twitter/rest/api/utils.rb +28 -34
- data/lib/twitter/rest/client.rb +8 -9
- data/lib/twitter/rest/request/multipart_with_file.rb +7 -5
- data/lib/twitter/rest/response/parse_error_json.rb +0 -2
- data/lib/twitter/rest/response/parse_json.rb +2 -2
- data/lib/twitter/rest/response/raise_error.rb +1 -3
- data/lib/twitter/search_results.rb +38 -56
- data/lib/twitter/settings.rb +2 -2
- data/lib/twitter/size.rb +2 -2
- data/lib/twitter/source_user.rb +1 -1
- data/lib/twitter/streaming/client.rb +69 -18
- data/lib/twitter/streaming/connection.rb +1 -3
- data/lib/twitter/streaming/deleted_tweet.rb +8 -0
- data/lib/twitter/streaming/event.rb +8 -8
- data/lib/twitter/streaming/friend_list.rb +2 -9
- data/lib/twitter/streaming/message_parser.rb +13 -3
- data/lib/twitter/streaming/response.rb +0 -2
- data/lib/twitter/streaming/stall_warning.rb +7 -0
- data/lib/twitter/suggestion.rb +0 -1
- data/lib/twitter/token.rb +2 -3
- data/lib/twitter/trend_results.rb +5 -8
- data/lib/twitter/tweet.rb +17 -18
- data/lib/twitter/user.rb +33 -35
- data/lib/twitter/utils.rb +14 -0
- data/lib/twitter/version.rb +2 -5
- data/lib/twitter.rb +1 -1
- data/spec/fixtures/forbidden.json +1 -0
- data/spec/fixtures/search.json +1 -1
- data/spec/fixtures/search2.json +1 -0
- data/spec/fixtures/track_streaming_user.json +2 -1
- data/spec/helper.rb +6 -2
- data/spec/twitter/base_spec.rb +9 -9
- data/spec/twitter/basic_user_spec.rb +6 -6
- data/spec/twitter/configuration_spec.rb +4 -4
- data/spec/twitter/cursor_spec.rb +13 -51
- data/spec/twitter/direct_message_spec.rb +36 -36
- data/spec/twitter/entity/uri_spec.rb +29 -29
- data/spec/twitter/error_spec.rb +21 -21
- data/spec/twitter/geo/point_spec.rb +9 -9
- data/spec/twitter/geo/polygon_spec.rb +5 -5
- data/spec/twitter/geo_factory_spec.rb +7 -7
- data/spec/twitter/geo_results_spec.rb +11 -11
- data/spec/twitter/geo_spec.rb +5 -5
- data/spec/twitter/identifiable_spec.rb +9 -9
- data/spec/twitter/list_spec.rb +38 -38
- data/spec/twitter/media/photo_spec.rb +58 -58
- data/spec/twitter/media_factory_spec.rb +5 -5
- data/spec/twitter/null_object_spec.rb +6 -6
- data/spec/twitter/oembed_spec.rb +68 -68
- data/spec/twitter/place_spec.rb +91 -62
- data/spec/twitter/profile_banner_spec.rb +3 -3
- data/spec/twitter/rate_limit_spec.rb +18 -18
- data/spec/twitter/relationship_spec.rb +16 -16
- data/spec/twitter/rest/api/direct_messages_spec.rb +61 -61
- data/spec/twitter/rest/api/favorites_spec.rb +93 -93
- data/spec/twitter/rest/api/friends_and_followers_spec.rb +357 -349
- data/spec/twitter/rest/api/geo_spec.rb +33 -33
- data/spec/twitter/rest/api/help_spec.rb +24 -24
- data/spec/twitter/rest/api/lists_spec.rb +487 -487
- data/spec/twitter/rest/api/oauth_spec.rb +30 -30
- data/spec/twitter/rest/api/saved_searches_spec.rb +50 -40
- data/spec/twitter/rest/api/search_spec.rb +27 -26
- data/spec/twitter/rest/api/spam_reporting_spec.rb +9 -9
- data/spec/twitter/rest/api/suggested_users_spec.rb +23 -23
- data/spec/twitter/rest/api/timelines_spec.rb +58 -58
- data/spec/twitter/rest/api/trends_spec.rb +26 -26
- data/spec/twitter/rest/api/tweets_spec.rb +304 -266
- data/spec/twitter/rest/api/undocumented_spec.rb +51 -51
- data/spec/twitter/rest/api/users_spec.rb +360 -360
- data/spec/twitter/rest/client_spec.rb +99 -103
- data/spec/twitter/saved_search_spec.rb +16 -16
- data/spec/twitter/search_results_spec.rb +14 -110
- data/spec/twitter/settings_spec.rb +8 -8
- data/spec/twitter/size_spec.rb +5 -5
- data/spec/twitter/source_user_spec.rb +6 -6
- data/spec/twitter/streaming/client_spec.rb +85 -54
- data/spec/twitter/streaming/deleted_tweet_spec.rb +23 -0
- data/spec/twitter/streaming/event_spec.rb +20 -22
- data/spec/twitter/streaming/friend_list_spec.rb +11 -0
- data/spec/twitter/streaming/message_parser_spec.rb +54 -0
- data/spec/twitter/suggestion_spec.rb +11 -11
- data/spec/twitter/target_user_spec.rb +6 -6
- data/spec/twitter/token_spec.rb +4 -4
- data/spec/twitter/trend_results_spec.rb +30 -30
- data/spec/twitter/trend_spec.rb +21 -21
- data/spec/twitter/tweet_spec.rb +178 -164
- data/spec/twitter/user_spec.rb +190 -190
- data/twitter.gemspec +6 -6
- data.tar.gz.sig +0 -0
- metadata +44 -16
- metadata.gz.sig +0 -0
- data/lib/twitter/core_ext/enumerable.rb +0 -10
- data/lib/twitter/core_ext/kernel.rb +0 -10
- data/spec/twitter_spec.rb +0 -0
|
@@ -3,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,95 @@ 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
|
+
stub_get('/1.1/saved_searches/show/16129013.json').to_return(:body => fixture('saved_search.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
13
14
|
end
|
|
14
|
-
it
|
|
15
|
-
@client.saved_searches(
|
|
16
|
-
expect(a_get(
|
|
15
|
+
it 'requests the correct resource' do
|
|
16
|
+
@client.saved_searches(16_129_012, 16_129_013)
|
|
17
|
+
expect(a_get('/1.1/saved_searches/show/16129012.json')).to have_been_made
|
|
18
|
+
expect(a_get('/1.1/saved_searches/show/16129013.json')).to have_been_made
|
|
17
19
|
end
|
|
18
|
-
it
|
|
19
|
-
saved_searches = @client.saved_searches(
|
|
20
|
+
it 'returns an array of saved searches' do
|
|
21
|
+
saved_searches = @client.saved_searches(16_129_012, 16_129_013)
|
|
20
22
|
expect(saved_searches).to be_an Array
|
|
23
|
+
expect(saved_searches.size).to eq(2)
|
|
21
24
|
expect(saved_searches.first).to be_a Twitter::SavedSearch
|
|
22
|
-
expect(saved_searches.first.name).to eq(
|
|
25
|
+
expect(saved_searches.first.name).to eq('twitter')
|
|
26
|
+
expect(saved_searches.last).to be_a Twitter::SavedSearch
|
|
27
|
+
expect(saved_searches.last.name).to eq('twitter')
|
|
23
28
|
end
|
|
24
29
|
end
|
|
25
|
-
context
|
|
30
|
+
context 'without ids passed' do
|
|
26
31
|
before do
|
|
27
|
-
stub_get(
|
|
32
|
+
stub_get('/1.1/saved_searches/list.json').to_return(:body => fixture('saved_searches.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
28
33
|
end
|
|
29
|
-
it
|
|
34
|
+
it 'requests the correct resource' do
|
|
30
35
|
@client.saved_searches
|
|
31
|
-
expect(a_get(
|
|
36
|
+
expect(a_get('/1.1/saved_searches/list.json')).to have_been_made
|
|
32
37
|
end
|
|
33
|
-
it
|
|
38
|
+
it 'returns the saved search queries for the authenticated user' do
|
|
34
39
|
saved_searches = @client.saved_searches
|
|
35
40
|
expect(saved_searches).to be_an Array
|
|
36
41
|
expect(saved_searches.first).to be_a Twitter::SavedSearch
|
|
37
|
-
expect(saved_searches.first.name).to eq(
|
|
42
|
+
expect(saved_searches.first.name).to eq('twitter')
|
|
38
43
|
end
|
|
39
44
|
end
|
|
40
45
|
end
|
|
41
46
|
|
|
42
|
-
describe
|
|
47
|
+
describe '#saved_search' do
|
|
43
48
|
before do
|
|
44
|
-
stub_get(
|
|
49
|
+
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
50
|
end
|
|
46
|
-
it
|
|
47
|
-
@client.saved_search(
|
|
48
|
-
expect(a_get(
|
|
51
|
+
it 'requests the correct resource' do
|
|
52
|
+
@client.saved_search(16_129_012)
|
|
53
|
+
expect(a_get('/1.1/saved_searches/show/16129012.json')).to have_been_made
|
|
49
54
|
end
|
|
50
|
-
it
|
|
51
|
-
saved_search = @client.saved_search(
|
|
55
|
+
it 'returns a saved search' do
|
|
56
|
+
saved_search = @client.saved_search(16_129_012)
|
|
52
57
|
expect(saved_search).to be_a Twitter::SavedSearch
|
|
53
|
-
expect(saved_search.name).to eq(
|
|
58
|
+
expect(saved_search.name).to eq('twitter')
|
|
54
59
|
end
|
|
55
60
|
end
|
|
56
61
|
|
|
57
|
-
describe
|
|
62
|
+
describe '#create_saved_search' do
|
|
58
63
|
before do
|
|
59
|
-
stub_post(
|
|
64
|
+
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
65
|
end
|
|
61
|
-
it
|
|
62
|
-
@client.create_saved_search(
|
|
63
|
-
expect(a_post(
|
|
66
|
+
it 'requests the correct resource' do
|
|
67
|
+
@client.create_saved_search('twitter')
|
|
68
|
+
expect(a_post('/1.1/saved_searches/create.json').with(:body => {:query => 'twitter'})).to have_been_made
|
|
64
69
|
end
|
|
65
|
-
it
|
|
66
|
-
saved_search = @client.create_saved_search(
|
|
70
|
+
it 'returns the created saved search' do
|
|
71
|
+
saved_search = @client.create_saved_search('twitter')
|
|
67
72
|
expect(saved_search).to be_a Twitter::SavedSearch
|
|
68
|
-
expect(saved_search.name).to eq(
|
|
73
|
+
expect(saved_search.name).to eq('twitter')
|
|
69
74
|
end
|
|
70
75
|
end
|
|
71
76
|
|
|
72
|
-
describe
|
|
77
|
+
describe '#destroy_saved_search' do
|
|
73
78
|
before do
|
|
74
|
-
stub_post(
|
|
79
|
+
stub_post('/1.1/saved_searches/destroy/16129012.json').to_return(:body => fixture('saved_search.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
80
|
+
stub_post('/1.1/saved_searches/destroy/16129013.json').to_return(:body => fixture('saved_search.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
75
81
|
end
|
|
76
|
-
it
|
|
77
|
-
@client.destroy_saved_search(
|
|
78
|
-
expect(a_post(
|
|
82
|
+
it 'requests the correct resource' do
|
|
83
|
+
@client.destroy_saved_search(16_129_012, 16_129_013)
|
|
84
|
+
expect(a_post('/1.1/saved_searches/destroy/16129012.json')).to have_been_made
|
|
85
|
+
expect(a_post('/1.1/saved_searches/destroy/16129013.json')).to have_been_made
|
|
79
86
|
end
|
|
80
|
-
it
|
|
81
|
-
saved_searches = @client.destroy_saved_search(
|
|
87
|
+
it 'returns an array of deleted saved searches' do
|
|
88
|
+
saved_searches = @client.destroy_saved_search(16_129_012, 16_129_013)
|
|
82
89
|
expect(saved_searches).to be_an Array
|
|
90
|
+
expect(saved_searches.size).to eq(2)
|
|
83
91
|
expect(saved_searches.first).to be_a Twitter::SavedSearch
|
|
84
|
-
expect(saved_searches.first.name).to eq(
|
|
92
|
+
expect(saved_searches.first.name).to eq('twitter')
|
|
93
|
+
expect(saved_searches.last).to be_a Twitter::SavedSearch
|
|
94
|
+
expect(saved_searches.last.name).to eq('twitter')
|
|
85
95
|
end
|
|
86
96
|
end
|
|
87
97
|
|
|
@@ -3,37 +3,38 @@ 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
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
search = @client.search("twitter")
|
|
25
|
-
expect(search.max_id).to eq(250126199840518145)
|
|
9
|
+
describe '#search' do
|
|
10
|
+
context 'without count specified' do
|
|
11
|
+
before do
|
|
12
|
+
stub_get('/1.1/search/tweets.json').with(:query => {:q => '#freebandnames', :count => '100'}).to_return(:body => fixture('search.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
13
|
+
end
|
|
14
|
+
it 'requests the correct resource' do
|
|
15
|
+
@client.search('#freebandnames')
|
|
16
|
+
expect(a_get('/1.1/search/tweets.json').with(:query => {:q => '#freebandnames', :count => '100'})).to have_been_made
|
|
17
|
+
end
|
|
18
|
+
it 'returns recent Tweets related to a query with images and videos embedded' do
|
|
19
|
+
search = @client.search('#freebandnames')
|
|
20
|
+
expect(search).to be_a Twitter::SearchResults
|
|
21
|
+
expect(search.first).to be_a Twitter::Tweet
|
|
22
|
+
expect(search.first.text).to eq('@Just_Reboot #FreeBandNames mono surround')
|
|
23
|
+
end
|
|
26
24
|
end
|
|
27
|
-
|
|
28
|
-
context "when search API responds a malformed result" do
|
|
25
|
+
context 'with count specified' do
|
|
29
26
|
before do
|
|
30
|
-
stub_get(
|
|
27
|
+
stub_get('/1.1/search/tweets.json').with(:query => {:q => '#freebandnames', :count => '3'}).to_return(:body => fixture('search.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
31
28
|
end
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
search
|
|
35
|
-
|
|
36
|
-
|
|
29
|
+
it 'requests the correct resource' do
|
|
30
|
+
@client.search('#freebandnames', :count => 3)
|
|
31
|
+
expect(a_get('/1.1/search/tweets.json').with(:query => {:q => '#freebandnames', :count => '3'})).to have_been_made
|
|
32
|
+
end
|
|
33
|
+
it 'returns recent Tweets related to a query with images and videos embedded' do
|
|
34
|
+
search = @client.search('#freebandnames', :count => 3)
|
|
35
|
+
expect(search).to be_a Twitter::SearchResults
|
|
36
|
+
expect(search.first).to be_a Twitter::Tweet
|
|
37
|
+
expect(search.first.text).to eq('@Just_Reboot #FreeBandNames mono surround')
|
|
37
38
|
end
|
|
38
39
|
end
|
|
39
40
|
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)
|