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,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
|
|
@@ -3,633 +3,633 @@ require 'helper'
|
|
|
3
3
|
describe Twitter::REST::API::Users 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 '#settings' do
|
|
10
10
|
before do
|
|
11
|
-
stub_get(
|
|
12
|
-
stub_post(
|
|
11
|
+
stub_get('/1.1/account/settings.json').to_return(:body => fixture('settings.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
12
|
+
stub_post('/1.1/account/settings.json').with(:body => {:trend_location_woeid => '23424803'}).to_return(:body => fixture('settings.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
13
13
|
end
|
|
14
|
-
it
|
|
14
|
+
it 'requests the correct resource on GET' do
|
|
15
15
|
@client.settings
|
|
16
|
-
expect(a_get(
|
|
16
|
+
expect(a_get('/1.1/account/settings.json')).to have_been_made
|
|
17
17
|
end
|
|
18
|
-
it
|
|
18
|
+
it 'returns settings' do
|
|
19
19
|
settings = @client.settings
|
|
20
20
|
expect(settings).to be_a Twitter::Settings
|
|
21
|
-
expect(settings.language).to eq(
|
|
21
|
+
expect(settings.language).to eq('en')
|
|
22
22
|
end
|
|
23
|
-
it
|
|
24
|
-
@client.settings(:trend_location_woeid =>
|
|
25
|
-
expect(a_post(
|
|
23
|
+
it 'requests the correct resource on POST' do
|
|
24
|
+
@client.settings(:trend_location_woeid => '23424803')
|
|
25
|
+
expect(a_post('/1.1/account/settings.json').with(:body => {:trend_location_woeid => '23424803'})).to have_been_made
|
|
26
26
|
end
|
|
27
|
-
it
|
|
28
|
-
settings = @client.settings(:trend_location_woeid =>
|
|
27
|
+
it 'returns settings' do
|
|
28
|
+
settings = @client.settings(:trend_location_woeid => '23424803')
|
|
29
29
|
expect(settings).to be_a Twitter::Settings
|
|
30
|
-
expect(settings.language).to eq(
|
|
30
|
+
expect(settings.language).to eq('en')
|
|
31
31
|
end
|
|
32
32
|
end
|
|
33
33
|
|
|
34
|
-
describe
|
|
34
|
+
describe '#verify_credentials' do
|
|
35
35
|
before do
|
|
36
|
-
stub_get(
|
|
36
|
+
stub_get('/1.1/account/verify_credentials.json').to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
37
37
|
end
|
|
38
|
-
it
|
|
38
|
+
it 'requests the correct resource' do
|
|
39
39
|
@client.verify_credentials
|
|
40
|
-
expect(a_get(
|
|
40
|
+
expect(a_get('/1.1/account/verify_credentials.json')).to have_been_made
|
|
41
41
|
end
|
|
42
|
-
it
|
|
42
|
+
it 'returns the requesting user' do
|
|
43
43
|
user = @client.verify_credentials
|
|
44
44
|
expect(user).to be_a Twitter::User
|
|
45
|
-
expect(user.id).to eq(
|
|
45
|
+
expect(user.id).to eq(7_505_382)
|
|
46
46
|
end
|
|
47
47
|
end
|
|
48
48
|
|
|
49
|
-
describe
|
|
49
|
+
describe '#update_delivery_device' do
|
|
50
50
|
before do
|
|
51
|
-
stub_post(
|
|
51
|
+
stub_post('/1.1/account/update_delivery_device.json').with(:body => {:device => 'sms'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
52
52
|
end
|
|
53
|
-
it
|
|
54
|
-
@client.update_delivery_device(
|
|
55
|
-
expect(a_post(
|
|
53
|
+
it 'requests the correct resource' do
|
|
54
|
+
@client.update_delivery_device('sms')
|
|
55
|
+
expect(a_post('/1.1/account/update_delivery_device.json').with(:body => {:device => 'sms'})).to have_been_made
|
|
56
56
|
end
|
|
57
|
-
it
|
|
58
|
-
user = @client.update_delivery_device(
|
|
57
|
+
it 'returns a user' do
|
|
58
|
+
user = @client.update_delivery_device('sms')
|
|
59
59
|
expect(user).to be_a Twitter::User
|
|
60
|
-
expect(user.id).to eq(
|
|
60
|
+
expect(user.id).to eq(7_505_382)
|
|
61
61
|
end
|
|
62
62
|
end
|
|
63
63
|
|
|
64
|
-
describe
|
|
64
|
+
describe '#update_profile' do
|
|
65
65
|
before do
|
|
66
|
-
stub_post(
|
|
66
|
+
stub_post('/1.1/account/update_profile.json').with(:body => {:url => 'http://github.com/sferik/'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
67
67
|
end
|
|
68
|
-
it
|
|
69
|
-
@client.update_profile(:url =>
|
|
70
|
-
expect(a_post(
|
|
68
|
+
it 'requests the correct resource' do
|
|
69
|
+
@client.update_profile(:url => 'http://github.com/sferik/')
|
|
70
|
+
expect(a_post('/1.1/account/update_profile.json').with(:body => {:url => 'http://github.com/sferik/'})).to have_been_made
|
|
71
71
|
end
|
|
72
|
-
it
|
|
73
|
-
user = @client.update_profile(:url =>
|
|
72
|
+
it 'returns a user' do
|
|
73
|
+
user = @client.update_profile(:url => 'http://github.com/sferik/')
|
|
74
74
|
expect(user).to be_a Twitter::User
|
|
75
|
-
expect(user.id).to eq(
|
|
75
|
+
expect(user.id).to eq(7_505_382)
|
|
76
76
|
end
|
|
77
77
|
end
|
|
78
78
|
|
|
79
|
-
describe
|
|
79
|
+
describe '#update_profile_background_image' do
|
|
80
80
|
before do
|
|
81
|
-
stub_post(
|
|
81
|
+
stub_post('/1.1/account/update_profile_background_image.json').to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
82
82
|
end
|
|
83
|
-
it
|
|
84
|
-
@client.update_profile_background_image(fixture(
|
|
85
|
-
expect(a_post(
|
|
83
|
+
it 'requests the correct resource' do
|
|
84
|
+
@client.update_profile_background_image(fixture('we_concept_bg2.png'))
|
|
85
|
+
expect(a_post('/1.1/account/update_profile_background_image.json')).to have_been_made
|
|
86
86
|
end
|
|
87
|
-
it
|
|
88
|
-
user = @client.update_profile_background_image(fixture(
|
|
87
|
+
it 'returns a user' do
|
|
88
|
+
user = @client.update_profile_background_image(fixture('we_concept_bg2.png'))
|
|
89
89
|
expect(user).to be_a Twitter::User
|
|
90
|
-
expect(user.id).to eq(
|
|
90
|
+
expect(user.id).to eq(7_505_382)
|
|
91
91
|
end
|
|
92
92
|
end
|
|
93
93
|
|
|
94
|
-
describe
|
|
94
|
+
describe '#update_profile_colors' do
|
|
95
95
|
before do
|
|
96
|
-
stub_post(
|
|
96
|
+
stub_post('/1.1/account/update_profile_colors.json').with(:body => {:profile_background_color => '000000'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
97
97
|
end
|
|
98
|
-
it
|
|
99
|
-
@client.update_profile_colors(:profile_background_color =>
|
|
100
|
-
expect(a_post(
|
|
98
|
+
it 'requests the correct resource' do
|
|
99
|
+
@client.update_profile_colors(:profile_background_color => '000000')
|
|
100
|
+
expect(a_post('/1.1/account/update_profile_colors.json').with(:body => {:profile_background_color => '000000'})).to have_been_made
|
|
101
101
|
end
|
|
102
|
-
it
|
|
103
|
-
user = @client.update_profile_colors(:profile_background_color =>
|
|
102
|
+
it 'returns a user' do
|
|
103
|
+
user = @client.update_profile_colors(:profile_background_color => '000000')
|
|
104
104
|
expect(user).to be_a Twitter::User
|
|
105
|
-
expect(user.id).to eq(
|
|
105
|
+
expect(user.id).to eq(7_505_382)
|
|
106
106
|
end
|
|
107
107
|
end
|
|
108
108
|
|
|
109
|
-
describe
|
|
109
|
+
describe '#update_profile_image' do
|
|
110
110
|
before do
|
|
111
|
-
stub_post(
|
|
111
|
+
stub_post('/1.1/account/update_profile_image.json').to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
112
112
|
end
|
|
113
|
-
it
|
|
114
|
-
@client.update_profile_image(fixture(
|
|
115
|
-
expect(a_post(
|
|
113
|
+
it 'requests the correct resource' do
|
|
114
|
+
@client.update_profile_image(fixture('me.jpeg'))
|
|
115
|
+
expect(a_post('/1.1/account/update_profile_image.json')).to have_been_made
|
|
116
116
|
end
|
|
117
|
-
it
|
|
118
|
-
user = @client.update_profile_image(fixture(
|
|
117
|
+
it 'returns a user' do
|
|
118
|
+
user = @client.update_profile_image(fixture('me.jpeg'))
|
|
119
119
|
expect(user).to be_a Twitter::User
|
|
120
|
-
expect(user.id).to eq(
|
|
120
|
+
expect(user.id).to eq(7_505_382)
|
|
121
121
|
end
|
|
122
122
|
end
|
|
123
123
|
|
|
124
|
-
describe
|
|
125
|
-
context
|
|
124
|
+
describe '#suggestions' do
|
|
125
|
+
context 'with a category slug passed' do
|
|
126
126
|
before do
|
|
127
|
-
stub_get(
|
|
127
|
+
stub_get('/1.1/users/suggestions/art-design.json').to_return(:body => fixture('category.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
128
128
|
end
|
|
129
|
-
it
|
|
130
|
-
@client.suggestions(
|
|
131
|
-
expect(a_get(
|
|
129
|
+
it 'requests the correct resource' do
|
|
130
|
+
@client.suggestions('art-design')
|
|
131
|
+
expect(a_get('/1.1/users/suggestions/art-design.json')).to have_been_made
|
|
132
132
|
end
|
|
133
|
-
it
|
|
134
|
-
suggestion = @client.suggestions(
|
|
133
|
+
it 'returns the users in a given category of the Twitter suggested user list' do
|
|
134
|
+
suggestion = @client.suggestions('art-design')
|
|
135
135
|
expect(suggestion).to be_a Twitter::Suggestion
|
|
136
|
-
expect(suggestion.name).to eq(
|
|
136
|
+
expect(suggestion.name).to eq('Art & Design')
|
|
137
137
|
expect(suggestion.users).to be_an Array
|
|
138
138
|
expect(suggestion.users.first).to be_a Twitter::User
|
|
139
139
|
end
|
|
140
140
|
end
|
|
141
|
-
context
|
|
141
|
+
context 'without arguments passed' do
|
|
142
142
|
before do
|
|
143
|
-
stub_get(
|
|
143
|
+
stub_get('/1.1/users/suggestions.json').to_return(:body => fixture('suggestions.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
144
144
|
end
|
|
145
|
-
it
|
|
145
|
+
it 'requests the correct resource' do
|
|
146
146
|
@client.suggestions
|
|
147
|
-
expect(a_get(
|
|
147
|
+
expect(a_get('/1.1/users/suggestions.json')).to have_been_made
|
|
148
148
|
end
|
|
149
|
-
it
|
|
149
|
+
it 'returns the list of suggested user categories' do
|
|
150
150
|
suggestions = @client.suggestions
|
|
151
151
|
expect(suggestions).to be_an Array
|
|
152
152
|
expect(suggestions.first).to be_a Twitter::Suggestion
|
|
153
|
-
expect(suggestions.first.name).to eq(
|
|
153
|
+
expect(suggestions.first.name).to eq('Art & Design')
|
|
154
154
|
end
|
|
155
155
|
end
|
|
156
156
|
end
|
|
157
157
|
|
|
158
|
-
describe
|
|
158
|
+
describe '#suggest_users' do
|
|
159
159
|
before do
|
|
160
|
-
stub_get(
|
|
160
|
+
stub_get('/1.1/users/suggestions/art-design/members.json').to_return(:body => fixture('members.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
161
161
|
end
|
|
162
|
-
it
|
|
163
|
-
@client.suggest_users(
|
|
164
|
-
expect(a_get(
|
|
162
|
+
it 'requests the correct resource' do
|
|
163
|
+
@client.suggest_users('art-design')
|
|
164
|
+
expect(a_get('/1.1/users/suggestions/art-design/members.json')).to have_been_made
|
|
165
165
|
end
|
|
166
|
-
it
|
|
167
|
-
suggest_users = @client.suggest_users(
|
|
166
|
+
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
|
|
167
|
+
suggest_users = @client.suggest_users('art-design')
|
|
168
168
|
expect(suggest_users).to be_an Array
|
|
169
169
|
expect(suggest_users.first).to be_a Twitter::User
|
|
170
170
|
expect(suggest_users.first.id).to eq(13)
|
|
171
171
|
end
|
|
172
172
|
end
|
|
173
173
|
|
|
174
|
-
describe
|
|
174
|
+
describe '#blocking' do
|
|
175
175
|
before do
|
|
176
|
-
stub_get(
|
|
176
|
+
stub_get('/1.1/blocks/list.json').with(:query => {:cursor => '-1'}).to_return(:body => fixture('users_list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
177
177
|
end
|
|
178
|
-
it
|
|
178
|
+
it 'requests the correct resource' do
|
|
179
179
|
@client.blocking
|
|
180
|
-
expect(a_get(
|
|
180
|
+
expect(a_get('/1.1/blocks/list.json').with(:query => {:cursor => '-1'})).to have_been_made
|
|
181
181
|
end
|
|
182
|
-
it
|
|
182
|
+
it 'returns an array of user objects that the authenticating user is blocking' do
|
|
183
183
|
blocking = @client.blocking
|
|
184
184
|
expect(blocking).to be_a Twitter::Cursor
|
|
185
185
|
expect(blocking.first).to be_a Twitter::User
|
|
186
|
-
expect(blocking.first.id).to eq(
|
|
186
|
+
expect(blocking.first.id).to eq(7_505_382)
|
|
187
187
|
end
|
|
188
|
-
context
|
|
188
|
+
context 'with each' do
|
|
189
189
|
before do
|
|
190
|
-
stub_get(
|
|
190
|
+
stub_get('/1.1/blocks/list.json').with(:query => {:cursor => '1322801608223717003'}).to_return(:body => fixture('users_list2.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
191
191
|
end
|
|
192
|
-
it
|
|
193
|
-
@client.blocking.each{}
|
|
194
|
-
expect(a_get(
|
|
195
|
-
expect(a_get(
|
|
192
|
+
it 'requests the correct resource' do
|
|
193
|
+
@client.blocking.each {}
|
|
194
|
+
expect(a_get('/1.1/blocks/list.json').with(:query => {:cursor => '-1'})).to have_been_made
|
|
195
|
+
expect(a_get('/1.1/blocks/list.json').with(:query => {:cursor => '1322801608223717003'})).to have_been_made
|
|
196
196
|
end
|
|
197
197
|
end
|
|
198
198
|
end
|
|
199
199
|
|
|
200
|
-
describe
|
|
200
|
+
describe '#blocked_ids' do
|
|
201
201
|
before do
|
|
202
|
-
stub_get(
|
|
202
|
+
stub_get('/1.1/blocks/ids.json').with(:query => {:cursor => '-1'}).to_return(:body => fixture('ids_list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
203
203
|
end
|
|
204
|
-
it
|
|
204
|
+
it 'requests the correct resource' do
|
|
205
205
|
@client.blocked_ids
|
|
206
|
-
expect(a_get(
|
|
206
|
+
expect(a_get('/1.1/blocks/ids.json').with(:query => {:cursor => '-1'})).to have_been_made
|
|
207
207
|
end
|
|
208
|
-
it
|
|
208
|
+
it 'returns an array of numeric user IDs the authenticating user is blocking' do
|
|
209
209
|
blocked_ids = @client.blocked_ids
|
|
210
210
|
expect(blocked_ids).to be_a Twitter::Cursor
|
|
211
|
-
expect(blocked_ids.first).to eq(
|
|
211
|
+
expect(blocked_ids.first).to eq(20_009_713)
|
|
212
212
|
end
|
|
213
|
-
context
|
|
213
|
+
context 'with each' do
|
|
214
214
|
before do
|
|
215
|
-
stub_get(
|
|
215
|
+
stub_get('/1.1/blocks/ids.json').with(:query => {:cursor => '1305102810874389703'}).to_return(:body => fixture('ids_list2.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
216
216
|
end
|
|
217
|
-
it
|
|
218
|
-
@client.blocked_ids.each{}
|
|
219
|
-
expect(a_get(
|
|
220
|
-
expect(a_get(
|
|
217
|
+
it 'requests the correct resource' do
|
|
218
|
+
@client.blocked_ids.each {}
|
|
219
|
+
expect(a_get('/1.1/blocks/ids.json').with(:query => {:cursor => '-1'})).to have_been_made
|
|
220
|
+
expect(a_get('/1.1/blocks/ids.json').with(:query => {:cursor => '1305102810874389703'})).to have_been_made
|
|
221
221
|
end
|
|
222
222
|
end
|
|
223
223
|
end
|
|
224
224
|
|
|
225
|
-
describe
|
|
226
|
-
context
|
|
225
|
+
describe '#block?' do
|
|
226
|
+
context 'with a screen name passed' do
|
|
227
227
|
before do
|
|
228
|
-
stub_get(
|
|
229
|
-
stub_get(
|
|
230
|
-
stub_get(
|
|
231
|
-
stub_get(
|
|
232
|
-
end
|
|
233
|
-
it
|
|
234
|
-
@client.block?(
|
|
235
|
-
expect(a_get(
|
|
236
|
-
expect(a_get(
|
|
237
|
-
expect(a_get(
|
|
238
|
-
end
|
|
239
|
-
it
|
|
240
|
-
block = @client.block?(
|
|
228
|
+
stub_get('/1.1/blocks/ids.json').with(:query => {:cursor => '-1'}).to_return(:body => fixture('ids_list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
229
|
+
stub_get('/1.1/blocks/ids.json').with(:query => {:cursor => '1305102810874389703'}).to_return(:body => fixture('ids_list2.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
230
|
+
stub_get('/1.1/users/show.json').with(:query => {:screen_name => 'pengwynn'}).to_return(:body => fixture('pengwynn.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
231
|
+
stub_get('/1.1/users/show.json').with(:query => {:screen_name => 'sferik'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
232
|
+
end
|
|
233
|
+
it 'requests the correct resource' do
|
|
234
|
+
@client.block?('sferik')
|
|
235
|
+
expect(a_get('/1.1/blocks/ids.json').with(:query => {:cursor => '-1'})).to have_been_made
|
|
236
|
+
expect(a_get('/1.1/blocks/ids.json').with(:query => {:cursor => '1305102810874389703'})).to have_been_made
|
|
237
|
+
expect(a_get('/1.1/users/show.json').with(:query => {:screen_name => 'sferik'})).to have_been_made
|
|
238
|
+
end
|
|
239
|
+
it 'returns true if block exists' do
|
|
240
|
+
block = @client.block?('pengwynn')
|
|
241
241
|
expect(block).to be true
|
|
242
242
|
end
|
|
243
|
-
it
|
|
244
|
-
block = @client.block?(
|
|
243
|
+
it 'returns false if block does not exist' do
|
|
244
|
+
block = @client.block?('sferik')
|
|
245
245
|
expect(block).to be false
|
|
246
246
|
end
|
|
247
247
|
end
|
|
248
|
-
context
|
|
248
|
+
context 'with a user ID passed' do
|
|
249
249
|
before do
|
|
250
|
-
stub_get(
|
|
251
|
-
stub_get(
|
|
250
|
+
stub_get('/1.1/blocks/ids.json').with(:query => {:cursor => '-1'}).to_return(:body => fixture('ids_list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
251
|
+
stub_get('/1.1/blocks/ids.json').with(:query => {:cursor => '1305102810874389703'}).to_return(:body => fixture('ids_list2.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
252
252
|
end
|
|
253
|
-
it
|
|
254
|
-
@client.block?(
|
|
255
|
-
expect(a_get(
|
|
256
|
-
expect(a_get(
|
|
253
|
+
it 'requests the correct resources' do
|
|
254
|
+
@client.block?(7_505_382)
|
|
255
|
+
expect(a_get('/1.1/blocks/ids.json').with(:query => {:cursor => '-1'})).to have_been_made
|
|
256
|
+
expect(a_get('/1.1/blocks/ids.json').with(:query => {:cursor => '1305102810874389703'})).to have_been_made
|
|
257
257
|
end
|
|
258
258
|
end
|
|
259
|
-
context
|
|
259
|
+
context 'with a user object passed' do
|
|
260
260
|
before do
|
|
261
|
-
stub_get(
|
|
262
|
-
stub_get(
|
|
261
|
+
stub_get('/1.1/blocks/ids.json').with(:query => {:cursor => '-1'}).to_return(:body => fixture('ids_list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
262
|
+
stub_get('/1.1/blocks/ids.json').with(:query => {:cursor => '1305102810874389703'}).to_return(:body => fixture('ids_list2.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
263
263
|
end
|
|
264
|
-
it
|
|
265
|
-
user = Twitter::User.new(:id =>
|
|
264
|
+
it 'requests the correct resources' do
|
|
265
|
+
user = Twitter::User.new(:id => '7505382')
|
|
266
266
|
@client.block?(user)
|
|
267
|
-
expect(a_get(
|
|
268
|
-
expect(a_get(
|
|
267
|
+
expect(a_get('/1.1/blocks/ids.json').with(:query => {:cursor => '-1'})).to have_been_made
|
|
268
|
+
expect(a_get('/1.1/blocks/ids.json').with(:query => {:cursor => '1305102810874389703'})).to have_been_made
|
|
269
269
|
end
|
|
270
270
|
end
|
|
271
271
|
end
|
|
272
272
|
|
|
273
|
-
describe
|
|
273
|
+
describe '#block' do
|
|
274
274
|
before do
|
|
275
|
-
stub_post(
|
|
275
|
+
stub_post('/1.1/blocks/create.json').with(:body => {:screen_name => 'sferik'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
276
276
|
end
|
|
277
|
-
it
|
|
278
|
-
@client.block(
|
|
279
|
-
expect(a_post(
|
|
277
|
+
it 'requests the correct resource' do
|
|
278
|
+
@client.block('sferik')
|
|
279
|
+
expect(a_post('/1.1/blocks/create.json')).to have_been_made
|
|
280
280
|
end
|
|
281
|
-
it
|
|
282
|
-
users = @client.block(
|
|
281
|
+
it 'returns an array of blocked users' do
|
|
282
|
+
users = @client.block('sferik')
|
|
283
283
|
expect(users).to be_an Array
|
|
284
284
|
expect(users.first).to be_a Twitter::User
|
|
285
|
-
expect(users.first.id).to eq(
|
|
285
|
+
expect(users.first.id).to eq(7_505_382)
|
|
286
286
|
end
|
|
287
287
|
end
|
|
288
288
|
|
|
289
|
-
describe
|
|
289
|
+
describe '#unblock' do
|
|
290
290
|
before do
|
|
291
|
-
stub_post(
|
|
291
|
+
stub_post('/1.1/blocks/destroy.json').with(:body => {:screen_name => 'sferik'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
292
292
|
end
|
|
293
|
-
it
|
|
294
|
-
@client.unblock(
|
|
295
|
-
expect(a_post(
|
|
293
|
+
it 'requests the correct resource' do
|
|
294
|
+
@client.unblock('sferik')
|
|
295
|
+
expect(a_post('/1.1/blocks/destroy.json').with(:body => {:screen_name => 'sferik'})).to have_been_made
|
|
296
296
|
end
|
|
297
|
-
it
|
|
298
|
-
users = @client.unblock(
|
|
297
|
+
it 'returns an array of un-blocked users' do
|
|
298
|
+
users = @client.unblock('sferik')
|
|
299
299
|
expect(users).to be_an Array
|
|
300
300
|
expect(users.first).to be_a Twitter::User
|
|
301
|
-
expect(users.first.id).to eq(
|
|
301
|
+
expect(users.first.id).to eq(7_505_382)
|
|
302
302
|
end
|
|
303
303
|
end
|
|
304
304
|
|
|
305
|
-
describe
|
|
306
|
-
context
|
|
307
|
-
context
|
|
305
|
+
describe '#users' do
|
|
306
|
+
context 'using a post request' do
|
|
307
|
+
context 'with screen names passed' do
|
|
308
308
|
before do
|
|
309
|
-
stub_post(
|
|
309
|
+
stub_post('/1.1/users/lookup.json').with(:body => {:screen_name => 'sferik,pengwynn'}).to_return(:body => fixture('users.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
310
310
|
end
|
|
311
|
-
it
|
|
312
|
-
@client.users(
|
|
313
|
-
expect(a_post(
|
|
311
|
+
it 'requests the correct resource' do
|
|
312
|
+
@client.users('sferik', 'pengwynn')
|
|
313
|
+
expect(a_post('/1.1/users/lookup.json').with(:body => {:screen_name => 'sferik,pengwynn'})).to have_been_made
|
|
314
314
|
end
|
|
315
|
-
it
|
|
316
|
-
users = @client.users(
|
|
315
|
+
it 'returns up to 100 users worth of extended information' do
|
|
316
|
+
users = @client.users('sferik', 'pengwynn')
|
|
317
317
|
expect(users).to be_an Array
|
|
318
318
|
expect(users.first).to be_a Twitter::User
|
|
319
|
-
expect(users.first.id).to eq(
|
|
319
|
+
expect(users.first.id).to eq(7_505_382)
|
|
320
320
|
end
|
|
321
|
-
context
|
|
322
|
-
it
|
|
323
|
-
sferik = URI.parse(
|
|
324
|
-
pengwynn = URI.parse(
|
|
321
|
+
context 'with URI objects passed' do
|
|
322
|
+
it 'requests the correct resource' do
|
|
323
|
+
sferik = URI.parse('https://twitter.com/sferik')
|
|
324
|
+
pengwynn = URI.parse('https://twitter.com/pengwynn')
|
|
325
325
|
@client.users(sferik, pengwynn)
|
|
326
|
-
expect(a_post(
|
|
326
|
+
expect(a_post('/1.1/users/lookup.json').with(:body => {:screen_name => 'sferik,pengwynn'})).to have_been_made
|
|
327
327
|
end
|
|
328
328
|
end
|
|
329
|
-
context
|
|
330
|
-
it
|
|
331
|
-
@client.users(
|
|
332
|
-
expect(a_post(
|
|
329
|
+
context 'with URI strings passed' do
|
|
330
|
+
it 'requests the correct resource' do
|
|
331
|
+
@client.users('https://twitter.com/sferik', 'https://twitter.com/pengwynn')
|
|
332
|
+
expect(a_post('/1.1/users/lookup.json').with(:body => {:screen_name => 'sferik,pengwynn'})).to have_been_made
|
|
333
333
|
end
|
|
334
334
|
end
|
|
335
335
|
end
|
|
336
|
-
context
|
|
336
|
+
context 'with numeric screen names passed' do
|
|
337
337
|
before do
|
|
338
|
-
stub_post(
|
|
338
|
+
stub_post('/1.1/users/lookup.json').with(:body => {:screen_name => '0,311'}).to_return(:body => fixture('users.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
339
339
|
end
|
|
340
|
-
it
|
|
341
|
-
@client.users(
|
|
342
|
-
expect(a_post(
|
|
340
|
+
it 'requests the correct resource' do
|
|
341
|
+
@client.users('0', '311')
|
|
342
|
+
expect(a_post('/1.1/users/lookup.json').with(:body => {:screen_name => '0,311'})).to have_been_made
|
|
343
343
|
end
|
|
344
344
|
end
|
|
345
|
-
context
|
|
345
|
+
context 'with user IDs passed' do
|
|
346
346
|
before do
|
|
347
|
-
stub_post(
|
|
347
|
+
stub_post('/1.1/users/lookup.json').with(:body => {:user_id => '7505382,14100886'}).to_return(:body => fixture('users.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
348
348
|
end
|
|
349
|
-
it
|
|
350
|
-
@client.users(
|
|
351
|
-
expect(a_post(
|
|
349
|
+
it 'requests the correct resource' do
|
|
350
|
+
@client.users(7_505_382, 14_100_886)
|
|
351
|
+
expect(a_post('/1.1/users/lookup.json').with(:body => {:user_id => '7505382,14100886'})).to have_been_made
|
|
352
352
|
end
|
|
353
353
|
end
|
|
354
|
-
context
|
|
354
|
+
context 'with both screen names and user IDs passed' do
|
|
355
355
|
before do
|
|
356
|
-
stub_post(
|
|
356
|
+
stub_post('/1.1/users/lookup.json').with(:body => {:screen_name => 'sferik', :user_id => '14100886'}).to_return(:body => fixture('users.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
357
357
|
end
|
|
358
|
-
it
|
|
359
|
-
@client.users(
|
|
360
|
-
expect(a_post(
|
|
358
|
+
it 'requests the correct resource' do
|
|
359
|
+
@client.users('sferik', 14_100_886)
|
|
360
|
+
expect(a_post('/1.1/users/lookup.json').with(:body => {:screen_name => 'sferik', :user_id => '14100886'})).to have_been_made
|
|
361
361
|
end
|
|
362
362
|
end
|
|
363
|
-
context
|
|
363
|
+
context 'with user objects passed' do
|
|
364
364
|
before do
|
|
365
|
-
stub_post(
|
|
365
|
+
stub_post('/1.1/users/lookup.json').with(:body => {:user_id => '7505382,14100886'}).to_return(:body => fixture('users.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
366
366
|
end
|
|
367
|
-
it
|
|
368
|
-
user1 = Twitter::User.new(:id =>
|
|
369
|
-
user2 = Twitter::User.new(:id =>
|
|
367
|
+
it 'requests the correct resource' do
|
|
368
|
+
user1 = Twitter::User.new(:id => '7505382')
|
|
369
|
+
user2 = Twitter::User.new(:id => '14100886')
|
|
370
370
|
@client.users(user1, user2)
|
|
371
|
-
expect(a_post(
|
|
371
|
+
expect(a_post('/1.1/users/lookup.json').with(:body => {:user_id => '7505382,14100886'})).to have_been_made
|
|
372
372
|
end
|
|
373
373
|
end
|
|
374
374
|
end
|
|
375
|
-
context
|
|
376
|
-
context
|
|
375
|
+
context 'using a get request' do
|
|
376
|
+
context 'with screen names passed' do
|
|
377
377
|
before do
|
|
378
|
-
stub_get(
|
|
378
|
+
stub_get('/1.1/users/lookup.json').with(:query => {:screen_name => 'sferik,pengwynn'}).to_return(:body => fixture('users.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
379
379
|
end
|
|
380
|
-
it
|
|
381
|
-
@client.users(
|
|
382
|
-
expect(a_get(
|
|
380
|
+
it 'requests the correct resource' do
|
|
381
|
+
@client.users('sferik', 'pengwynn', :method => :get)
|
|
382
|
+
expect(a_get('/1.1/users/lookup.json').with(:query => {:screen_name => 'sferik,pengwynn'})).to have_been_made
|
|
383
383
|
end
|
|
384
|
-
it
|
|
385
|
-
users = @client.users(
|
|
384
|
+
it 'returns up to 100 users worth of extended information' do
|
|
385
|
+
users = @client.users('sferik', 'pengwynn', :method => :get)
|
|
386
386
|
expect(users).to be_an Array
|
|
387
387
|
expect(users.first).to be_a Twitter::User
|
|
388
|
-
expect(users.first.id).to eq(
|
|
388
|
+
expect(users.first.id).to eq(7_505_382)
|
|
389
389
|
end
|
|
390
|
-
context
|
|
391
|
-
it
|
|
392
|
-
sferik = URI.parse(
|
|
393
|
-
pengwynn = URI.parse(
|
|
390
|
+
context 'with URI objects passed' do
|
|
391
|
+
it 'requests the correct resource' do
|
|
392
|
+
sferik = URI.parse('https://twitter.com/sferik')
|
|
393
|
+
pengwynn = URI.parse('https://twitter.com/pengwynn')
|
|
394
394
|
@client.users(sferik, pengwynn, :method => :get)
|
|
395
|
-
expect(a_get(
|
|
395
|
+
expect(a_get('/1.1/users/lookup.json').with(:query => {:screen_name => 'sferik,pengwynn'})).to have_been_made
|
|
396
396
|
end
|
|
397
397
|
end
|
|
398
|
-
context
|
|
399
|
-
it
|
|
400
|
-
@client.users(
|
|
401
|
-
expect(a_get(
|
|
398
|
+
context 'with URI objects passed' do
|
|
399
|
+
it 'requests the correct resource' do
|
|
400
|
+
@client.users('https://twitter.com/sferik', 'https://twitter.com/pengwynn', :method => :get)
|
|
401
|
+
expect(a_get('/1.1/users/lookup.json').with(:query => {:screen_name => 'sferik,pengwynn'})).to have_been_made
|
|
402
402
|
end
|
|
403
403
|
end
|
|
404
404
|
end
|
|
405
|
-
context
|
|
405
|
+
context 'with numeric screen names passed' do
|
|
406
406
|
before do
|
|
407
|
-
stub_get(
|
|
407
|
+
stub_get('/1.1/users/lookup.json').with(:query => {:screen_name => '0,311'}).to_return(:body => fixture('users.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
408
408
|
end
|
|
409
|
-
it
|
|
410
|
-
@client.users(
|
|
411
|
-
expect(a_get(
|
|
409
|
+
it 'requests the correct resource' do
|
|
410
|
+
@client.users('0', '311', :method => :get)
|
|
411
|
+
expect(a_get('/1.1/users/lookup.json').with(:query => {:screen_name => '0,311'})).to have_been_made
|
|
412
412
|
end
|
|
413
413
|
end
|
|
414
|
-
context
|
|
414
|
+
context 'with user IDs passed' do
|
|
415
415
|
before do
|
|
416
|
-
stub_get(
|
|
416
|
+
stub_get('/1.1/users/lookup.json').with(:query => {:user_id => '7505382,14100886'}).to_return(:body => fixture('users.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
417
417
|
end
|
|
418
|
-
it
|
|
419
|
-
@client.users(
|
|
420
|
-
expect(a_get(
|
|
418
|
+
it 'requests the correct resource' do
|
|
419
|
+
@client.users(7_505_382, 14_100_886, :method => :get)
|
|
420
|
+
expect(a_get('/1.1/users/lookup.json').with(:query => {:user_id => '7505382,14100886'})).to have_been_made
|
|
421
421
|
end
|
|
422
422
|
end
|
|
423
|
-
context
|
|
423
|
+
context 'with both screen names and user IDs passed' do
|
|
424
424
|
before do
|
|
425
|
-
stub_get(
|
|
425
|
+
stub_get('/1.1/users/lookup.json').with(:query => {:screen_name => 'sferik', :user_id => '14100886'}).to_return(:body => fixture('users.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
426
426
|
end
|
|
427
|
-
it
|
|
428
|
-
@client.users(
|
|
429
|
-
expect(a_get(
|
|
427
|
+
it 'requests the correct resource' do
|
|
428
|
+
@client.users('sferik', 14_100_886, :method => :get)
|
|
429
|
+
expect(a_get('/1.1/users/lookup.json').with(:query => {:screen_name => 'sferik', :user_id => '14100886'})).to have_been_made
|
|
430
430
|
end
|
|
431
431
|
end
|
|
432
|
-
context
|
|
432
|
+
context 'with user objects passed' do
|
|
433
433
|
before do
|
|
434
|
-
stub_get(
|
|
434
|
+
stub_get('/1.1/users/lookup.json').with(:query => {:user_id => '7505382,14100886'}).to_return(:body => fixture('users.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
435
435
|
end
|
|
436
|
-
it
|
|
437
|
-
user1 = Twitter::User.new(:id =>
|
|
438
|
-
user2 = Twitter::User.new(:id =>
|
|
436
|
+
it 'requests the correct resource' do
|
|
437
|
+
user1 = Twitter::User.new(:id => '7505382')
|
|
438
|
+
user2 = Twitter::User.new(:id => '14100886')
|
|
439
439
|
@client.users(user1, user2, :method => :get)
|
|
440
|
-
expect(a_get(
|
|
440
|
+
expect(a_get('/1.1/users/lookup.json').with(:query => {:user_id => '7505382,14100886'})).to have_been_made
|
|
441
441
|
end
|
|
442
442
|
end
|
|
443
443
|
end
|
|
444
444
|
end
|
|
445
445
|
|
|
446
|
-
describe
|
|
447
|
-
context
|
|
446
|
+
describe '#user' do
|
|
447
|
+
context 'with a screen name passed' do
|
|
448
448
|
before do
|
|
449
|
-
stub_get(
|
|
449
|
+
stub_get('/1.1/users/show.json').with(:query => {:screen_name => 'sferik'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
450
450
|
end
|
|
451
|
-
it
|
|
452
|
-
@client.user(
|
|
453
|
-
expect(a_get(
|
|
451
|
+
it 'requests the correct resource' do
|
|
452
|
+
@client.user('sferik')
|
|
453
|
+
expect(a_get('/1.1/users/show.json').with(:query => {:screen_name => 'sferik'})).to have_been_made
|
|
454
454
|
end
|
|
455
|
-
it
|
|
456
|
-
user = @client.user(
|
|
455
|
+
it 'returns extended information of a given user' do
|
|
456
|
+
user = @client.user('sferik')
|
|
457
457
|
expect(user).to be_a Twitter::User
|
|
458
|
-
expect(user.id).to eq(
|
|
458
|
+
expect(user.id).to eq(7_505_382)
|
|
459
459
|
end
|
|
460
460
|
end
|
|
461
|
-
context
|
|
461
|
+
context 'with a screen name including "@" passed' do
|
|
462
462
|
before do
|
|
463
|
-
stub_get(
|
|
463
|
+
stub_get('/1.1/users/show.json').with(:query => {:screen_name => '@sferik'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
464
464
|
end
|
|
465
|
-
it
|
|
466
|
-
@client.user(
|
|
467
|
-
expect(a_get(
|
|
465
|
+
it 'requests the correct resource' do
|
|
466
|
+
@client.user('@sferik')
|
|
467
|
+
expect(a_get('/1.1/users/show.json').with(:query => {:screen_name => '@sferik'})).to have_been_made
|
|
468
468
|
end
|
|
469
469
|
end
|
|
470
|
-
context
|
|
470
|
+
context 'with a numeric screen name passed' do
|
|
471
471
|
before do
|
|
472
|
-
stub_get(
|
|
472
|
+
stub_get('/1.1/users/show.json').with(:query => {:screen_name => '0'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
473
473
|
end
|
|
474
|
-
it
|
|
475
|
-
@client.user(
|
|
476
|
-
expect(a_get(
|
|
474
|
+
it 'requests the correct resource' do
|
|
475
|
+
@client.user('0')
|
|
476
|
+
expect(a_get('/1.1/users/show.json').with(:query => {:screen_name => '0'})).to have_been_made
|
|
477
477
|
end
|
|
478
478
|
end
|
|
479
|
-
context
|
|
479
|
+
context 'with a user ID passed' do
|
|
480
480
|
before do
|
|
481
|
-
stub_get(
|
|
481
|
+
stub_get('/1.1/users/show.json').with(:query => {:user_id => '7505382'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
482
482
|
end
|
|
483
|
-
it
|
|
484
|
-
@client.user(
|
|
485
|
-
expect(a_get(
|
|
483
|
+
it 'requests the correct resource' do
|
|
484
|
+
@client.user(7_505_382)
|
|
485
|
+
expect(a_get('/1.1/users/show.json').with(:query => {:user_id => '7505382'})).to have_been_made
|
|
486
486
|
end
|
|
487
487
|
end
|
|
488
|
-
context
|
|
488
|
+
context 'with a user object passed' do
|
|
489
489
|
before do
|
|
490
|
-
stub_get(
|
|
490
|
+
stub_get('/1.1/users/show.json').with(:query => {:user_id => '7505382'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
491
491
|
end
|
|
492
|
-
it
|
|
493
|
-
user = Twitter::User.new(:id =>
|
|
492
|
+
it 'requests the correct resource' do
|
|
493
|
+
user = Twitter::User.new(:id => 7_505_382)
|
|
494
494
|
@client.user(user)
|
|
495
|
-
expect(a_get(
|
|
495
|
+
expect(a_get('/1.1/users/show.json').with(:query => {:user_id => '7505382'})).to have_been_made
|
|
496
496
|
end
|
|
497
497
|
end
|
|
498
498
|
end
|
|
499
|
-
context
|
|
500
|
-
context
|
|
499
|
+
context 'without a screen name or user ID passed' do
|
|
500
|
+
context 'without options passed' do
|
|
501
501
|
before do
|
|
502
|
-
stub_get(
|
|
502
|
+
stub_get('/1.1/account/verify_credentials.json').to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
503
503
|
end
|
|
504
|
-
it
|
|
504
|
+
it 'requests the correct resource' do
|
|
505
505
|
@client.user
|
|
506
|
-
expect(a_get(
|
|
506
|
+
expect(a_get('/1.1/account/verify_credentials.json')).to have_been_made
|
|
507
507
|
end
|
|
508
508
|
end
|
|
509
|
-
context
|
|
509
|
+
context 'with options passed' do
|
|
510
510
|
before do
|
|
511
|
-
stub_get(
|
|
511
|
+
stub_get('/1.1/account/verify_credentials.json').with(:query => {:skip_status => 'true'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
512
512
|
end
|
|
513
|
-
it
|
|
513
|
+
it 'requests the correct resource' do
|
|
514
514
|
@client.user(:skip_status => true)
|
|
515
|
-
expect(a_get(
|
|
515
|
+
expect(a_get('/1.1/account/verify_credentials.json').with(:query => {:skip_status => 'true'})).to have_been_made
|
|
516
516
|
end
|
|
517
517
|
end
|
|
518
518
|
end
|
|
519
519
|
|
|
520
|
-
describe
|
|
520
|
+
describe '#user?' do
|
|
521
521
|
before do
|
|
522
|
-
stub_get(
|
|
523
|
-
stub_get(
|
|
522
|
+
stub_get('/1.1/users/show.json').with(:query => {:screen_name => 'sferik'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
523
|
+
stub_get('/1.1/users/show.json').with(:query => {:screen_name => 'pengwynn'}).to_return(:body => fixture('not_found.json'), :status => 404, :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
524
524
|
end
|
|
525
|
-
it
|
|
526
|
-
@client.user?(
|
|
527
|
-
expect(a_get(
|
|
525
|
+
it 'requests the correct resource' do
|
|
526
|
+
@client.user?('sferik')
|
|
527
|
+
expect(a_get('/1.1/users/show.json').with(:query => {:screen_name => 'sferik'})).to have_been_made
|
|
528
528
|
end
|
|
529
|
-
it
|
|
530
|
-
user = @client.user?(
|
|
529
|
+
it 'returns true if user exists' do
|
|
530
|
+
user = @client.user?('sferik')
|
|
531
531
|
expect(user).to be true
|
|
532
532
|
end
|
|
533
|
-
it
|
|
534
|
-
user = @client.user?(
|
|
533
|
+
it 'returns false if user does not exist' do
|
|
534
|
+
user = @client.user?('pengwynn')
|
|
535
535
|
expect(user).to be false
|
|
536
536
|
end
|
|
537
537
|
end
|
|
538
538
|
|
|
539
|
-
describe
|
|
539
|
+
describe '#user_search' do
|
|
540
540
|
before do
|
|
541
|
-
stub_get(
|
|
541
|
+
stub_get('/1.1/users/search.json').with(:query => {:q => 'Erik Michaels-Ober'}).to_return(:body => fixture('user_search.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
542
542
|
end
|
|
543
|
-
it
|
|
544
|
-
@client.user_search(
|
|
545
|
-
expect(a_get(
|
|
543
|
+
it 'requests the correct resource' do
|
|
544
|
+
@client.user_search('Erik Michaels-Ober')
|
|
545
|
+
expect(a_get('/1.1/users/search.json').with(:query => {:q => 'Erik Michaels-Ober'})).to have_been_made
|
|
546
546
|
end
|
|
547
|
-
it
|
|
548
|
-
user_search = @client.user_search(
|
|
547
|
+
it 'returns an array of user search results' do
|
|
548
|
+
user_search = @client.user_search('Erik Michaels-Ober')
|
|
549
549
|
expect(user_search).to be_an Array
|
|
550
550
|
expect(user_search.first).to be_a Twitter::User
|
|
551
|
-
expect(user_search.first.id).to eq(
|
|
551
|
+
expect(user_search.first.id).to eq(7_505_382)
|
|
552
552
|
end
|
|
553
553
|
end
|
|
554
554
|
|
|
555
|
-
describe
|
|
556
|
-
context
|
|
555
|
+
describe '#contributees' do
|
|
556
|
+
context 'with a screen name passed' do
|
|
557
557
|
before do
|
|
558
|
-
stub_get(
|
|
558
|
+
stub_get('/1.1/users/contributees.json').with(:query => {:screen_name => 'sferik'}).to_return(:body => fixture('contributees.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
559
559
|
end
|
|
560
|
-
it
|
|
561
|
-
@client.contributees(
|
|
562
|
-
expect(a_get(
|
|
560
|
+
it 'requests the correct resource' do
|
|
561
|
+
@client.contributees('sferik')
|
|
562
|
+
expect(a_get('/1.1/users/contributees.json').with(:query => {:screen_name => 'sferik'})).to have_been_made
|
|
563
563
|
end
|
|
564
|
-
it
|
|
565
|
-
contributees = @client.contributees(
|
|
564
|
+
it 'returns contributees' do
|
|
565
|
+
contributees = @client.contributees('sferik')
|
|
566
566
|
expect(contributees).to be_an Array
|
|
567
567
|
expect(contributees.first).to be_a Twitter::User
|
|
568
|
-
expect(contributees.first.name).to eq(
|
|
568
|
+
expect(contributees.first.name).to eq('Twitter API')
|
|
569
569
|
end
|
|
570
570
|
end
|
|
571
|
-
context
|
|
571
|
+
context 'with a user ID passed' do
|
|
572
572
|
before do
|
|
573
|
-
stub_get(
|
|
573
|
+
stub_get('/1.1/users/contributees.json').with(:query => {:user_id => '7505382'}).to_return(:body => fixture('contributees.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
574
574
|
end
|
|
575
|
-
it
|
|
576
|
-
@client.contributees(
|
|
577
|
-
expect(a_get(
|
|
575
|
+
it 'requests the correct resource' do
|
|
576
|
+
@client.contributees(7_505_382)
|
|
577
|
+
expect(a_get('/1.1/users/contributees.json').with(:query => {:user_id => '7505382'})).to have_been_made
|
|
578
578
|
end
|
|
579
579
|
end
|
|
580
|
-
context
|
|
580
|
+
context 'without arguments passed' do
|
|
581
581
|
before do
|
|
582
|
-
stub_get(
|
|
583
|
-
stub_get(
|
|
582
|
+
stub_get('/1.1/account/verify_credentials.json').to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
583
|
+
stub_get('/1.1/users/contributees.json').with(:query => {:screen_name => 'sferik'}).to_return(:body => fixture('contributees.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
584
584
|
end
|
|
585
|
-
it
|
|
585
|
+
it 'requests the correct resource' do
|
|
586
586
|
@client.contributees
|
|
587
|
-
expect(a_get(
|
|
587
|
+
expect(a_get('/1.1/users/contributees.json').with(:query => {:screen_name => 'sferik'})).to have_been_made
|
|
588
588
|
end
|
|
589
|
-
it
|
|
589
|
+
it 'returns contributees' do
|
|
590
590
|
contributees = @client.contributees
|
|
591
591
|
expect(contributees).to be_an Array
|
|
592
592
|
expect(contributees.first).to be_a Twitter::User
|
|
593
|
-
expect(contributees.first.name).to eq(
|
|
593
|
+
expect(contributees.first.name).to eq('Twitter API')
|
|
594
594
|
end
|
|
595
595
|
end
|
|
596
596
|
end
|
|
597
597
|
|
|
598
|
-
describe
|
|
599
|
-
context
|
|
598
|
+
describe '#contributors' do
|
|
599
|
+
context 'with a screen name passed' do
|
|
600
600
|
before do
|
|
601
|
-
stub_get(
|
|
601
|
+
stub_get('/1.1/users/contributors.json').with(:query => {:screen_name => 'sferik'}).to_return(:body => fixture('members.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
602
602
|
end
|
|
603
|
-
it
|
|
604
|
-
@client.contributors(
|
|
605
|
-
expect(a_get(
|
|
603
|
+
it 'requests the correct resource' do
|
|
604
|
+
@client.contributors('sferik')
|
|
605
|
+
expect(a_get('/1.1/users/contributors.json').with(:query => {:screen_name => 'sferik'})).to have_been_made
|
|
606
606
|
end
|
|
607
|
-
it
|
|
608
|
-
contributors = @client.contributors(
|
|
607
|
+
it 'returns contributors' do
|
|
608
|
+
contributors = @client.contributors('sferik')
|
|
609
609
|
expect(contributors).to be_an Array
|
|
610
610
|
expect(contributors.first).to be_a Twitter::User
|
|
611
611
|
expect(contributors.first.id).to eq(13)
|
|
612
612
|
end
|
|
613
613
|
end
|
|
614
|
-
context
|
|
614
|
+
context 'with a user ID passed' do
|
|
615
615
|
before do
|
|
616
|
-
stub_get(
|
|
616
|
+
stub_get('/1.1/users/contributors.json').with(:query => {:user_id => '7505382'}).to_return(:body => fixture('members.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
617
617
|
end
|
|
618
|
-
it
|
|
619
|
-
@client.contributors(
|
|
620
|
-
expect(a_get(
|
|
618
|
+
it 'requests the correct resource' do
|
|
619
|
+
@client.contributors(7_505_382)
|
|
620
|
+
expect(a_get('/1.1/users/contributors.json').with(:query => {:user_id => '7505382'})).to have_been_made
|
|
621
621
|
end
|
|
622
622
|
end
|
|
623
|
-
context
|
|
623
|
+
context 'without arguments passed' do
|
|
624
624
|
before do
|
|
625
|
-
stub_get(
|
|
626
|
-
stub_get(
|
|
625
|
+
stub_get('/1.1/account/verify_credentials.json').to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
626
|
+
stub_get('/1.1/users/contributors.json').with(:query => {:screen_name => 'sferik'}).to_return(:body => fixture('members.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
627
627
|
end
|
|
628
|
-
it
|
|
628
|
+
it 'requests the correct resource' do
|
|
629
629
|
@client.contributors
|
|
630
|
-
expect(a_get(
|
|
630
|
+
expect(a_get('/1.1/users/contributors.json').with(:query => {:screen_name => 'sferik'})).to have_been_made
|
|
631
631
|
end
|
|
632
|
-
it
|
|
632
|
+
it 'returns contributors' do
|
|
633
633
|
contributors = @client.contributors
|
|
634
634
|
expect(contributors).to be_an Array
|
|
635
635
|
expect(contributors.first).to be_a Twitter::User
|
|
@@ -638,70 +638,70 @@ describe Twitter::REST::API::Users do
|
|
|
638
638
|
end
|
|
639
639
|
end
|
|
640
640
|
|
|
641
|
-
describe
|
|
641
|
+
describe '#remove_profile_banner' do
|
|
642
642
|
before do
|
|
643
|
-
stub_post(
|
|
643
|
+
stub_post('/1.1/account/remove_profile_banner.json').to_return(:body => fixture('empty.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
644
644
|
end
|
|
645
|
-
it
|
|
645
|
+
it 'requests the correct resource' do
|
|
646
646
|
@client.remove_profile_banner
|
|
647
|
-
expect(a_post(
|
|
647
|
+
expect(a_post('/1.1/account/remove_profile_banner.json')).to have_been_made
|
|
648
648
|
end
|
|
649
|
-
it
|
|
649
|
+
it 'returns a user' do
|
|
650
650
|
user = @client.remove_profile_banner
|
|
651
651
|
expect(user).to be_nil
|
|
652
652
|
end
|
|
653
653
|
end
|
|
654
654
|
|
|
655
|
-
describe
|
|
655
|
+
describe '#update_profile_banner' do
|
|
656
656
|
before do
|
|
657
|
-
stub_post(
|
|
657
|
+
stub_post('/1.1/account/update_profile_banner.json').to_return(:body => fixture('empty.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
658
658
|
end
|
|
659
|
-
it
|
|
660
|
-
@client.update_profile_banner(fixture(
|
|
661
|
-
expect(a_post(
|
|
659
|
+
it 'requests the correct resource' do
|
|
660
|
+
@client.update_profile_banner(fixture('me.jpeg'))
|
|
661
|
+
expect(a_post('/1.1/account/update_profile_banner.json')).to have_been_made
|
|
662
662
|
end
|
|
663
|
-
it
|
|
664
|
-
user = @client.update_profile_banner(fixture(
|
|
663
|
+
it 'returns a user' do
|
|
664
|
+
user = @client.update_profile_banner(fixture('me.jpeg'))
|
|
665
665
|
expect(user).to be_nil
|
|
666
666
|
end
|
|
667
667
|
end
|
|
668
668
|
|
|
669
|
-
describe
|
|
670
|
-
context
|
|
669
|
+
describe '#profile_banner' do
|
|
670
|
+
context 'with a screen_name passed' do
|
|
671
671
|
before do
|
|
672
|
-
stub_get(
|
|
672
|
+
stub_get('/1.1/users/profile_banner.json').with(:query => {:screen_name => 'sferik'}).to_return(:body => fixture('profile_banner.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
673
673
|
end
|
|
674
|
-
it
|
|
675
|
-
@client.profile_banner(
|
|
676
|
-
expect(a_get(
|
|
674
|
+
it 'requests the correct resource' do
|
|
675
|
+
@client.profile_banner('sferik')
|
|
676
|
+
expect(a_get('/1.1/users/profile_banner.json').with(:query => {:screen_name => 'sferik'})).to have_been_made
|
|
677
677
|
end
|
|
678
|
-
it
|
|
679
|
-
banner = @client.profile_banner(
|
|
678
|
+
it 'returns a profile banner' do
|
|
679
|
+
banner = @client.profile_banner('sferik')
|
|
680
680
|
expect(banner).to be_a Twitter::ProfileBanner
|
|
681
681
|
expect(banner.sizes).to be_a Hash
|
|
682
682
|
expect(banner.sizes[:mobile].height).to eq(160)
|
|
683
683
|
end
|
|
684
684
|
end
|
|
685
|
-
context
|
|
685
|
+
context 'with a user ID passed' do
|
|
686
686
|
before do
|
|
687
|
-
stub_get(
|
|
687
|
+
stub_get('/1.1/users/profile_banner.json').with(:query => {:user_id => '7505382'}).to_return(:body => fixture('profile_banner.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
688
688
|
end
|
|
689
|
-
it
|
|
690
|
-
@client.profile_banner(
|
|
691
|
-
expect(a_get(
|
|
689
|
+
it 'requests the correct resource' do
|
|
690
|
+
@client.profile_banner(7_505_382)
|
|
691
|
+
expect(a_get('/1.1/users/profile_banner.json').with(:query => {:user_id => '7505382'})).to have_been_made
|
|
692
692
|
end
|
|
693
693
|
end
|
|
694
|
-
context
|
|
694
|
+
context 'without arguments passed' do
|
|
695
695
|
before do
|
|
696
|
-
stub_get(
|
|
697
|
-
stub_get(
|
|
696
|
+
stub_get('/1.1/account/verify_credentials.json').to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
697
|
+
stub_get('/1.1/users/profile_banner.json').with(:query => {:screen_name => 'sferik'}).to_return(:body => fixture('profile_banner.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
698
698
|
end
|
|
699
|
-
it
|
|
699
|
+
it 'requests the correct resource' do
|
|
700
700
|
@client.profile_banner
|
|
701
|
-
expect(a_get(
|
|
702
|
-
expect(a_get(
|
|
701
|
+
expect(a_get('/1.1/account/verify_credentials.json')).to have_been_made
|
|
702
|
+
expect(a_get('/1.1/users/profile_banner.json').with(:query => {:screen_name => 'sferik'})).to have_been_made
|
|
703
703
|
end
|
|
704
|
-
it
|
|
704
|
+
it 'returns an array of numeric IDs for every user following the specified user' do
|
|
705
705
|
banner = @client.profile_banner
|
|
706
706
|
expect(banner).to be_a Twitter::ProfileBanner
|
|
707
707
|
expect(banner.sizes).to be_a Hash
|