twitter 5.1.1 → 5.2.0
Sign up to get free protection for your applications and to get access to all the features.
- 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,653 +3,653 @@ 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
353
|
end
|
354
354
|
end
|
355
355
|
|
356
|
-
describe
|
356
|
+
describe '#unfollow' do
|
357
357
|
before do
|
358
|
-
stub_post(
|
358
|
+
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
359
|
end
|
360
|
-
it
|
361
|
-
@client.unfollow(
|
362
|
-
expect(a_post(
|
360
|
+
it 'requests the correct resource' do
|
361
|
+
@client.unfollow('sferik')
|
362
|
+
expect(a_post('/1.1/friendships/destroy.json').with(:body => {:screen_name => 'sferik'})).to have_been_made
|
363
363
|
end
|
364
|
-
it
|
365
|
-
users = @client.unfollow(
|
364
|
+
it 'returns an array of unfollowed users' do
|
365
|
+
users = @client.unfollow('sferik')
|
366
366
|
expect(users).to be_an Array
|
367
367
|
expect(users.first).to be_a Twitter::User
|
368
|
-
expect(users.first.id).to eq(
|
368
|
+
expect(users.first.id).to eq(7_505_382)
|
369
369
|
end
|
370
370
|
end
|
371
371
|
|
372
|
-
describe
|
372
|
+
describe '#friendship_update' do
|
373
373
|
before do
|
374
|
-
stub_post(
|
374
|
+
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
375
|
end
|
376
|
-
it
|
377
|
-
@client.friendship_update(
|
378
|
-
expect(a_post(
|
376
|
+
it 'requests the correct resource' do
|
377
|
+
@client.friendship_update('sferik', :retweets => true)
|
378
|
+
expect(a_post('/1.1/friendships/update.json').with(:body => {:screen_name => 'sferik', :retweets => 'true'})).to have_been_made
|
379
379
|
end
|
380
|
-
it
|
381
|
-
relationship = @client.friendship_update(
|
380
|
+
it 'returns detailed information about the relationship between two users' do
|
381
|
+
relationship = @client.friendship_update('sferik', :retweets => true)
|
382
382
|
expect(relationship).to be_a Twitter::Relationship
|
383
|
-
expect(relationship.source.id).to eq(
|
383
|
+
expect(relationship.source.id).to eq(7_505_382)
|
384
384
|
end
|
385
385
|
end
|
386
386
|
|
387
|
-
describe
|
388
|
-
context
|
387
|
+
describe '#friendship' do
|
388
|
+
context 'with screen names passed' do
|
389
389
|
before do
|
390
|
-
stub_get(
|
390
|
+
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
391
|
end
|
392
|
-
it
|
393
|
-
@client.friendship(
|
394
|
-
expect(a_get(
|
392
|
+
it 'requests the correct resource' do
|
393
|
+
@client.friendship('sferik', 'pengwynn')
|
394
|
+
expect(a_get('/1.1/friendships/show.json').with(:query => {:source_screen_name => 'sferik', :target_screen_name => 'pengwynn'})).to have_been_made
|
395
395
|
end
|
396
|
-
it
|
397
|
-
relationship = @client.friendship(
|
396
|
+
it 'returns detailed information about the relationship between two users' do
|
397
|
+
relationship = @client.friendship('sferik', 'pengwynn')
|
398
398
|
expect(relationship).to be_a Twitter::Relationship
|
399
|
-
expect(relationship.source.id).to eq(
|
399
|
+
expect(relationship.source.id).to eq(7_505_382)
|
400
400
|
end
|
401
401
|
end
|
402
|
-
context
|
402
|
+
context 'with numeric screen names passed' do
|
403
403
|
before do
|
404
|
-
stub_get(
|
404
|
+
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
405
|
end
|
406
|
-
it
|
407
|
-
@client.friendship(
|
408
|
-
expect(a_get(
|
406
|
+
it 'requests the correct resource' do
|
407
|
+
@client.friendship('0', '311')
|
408
|
+
expect(a_get('/1.1/friendships/show.json').with(:query => {:source_screen_name => '0', :target_screen_name => '311'})).to have_been_made
|
409
409
|
end
|
410
410
|
end
|
411
|
-
context
|
411
|
+
context 'with user IDs passed' do
|
412
412
|
before do
|
413
|
-
stub_get(
|
413
|
+
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
414
|
end
|
415
|
-
it
|
416
|
-
@client.friendship(
|
417
|
-
expect(a_get(
|
415
|
+
it 'requests the correct resource' do
|
416
|
+
@client.friendship(7_505_382, 14_100_886)
|
417
|
+
expect(a_get('/1.1/friendships/show.json').with(:query => {:source_id => '7505382', :target_id => '14100886'})).to have_been_made
|
418
418
|
end
|
419
419
|
end
|
420
|
-
context
|
420
|
+
context 'with user objects passed' do
|
421
421
|
before do
|
422
|
-
stub_get(
|
422
|
+
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
423
|
end
|
424
|
-
it
|
425
|
-
user1 = Twitter::User.new(:id =>
|
426
|
-
user2 = Twitter::User.new(:id =>
|
424
|
+
it 'requests the correct resource' do
|
425
|
+
user1 = Twitter::User.new(:id => '7505382')
|
426
|
+
user2 = Twitter::User.new(:id => '14100886')
|
427
427
|
@client.friendship(user1, user2)
|
428
|
-
expect(a_get(
|
428
|
+
expect(a_get('/1.1/friendships/show.json').with(:query => {:source_id => '7505382', :target_id => '14100886'})).to have_been_made
|
429
429
|
end
|
430
430
|
end
|
431
|
-
context
|
431
|
+
context 'with URI objects passed' do
|
432
432
|
before do
|
433
|
-
stub_get(
|
433
|
+
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
434
|
end
|
435
|
-
it
|
436
|
-
user1 = URI.parse(
|
437
|
-
user2 = URI.parse(
|
435
|
+
it 'requests the correct resource' do
|
436
|
+
user1 = URI.parse('https://twitter.com/sferik')
|
437
|
+
user2 = URI.parse('https://twitter.com/pengwynn')
|
438
438
|
@client.friendship(user1, user2)
|
439
|
-
expect(a_get(
|
439
|
+
expect(a_get('/1.1/friendships/show.json').with(:query => {:source_screen_name => 'sferik', :target_screen_name => 'pengwynn'})).to have_been_made
|
440
440
|
end
|
441
441
|
end
|
442
|
-
context
|
442
|
+
context 'with URI strings passed' do
|
443
443
|
before do
|
444
|
-
stub_get(
|
444
|
+
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
445
|
end
|
446
|
-
it
|
447
|
-
@client.friendship(
|
448
|
-
expect(a_get(
|
446
|
+
it 'requests the correct resource' do
|
447
|
+
@client.friendship('https://twitter.com/sferik', 'https://twitter.com/pengwynn')
|
448
|
+
expect(a_get('/1.1/friendships/show.json').with(:query => {:source_screen_name => 'sferik', :target_screen_name => 'pengwynn'})).to have_been_made
|
449
449
|
end
|
450
450
|
end
|
451
451
|
end
|
452
452
|
|
453
|
-
describe
|
454
|
-
context
|
453
|
+
describe '#friendship?' do
|
454
|
+
context 'with screen names passed' do
|
455
455
|
before do
|
456
|
-
stub_get(
|
457
|
-
stub_get(
|
456
|
+
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'})
|
457
|
+
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
458
|
end
|
459
|
-
it
|
460
|
-
@client.friendship?(
|
461
|
-
expect(a_get(
|
459
|
+
it 'requests the correct resource' do
|
460
|
+
@client.friendship?('sferik', 'pengwynn')
|
461
|
+
expect(a_get('/1.1/friendships/show.json').with(:query => {:source_screen_name => 'sferik', :target_screen_name => 'pengwynn'})).to have_been_made
|
462
462
|
end
|
463
|
-
it
|
464
|
-
friendship = @client.friendship?(
|
463
|
+
it 'returns true if user A follows user B' do
|
464
|
+
friendship = @client.friendship?('sferik', 'pengwynn')
|
465
465
|
expect(friendship).to be true
|
466
466
|
end
|
467
|
-
it
|
468
|
-
friendship = @client.friendship?(
|
467
|
+
it 'returns false if user A does not follow user B' do
|
468
|
+
friendship = @client.friendship?('pengwynn', 'sferik')
|
469
469
|
expect(friendship).to be false
|
470
470
|
end
|
471
471
|
end
|
472
|
-
context
|
472
|
+
context 'with user IDs passed' do
|
473
473
|
before do
|
474
|
-
stub_get(
|
474
|
+
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
475
|
end
|
476
|
-
it
|
477
|
-
@client.friendship?(
|
478
|
-
expect(a_get(
|
476
|
+
it 'requests the correct resource' do
|
477
|
+
@client.friendship?(7_505_382, 14_100_886)
|
478
|
+
expect(a_get('/1.1/friendships/show.json').with(:query => {:source_id => '7505382', :target_id => '14100886'})).to have_been_made
|
479
479
|
end
|
480
480
|
end
|
481
|
-
context
|
481
|
+
context 'with user objects passed' do
|
482
482
|
before do
|
483
|
-
stub_get(
|
483
|
+
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
484
|
end
|
485
|
-
it
|
486
|
-
user1 = Twitter::User.new(:id =>
|
487
|
-
user2 = Twitter::User.new(:id =>
|
485
|
+
it 'requests the correct resource' do
|
486
|
+
user1 = Twitter::User.new(:id => '7505382')
|
487
|
+
user2 = Twitter::User.new(:id => '14100886')
|
488
488
|
@client.friendship?(user1, user2)
|
489
|
-
expect(a_get(
|
489
|
+
expect(a_get('/1.1/friendships/show.json').with(:query => {:source_id => '7505382', :target_id => '14100886'})).to have_been_made
|
490
490
|
end
|
491
491
|
end
|
492
492
|
end
|
493
493
|
|
494
|
-
describe
|
495
|
-
context
|
494
|
+
describe '#followers' do
|
495
|
+
context 'with a screen_name passed' do
|
496
496
|
before do
|
497
|
-
stub_get(
|
497
|
+
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
498
|
end
|
499
|
-
it
|
500
|
-
@client.followers(
|
501
|
-
expect(a_get(
|
499
|
+
it 'requests the correct resource' do
|
500
|
+
@client.followers('sferik')
|
501
|
+
expect(a_get('/1.1/followers/list.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'})).to have_been_made
|
502
502
|
end
|
503
|
-
it
|
504
|
-
followers = @client.followers(
|
503
|
+
it 'returns a cursor of followers with details for every user the specified user is followed by' do
|
504
|
+
followers = @client.followers('sferik')
|
505
505
|
expect(followers).to be_a Twitter::Cursor
|
506
506
|
expect(followers.first).to be_a Twitter::User
|
507
507
|
end
|
508
|
-
context
|
508
|
+
context 'with each' do
|
509
509
|
before do
|
510
|
-
stub_get(
|
510
|
+
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
511
|
end
|
512
|
-
it
|
513
|
-
@client.followers(
|
514
|
-
expect(a_get(
|
515
|
-
expect(a_get(
|
512
|
+
it 'requests the correct resource' do
|
513
|
+
@client.followers('sferik').each {}
|
514
|
+
expect(a_get('/1.1/followers/list.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'})).to have_been_made
|
515
|
+
expect(a_get('/1.1/followers/list.json').with(:query => {:cursor => '1419103567112105362', :screen_name => 'sferik'})).to have_been_made
|
516
516
|
end
|
517
517
|
end
|
518
518
|
end
|
519
|
-
context
|
519
|
+
context 'with a user ID passed' do
|
520
520
|
before do
|
521
|
-
stub_get(
|
521
|
+
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
522
|
end
|
523
|
-
it
|
524
|
-
@client.followers(
|
525
|
-
expect(a_get(
|
523
|
+
it 'requests the correct resource' do
|
524
|
+
@client.followers(7_505_382)
|
525
|
+
expect(a_get('/1.1/followers/list.json').with(:query => {:cursor => '-1', :user_id => '7505382'})).to have_been_made
|
526
526
|
end
|
527
|
-
context
|
527
|
+
context 'with each' do
|
528
528
|
before do
|
529
|
-
stub_get(
|
529
|
+
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
530
|
end
|
531
|
-
it
|
532
|
-
@client.followers(
|
533
|
-
expect(a_get(
|
534
|
-
expect(a_get(
|
531
|
+
it 'requests the correct resource' do
|
532
|
+
@client.followers(7_505_382).each {}
|
533
|
+
expect(a_get('/1.1/followers/list.json').with(:query => {:cursor => '-1', :user_id => '7505382'})).to have_been_made
|
534
|
+
expect(a_get('/1.1/followers/list.json').with(:query => {:cursor => '1419103567112105362', :user_id => '7505382'})).to have_been_made
|
535
535
|
end
|
536
536
|
end
|
537
537
|
end
|
538
|
-
context
|
538
|
+
context 'without arguments passed' do
|
539
539
|
before do
|
540
|
-
stub_get(
|
541
|
-
stub_get(
|
540
|
+
stub_get('/1.1/account/verify_credentials.json').to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
541
|
+
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
542
|
end
|
543
|
-
it
|
543
|
+
it 'requests the correct resource' do
|
544
544
|
@client.followers
|
545
|
-
expect(a_get(
|
546
|
-
expect(a_get(
|
545
|
+
expect(a_get('/1.1/account/verify_credentials.json')).to have_been_made
|
546
|
+
expect(a_get('/1.1/followers/list.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'})).to have_been_made
|
547
547
|
end
|
548
|
-
it
|
548
|
+
it 'returns a cursor of followers with details for every user the specified user is followed by' do
|
549
549
|
followers = @client.followers
|
550
550
|
expect(followers).to be_a Twitter::Cursor
|
551
551
|
expect(followers.first).to be_a Twitter::User
|
552
552
|
end
|
553
|
-
context
|
553
|
+
context 'with each' do
|
554
554
|
before do
|
555
|
-
stub_get(
|
555
|
+
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
556
|
end
|
557
|
-
it
|
558
|
-
@client.followers.each{}
|
559
|
-
expect(a_get(
|
560
|
-
expect(a_get(
|
561
|
-
expect(a_get(
|
557
|
+
it 'requests the correct resource' do
|
558
|
+
@client.followers.each {}
|
559
|
+
expect(a_get('/1.1/account/verify_credentials.json')).to have_been_made
|
560
|
+
expect(a_get('/1.1/followers/list.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'})).to have_been_made
|
561
|
+
expect(a_get('/1.1/followers/list.json').with(:query => {:cursor => '1419103567112105362', :screen_name => 'sferik'})).to have_been_made
|
562
562
|
end
|
563
563
|
end
|
564
564
|
end
|
565
565
|
end
|
566
566
|
|
567
|
-
describe
|
568
|
-
context
|
567
|
+
describe '#friends' do
|
568
|
+
context 'with a screen_name passed' do
|
569
569
|
before do
|
570
|
-
stub_get(
|
570
|
+
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
571
|
end
|
572
|
-
it
|
573
|
-
@client.friends(
|
574
|
-
expect(a_get(
|
572
|
+
it 'requests the correct resource' do
|
573
|
+
@client.friends('sferik')
|
574
|
+
expect(a_get('/1.1/friends/list.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'})).to have_been_made
|
575
575
|
end
|
576
|
-
it
|
577
|
-
friends = @client.friends(
|
576
|
+
it 'returns a cursor of friends with details for every user the specified user is following' do
|
577
|
+
friends = @client.friends('sferik')
|
578
578
|
expect(friends).to be_a Twitter::Cursor
|
579
579
|
expect(friends.first).to be_a Twitter::User
|
580
580
|
end
|
581
|
-
context
|
581
|
+
context 'with each' do
|
582
582
|
before do
|
583
|
-
stub_get(
|
583
|
+
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
584
|
end
|
585
|
-
it
|
586
|
-
@client.friends(
|
587
|
-
expect(a_get(
|
588
|
-
expect(a_get(
|
585
|
+
it 'requests the correct resource' do
|
586
|
+
@client.friends('sferik').each {}
|
587
|
+
expect(a_get('/1.1/friends/list.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'})).to have_been_made
|
588
|
+
expect(a_get('/1.1/friends/list.json').with(:query => {:cursor => '1418947360875712729', :screen_name => 'sferik'})).to have_been_made
|
589
589
|
end
|
590
590
|
end
|
591
591
|
end
|
592
|
-
context
|
592
|
+
context 'with a user ID passed' do
|
593
593
|
before do
|
594
|
-
stub_get(
|
594
|
+
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
595
|
end
|
596
|
-
it
|
597
|
-
@client.friends(
|
598
|
-
expect(a_get(
|
596
|
+
it 'requests the correct resource' do
|
597
|
+
@client.friends(7_505_382)
|
598
|
+
expect(a_get('/1.1/friends/list.json').with(:query => {:cursor => '-1', :user_id => '7505382'})).to have_been_made
|
599
599
|
end
|
600
|
-
context
|
600
|
+
context 'with each' do
|
601
601
|
before do
|
602
|
-
stub_get(
|
602
|
+
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
603
|
end
|
604
|
-
it
|
605
|
-
@client.friends(
|
606
|
-
expect(a_get(
|
607
|
-
expect(a_get(
|
604
|
+
it 'requests the correct resource' do
|
605
|
+
@client.friends(7_505_382).each {}
|
606
|
+
expect(a_get('/1.1/friends/list.json').with(:query => {:cursor => '-1', :user_id => '7505382'})).to have_been_made
|
607
|
+
expect(a_get('/1.1/friends/list.json').with(:query => {:cursor => '1418947360875712729', :user_id => '7505382'})).to have_been_made
|
608
608
|
end
|
609
609
|
end
|
610
610
|
end
|
611
|
-
context
|
611
|
+
context 'without arguments passed' do
|
612
612
|
before do
|
613
|
-
stub_get(
|
614
|
-
stub_get(
|
613
|
+
stub_get('/1.1/account/verify_credentials.json').to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
614
|
+
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
615
|
end
|
616
|
-
it
|
616
|
+
it 'requests the correct resource' do
|
617
617
|
@client.friends
|
618
|
-
expect(a_get(
|
619
|
-
expect(a_get(
|
618
|
+
expect(a_get('/1.1/account/verify_credentials.json')).to have_been_made
|
619
|
+
expect(a_get('/1.1/friends/list.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'})).to have_been_made
|
620
620
|
end
|
621
|
-
it
|
621
|
+
it 'returns a cursor of friends with details for every user the specified user is following' do
|
622
622
|
friends = @client.friends
|
623
623
|
expect(friends).to be_a Twitter::Cursor
|
624
624
|
expect(friends.first).to be_a Twitter::User
|
625
625
|
end
|
626
|
-
context
|
626
|
+
context 'with each' do
|
627
627
|
before do
|
628
|
-
stub_get(
|
628
|
+
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
629
|
end
|
630
|
-
it
|
631
|
-
@client.friends.each{}
|
632
|
-
expect(a_get(
|
633
|
-
expect(a_get(
|
634
|
-
expect(a_get(
|
630
|
+
it 'requests the correct resource' do
|
631
|
+
@client.friends.each {}
|
632
|
+
expect(a_get('/1.1/account/verify_credentials.json')).to have_been_made
|
633
|
+
expect(a_get('/1.1/friends/list.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'})).to have_been_made
|
634
|
+
expect(a_get('/1.1/friends/list.json').with(:query => {:cursor => '1418947360875712729', :screen_name => 'sferik'})).to have_been_made
|
635
635
|
end
|
636
636
|
end
|
637
637
|
end
|
638
638
|
end
|
639
639
|
|
640
|
-
describe
|
640
|
+
describe '#no_retweet_ids' do
|
641
641
|
before do
|
642
|
-
stub_get(
|
642
|
+
stub_get('/1.1/friendships/no_retweets/ids.json').to_return(:body => fixture('ids.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
643
643
|
end
|
644
|
-
it
|
644
|
+
it 'requests the correct resource' do
|
645
645
|
@client.no_retweet_ids
|
646
|
-
expect(a_get(
|
646
|
+
expect(a_get('/1.1/friendships/no_retweets/ids.json')).to have_been_made
|
647
647
|
end
|
648
|
-
it
|
648
|
+
it 'requests the correct resource when the alias is called' do
|
649
649
|
@client.no_retweets_ids
|
650
|
-
expect(a_get(
|
650
|
+
expect(a_get('/1.1/friendships/no_retweets/ids.json')).to have_been_made
|
651
651
|
end
|
652
|
-
it
|
652
|
+
it 'returns users ids of those that do not wish to be retweeted' do
|
653
653
|
no_retweet_ids = @client.no_retweet_ids
|
654
654
|
expect(no_retweet_ids).to be_an Array
|
655
655
|
expect(no_retweet_ids.first).to be_an Integer
|