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,653 +3,661 @@ require 'helper'
|
|
|
3
3
|
describe Twitter::REST::API::FriendsAndFollowers 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 '#friend_ids' do
|
|
10
|
+
context 'with a screen name passed' do
|
|
11
11
|
before do
|
|
12
|
-
stub_get(
|
|
12
|
+
stub_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'}).to_return(:body => fixture('ids_list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
13
13
|
end
|
|
14
|
-
it
|
|
15
|
-
@client.friend_ids(
|
|
16
|
-
expect(a_get(
|
|
14
|
+
it 'requests the correct resource' do
|
|
15
|
+
@client.friend_ids('sferik')
|
|
16
|
+
expect(a_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'})).to have_been_made
|
|
17
17
|
end
|
|
18
|
-
it
|
|
19
|
-
friend_ids = @client.friend_ids(
|
|
18
|
+
it 'returns an array of numeric IDs for every user the specified user is following' do
|
|
19
|
+
friend_ids = @client.friend_ids('sferik')
|
|
20
20
|
expect(friend_ids).to be_a Twitter::Cursor
|
|
21
|
-
expect(friend_ids.first).to eq(
|
|
21
|
+
expect(friend_ids.first).to eq(20_009_713)
|
|
22
22
|
end
|
|
23
|
-
context
|
|
23
|
+
context 'with each' do
|
|
24
24
|
before do
|
|
25
|
-
stub_get(
|
|
25
|
+
stub_get('/1.1/friends/ids.json').with(:query => {:cursor => '1305102810874389703', :screen_name => 'sferik'}).to_return(:body => fixture('ids_list2.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
26
26
|
end
|
|
27
|
-
it
|
|
28
|
-
@client.friend_ids(
|
|
29
|
-
expect(a_get(
|
|
30
|
-
expect(a_get(
|
|
27
|
+
it 'requests the correct resource' do
|
|
28
|
+
@client.friend_ids('sferik').each {}
|
|
29
|
+
expect(a_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'})).to have_been_made
|
|
30
|
+
expect(a_get('/1.1/friends/ids.json').with(:query => {:cursor => '1305102810874389703', :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('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :user_id => '7505382'}).to_return(:body => fixture('ids_list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
37
37
|
end
|
|
38
|
-
it
|
|
39
|
-
@client.friend_ids(
|
|
40
|
-
expect(a_get(
|
|
38
|
+
it 'requests the correct resource' do
|
|
39
|
+
@client.friend_ids(7_505_382)
|
|
40
|
+
expect(a_get('/1.1/friends/ids.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('/1.1/friends/ids.json').with(:query => {:cursor => '1305102810874389703', :user_id => '7505382'}).to_return(:body => fixture('ids_list2.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
45
45
|
end
|
|
46
|
-
it
|
|
47
|
-
@client.friend_ids(
|
|
48
|
-
expect(a_get(
|
|
49
|
-
expect(a_get(
|
|
46
|
+
it 'requests the correct resource' do
|
|
47
|
+
@client.friend_ids(7_505_382).each {}
|
|
48
|
+
expect(a_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :user_id => '7505382'})).to have_been_made
|
|
49
|
+
expect(a_get('/1.1/friends/ids.json').with(:query => {:cursor => '1305102810874389703', :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('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'}).to_return(:body => fixture('ids_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.friend_ids
|
|
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('/1.1/friends/ids.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 the specified user is following' do
|
|
64
64
|
friend_ids = @client.friend_ids
|
|
65
65
|
expect(friend_ids).to be_a Twitter::Cursor
|
|
66
|
-
expect(friend_ids.first).to eq(
|
|
66
|
+
expect(friend_ids.first).to eq(20_009_713)
|
|
67
67
|
end
|
|
68
|
-
context
|
|
68
|
+
context 'with each' do
|
|
69
69
|
before do
|
|
70
|
-
stub_get(
|
|
70
|
+
stub_get('/1.1/friends/ids.json').with(:query => {:cursor => '1305102810874389703', :screen_name => 'sferik'}).to_return(:body => fixture('ids_list2.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
71
71
|
end
|
|
72
|
-
it
|
|
73
|
-
@client.friend_ids.each{}
|
|
74
|
-
expect(a_get(
|
|
75
|
-
expect(a_get(
|
|
76
|
-
expect(a_get(
|
|
72
|
+
it 'requests the correct resource' do
|
|
73
|
+
@client.friend_ids.each {}
|
|
74
|
+
expect(a_get('/1.1/account/verify_credentials.json')).to have_been_made
|
|
75
|
+
expect(a_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'})).to have_been_made
|
|
76
|
+
expect(a_get('/1.1/friends/ids.json').with(:query => {:cursor => '1305102810874389703', :screen_name => 'sferik'})).to have_been_made
|
|
77
77
|
end
|
|
78
78
|
end
|
|
79
79
|
end
|
|
80
80
|
end
|
|
81
81
|
|
|
82
|
-
describe
|
|
83
|
-
context
|
|
82
|
+
describe '#follower_ids' do
|
|
83
|
+
context 'with a screen name passed' do
|
|
84
84
|
before do
|
|
85
|
-
stub_get(
|
|
85
|
+
stub_get('/1.1/followers/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'}).to_return(:body => fixture('ids_list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
86
86
|
end
|
|
87
|
-
it
|
|
88
|
-
@client.follower_ids(
|
|
89
|
-
expect(a_get(
|
|
87
|
+
it 'requests the correct resource' do
|
|
88
|
+
@client.follower_ids('sferik')
|
|
89
|
+
expect(a_get('/1.1/followers/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'})).to have_been_made
|
|
90
90
|
end
|
|
91
|
-
it
|
|
92
|
-
follower_ids = @client.follower_ids(
|
|
91
|
+
it 'returns an array of numeric IDs for every user following the specified user' do
|
|
92
|
+
follower_ids = @client.follower_ids('sferik')
|
|
93
93
|
expect(follower_ids).to be_a Twitter::Cursor
|
|
94
|
-
expect(follower_ids.first).to eq(
|
|
94
|
+
expect(follower_ids.first).to eq(20_009_713)
|
|
95
95
|
end
|
|
96
|
-
context
|
|
96
|
+
context 'with each' do
|
|
97
97
|
before do
|
|
98
|
-
stub_get(
|
|
98
|
+
stub_get('/1.1/followers/ids.json').with(:query => {:cursor => '1305102810874389703', :screen_name => 'sferik'}).to_return(:body => fixture('ids_list2.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
99
99
|
end
|
|
100
|
-
it
|
|
101
|
-
@client.follower_ids(
|
|
102
|
-
expect(a_get(
|
|
103
|
-
expect(a_get(
|
|
100
|
+
it 'requests the correct resource' do
|
|
101
|
+
@client.follower_ids('sferik').each {}
|
|
102
|
+
expect(a_get('/1.1/followers/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'})).to have_been_made
|
|
103
|
+
expect(a_get('/1.1/followers/ids.json').with(:query => {:cursor => '1305102810874389703', :screen_name => 'sferik'})).to have_been_made
|
|
104
104
|
end
|
|
105
105
|
end
|
|
106
106
|
end
|
|
107
|
-
context
|
|
107
|
+
context 'with a user ID passed' do
|
|
108
108
|
before do
|
|
109
|
-
stub_get(
|
|
109
|
+
stub_get('/1.1/followers/ids.json').with(:query => {:cursor => '-1', :user_id => '7505382'}).to_return(:body => fixture('ids_list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
110
110
|
end
|
|
111
|
-
it
|
|
112
|
-
@client.follower_ids(
|
|
113
|
-
expect(a_get(
|
|
111
|
+
it 'requests the correct resource' do
|
|
112
|
+
@client.follower_ids(7_505_382)
|
|
113
|
+
expect(a_get('/1.1/followers/ids.json').with(:query => {:cursor => '-1', :user_id => '7505382'})).to have_been_made
|
|
114
114
|
end
|
|
115
|
-
context
|
|
115
|
+
context 'with each' do
|
|
116
116
|
before do
|
|
117
|
-
stub_get(
|
|
117
|
+
stub_get('/1.1/followers/ids.json').with(:query => {:cursor => '1305102810874389703', :user_id => '7505382'}).to_return(:body => fixture('ids_list2.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
118
118
|
end
|
|
119
|
-
it
|
|
120
|
-
@client.follower_ids(
|
|
121
|
-
expect(a_get(
|
|
122
|
-
expect(a_get(
|
|
119
|
+
it 'requests the correct resource' do
|
|
120
|
+
@client.follower_ids(7_505_382).each {}
|
|
121
|
+
expect(a_get('/1.1/followers/ids.json').with(:query => {:cursor => '-1', :user_id => '7505382'})).to have_been_made
|
|
122
|
+
expect(a_get('/1.1/followers/ids.json').with(:query => {:cursor => '1305102810874389703', :user_id => '7505382'})).to have_been_made
|
|
123
123
|
end
|
|
124
124
|
end
|
|
125
125
|
end
|
|
126
|
-
context
|
|
126
|
+
context 'without arguments passed' do
|
|
127
127
|
before do
|
|
128
|
-
stub_get(
|
|
129
|
-
stub_get(
|
|
128
|
+
stub_get('/1.1/account/verify_credentials.json').to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
129
|
+
stub_get('/1.1/followers/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'}).to_return(:body => fixture('ids_list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
130
130
|
end
|
|
131
|
-
it
|
|
131
|
+
it 'requests the correct resource' do
|
|
132
132
|
@client.follower_ids
|
|
133
|
-
expect(a_get(
|
|
134
|
-
expect(a_get(
|
|
133
|
+
expect(a_get('/1.1/account/verify_credentials.json')).to have_been_made
|
|
134
|
+
expect(a_get('/1.1/followers/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'})).to have_been_made
|
|
135
135
|
end
|
|
136
|
-
it
|
|
136
|
+
it 'returns an array of numeric IDs for every user following the specified user' do
|
|
137
137
|
follower_ids = @client.follower_ids
|
|
138
138
|
expect(follower_ids).to be_a Twitter::Cursor
|
|
139
|
-
expect(follower_ids.first).to eq(
|
|
139
|
+
expect(follower_ids.first).to eq(20_009_713)
|
|
140
140
|
end
|
|
141
|
-
context
|
|
141
|
+
context 'with each' do
|
|
142
142
|
before do
|
|
143
|
-
stub_get(
|
|
143
|
+
stub_get('/1.1/followers/ids.json').with(:query => {:cursor => '1305102810874389703', :screen_name => 'sferik'}).to_return(:body => fixture('ids_list2.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
144
144
|
end
|
|
145
|
-
it
|
|
146
|
-
@client.follower_ids.each{}
|
|
147
|
-
expect(a_get(
|
|
148
|
-
expect(a_get(
|
|
149
|
-
expect(a_get(
|
|
145
|
+
it 'requests the correct resource' do
|
|
146
|
+
@client.follower_ids.each {}
|
|
147
|
+
expect(a_get('/1.1/account/verify_credentials.json')).to have_been_made
|
|
148
|
+
expect(a_get('/1.1/followers/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'})).to have_been_made
|
|
149
|
+
expect(a_get('/1.1/followers/ids.json').with(:query => {:cursor => '1305102810874389703', :screen_name => 'sferik'})).to have_been_made
|
|
150
150
|
end
|
|
151
151
|
end
|
|
152
152
|
end
|
|
153
153
|
end
|
|
154
154
|
|
|
155
|
-
describe
|
|
156
|
-
context
|
|
155
|
+
describe '#friendships' do
|
|
156
|
+
context 'with screen names passed' do
|
|
157
157
|
before do
|
|
158
|
-
stub_get(
|
|
158
|
+
stub_get('/1.1/friendships/lookup.json').with(:query => {:screen_name => 'sferik,pengwynn'}).to_return(:body => fixture('friendships.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
159
159
|
end
|
|
160
|
-
it
|
|
161
|
-
@client.friendships(
|
|
162
|
-
expect(a_get(
|
|
160
|
+
it 'requests the correct resource' do
|
|
161
|
+
@client.friendships('sferik', 'pengwynn')
|
|
162
|
+
expect(a_get('/1.1/friendships/lookup.json').with(:query => {:screen_name => 'sferik,pengwynn'})).to have_been_made
|
|
163
163
|
end
|
|
164
|
-
it
|
|
165
|
-
friendships = @client.friendships(
|
|
164
|
+
it 'returns up to 100 users worth of extended information' do
|
|
165
|
+
friendships = @client.friendships('sferik', 'pengwynn')
|
|
166
166
|
expect(friendships).to be_an Array
|
|
167
167
|
expect(friendships.first).to be_a Twitter::User
|
|
168
|
-
expect(friendships.first.id).to eq(
|
|
169
|
-
expect(friendships.first.connections).to eq([
|
|
168
|
+
expect(friendships.first.id).to eq(7_505_382)
|
|
169
|
+
expect(friendships.first.connections).to eq(['none'])
|
|
170
170
|
end
|
|
171
171
|
end
|
|
172
|
-
context
|
|
172
|
+
context 'with numeric screen names passed' do
|
|
173
173
|
before do
|
|
174
|
-
stub_get(
|
|
174
|
+
stub_get('/1.1/friendships/lookup.json').with(:query => {:screen_name => '0,311'}).to_return(:body => fixture('friendships.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
175
175
|
end
|
|
176
|
-
it
|
|
177
|
-
@client.friendships(
|
|
178
|
-
expect(a_get(
|
|
176
|
+
it 'requests the correct resource' do
|
|
177
|
+
@client.friendships('0', '311')
|
|
178
|
+
expect(a_get('/1.1/friendships/lookup.json').with(:query => {:screen_name => '0,311'})).to have_been_made
|
|
179
179
|
end
|
|
180
180
|
end
|
|
181
|
-
context
|
|
181
|
+
context 'with user IDs passed' do
|
|
182
182
|
before do
|
|
183
|
-
stub_get(
|
|
183
|
+
stub_get('/1.1/friendships/lookup.json').with(:query => {:user_id => '7505382,14100886'}).to_return(:body => fixture('friendships.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
184
184
|
end
|
|
185
|
-
it
|
|
186
|
-
@client.friendships(
|
|
187
|
-
expect(a_get(
|
|
185
|
+
it 'requests the correct resource' do
|
|
186
|
+
@client.friendships(7_505_382, 14_100_886)
|
|
187
|
+
expect(a_get('/1.1/friendships/lookup.json').with(:query => {:user_id => '7505382,14100886'})).to have_been_made
|
|
188
188
|
end
|
|
189
189
|
end
|
|
190
|
-
context
|
|
190
|
+
context 'with both screen names and user IDs passed' do
|
|
191
191
|
before do
|
|
192
|
-
stub_get(
|
|
192
|
+
stub_get('/1.1/friendships/lookup.json').with(:query => {:screen_name => 'sferik', :user_id => '14100886'}).to_return(:body => fixture('friendships.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
193
193
|
end
|
|
194
|
-
it
|
|
195
|
-
@client.friendships(
|
|
196
|
-
expect(a_get(
|
|
194
|
+
it 'requests the correct resource' do
|
|
195
|
+
@client.friendships('sferik', 14_100_886)
|
|
196
|
+
expect(a_get('/1.1/friendships/lookup.json').with(:query => {:screen_name => 'sferik', :user_id => '14100886'})).to have_been_made
|
|
197
197
|
end
|
|
198
198
|
end
|
|
199
199
|
end
|
|
200
200
|
|
|
201
|
-
describe
|
|
202
|
-
context
|
|
201
|
+
describe '#friendships' do
|
|
202
|
+
context 'with screen names passed' do
|
|
203
203
|
before do
|
|
204
|
-
stub_get(
|
|
204
|
+
stub_get('/1.1/friendships/lookup.json').with(:query => {:screen_name => 'sferik,pengwynn'}).to_return(:body => fixture('friendships.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
205
205
|
end
|
|
206
|
-
it
|
|
207
|
-
@client.friendships(
|
|
208
|
-
expect(a_get(
|
|
206
|
+
it 'requests the correct resource' do
|
|
207
|
+
@client.friendships('sferik', 'pengwynn')
|
|
208
|
+
expect(a_get('/1.1/friendships/lookup.json').with(:query => {:screen_name => 'sferik,pengwynn'})).to have_been_made
|
|
209
209
|
end
|
|
210
|
-
it
|
|
211
|
-
friendships = @client.friendships(
|
|
210
|
+
it 'returns up to 100 users worth of extended information' do
|
|
211
|
+
friendships = @client.friendships('sferik', 'pengwynn')
|
|
212
212
|
expect(friendships).to be_an Array
|
|
213
213
|
expect(friendships.first).to be_a Twitter::User
|
|
214
|
-
expect(friendships.first.id).to eq(
|
|
215
|
-
expect(friendships.first.connections).to eq([
|
|
214
|
+
expect(friendships.first.id).to eq(7_505_382)
|
|
215
|
+
expect(friendships.first.connections).to eq(['none'])
|
|
216
216
|
end
|
|
217
217
|
end
|
|
218
|
-
context
|
|
218
|
+
context 'with numeric screen names passed' do
|
|
219
219
|
before do
|
|
220
|
-
stub_get(
|
|
220
|
+
stub_get('/1.1/friendships/lookup.json').with(:query => {:screen_name => '0,311'}).to_return(:body => fixture('friendships.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
221
221
|
end
|
|
222
|
-
it
|
|
223
|
-
@client.friendships(
|
|
224
|
-
expect(a_get(
|
|
222
|
+
it 'requests the correct resource' do
|
|
223
|
+
@client.friendships('0', '311')
|
|
224
|
+
expect(a_get('/1.1/friendships/lookup.json').with(:query => {:screen_name => '0,311'})).to have_been_made
|
|
225
225
|
end
|
|
226
226
|
end
|
|
227
|
-
context
|
|
227
|
+
context 'with user IDs passed' do
|
|
228
228
|
before do
|
|
229
|
-
stub_get(
|
|
229
|
+
stub_get('/1.1/friendships/lookup.json').with(:query => {:user_id => '7505382,14100886'}).to_return(:body => fixture('friendships.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
230
230
|
end
|
|
231
|
-
it
|
|
232
|
-
@client.friendships(
|
|
233
|
-
expect(a_get(
|
|
231
|
+
it 'requests the correct resource' do
|
|
232
|
+
@client.friendships(7_505_382, 14_100_886)
|
|
233
|
+
expect(a_get('/1.1/friendships/lookup.json').with(:query => {:user_id => '7505382,14100886'})).to have_been_made
|
|
234
234
|
end
|
|
235
235
|
end
|
|
236
|
-
context
|
|
236
|
+
context 'with both screen names and user IDs passed' do
|
|
237
237
|
before do
|
|
238
|
-
stub_get(
|
|
238
|
+
stub_get('/1.1/friendships/lookup.json').with(:query => {:screen_name => 'sferik', :user_id => '14100886'}).to_return(:body => fixture('friendships.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
239
239
|
end
|
|
240
|
-
it
|
|
241
|
-
@client.friendships(
|
|
242
|
-
expect(a_get(
|
|
240
|
+
it 'requests the correct resource' do
|
|
241
|
+
@client.friendships('sferik', 14_100_886)
|
|
242
|
+
expect(a_get('/1.1/friendships/lookup.json').with(:query => {:screen_name => 'sferik', :user_id => '14100886'})).to have_been_made
|
|
243
243
|
end
|
|
244
244
|
end
|
|
245
245
|
end
|
|
246
246
|
|
|
247
|
-
describe
|
|
247
|
+
describe '#friendships_incoming' do
|
|
248
248
|
before do
|
|
249
|
-
stub_get(
|
|
249
|
+
stub_get('/1.1/friendships/incoming.json').with(:query => {:cursor => '-1'}).to_return(:body => fixture('ids_list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
250
250
|
end
|
|
251
|
-
it
|
|
251
|
+
it 'requests the correct resource' do
|
|
252
252
|
@client.friendships_incoming
|
|
253
|
-
expect(a_get(
|
|
253
|
+
expect(a_get('/1.1/friendships/incoming.json').with(:query => {:cursor => '-1'})).to have_been_made
|
|
254
254
|
end
|
|
255
|
-
it
|
|
255
|
+
it 'returns an array of numeric IDs for every user who has a pending request to follow the authenticating user' do
|
|
256
256
|
friendships_incoming = @client.friendships_incoming
|
|
257
257
|
expect(friendships_incoming).to be_a Twitter::Cursor
|
|
258
|
-
expect(friendships_incoming.first).to eq(
|
|
258
|
+
expect(friendships_incoming.first).to eq(20_009_713)
|
|
259
259
|
end
|
|
260
|
-
context
|
|
260
|
+
context 'with each' do
|
|
261
261
|
before do
|
|
262
|
-
stub_get(
|
|
262
|
+
stub_get('/1.1/friendships/incoming.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
|
-
@client.friendships_incoming.each{}
|
|
266
|
-
expect(a_get(
|
|
264
|
+
it 'requests the correct resource' do
|
|
265
|
+
@client.friendships_incoming.each {}
|
|
266
|
+
expect(a_get('/1.1/friendships/incoming.json').with(:query => {:cursor => '1305102810874389703'})).to have_been_made
|
|
267
267
|
end
|
|
268
268
|
end
|
|
269
269
|
end
|
|
270
270
|
|
|
271
|
-
describe
|
|
271
|
+
describe '#friendships_outgoing' do
|
|
272
272
|
before do
|
|
273
|
-
stub_get(
|
|
273
|
+
stub_get('/1.1/friendships/outgoing.json').with(:query => {:cursor => '-1'}).to_return(:body => fixture('ids_list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
274
274
|
end
|
|
275
|
-
it
|
|
275
|
+
it 'requests the correct resource' do
|
|
276
276
|
@client.friendships_outgoing
|
|
277
|
-
expect(a_get(
|
|
277
|
+
expect(a_get('/1.1/friendships/outgoing.json').with(:query => {:cursor => '-1'})).to have_been_made
|
|
278
278
|
end
|
|
279
|
-
it
|
|
279
|
+
it 'returns an array of numeric IDs for every protected user for whom the authenticating user has a pending follow request' do
|
|
280
280
|
friendships_outgoing = @client.friendships_outgoing
|
|
281
281
|
expect(friendships_outgoing).to be_a Twitter::Cursor
|
|
282
|
-
expect(friendships_outgoing.first).to eq(
|
|
282
|
+
expect(friendships_outgoing.first).to eq(20_009_713)
|
|
283
283
|
end
|
|
284
|
-
context
|
|
284
|
+
context 'with each' do
|
|
285
285
|
before do
|
|
286
|
-
stub_get(
|
|
286
|
+
stub_get('/1.1/friendships/outgoing.json').with(:query => {:cursor => '1305102810874389703'}).to_return(:body => fixture('ids_list2.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
287
287
|
end
|
|
288
|
-
it
|
|
289
|
-
@client.friendships_outgoing.each{}
|
|
290
|
-
expect(a_get(
|
|
288
|
+
it 'requests the correct resource' do
|
|
289
|
+
@client.friendships_outgoing.each {}
|
|
290
|
+
expect(a_get('/1.1/friendships/outgoing.json').with(:query => {:cursor => '1305102810874389703'})).to have_been_made
|
|
291
291
|
end
|
|
292
292
|
end
|
|
293
293
|
end
|
|
294
294
|
|
|
295
|
-
describe
|
|
295
|
+
describe '#follow' do
|
|
296
296
|
before do
|
|
297
|
-
stub_get(
|
|
298
|
-
stub_get(
|
|
299
|
-
stub_post(
|
|
300
|
-
stub_post(
|
|
301
|
-
end
|
|
302
|
-
it
|
|
303
|
-
@client.follow(
|
|
304
|
-
expect(a_get(
|
|
305
|
-
expect(a_get(
|
|
306
|
-
expect(a_post(
|
|
307
|
-
expect(a_post(
|
|
297
|
+
stub_get('/1.1/account/verify_credentials.json').to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
298
|
+
stub_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'}).to_return(:body => fixture('ids_list2.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
299
|
+
stub_post('/1.1/users/lookup.json').with(:body => {:screen_name => 'sferik,pengwynn'}).to_return(:body => fixture('friendships.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
300
|
+
stub_post('/1.1/friendships/create.json').with(:body => {:user_id => '7505382'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
301
|
+
end
|
|
302
|
+
it 'requests the correct resource' do
|
|
303
|
+
@client.follow('sferik', 'pengwynn')
|
|
304
|
+
expect(a_get('/1.1/account/verify_credentials.json')).to have_been_made
|
|
305
|
+
expect(a_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'})).to have_been_made
|
|
306
|
+
expect(a_post('/1.1/users/lookup.json').with(:body => {:screen_name => 'sferik,pengwynn'})).to have_been_made
|
|
307
|
+
expect(a_post('/1.1/friendships/create.json').with(:body => {:user_id => '7505382'})).to have_been_made
|
|
308
308
|
end
|
|
309
309
|
end
|
|
310
310
|
|
|
311
|
-
describe
|
|
311
|
+
describe '#follow!' do
|
|
312
312
|
before do
|
|
313
|
-
stub_post(
|
|
313
|
+
stub_post('/1.1/friendships/create.json').with(:body => {:screen_name => 'sferik'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
314
314
|
end
|
|
315
|
-
it
|
|
316
|
-
@client.follow!(
|
|
317
|
-
expect(a_post(
|
|
315
|
+
it 'requests the correct resource' do
|
|
316
|
+
@client.follow!('sferik')
|
|
317
|
+
expect(a_post('/1.1/friendships/create.json').with(:body => {:screen_name => 'sferik'})).to have_been_made
|
|
318
318
|
end
|
|
319
|
-
it
|
|
320
|
-
users = @client.follow!(
|
|
319
|
+
it 'returns an array of befriended users' do
|
|
320
|
+
users = @client.follow!('sferik')
|
|
321
321
|
expect(users).to be_an Array
|
|
322
322
|
expect(users.first).to be_a Twitter::User
|
|
323
|
-
expect(users.first.id).to eq(
|
|
323
|
+
expect(users.first.id).to eq(7_505_382)
|
|
324
324
|
end
|
|
325
325
|
end
|
|
326
|
-
context
|
|
326
|
+
context 'with a user object passed' do
|
|
327
327
|
before do
|
|
328
|
-
stub_post(
|
|
328
|
+
stub_post('/1.1/friendships/create.json').with(:body => {:user_id => '7505382'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
329
329
|
end
|
|
330
|
-
it
|
|
331
|
-
user = Twitter::User.new(:id =>
|
|
330
|
+
it 'requests the correct resources' do
|
|
331
|
+
user = Twitter::User.new(:id => '7505382')
|
|
332
332
|
@client.follow!(user)
|
|
333
|
-
expect(a_post(
|
|
333
|
+
expect(a_post('/1.1/friendships/create.json').with(:body => {:user_id => '7505382'})).to have_been_made
|
|
334
334
|
end
|
|
335
335
|
end
|
|
336
|
-
context
|
|
336
|
+
context 'with a URI object passed' do
|
|
337
337
|
before do
|
|
338
|
-
stub_post(
|
|
338
|
+
stub_post('/1.1/friendships/create.json').with(:body => {:screen_name => 'sferik'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
339
339
|
end
|
|
340
|
-
it
|
|
341
|
-
user = URI.parse(
|
|
340
|
+
it 'requests the correct resource' do
|
|
341
|
+
user = URI.parse('https://twitter.com/sferik')
|
|
342
342
|
@client.follow!(user)
|
|
343
|
-
expect(a_post(
|
|
343
|
+
expect(a_post('/1.1/friendships/create.json').with(:body => {:screen_name => 'sferik'})).to have_been_made
|
|
344
344
|
end
|
|
345
345
|
end
|
|
346
|
-
context
|
|
346
|
+
context 'with a URI string passed' do
|
|
347
347
|
before do
|
|
348
|
-
stub_post(
|
|
348
|
+
stub_post('/1.1/friendships/create.json').with(:body => {:screen_name => 'sferik'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
349
349
|
end
|
|
350
|
-
it
|
|
351
|
-
@client.follow!(
|
|
352
|
-
expect(a_post(
|
|
350
|
+
it 'requests the correct resource' do
|
|
351
|
+
@client.follow!('https://twitter.com/sferik')
|
|
352
|
+
expect(a_post('/1.1/friendships/create.json').with(:body => {:screen_name => 'sferik'})).to have_been_made
|
|
353
|
+
end
|
|
354
|
+
end
|
|
355
|
+
context 'with a forbidden error' do
|
|
356
|
+
before do
|
|
357
|
+
stub_post('/1.1/friendships/create.json').with(:body => {:screen_name => 'sferik'}).to_return(:status => 403, :body => fixture('forbidden.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
358
|
+
end
|
|
359
|
+
it 'raises an exception' do
|
|
360
|
+
expect { @client.follow!('sferik') }.to raise_error(Twitter::Error::Forbidden)
|
|
353
361
|
end
|
|
354
362
|
end
|
|
355
363
|
|
|
356
|
-
describe
|
|
364
|
+
describe '#unfollow' do
|
|
357
365
|
before do
|
|
358
|
-
stub_post(
|
|
366
|
+
stub_post('/1.1/friendships/destroy.json').with(:body => {:screen_name => 'sferik'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
359
367
|
end
|
|
360
|
-
it
|
|
361
|
-
@client.unfollow(
|
|
362
|
-
expect(a_post(
|
|
368
|
+
it 'requests the correct resource' do
|
|
369
|
+
@client.unfollow('sferik')
|
|
370
|
+
expect(a_post('/1.1/friendships/destroy.json').with(:body => {:screen_name => 'sferik'})).to have_been_made
|
|
363
371
|
end
|
|
364
|
-
it
|
|
365
|
-
users = @client.unfollow(
|
|
372
|
+
it 'returns an array of unfollowed users' do
|
|
373
|
+
users = @client.unfollow('sferik')
|
|
366
374
|
expect(users).to be_an Array
|
|
367
375
|
expect(users.first).to be_a Twitter::User
|
|
368
|
-
expect(users.first.id).to eq(
|
|
376
|
+
expect(users.first.id).to eq(7_505_382)
|
|
369
377
|
end
|
|
370
378
|
end
|
|
371
379
|
|
|
372
|
-
describe
|
|
380
|
+
describe '#friendship_update' do
|
|
373
381
|
before do
|
|
374
|
-
stub_post(
|
|
382
|
+
stub_post('/1.1/friendships/update.json').with(:body => {:screen_name => 'sferik', :retweets => 'true'}).to_return(:body => fixture('following.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
375
383
|
end
|
|
376
|
-
it
|
|
377
|
-
@client.friendship_update(
|
|
378
|
-
expect(a_post(
|
|
384
|
+
it 'requests the correct resource' do
|
|
385
|
+
@client.friendship_update('sferik', :retweets => true)
|
|
386
|
+
expect(a_post('/1.1/friendships/update.json').with(:body => {:screen_name => 'sferik', :retweets => 'true'})).to have_been_made
|
|
379
387
|
end
|
|
380
|
-
it
|
|
381
|
-
relationship = @client.friendship_update(
|
|
388
|
+
it 'returns detailed information about the relationship between two users' do
|
|
389
|
+
relationship = @client.friendship_update('sferik', :retweets => true)
|
|
382
390
|
expect(relationship).to be_a Twitter::Relationship
|
|
383
|
-
expect(relationship.source.id).to eq(
|
|
391
|
+
expect(relationship.source.id).to eq(7_505_382)
|
|
384
392
|
end
|
|
385
393
|
end
|
|
386
394
|
|
|
387
|
-
describe
|
|
388
|
-
context
|
|
395
|
+
describe '#friendship' do
|
|
396
|
+
context 'with screen names passed' do
|
|
389
397
|
before do
|
|
390
|
-
stub_get(
|
|
398
|
+
stub_get('/1.1/friendships/show.json').with(:query => {:source_screen_name => 'sferik', :target_screen_name => 'pengwynn'}).to_return(:body => fixture('following.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
391
399
|
end
|
|
392
|
-
it
|
|
393
|
-
@client.friendship(
|
|
394
|
-
expect(a_get(
|
|
400
|
+
it 'requests the correct resource' do
|
|
401
|
+
@client.friendship('sferik', 'pengwynn')
|
|
402
|
+
expect(a_get('/1.1/friendships/show.json').with(:query => {:source_screen_name => 'sferik', :target_screen_name => 'pengwynn'})).to have_been_made
|
|
395
403
|
end
|
|
396
|
-
it
|
|
397
|
-
relationship = @client.friendship(
|
|
404
|
+
it 'returns detailed information about the relationship between two users' do
|
|
405
|
+
relationship = @client.friendship('sferik', 'pengwynn')
|
|
398
406
|
expect(relationship).to be_a Twitter::Relationship
|
|
399
|
-
expect(relationship.source.id).to eq(
|
|
407
|
+
expect(relationship.source.id).to eq(7_505_382)
|
|
400
408
|
end
|
|
401
409
|
end
|
|
402
|
-
context
|
|
410
|
+
context 'with numeric screen names passed' do
|
|
403
411
|
before do
|
|
404
|
-
stub_get(
|
|
412
|
+
stub_get('/1.1/friendships/show.json').with(:query => {:source_screen_name => '0', :target_screen_name => '311'}).to_return(:body => fixture('following.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
405
413
|
end
|
|
406
|
-
it
|
|
407
|
-
@client.friendship(
|
|
408
|
-
expect(a_get(
|
|
414
|
+
it 'requests the correct resource' do
|
|
415
|
+
@client.friendship('0', '311')
|
|
416
|
+
expect(a_get('/1.1/friendships/show.json').with(:query => {:source_screen_name => '0', :target_screen_name => '311'})).to have_been_made
|
|
409
417
|
end
|
|
410
418
|
end
|
|
411
|
-
context
|
|
419
|
+
context 'with user IDs passed' do
|
|
412
420
|
before do
|
|
413
|
-
stub_get(
|
|
421
|
+
stub_get('/1.1/friendships/show.json').with(:query => {:source_id => '7505382', :target_id => '14100886'}).to_return(:body => fixture('following.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
414
422
|
end
|
|
415
|
-
it
|
|
416
|
-
@client.friendship(
|
|
417
|
-
expect(a_get(
|
|
423
|
+
it 'requests the correct resource' do
|
|
424
|
+
@client.friendship(7_505_382, 14_100_886)
|
|
425
|
+
expect(a_get('/1.1/friendships/show.json').with(:query => {:source_id => '7505382', :target_id => '14100886'})).to have_been_made
|
|
418
426
|
end
|
|
419
427
|
end
|
|
420
|
-
context
|
|
428
|
+
context 'with user objects passed' do
|
|
421
429
|
before do
|
|
422
|
-
stub_get(
|
|
430
|
+
stub_get('/1.1/friendships/show.json').with(:query => {:source_id => '7505382', :target_id => '14100886'}).to_return(:body => fixture('following.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
423
431
|
end
|
|
424
|
-
it
|
|
425
|
-
user1 = Twitter::User.new(:id =>
|
|
426
|
-
user2 = Twitter::User.new(:id =>
|
|
432
|
+
it 'requests the correct resource' do
|
|
433
|
+
user1 = Twitter::User.new(:id => '7505382')
|
|
434
|
+
user2 = Twitter::User.new(:id => '14100886')
|
|
427
435
|
@client.friendship(user1, user2)
|
|
428
|
-
expect(a_get(
|
|
436
|
+
expect(a_get('/1.1/friendships/show.json').with(:query => {:source_id => '7505382', :target_id => '14100886'})).to have_been_made
|
|
429
437
|
end
|
|
430
438
|
end
|
|
431
|
-
context
|
|
439
|
+
context 'with URI objects passed' do
|
|
432
440
|
before do
|
|
433
|
-
stub_get(
|
|
441
|
+
stub_get('/1.1/friendships/show.json').with(:query => {:source_screen_name => 'sferik', :target_screen_name => 'pengwynn'}).to_return(:body => fixture('following.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
434
442
|
end
|
|
435
|
-
it
|
|
436
|
-
user1 = URI.parse(
|
|
437
|
-
user2 = URI.parse(
|
|
443
|
+
it 'requests the correct resource' do
|
|
444
|
+
user1 = URI.parse('https://twitter.com/sferik')
|
|
445
|
+
user2 = URI.parse('https://twitter.com/pengwynn')
|
|
438
446
|
@client.friendship(user1, user2)
|
|
439
|
-
expect(a_get(
|
|
447
|
+
expect(a_get('/1.1/friendships/show.json').with(:query => {:source_screen_name => 'sferik', :target_screen_name => 'pengwynn'})).to have_been_made
|
|
440
448
|
end
|
|
441
449
|
end
|
|
442
|
-
context
|
|
450
|
+
context 'with URI strings passed' do
|
|
443
451
|
before do
|
|
444
|
-
stub_get(
|
|
452
|
+
stub_get('/1.1/friendships/show.json').with(:query => {:source_screen_name => 'sferik', :target_screen_name => 'pengwynn'}).to_return(:body => fixture('following.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
445
453
|
end
|
|
446
|
-
it
|
|
447
|
-
@client.friendship(
|
|
448
|
-
expect(a_get(
|
|
454
|
+
it 'requests the correct resource' do
|
|
455
|
+
@client.friendship('https://twitter.com/sferik', 'https://twitter.com/pengwynn')
|
|
456
|
+
expect(a_get('/1.1/friendships/show.json').with(:query => {:source_screen_name => 'sferik', :target_screen_name => 'pengwynn'})).to have_been_made
|
|
449
457
|
end
|
|
450
458
|
end
|
|
451
459
|
end
|
|
452
460
|
|
|
453
|
-
describe
|
|
454
|
-
context
|
|
461
|
+
describe '#friendship?' do
|
|
462
|
+
context 'with screen names passed' do
|
|
455
463
|
before do
|
|
456
|
-
stub_get(
|
|
457
|
-
stub_get(
|
|
464
|
+
stub_get('/1.1/friendships/show.json').with(:query => {:source_screen_name => 'sferik', :target_screen_name => 'pengwynn'}).to_return(:body => fixture('following.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
465
|
+
stub_get('/1.1/friendships/show.json').with(:query => {:source_screen_name => 'pengwynn', :target_screen_name => 'sferik'}).to_return(:body => fixture('not_following.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
458
466
|
end
|
|
459
|
-
it
|
|
460
|
-
@client.friendship?(
|
|
461
|
-
expect(a_get(
|
|
467
|
+
it 'requests the correct resource' do
|
|
468
|
+
@client.friendship?('sferik', 'pengwynn')
|
|
469
|
+
expect(a_get('/1.1/friendships/show.json').with(:query => {:source_screen_name => 'sferik', :target_screen_name => 'pengwynn'})).to have_been_made
|
|
462
470
|
end
|
|
463
|
-
it
|
|
464
|
-
friendship = @client.friendship?(
|
|
471
|
+
it 'returns true if user A follows user B' do
|
|
472
|
+
friendship = @client.friendship?('sferik', 'pengwynn')
|
|
465
473
|
expect(friendship).to be true
|
|
466
474
|
end
|
|
467
|
-
it
|
|
468
|
-
friendship = @client.friendship?(
|
|
475
|
+
it 'returns false if user A does not follow user B' do
|
|
476
|
+
friendship = @client.friendship?('pengwynn', 'sferik')
|
|
469
477
|
expect(friendship).to be false
|
|
470
478
|
end
|
|
471
479
|
end
|
|
472
|
-
context
|
|
480
|
+
context 'with user IDs passed' do
|
|
473
481
|
before do
|
|
474
|
-
stub_get(
|
|
482
|
+
stub_get('/1.1/friendships/show.json').with(:query => {:source_id => '7505382', :target_id => '14100886'}).to_return(:body => fixture('following.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
475
483
|
end
|
|
476
|
-
it
|
|
477
|
-
@client.friendship?(
|
|
478
|
-
expect(a_get(
|
|
484
|
+
it 'requests the correct resource' do
|
|
485
|
+
@client.friendship?(7_505_382, 14_100_886)
|
|
486
|
+
expect(a_get('/1.1/friendships/show.json').with(:query => {:source_id => '7505382', :target_id => '14100886'})).to have_been_made
|
|
479
487
|
end
|
|
480
488
|
end
|
|
481
|
-
context
|
|
489
|
+
context 'with user objects passed' do
|
|
482
490
|
before do
|
|
483
|
-
stub_get(
|
|
491
|
+
stub_get('/1.1/friendships/show.json').with(:query => {:source_id => '7505382', :target_id => '14100886'}).to_return(:body => fixture('following.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
484
492
|
end
|
|
485
|
-
it
|
|
486
|
-
user1 = Twitter::User.new(:id =>
|
|
487
|
-
user2 = Twitter::User.new(:id =>
|
|
493
|
+
it 'requests the correct resource' do
|
|
494
|
+
user1 = Twitter::User.new(:id => '7505382')
|
|
495
|
+
user2 = Twitter::User.new(:id => '14100886')
|
|
488
496
|
@client.friendship?(user1, user2)
|
|
489
|
-
expect(a_get(
|
|
497
|
+
expect(a_get('/1.1/friendships/show.json').with(:query => {:source_id => '7505382', :target_id => '14100886'})).to have_been_made
|
|
490
498
|
end
|
|
491
499
|
end
|
|
492
500
|
end
|
|
493
501
|
|
|
494
|
-
describe
|
|
495
|
-
context
|
|
502
|
+
describe '#followers' do
|
|
503
|
+
context 'with a screen_name passed' do
|
|
496
504
|
before do
|
|
497
|
-
stub_get(
|
|
505
|
+
stub_get('/1.1/followers/list.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'}).to_return(:body => fixture('followers_list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
498
506
|
end
|
|
499
|
-
it
|
|
500
|
-
@client.followers(
|
|
501
|
-
expect(a_get(
|
|
507
|
+
it 'requests the correct resource' do
|
|
508
|
+
@client.followers('sferik')
|
|
509
|
+
expect(a_get('/1.1/followers/list.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'})).to have_been_made
|
|
502
510
|
end
|
|
503
|
-
it
|
|
504
|
-
followers = @client.followers(
|
|
511
|
+
it 'returns a cursor of followers with details for every user the specified user is followed by' do
|
|
512
|
+
followers = @client.followers('sferik')
|
|
505
513
|
expect(followers).to be_a Twitter::Cursor
|
|
506
514
|
expect(followers.first).to be_a Twitter::User
|
|
507
515
|
end
|
|
508
|
-
context
|
|
516
|
+
context 'with each' do
|
|
509
517
|
before do
|
|
510
|
-
stub_get(
|
|
518
|
+
stub_get('/1.1/followers/list.json').with(:query => {:cursor => '1419103567112105362', :screen_name => 'sferik'}).to_return(:body => fixture('followers_list2.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
511
519
|
end
|
|
512
|
-
it
|
|
513
|
-
@client.followers(
|
|
514
|
-
expect(a_get(
|
|
515
|
-
expect(a_get(
|
|
520
|
+
it 'requests the correct resource' do
|
|
521
|
+
@client.followers('sferik').each {}
|
|
522
|
+
expect(a_get('/1.1/followers/list.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'})).to have_been_made
|
|
523
|
+
expect(a_get('/1.1/followers/list.json').with(:query => {:cursor => '1419103567112105362', :screen_name => 'sferik'})).to have_been_made
|
|
516
524
|
end
|
|
517
525
|
end
|
|
518
526
|
end
|
|
519
|
-
context
|
|
527
|
+
context 'with a user ID passed' do
|
|
520
528
|
before do
|
|
521
|
-
stub_get(
|
|
529
|
+
stub_get('/1.1/followers/list.json').with(:query => {:cursor => '-1', :user_id => '7505382'}).to_return(:body => fixture('followers_list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
522
530
|
end
|
|
523
|
-
it
|
|
524
|
-
@client.followers(
|
|
525
|
-
expect(a_get(
|
|
531
|
+
it 'requests the correct resource' do
|
|
532
|
+
@client.followers(7_505_382)
|
|
533
|
+
expect(a_get('/1.1/followers/list.json').with(:query => {:cursor => '-1', :user_id => '7505382'})).to have_been_made
|
|
526
534
|
end
|
|
527
|
-
context
|
|
535
|
+
context 'with each' do
|
|
528
536
|
before do
|
|
529
|
-
stub_get(
|
|
537
|
+
stub_get('/1.1/followers/list.json').with(:query => {:cursor => '1419103567112105362', :user_id => '7505382'}).to_return(:body => fixture('followers_list2.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
530
538
|
end
|
|
531
|
-
it
|
|
532
|
-
@client.followers(
|
|
533
|
-
expect(a_get(
|
|
534
|
-
expect(a_get(
|
|
539
|
+
it 'requests the correct resource' do
|
|
540
|
+
@client.followers(7_505_382).each {}
|
|
541
|
+
expect(a_get('/1.1/followers/list.json').with(:query => {:cursor => '-1', :user_id => '7505382'})).to have_been_made
|
|
542
|
+
expect(a_get('/1.1/followers/list.json').with(:query => {:cursor => '1419103567112105362', :user_id => '7505382'})).to have_been_made
|
|
535
543
|
end
|
|
536
544
|
end
|
|
537
545
|
end
|
|
538
|
-
context
|
|
546
|
+
context 'without arguments passed' do
|
|
539
547
|
before do
|
|
540
|
-
stub_get(
|
|
541
|
-
stub_get(
|
|
548
|
+
stub_get('/1.1/account/verify_credentials.json').to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
549
|
+
stub_get('/1.1/followers/list.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'}).to_return(:body => fixture('followers_list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
542
550
|
end
|
|
543
|
-
it
|
|
551
|
+
it 'requests the correct resource' do
|
|
544
552
|
@client.followers
|
|
545
|
-
expect(a_get(
|
|
546
|
-
expect(a_get(
|
|
553
|
+
expect(a_get('/1.1/account/verify_credentials.json')).to have_been_made
|
|
554
|
+
expect(a_get('/1.1/followers/list.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'})).to have_been_made
|
|
547
555
|
end
|
|
548
|
-
it
|
|
556
|
+
it 'returns a cursor of followers with details for every user the specified user is followed by' do
|
|
549
557
|
followers = @client.followers
|
|
550
558
|
expect(followers).to be_a Twitter::Cursor
|
|
551
559
|
expect(followers.first).to be_a Twitter::User
|
|
552
560
|
end
|
|
553
|
-
context
|
|
561
|
+
context 'with each' do
|
|
554
562
|
before do
|
|
555
|
-
stub_get(
|
|
563
|
+
stub_get('/1.1/followers/list.json').with(:query => {:cursor => '1419103567112105362', :screen_name => 'sferik'}).to_return(:body => fixture('followers_list2.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
556
564
|
end
|
|
557
|
-
it
|
|
558
|
-
@client.followers.each{}
|
|
559
|
-
expect(a_get(
|
|
560
|
-
expect(a_get(
|
|
561
|
-
expect(a_get(
|
|
565
|
+
it 'requests the correct resource' do
|
|
566
|
+
@client.followers.each {}
|
|
567
|
+
expect(a_get('/1.1/account/verify_credentials.json')).to have_been_made
|
|
568
|
+
expect(a_get('/1.1/followers/list.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'})).to have_been_made
|
|
569
|
+
expect(a_get('/1.1/followers/list.json').with(:query => {:cursor => '1419103567112105362', :screen_name => 'sferik'})).to have_been_made
|
|
562
570
|
end
|
|
563
571
|
end
|
|
564
572
|
end
|
|
565
573
|
end
|
|
566
574
|
|
|
567
|
-
describe
|
|
568
|
-
context
|
|
575
|
+
describe '#friends' do
|
|
576
|
+
context 'with a screen_name passed' do
|
|
569
577
|
before do
|
|
570
|
-
stub_get(
|
|
578
|
+
stub_get('/1.1/friends/list.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'}).to_return(:body => fixture('friends_list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
571
579
|
end
|
|
572
|
-
it
|
|
573
|
-
@client.friends(
|
|
574
|
-
expect(a_get(
|
|
580
|
+
it 'requests the correct resource' do
|
|
581
|
+
@client.friends('sferik')
|
|
582
|
+
expect(a_get('/1.1/friends/list.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'})).to have_been_made
|
|
575
583
|
end
|
|
576
|
-
it
|
|
577
|
-
friends = @client.friends(
|
|
584
|
+
it 'returns a cursor of friends with details for every user the specified user is following' do
|
|
585
|
+
friends = @client.friends('sferik')
|
|
578
586
|
expect(friends).to be_a Twitter::Cursor
|
|
579
587
|
expect(friends.first).to be_a Twitter::User
|
|
580
588
|
end
|
|
581
|
-
context
|
|
589
|
+
context 'with each' do
|
|
582
590
|
before do
|
|
583
|
-
stub_get(
|
|
591
|
+
stub_get('/1.1/friends/list.json').with(:query => {:cursor => '1418947360875712729', :screen_name => 'sferik'}).to_return(:body => fixture('friends_list2.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
584
592
|
end
|
|
585
|
-
it
|
|
586
|
-
@client.friends(
|
|
587
|
-
expect(a_get(
|
|
588
|
-
expect(a_get(
|
|
593
|
+
it 'requests the correct resource' do
|
|
594
|
+
@client.friends('sferik').each {}
|
|
595
|
+
expect(a_get('/1.1/friends/list.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'})).to have_been_made
|
|
596
|
+
expect(a_get('/1.1/friends/list.json').with(:query => {:cursor => '1418947360875712729', :screen_name => 'sferik'})).to have_been_made
|
|
589
597
|
end
|
|
590
598
|
end
|
|
591
599
|
end
|
|
592
|
-
context
|
|
600
|
+
context 'with a user ID passed' do
|
|
593
601
|
before do
|
|
594
|
-
stub_get(
|
|
602
|
+
stub_get('/1.1/friends/list.json').with(:query => {:cursor => '-1', :user_id => '7505382'}).to_return(:body => fixture('friends_list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
595
603
|
end
|
|
596
|
-
it
|
|
597
|
-
@client.friends(
|
|
598
|
-
expect(a_get(
|
|
604
|
+
it 'requests the correct resource' do
|
|
605
|
+
@client.friends(7_505_382)
|
|
606
|
+
expect(a_get('/1.1/friends/list.json').with(:query => {:cursor => '-1', :user_id => '7505382'})).to have_been_made
|
|
599
607
|
end
|
|
600
|
-
context
|
|
608
|
+
context 'with each' do
|
|
601
609
|
before do
|
|
602
|
-
stub_get(
|
|
610
|
+
stub_get('/1.1/friends/list.json').with(:query => {:cursor => '1418947360875712729', :user_id => '7505382'}).to_return(:body => fixture('friends_list2.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
603
611
|
end
|
|
604
|
-
it
|
|
605
|
-
@client.friends(
|
|
606
|
-
expect(a_get(
|
|
607
|
-
expect(a_get(
|
|
612
|
+
it 'requests the correct resource' do
|
|
613
|
+
@client.friends(7_505_382).each {}
|
|
614
|
+
expect(a_get('/1.1/friends/list.json').with(:query => {:cursor => '-1', :user_id => '7505382'})).to have_been_made
|
|
615
|
+
expect(a_get('/1.1/friends/list.json').with(:query => {:cursor => '1418947360875712729', :user_id => '7505382'})).to have_been_made
|
|
608
616
|
end
|
|
609
617
|
end
|
|
610
618
|
end
|
|
611
|
-
context
|
|
619
|
+
context 'without arguments passed' do
|
|
612
620
|
before do
|
|
613
|
-
stub_get(
|
|
614
|
-
stub_get(
|
|
621
|
+
stub_get('/1.1/account/verify_credentials.json').to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
622
|
+
stub_get('/1.1/friends/list.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'}).to_return(:body => fixture('friends_list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
615
623
|
end
|
|
616
|
-
it
|
|
624
|
+
it 'requests the correct resource' do
|
|
617
625
|
@client.friends
|
|
618
|
-
expect(a_get(
|
|
619
|
-
expect(a_get(
|
|
626
|
+
expect(a_get('/1.1/account/verify_credentials.json')).to have_been_made
|
|
627
|
+
expect(a_get('/1.1/friends/list.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'})).to have_been_made
|
|
620
628
|
end
|
|
621
|
-
it
|
|
629
|
+
it 'returns a cursor of friends with details for every user the specified user is following' do
|
|
622
630
|
friends = @client.friends
|
|
623
631
|
expect(friends).to be_a Twitter::Cursor
|
|
624
632
|
expect(friends.first).to be_a Twitter::User
|
|
625
633
|
end
|
|
626
|
-
context
|
|
634
|
+
context 'with each' do
|
|
627
635
|
before do
|
|
628
|
-
stub_get(
|
|
636
|
+
stub_get('/1.1/friends/list.json').with(:query => {:cursor => '1418947360875712729', :screen_name => 'sferik'}).to_return(:body => fixture('friends_list2.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
629
637
|
end
|
|
630
|
-
it
|
|
631
|
-
@client.friends.each{}
|
|
632
|
-
expect(a_get(
|
|
633
|
-
expect(a_get(
|
|
634
|
-
expect(a_get(
|
|
638
|
+
it 'requests the correct resource' do
|
|
639
|
+
@client.friends.each {}
|
|
640
|
+
expect(a_get('/1.1/account/verify_credentials.json')).to have_been_made
|
|
641
|
+
expect(a_get('/1.1/friends/list.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'})).to have_been_made
|
|
642
|
+
expect(a_get('/1.1/friends/list.json').with(:query => {:cursor => '1418947360875712729', :screen_name => 'sferik'})).to have_been_made
|
|
635
643
|
end
|
|
636
644
|
end
|
|
637
645
|
end
|
|
638
646
|
end
|
|
639
647
|
|
|
640
|
-
describe
|
|
648
|
+
describe '#no_retweet_ids' do
|
|
641
649
|
before do
|
|
642
|
-
stub_get(
|
|
650
|
+
stub_get('/1.1/friendships/no_retweets/ids.json').to_return(:body => fixture('ids.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
|
643
651
|
end
|
|
644
|
-
it
|
|
652
|
+
it 'requests the correct resource' do
|
|
645
653
|
@client.no_retweet_ids
|
|
646
|
-
expect(a_get(
|
|
654
|
+
expect(a_get('/1.1/friendships/no_retweets/ids.json')).to have_been_made
|
|
647
655
|
end
|
|
648
|
-
it
|
|
656
|
+
it 'requests the correct resource when the alias is called' do
|
|
649
657
|
@client.no_retweets_ids
|
|
650
|
-
expect(a_get(
|
|
658
|
+
expect(a_get('/1.1/friendships/no_retweets/ids.json')).to have_been_made
|
|
651
659
|
end
|
|
652
|
-
it
|
|
660
|
+
it 'returns users ids of those that do not wish to be retweeted' do
|
|
653
661
|
no_retweet_ids = @client.no_retweet_ids
|
|
654
662
|
expect(no_retweet_ids).to be_an Array
|
|
655
663
|
expect(no_retweet_ids.first).to be_an Integer
|