twitter 5.8.0 → 5.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +18 -0
- data/README.md +10 -36
- data/lib/twitter/base.rb +20 -3
- data/lib/twitter/basic_user.rb +6 -4
- data/lib/twitter/client.rb +2 -1
- data/lib/twitter/configuration.rb +1 -1
- data/lib/twitter/cursor.rb +1 -1
- data/lib/twitter/entities.rb +10 -6
- data/lib/twitter/enumerable.rb +2 -2
- data/lib/twitter/error.rb +7 -0
- data/lib/twitter/geo_results.rb +1 -1
- data/lib/twitter/list.rb +3 -2
- data/lib/twitter/media/photo.rb +1 -1
- data/lib/twitter/place.rb +13 -15
- data/lib/twitter/profile.rb +1 -1
- data/lib/twitter/profile_banner.rb +1 -1
- data/lib/twitter/rest/client.rb +17 -2
- data/lib/twitter/rest/friends_and_followers.rb +1 -1
- data/lib/twitter/rest/lists.rb +4 -2
- data/lib/twitter/rest/spam_reporting.rb +1 -1
- data/lib/twitter/rest/tweets.rb +17 -17
- data/lib/twitter/rest/users.rb +77 -13
- data/lib/twitter/rest/utils.rb +10 -6
- data/lib/twitter/search_results.rb +1 -1
- data/lib/twitter/settings.rb +4 -3
- data/lib/twitter/source_user.rb +3 -2
- data/lib/twitter/streaming/client.rb +7 -2
- data/lib/twitter/streaming/connection.rb +9 -2
- data/lib/twitter/streaming/response.rb +3 -3
- data/lib/twitter/suggestion.rb +1 -1
- data/lib/twitter/target_user.rb +1 -1
- data/lib/twitter/trend.rb +2 -1
- data/lib/twitter/trend_results.rb +1 -1
- data/lib/twitter/tweet.rb +4 -4
- data/lib/twitter/user.rb +60 -19
- data/lib/twitter/utils.rb +12 -5
- data/lib/twitter/version.rb +1 -1
- data/spec/fixtures/following.json +1 -1
- data/spec/fixtures/sferik.json +1 -1
- data/spec/helper.rb +14 -5
- data/spec/twitter/base_spec.rb +16 -4
- data/spec/twitter/direct_message_spec.rb +12 -13
- data/spec/twitter/entity/uri_spec.rb +2 -2
- data/spec/twitter/error_spec.rb +2 -2
- data/spec/twitter/media/photo_spec.rb +4 -4
- data/spec/twitter/oembed_spec.rb +3 -3
- data/spec/twitter/place_spec.rb +1 -1
- data/spec/twitter/rest/client_spec.rb +54 -14
- data/spec/twitter/rest/friends_and_followers_spec.rb +76 -76
- data/spec/twitter/rest/lists_spec.rb +85 -64
- data/spec/twitter/rest/timelines_spec.rb +2 -2
- data/spec/twitter/rest/tweets_spec.rb +20 -16
- data/spec/twitter/rest/undocumented_spec.rb +17 -17
- data/spec/twitter/rest/users_spec.rb +101 -17
- data/spec/twitter/streaming/client_spec.rb +1 -1
- data/spec/twitter/streaming/connection_spec.rb +32 -0
- data/spec/twitter/streaming/response_spec.rb +21 -0
- data/spec/twitter/trend_spec.rb +1 -1
- data/spec/twitter/tweet_spec.rb +14 -23
- data/spec/twitter/user_spec.rb +120 -13
- data/twitter.gemspec +3 -3
- metadata +8 -4
@@ -108,8 +108,8 @@ describe Twitter::REST::Timelines do
|
|
108
108
|
end
|
109
109
|
it 'requests the correct resource' do
|
110
110
|
@client.retweeted_to_me
|
111
|
-
expect(
|
112
|
-
expect(
|
111
|
+
expect(a_get('/1.1/statuses/home_timeline.json').with(:query => {:include_rts => 'true', :count => '200'})).to have_been_made
|
112
|
+
expect(a_get('/1.1/statuses/home_timeline.json').with(:query => {:include_rts => 'true', :count => '200', :max_id => '244102729860009983'})).to have_been_made.times(3)
|
113
113
|
end
|
114
114
|
it 'returns the 20 most recent retweets posted by users the authenticating user follow' do
|
115
115
|
tweets = @client.retweeted_to_me
|
@@ -135,36 +135,34 @@ describe Twitter::REST::Tweets do
|
|
135
135
|
|
136
136
|
describe '#statuses' do
|
137
137
|
before do
|
138
|
-
|
138
|
+
stub_post('/1.1/statuses/lookup.json').with(:body => {:id => '25938088801,91151181040201728'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
139
139
|
end
|
140
140
|
it 'requests the correct resource' do
|
141
|
-
@client.statuses(25_938_088_801)
|
142
|
-
expect(
|
141
|
+
@client.statuses(25_938_088_801, 91_151_181_040_201_728)
|
142
|
+
expect(a_post('/1.1/statuses/lookup.json').with(:body => {:id => '25938088801,91151181040201728'})).to have_been_made
|
143
143
|
end
|
144
144
|
it 'returns an array of Tweets' do
|
145
|
-
tweets = @client.statuses(25_938_088_801)
|
145
|
+
tweets = @client.statuses(25_938_088_801, 91_151_181_040_201_728)
|
146
146
|
expect(tweets).to be_an Array
|
147
147
|
expect(tweets.first).to be_a Twitter::Tweet
|
148
|
-
expect(tweets.first.text).to eq(
|
148
|
+
expect(tweets.first.text).to eq('Happy Birthday @imdane. Watch out for those @rally pranksters!')
|
149
149
|
end
|
150
|
-
context 'with
|
150
|
+
context 'with URI objects passed' do
|
151
151
|
it 'requests the correct resource' do
|
152
|
-
|
153
|
-
|
154
|
-
expect(a_get('/1.1/statuses/show/25938088801.json')).to have_been_made
|
152
|
+
@client.statuses(URI.parse('https://twitter.com/sferik/status/25938088801'), URI.parse('https://twitter.com/sferik/status/91151181040201728'))
|
153
|
+
expect(a_post('/1.1/statuses/lookup.json').with(:body => {:id => '25938088801,91151181040201728'})).to have_been_made
|
155
154
|
end
|
156
155
|
end
|
157
|
-
context 'with
|
156
|
+
context 'with URI strings passed' do
|
158
157
|
it 'requests the correct resource' do
|
159
|
-
@client.statuses('https://twitter.com/sferik/status/25938088801')
|
160
|
-
expect(
|
158
|
+
@client.statuses('https://twitter.com/sferik/status/25938088801', 'https://twitter.com/sferik/status/91151181040201728')
|
159
|
+
expect(a_post('/1.1/statuses/lookup.json').with(:body => {:id => '25938088801,91151181040201728'})).to have_been_made
|
161
160
|
end
|
162
161
|
end
|
163
|
-
context 'with
|
162
|
+
context 'with Tweets passed' do
|
164
163
|
it 'requests the correct resource' do
|
165
|
-
|
166
|
-
|
167
|
-
expect(a_get('/1.1/statuses/show/25938088801.json')).to have_been_made
|
164
|
+
@client.statuses(Twitter::Tweet.new(:id => 25_938_088_801), Twitter::Tweet.new(:id => 91_151_181_040_201_728))
|
165
|
+
expect(a_post('/1.1/statuses/lookup.json').with(:body => {:id => '25938088801,91151181040201728'})).to have_been_made
|
168
166
|
end
|
169
167
|
end
|
170
168
|
end
|
@@ -474,6 +472,12 @@ describe Twitter::REST::Tweets do
|
|
474
472
|
expect(a_post('/1.1/statuses/update_with_media.json')).to have_been_made
|
475
473
|
end
|
476
474
|
end
|
475
|
+
context 'A non IO object' do
|
476
|
+
it 'raises an error' do
|
477
|
+
update = lambda { @client.update_with_media('You always have options', 'Unacceptable IO') }
|
478
|
+
expect { update.call }.to raise_error(Twitter::Error::UnacceptableIO)
|
479
|
+
end
|
480
|
+
end
|
477
481
|
context 'already posted' do
|
478
482
|
before do
|
479
483
|
stub_post('/1.1/statuses/update_with_media.json').to_return(:status => 403, :body => fixture('already_posted.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
@@ -9,11 +9,11 @@ describe Twitter::REST::Undocumented do
|
|
9
9
|
describe '#following_followers_of' do
|
10
10
|
context 'with a screen_name passed' do
|
11
11
|
before do
|
12
|
-
stub_get('/users/following_followers_of.json').with(:query => {:
|
12
|
+
stub_get('/users/following_followers_of.json').with(:query => {:screen_name => 'sferik', :cursor => '-1'}).to_return(:body => fixture('users_list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
13
13
|
end
|
14
14
|
it 'requests the correct resource' do
|
15
15
|
@client.following_followers_of('sferik')
|
16
|
-
expect(a_get('/users/following_followers_of.json').with(:query => {:
|
16
|
+
expect(a_get('/users/following_followers_of.json').with(:query => {:screen_name => 'sferik', :cursor => '-1'})).to have_been_made
|
17
17
|
end
|
18
18
|
it 'returns an array of numeric IDs for every user following the specified user' do
|
19
19
|
following_followers_of = @client.following_followers_of('sferik')
|
@@ -22,43 +22,43 @@ describe Twitter::REST::Undocumented do
|
|
22
22
|
end
|
23
23
|
context 'with each' do
|
24
24
|
before do
|
25
|
-
stub_get('/users/following_followers_of.json').with(:query => {:
|
25
|
+
stub_get('/users/following_followers_of.json').with(:query => {:screen_name => 'sferik', :cursor => '1322801608223717003'}).to_return(:body => fixture('users_list2.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
26
26
|
end
|
27
27
|
it 'requests the correct resource' do
|
28
28
|
@client.following_followers_of('sferik').each {}
|
29
|
-
expect(a_get('/users/following_followers_of.json').with(:query => {:
|
30
|
-
expect(a_get('/users/following_followers_of.json').with(:query => {:
|
29
|
+
expect(a_get('/users/following_followers_of.json').with(:query => {:screen_name => 'sferik', :cursor => '-1'})).to have_been_made
|
30
|
+
expect(a_get('/users/following_followers_of.json').with(:query => {:screen_name => 'sferik', :cursor => '1322801608223717003'})).to have_been_made
|
31
31
|
end
|
32
32
|
end
|
33
33
|
end
|
34
34
|
context 'with a user ID passed' do
|
35
35
|
before do
|
36
|
-
stub_get('/users/following_followers_of.json').with(:query => {:
|
36
|
+
stub_get('/users/following_followers_of.json').with(:query => {:user_id => '7505382', :cursor => '-1'}).to_return(:body => fixture('users_list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
37
37
|
end
|
38
38
|
it 'requests the correct resource' do
|
39
39
|
@client.following_followers_of(7_505_382)
|
40
|
-
expect(a_get('/users/following_followers_of.json').with(:query => {:
|
40
|
+
expect(a_get('/users/following_followers_of.json').with(:query => {:user_id => '7505382', :cursor => '-1'})).to have_been_made
|
41
41
|
end
|
42
42
|
context 'with each' do
|
43
43
|
before do
|
44
|
-
stub_get('/users/following_followers_of.json').with(:query => {:
|
44
|
+
stub_get('/users/following_followers_of.json').with(:query => {:user_id => '7505382', :cursor => '1322801608223717003'}).to_return(:body => fixture('users_list2.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
45
45
|
end
|
46
46
|
it 'requests the correct resource' do
|
47
47
|
@client.following_followers_of(7_505_382).each {}
|
48
|
-
expect(a_get('/users/following_followers_of.json').with(:query => {:
|
49
|
-
expect(a_get('/users/following_followers_of.json').with(:query => {:
|
48
|
+
expect(a_get('/users/following_followers_of.json').with(:query => {:user_id => '7505382', :cursor => '-1'})).to have_been_made
|
49
|
+
expect(a_get('/users/following_followers_of.json').with(:query => {:user_id => '7505382', :cursor => '1322801608223717003'})).to have_been_made
|
50
50
|
end
|
51
51
|
end
|
52
52
|
end
|
53
53
|
context 'without arguments passed' do
|
54
54
|
before do
|
55
|
-
stub_get('/1.1/account/verify_credentials.json').to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
56
|
-
stub_get('/users/following_followers_of.json').with(:query => {:
|
55
|
+
stub_get('/1.1/account/verify_credentials.json').with(:query => {:include_entities => 'false', :skip_status => 'true'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
56
|
+
stub_get('/users/following_followers_of.json').with(:query => {:user_id => '7505382', :cursor => '-1'}).to_return(:body => fixture('users_list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
57
57
|
end
|
58
58
|
it 'requests the correct resource' do
|
59
59
|
@client.following_followers_of
|
60
|
-
expect(a_get('/1.1/account/verify_credentials.json')).to have_been_made
|
61
|
-
expect(a_get('/users/following_followers_of.json').with(:query => {:
|
60
|
+
expect(a_get('/1.1/account/verify_credentials.json').with(:query => {:include_entities => 'false', :skip_status => 'true'})).to have_been_made
|
61
|
+
expect(a_get('/users/following_followers_of.json').with(:query => {:user_id => '7505382', :cursor => '-1'})).to have_been_made
|
62
62
|
end
|
63
63
|
it 'returns an array of numeric IDs for every user following the specified user' do
|
64
64
|
following_followers_of = @client.following_followers_of
|
@@ -67,12 +67,12 @@ describe Twitter::REST::Undocumented do
|
|
67
67
|
end
|
68
68
|
context 'with each' do
|
69
69
|
before do
|
70
|
-
stub_get('/users/following_followers_of.json').with(:query => {:
|
70
|
+
stub_get('/users/following_followers_of.json').with(:query => {:user_id => '7505382', :cursor => '1322801608223717003'}).to_return(:body => fixture('users_list2.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
71
71
|
end
|
72
72
|
it 'requests the correct resource' do
|
73
73
|
@client.following_followers_of.each {}
|
74
|
-
expect(a_get('/users/following_followers_of.json').with(:query => {:
|
75
|
-
expect(a_get('/users/following_followers_of.json').with(:query => {:
|
74
|
+
expect(a_get('/users/following_followers_of.json').with(:query => {:user_id => '7505382', :cursor => '-1'})).to have_been_made
|
75
|
+
expect(a_get('/users/following_followers_of.json').with(:query => {:user_id => '7505382', :cursor => '1322801608223717003'})).to have_been_made
|
76
76
|
end
|
77
77
|
end
|
78
78
|
end
|
@@ -171,26 +171,26 @@ describe Twitter::REST::Users do
|
|
171
171
|
end
|
172
172
|
end
|
173
173
|
|
174
|
-
describe '#
|
174
|
+
describe '#blocked' do
|
175
175
|
before do
|
176
176
|
stub_get('/1.1/blocks/list.json').with(:query => {:cursor => '-1'}).to_return(:body => fixture('users_list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
177
177
|
end
|
178
178
|
it 'requests the correct resource' do
|
179
|
-
@client.
|
179
|
+
@client.blocked
|
180
180
|
expect(a_get('/1.1/blocks/list.json').with(:query => {:cursor => '-1'})).to have_been_made
|
181
181
|
end
|
182
182
|
it 'returns an array of user objects that the authenticating user is blocking' do
|
183
|
-
|
184
|
-
expect(
|
185
|
-
expect(
|
186
|
-
expect(
|
183
|
+
blocked = @client.blocked
|
184
|
+
expect(blocked).to be_a Twitter::Cursor
|
185
|
+
expect(blocked.first).to be_a Twitter::User
|
186
|
+
expect(blocked.first.id).to eq(7_505_382)
|
187
187
|
end
|
188
188
|
context 'with each' do
|
189
189
|
before do
|
190
190
|
stub_get('/1.1/blocks/list.json').with(:query => {:cursor => '1322801608223717003'}).to_return(:body => fixture('users_list2.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
191
191
|
end
|
192
192
|
it 'requests the correct resource' do
|
193
|
-
@client.
|
193
|
+
@client.blocked.each {}
|
194
194
|
expect(a_get('/1.1/blocks/list.json').with(:query => {:cursor => '-1'})).to have_been_made
|
195
195
|
expect(a_get('/1.1/blocks/list.json').with(:query => {:cursor => '1322801608223717003'})).to have_been_made
|
196
196
|
end
|
@@ -579,12 +579,13 @@ describe Twitter::REST::Users do
|
|
579
579
|
end
|
580
580
|
context 'without arguments passed' do
|
581
581
|
before do
|
582
|
-
stub_get('/1.1/account/verify_credentials.json').to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
583
|
-
stub_get('/1.1/users/contributees.json').with(:query => {:
|
582
|
+
stub_get('/1.1/account/verify_credentials.json').with(:query => {:include_entities => 'false', :skip_status => 'true'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
583
|
+
stub_get('/1.1/users/contributees.json').with(:query => {:user_id => '7505382'}).to_return(:body => fixture('contributees.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
584
584
|
end
|
585
585
|
it 'requests the correct resource' do
|
586
586
|
@client.contributees
|
587
|
-
expect(a_get('/1.1/
|
587
|
+
expect(a_get('/1.1/account/verify_credentials.json').with(:query => {:include_entities => 'false', :skip_status => 'true'})).to have_been_made
|
588
|
+
expect(a_get('/1.1/users/contributees.json').with(:query => {:user_id => '7505382'})).to have_been_made
|
588
589
|
end
|
589
590
|
it 'returns contributees' do
|
590
591
|
contributees = @client.contributees
|
@@ -622,12 +623,13 @@ describe Twitter::REST::Users do
|
|
622
623
|
end
|
623
624
|
context 'without arguments passed' do
|
624
625
|
before do
|
625
|
-
stub_get('/1.1/account/verify_credentials.json').to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
626
|
-
stub_get('/1.1/users/contributors.json').with(:query => {:
|
626
|
+
stub_get('/1.1/account/verify_credentials.json').with(:query => {:include_entities => 'false', :skip_status => 'true'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
627
|
+
stub_get('/1.1/users/contributors.json').with(:query => {:user_id => '7505382'}).to_return(:body => fixture('members.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
627
628
|
end
|
628
629
|
it 'requests the correct resource' do
|
629
630
|
@client.contributors
|
630
|
-
expect(a_get('/1.1/
|
631
|
+
expect(a_get('/1.1/account/verify_credentials.json').with(:query => {:include_entities => 'false', :skip_status => 'true'})).to have_been_made
|
632
|
+
expect(a_get('/1.1/users/contributors.json').with(:query => {:user_id => '7505382'})).to have_been_made
|
631
633
|
end
|
632
634
|
it 'returns contributors' do
|
633
635
|
contributors = @client.contributors
|
@@ -693,13 +695,13 @@ describe Twitter::REST::Users do
|
|
693
695
|
end
|
694
696
|
context 'without arguments passed' do
|
695
697
|
before do
|
696
|
-
stub_get('/1.1/account/verify_credentials.json').to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
697
|
-
stub_get('/1.1/users/profile_banner.json').with(:query => {:
|
698
|
+
stub_get('/1.1/account/verify_credentials.json').with(:query => {:include_entities => 'false', :skip_status => 'true'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
699
|
+
stub_get('/1.1/users/profile_banner.json').with(:query => {:user_id => '7505382'}).to_return(:body => fixture('profile_banner.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
698
700
|
end
|
699
701
|
it 'requests the correct resource' do
|
700
702
|
@client.profile_banner
|
701
|
-
expect(a_get('/1.1/account/verify_credentials.json')).to have_been_made
|
702
|
-
expect(a_get('/1.1/users/profile_banner.json').with(:query => {:
|
703
|
+
expect(a_get('/1.1/account/verify_credentials.json').with(:query => {:include_entities => 'false', :skip_status => 'true'})).to have_been_made
|
704
|
+
expect(a_get('/1.1/users/profile_banner.json').with(:query => {:user_id => '7505382'})).to have_been_made
|
703
705
|
end
|
704
706
|
it 'returns an array of numeric IDs for every user following the specified user' do
|
705
707
|
banner = @client.profile_banner
|
@@ -710,4 +712,86 @@ describe Twitter::REST::Users do
|
|
710
712
|
end
|
711
713
|
end
|
712
714
|
|
715
|
+
describe '#mute' do
|
716
|
+
before do
|
717
|
+
stub_post('/1.1/mutes/users/create.json').with(:body => {:screen_name => 'sferik'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
718
|
+
end
|
719
|
+
it 'requests the correct resource' do
|
720
|
+
@client.mute('sferik')
|
721
|
+
expect(a_post('/1.1/mutes/users/create.json')).to have_been_made
|
722
|
+
end
|
723
|
+
it 'returns an array of muteed users' do
|
724
|
+
users = @client.mute('sferik')
|
725
|
+
expect(users).to be_an Array
|
726
|
+
expect(users.first).to be_a Twitter::User
|
727
|
+
expect(users.first.id).to eq(7_505_382)
|
728
|
+
end
|
729
|
+
end
|
730
|
+
|
731
|
+
describe '#unmute' do
|
732
|
+
before do
|
733
|
+
stub_post('/1.1/mutes/users/destroy.json').with(:body => {:screen_name => 'sferik'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
734
|
+
end
|
735
|
+
it 'requests the correct resource' do
|
736
|
+
@client.unmute('sferik')
|
737
|
+
expect(a_post('/1.1/mutes/users/destroy.json').with(:body => {:screen_name => 'sferik'})).to have_been_made
|
738
|
+
end
|
739
|
+
it 'returns an array of un-muteed users' do
|
740
|
+
users = @client.unmute('sferik')
|
741
|
+
expect(users).to be_an Array
|
742
|
+
expect(users.first).to be_a Twitter::User
|
743
|
+
expect(users.first.id).to eq(7_505_382)
|
744
|
+
end
|
745
|
+
end
|
746
|
+
|
747
|
+
describe '#muted' do
|
748
|
+
before do
|
749
|
+
stub_get('/1.1/mutes/users/list.json').with(:query => {:cursor => '-1'}).to_return(:body => fixture('users_list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
750
|
+
end
|
751
|
+
it 'requests the correct resource' do
|
752
|
+
@client.muted
|
753
|
+
expect(a_get('/1.1/mutes/users/list.json').with(:query => {:cursor => '-1'})).to have_been_made
|
754
|
+
end
|
755
|
+
it 'returns an array of user objects that the authenticating user is muting' do
|
756
|
+
muted = @client.muted
|
757
|
+
expect(muted).to be_a Twitter::Cursor
|
758
|
+
expect(muted.first).to be_a Twitter::User
|
759
|
+
expect(muted.first.id).to eq(7_505_382)
|
760
|
+
end
|
761
|
+
context 'with each' do
|
762
|
+
before do
|
763
|
+
stub_get('/1.1/mutes/users/list.json').with(:query => {:cursor => '1322801608223717003'}).to_return(:body => fixture('users_list2.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
764
|
+
end
|
765
|
+
it 'requests the correct resource' do
|
766
|
+
@client.muted.each {}
|
767
|
+
expect(a_get('/1.1/mutes/users/list.json').with(:query => {:cursor => '-1'})).to have_been_made
|
768
|
+
expect(a_get('/1.1/mutes/users/list.json').with(:query => {:cursor => '1322801608223717003'})).to have_been_made
|
769
|
+
end
|
770
|
+
end
|
771
|
+
end
|
772
|
+
|
773
|
+
describe '#muted_ids' do
|
774
|
+
before do
|
775
|
+
stub_get('/1.1/mutes/users/ids.json').with(:query => {:cursor => '-1'}).to_return(:body => fixture('ids_list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
776
|
+
end
|
777
|
+
it 'requests the correct resource' do
|
778
|
+
@client.muted_ids
|
779
|
+
expect(a_get('/1.1/mutes/users/ids.json').with(:query => {:cursor => '-1'})).to have_been_made
|
780
|
+
end
|
781
|
+
it 'returns an array of numeric user IDs the authenticating user is muting' do
|
782
|
+
muted_ids = @client.muted_ids
|
783
|
+
expect(muted_ids).to be_a Twitter::Cursor
|
784
|
+
expect(muted_ids.first).to eq(20_009_713)
|
785
|
+
end
|
786
|
+
context 'with each' do
|
787
|
+
before do
|
788
|
+
stub_get('/1.1/mutes/users/ids.json').with(:query => {:cursor => '1305102810874389703'}).to_return(:body => fixture('ids_list2.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
789
|
+
end
|
790
|
+
it 'requests the correct resource' do
|
791
|
+
@client.muted_ids.each {}
|
792
|
+
expect(a_get('/1.1/mutes/users/ids.json').with(:query => {:cursor => '-1'})).to have_been_made
|
793
|
+
expect(a_get('/1.1/mutes/users/ids.json').with(:query => {:cursor => '1305102810874389703'})).to have_been_made
|
794
|
+
end
|
795
|
+
end
|
796
|
+
end
|
713
797
|
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Twitter::Streaming::Connection do
|
4
|
+
|
5
|
+
describe 'initialize' do
|
6
|
+
context 'no options provided' do
|
7
|
+
subject(:connection) { Twitter::Streaming::Connection.new }
|
8
|
+
|
9
|
+
it 'sets the default socket classes' do
|
10
|
+
expect(connection.tcp_socket_class).to eq TCPSocket
|
11
|
+
expect(connection.ssl_socket_class).to eq OpenSSL::SSL::SSLSocket
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
context 'custom socket classes provided in opts' do
|
16
|
+
class DummyTCPSocket; end
|
17
|
+
class DummySSLSocket; end
|
18
|
+
|
19
|
+
subject(:connection) do
|
20
|
+
Twitter::Streaming::Connection.new(
|
21
|
+
:tcp_socket_class => DummyTCPSocket,
|
22
|
+
:ssl_socket_class => DummySSLSocket
|
23
|
+
)
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'sets the default socket classes' do
|
27
|
+
expect(connection.tcp_socket_class).to eq DummyTCPSocket
|
28
|
+
expect(connection.ssl_socket_class).to eq DummySSLSocket
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Twitter::Streaming::Response do
|
4
|
+
subject { Twitter::Streaming::Response.new }
|
5
|
+
|
6
|
+
describe '#on_headers_complete' do
|
7
|
+
it 'should not error if status code is 200' do
|
8
|
+
expect do
|
9
|
+
subject << "HTTP/1.1 200 OK\r\nSome-Header: Woo\r\n\r\n"
|
10
|
+
end.to_not raise_error
|
11
|
+
end
|
12
|
+
|
13
|
+
Twitter::Error.errors.each do |code, klass|
|
14
|
+
it "should raise an exception of type #{klass} for status code #{code}" do
|
15
|
+
expect do
|
16
|
+
subject << "HTTP/1.1 #{code} NOK\r\nSome-Header: Woo\r\n\r\n"
|
17
|
+
end.to raise_error(klass)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/spec/twitter/trend_spec.rb
CHANGED
@@ -28,7 +28,7 @@ describe Twitter::Trend do
|
|
28
28
|
describe '#uri' do
|
29
29
|
it 'returns a URI when the url is set' do
|
30
30
|
trend = Twitter::Trend.new(:url => 'http://twitter.com/search/?q=%23sevenwordsaftersex')
|
31
|
-
expect(trend.uri).to
|
31
|
+
expect(trend.uri).to be_an Addressable::URI
|
32
32
|
expect(trend.uri.to_s).to eq('http://twitter.com/search/?q=%23sevenwordsaftersex')
|
33
33
|
end
|
34
34
|
it 'returns nil when the url is not set' do
|
data/spec/twitter/tweet_spec.rb
CHANGED
@@ -53,27 +53,26 @@ describe Twitter::Tweet do
|
|
53
53
|
end
|
54
54
|
|
55
55
|
describe '#entities?' do
|
56
|
-
it 'returns false if there are no entities set' do
|
57
|
-
tweet = Twitter::Tweet.new(:id => 28_669_546_014)
|
58
|
-
expect(tweet.entities?).to be false
|
59
|
-
end
|
60
|
-
|
61
|
-
it 'returns false if there are blank lists of entities set' do
|
62
|
-
tweet = Twitter::Tweet.new(:id => 28_669_546_014, :entities => {:urls => []})
|
63
|
-
expect(tweet.entities?).to be false
|
64
|
-
end
|
65
56
|
it 'returns true if there are entities set' do
|
66
57
|
urls_array = [
|
67
58
|
{
|
68
|
-
:url => '
|
59
|
+
:url => 'https://t.co/L2xIBazMPf',
|
69
60
|
:expanded_url => 'http://example.com/expanded',
|
70
|
-
:display_url => 'example.com/expanded
|
61
|
+
:display_url => 'example.com/expanded…',
|
71
62
|
:indices => [10, 33],
|
72
63
|
}
|
73
64
|
]
|
74
65
|
tweet = Twitter::Tweet.new(:id => 28_669_546_014, :entities => {:urls => urls_array})
|
75
66
|
expect(tweet.entities?).to be true
|
76
67
|
end
|
68
|
+
it 'returns false if there are blank lists of entities set' do
|
69
|
+
tweet = Twitter::Tweet.new(:id => 28_669_546_014, :entities => {:urls => []})
|
70
|
+
expect(tweet.entities?).to be false
|
71
|
+
end
|
72
|
+
it 'returns false if there are no entities set' do
|
73
|
+
tweet = Twitter::Tweet.new(:id => 28_669_546_014)
|
74
|
+
expect(tweet.entities?).to be false
|
75
|
+
end
|
77
76
|
end
|
78
77
|
|
79
78
|
describe '#filter_level' do
|
@@ -140,11 +139,9 @@ describe Twitter::Tweet do
|
|
140
139
|
:indices => [10, 33],
|
141
140
|
}]
|
142
141
|
end
|
143
|
-
|
144
142
|
let(:subject) do
|
145
143
|
Twitter::Tweet.new(:id => 28_669_546_014, :entities => {:hashtags => hashtags_array})
|
146
144
|
end
|
147
|
-
|
148
145
|
it 'returns an array of Entity::Hashtag' do
|
149
146
|
hashtags = subject.hashtags
|
150
147
|
expect(hashtags).to be_an Array
|
@@ -153,27 +150,21 @@ describe Twitter::Tweet do
|
|
153
150
|
expect(hashtags.first.text).to eq('twitter')
|
154
151
|
end
|
155
152
|
end
|
156
|
-
|
157
153
|
context 'when entities are set, but empty' do
|
158
154
|
subject { Twitter::Tweet.new(:id => 28_669_546_014, :entities => {:hashtags => []}) }
|
159
|
-
|
160
155
|
it 'is empty' do
|
161
156
|
expect(subject.hashtags).to be_empty
|
162
157
|
end
|
163
|
-
|
164
158
|
it 'does not warn' do
|
165
159
|
subject.hashtags
|
166
160
|
expect($stderr.string).to be_empty
|
167
161
|
end
|
168
162
|
end
|
169
|
-
|
170
163
|
context 'when entities are not set' do
|
171
164
|
subject { Twitter::Tweet.new(:id => 28_669_546_014) }
|
172
|
-
|
173
165
|
it 'is empty' do
|
174
166
|
expect(subject.hashtags).to be_empty
|
175
167
|
end
|
176
|
-
|
177
168
|
it 'warns' do
|
178
169
|
subject.hashtags
|
179
170
|
expect($stderr.string).to match(/To get hashtags, you must pass `:include_entities => true` when requesting the Twitter::Tweet\./)
|
@@ -355,7 +346,7 @@ describe Twitter::Tweet do
|
|
355
346
|
it 'returns an array of Entity::URIs when entities are set' do
|
356
347
|
urls_array = [
|
357
348
|
{
|
358
|
-
:url => '
|
349
|
+
:url => 'https://t.co/L2xIBazMPf',
|
359
350
|
:expanded_url => 'http://example.com/expanded',
|
360
351
|
:display_url => 'example.com/expanded…',
|
361
352
|
:indices => [10, 33],
|
@@ -379,7 +370,7 @@ describe Twitter::Tweet do
|
|
379
370
|
it 'can handle strange urls' do
|
380
371
|
urls_array = [
|
381
372
|
{
|
382
|
-
:url => '
|
373
|
+
:url => 'https://t.co/L2xIBazMPf',
|
383
374
|
:expanded_url => 'http://with_underscore.example.com/expanded',
|
384
375
|
:display_url => 'with_underscore.example.com/expanded…',
|
385
376
|
:indices => [10, 33],
|
@@ -396,7 +387,7 @@ describe Twitter::Tweet do
|
|
396
387
|
describe '#uri' do
|
397
388
|
it 'returns the URI to the tweet' do
|
398
389
|
tweet = Twitter::Tweet.new(:id => 28_669_546_014, :user => {:id => 7_505_382, :screen_name => 'sferik'})
|
399
|
-
expect(tweet.uri).to
|
390
|
+
expect(tweet.uri).to be_an Addressable::URI
|
400
391
|
expect(tweet.uri.to_s).to eq('https://twitter.com/sferik/status/28669546014')
|
401
392
|
end
|
402
393
|
end
|
@@ -404,7 +395,7 @@ describe Twitter::Tweet do
|
|
404
395
|
describe '#uris?' do
|
405
396
|
it 'returns true when the tweet includes urls entities' do
|
406
397
|
entities = {
|
407
|
-
:urls => [{:url => '
|
398
|
+
:urls => [{:url => 'https://t.co/L2xIBazMPf'}]
|
408
399
|
}
|
409
400
|
tweet = Twitter::Tweet.new(:id => 28_669_546_014, :entities => entities)
|
410
401
|
expect(tweet.uris?).to be true
|