twitter 5.11.0 → 5.12.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 +11 -1
- data/README.md +7 -5
- data/lib/twitter/arguments.rb +1 -0
- data/lib/twitter/base.rb +4 -5
- data/lib/twitter/basic_user.rb +1 -0
- data/lib/twitter/client.rb +10 -9
- data/lib/twitter/configuration.rb +4 -2
- data/lib/twitter/cursor.rb +3 -2
- data/lib/twitter/direct_message.rb +1 -0
- data/lib/twitter/entity.rb +1 -0
- data/lib/twitter/entity/hashtag.rb +1 -0
- data/lib/twitter/entity/symbol.rb +1 -0
- data/lib/twitter/entity/user_mention.rb +4 -1
- data/lib/twitter/error.rb +22 -19
- data/lib/twitter/geo.rb +1 -0
- data/lib/twitter/geo_results.rb +3 -2
- data/lib/twitter/identity.rb +1 -0
- data/lib/twitter/language.rb +1 -0
- data/lib/twitter/list.rb +12 -5
- data/lib/twitter/media/photo.rb +1 -0
- data/lib/twitter/metadata.rb +1 -0
- data/lib/twitter/null_object.rb +22 -0
- data/lib/twitter/oembed.rb +5 -2
- data/lib/twitter/place.rb +4 -1
- data/lib/twitter/profile.rb +1 -1
- data/lib/twitter/rest/client.rb +4 -4
- data/lib/twitter/rest/favorites.rb +4 -3
- data/lib/twitter/rest/lists.rb +18 -3
- data/lib/twitter/rest/request/multipart_with_file.rb +1 -1
- data/lib/twitter/rest/response/parse_json.rb +1 -1
- data/lib/twitter/rest/response/raise_error.rb +4 -5
- data/lib/twitter/rest/tweets.rb +2 -1
- data/lib/twitter/rest/users.rb +10 -7
- data/lib/twitter/saved_search.rb +1 -0
- data/lib/twitter/search_results.rb +3 -2
- data/lib/twitter/settings.rb +7 -3
- data/lib/twitter/size.rb +4 -1
- data/lib/twitter/streaming/deleted_tweet.rb +1 -0
- data/lib/twitter/streaming/event.rb +2 -2
- data/lib/twitter/streaming/message_parser.rb +1 -1
- data/lib/twitter/suggestion.rb +4 -1
- data/lib/twitter/token.rb +1 -0
- data/lib/twitter/trend.rb +1 -0
- data/lib/twitter/trend_results.rb +3 -2
- data/lib/twitter/tweet.rb +9 -6
- data/lib/twitter/user.rb +15 -13
- data/lib/twitter/utils.rb +2 -6
- data/lib/twitter/version.rb +1 -1
- data/twitter.gemspec +6 -9
- metadata +6 -259
- data/Rakefile +0 -37
- data/spec/fixtures/already_favorited.json +0 -1
- data/spec/fixtures/already_posted.json +0 -1
- data/spec/fixtures/already_retweeted.json +0 -1
- data/spec/fixtures/bearer_token.json +0 -1
- data/spec/fixtures/category.json +0 -1
- data/spec/fixtures/configuration.json +0 -1
- data/spec/fixtures/contributees.json +0 -1
- data/spec/fixtures/count.json +0 -1
- data/spec/fixtures/direct_message.json +0 -1
- data/spec/fixtures/direct_messages.json +0 -1
- data/spec/fixtures/empty.json +0 -0
- data/spec/fixtures/followers_list.json +0 -1
- data/spec/fixtures/followers_list2.json +0 -1
- data/spec/fixtures/following.json +0 -1
- data/spec/fixtures/forbidden.json +0 -1
- data/spec/fixtures/friends_list.json +0 -1
- data/spec/fixtures/friends_list2.json +0 -1
- data/spec/fixtures/friendships.json +0 -1
- data/spec/fixtures/ids.json +0 -1
- data/spec/fixtures/ids_list.json +0 -1
- data/spec/fixtures/ids_list2.json +0 -1
- data/spec/fixtures/languages.json +0 -1
- data/spec/fixtures/list.json +0 -1
- data/spec/fixtures/lists.json +0 -1
- data/spec/fixtures/locations.json +0 -1
- data/spec/fixtures/matching_trends.json +0 -1
- data/spec/fixtures/me.jpeg +0 -0
- data/spec/fixtures/members.json +0 -1
- data/spec/fixtures/memberships.json +0 -1
- data/spec/fixtures/memberships2.json +0 -1
- data/spec/fixtures/not_following.json +0 -1
- data/spec/fixtures/not_found.json +0 -1
- data/spec/fixtures/oembed.json +0 -1
- data/spec/fixtures/ownerships.json +0 -1
- data/spec/fixtures/pbjt.gif +0 -0
- data/spec/fixtures/pengwynn.json +0 -1
- data/spec/fixtures/place.json +0 -1
- data/spec/fixtures/places.json +0 -1
- data/spec/fixtures/privacy.json +0 -1
- data/spec/fixtures/profile_banner.json +0 -1
- data/spec/fixtures/request_token.txt +0 -6
- data/spec/fixtures/retweet.json +0 -1
- data/spec/fixtures/retweets.json +0 -1
- data/spec/fixtures/saved_search.json +0 -1
- data/spec/fixtures/saved_searches.json +0 -1
- data/spec/fixtures/search.json +0 -1
- data/spec/fixtures/search2.json +0 -1
- data/spec/fixtures/search_malformed.json +0 -1
- data/spec/fixtures/settings.json +0 -1
- data/spec/fixtures/sferik.json +0 -1
- data/spec/fixtures/status.json +0 -1
- data/spec/fixtures/statuses.json +0 -1
- data/spec/fixtures/subscriptions.json +0 -1
- data/spec/fixtures/subscriptions2.json +0 -1
- data/spec/fixtures/suggestions.json +0 -1
- data/spec/fixtures/tos.json +0 -1
- data/spec/fixtures/track_streaming.json +0 -3
- data/spec/fixtures/track_streaming_user.json +0 -6
- data/spec/fixtures/upload.json +0 -1
- data/spec/fixtures/user_search.json +0 -1
- data/spec/fixtures/user_timeline.json +0 -1
- data/spec/fixtures/users.json +0 -1
- data/spec/fixtures/users_list.json +0 -1
- data/spec/fixtures/users_list2.json +0 -1
- data/spec/fixtures/we_concept_bg2.png +0 -0
- data/spec/fixtures/wildcomet2.jpe +0 -0
- data/spec/helper.rb +0 -68
- data/spec/twitter/base_spec.rb +0 -39
- data/spec/twitter/basic_user_spec.rb +0 -23
- data/spec/twitter/configuration_spec.rb +0 -17
- data/spec/twitter/cursor_spec.rb +0 -30
- data/spec/twitter/direct_message_spec.rb +0 -232
- data/spec/twitter/entity/uri_spec.rb +0 -75
- data/spec/twitter/error_spec.rb +0 -52
- data/spec/twitter/geo/point_spec.rb +0 -41
- data/spec/twitter/geo/polygon_spec.rb +0 -29
- data/spec/twitter/geo_factory_spec.rb +0 -19
- data/spec/twitter/geo_results_spec.rb +0 -35
- data/spec/twitter/geo_spec.rb +0 -29
- data/spec/twitter/identifiable_spec.rb +0 -29
- data/spec/twitter/list_spec.rb +0 -88
- data/spec/twitter/media/photo_spec.rb +0 -151
- data/spec/twitter/media_factory_spec.rb +0 -15
- data/spec/twitter/oembed_spec.rb +0 -170
- data/spec/twitter/place_spec.rb +0 -168
- data/spec/twitter/profile_banner_spec.rb +0 -13
- data/spec/twitter/rate_limit_spec.rb +0 -59
- data/spec/twitter/relationship_spec.rb +0 -49
- data/spec/twitter/rest/client_spec.rb +0 -217
- data/spec/twitter/rest/direct_messages_spec.rb +0 -133
- data/spec/twitter/rest/favorites_spec.rb +0 -188
- data/spec/twitter/rest/friends_and_followers_spec.rb +0 -667
- data/spec/twitter/rest/geo_spec.rb +0 -68
- data/spec/twitter/rest/help_spec.rb +0 -68
- data/spec/twitter/rest/lists_spec.rb +0 -910
- data/spec/twitter/rest/media_spec.rb +0 -54
- data/spec/twitter/rest/oauth_spec.rb +0 -63
- data/spec/twitter/rest/saved_searches_spec.rb +0 -98
- data/spec/twitter/rest/search_spec.rb +0 -42
- data/spec/twitter/rest/spam_reporting_spec.rb +0 -25
- data/spec/twitter/rest/suggested_users_spec.rb +0 -59
- data/spec/twitter/rest/timelines_spec.rb +0 -138
- data/spec/twitter/rest/trends_spec.rb +0 -68
- data/spec/twitter/rest/tweets_spec.rb +0 -614
- data/spec/twitter/rest/undocumented_spec.rb +0 -103
- data/spec/twitter/rest/users_spec.rb +0 -797
- data/spec/twitter/saved_search_spec.rb +0 -45
- data/spec/twitter/search_results_spec.rb +0 -30
- data/spec/twitter/settings_spec.rb +0 -27
- data/spec/twitter/size_spec.rb +0 -28
- data/spec/twitter/source_user_spec.rb +0 -23
- data/spec/twitter/streaming/client_spec.rb +0 -123
- data/spec/twitter/streaming/connection_spec.rb +0 -32
- data/spec/twitter/streaming/deleted_tweet_spec.rb +0 -23
- data/spec/twitter/streaming/event_spec.rb +0 -43
- data/spec/twitter/streaming/friend_list_spec.rb +0 -11
- data/spec/twitter/streaming/message_parser_spec.rb +0 -54
- data/spec/twitter/streaming/response_spec.rb +0 -21
- data/spec/twitter/suggestion_spec.rb +0 -40
- data/spec/twitter/target_user_spec.rb +0 -23
- data/spec/twitter/token_spec.rb +0 -16
- data/spec/twitter/trend_results_spec.rb +0 -89
- data/spec/twitter/trend_spec.rb +0 -51
- data/spec/twitter/tweet_spec.rb +0 -456
- data/spec/twitter/user_spec.rb +0 -447
- data/spec/twitter/utils_spec.rb +0 -34
data/spec/twitter/user_spec.rb
DELETED
@@ -1,447 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
require 'helper'
|
3
|
-
|
4
|
-
describe Twitter::User do
|
5
|
-
|
6
|
-
describe '#==' do
|
7
|
-
it 'returns true when objects IDs are the same' do
|
8
|
-
user = Twitter::User.new(:id => 1, :screen_name => 'foo')
|
9
|
-
other = Twitter::User.new(:id => 1, :screen_name => 'bar')
|
10
|
-
expect(user == other).to be true
|
11
|
-
end
|
12
|
-
it 'returns false when objects IDs are different' do
|
13
|
-
user = Twitter::User.new(:id => 1)
|
14
|
-
other = Twitter::User.new(:id => 2)
|
15
|
-
expect(user == other).to be false
|
16
|
-
end
|
17
|
-
it 'returns false when classes are different' do
|
18
|
-
user = Twitter::User.new(:id => 1)
|
19
|
-
other = Twitter::Identity.new(:id => 1)
|
20
|
-
expect(user == other).to be false
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
describe '#created_at' do
|
25
|
-
it 'returns a Time when created_at is set' do
|
26
|
-
user = Twitter::User.new(:id => 7_505_382, :created_at => 'Mon Jul 16 12:59:01 +0000 2007')
|
27
|
-
expect(user.created_at).to be_a Time
|
28
|
-
end
|
29
|
-
it 'returns nil when created_at is not set' do
|
30
|
-
user = Twitter::User.new(:id => 7_505_382)
|
31
|
-
expect(user.created_at).to be_nil
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
describe '#created?' do
|
36
|
-
it 'returns true when created_at is set' do
|
37
|
-
user = Twitter::User.new(:id => 7_505_382, :created_at => 'Mon Jul 16 12:59:01 +0000 2007')
|
38
|
-
expect(user.created?).to be true
|
39
|
-
end
|
40
|
-
it 'returns false when created_at is not set' do
|
41
|
-
user = Twitter::User.new(:id => 7_505_382)
|
42
|
-
expect(user.created?).to be false
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
describe '#description_uris' do
|
47
|
-
it 'returns an array of Entity::URIs when description URI entities are set' do
|
48
|
-
urls_array = [
|
49
|
-
{
|
50
|
-
:url => 'https://t.co/L2xIBazMPf',
|
51
|
-
:expanded_url => 'http://example.com/expanded',
|
52
|
-
:display_url => 'example.com/expanded…',
|
53
|
-
:indices => [10, 33],
|
54
|
-
}
|
55
|
-
]
|
56
|
-
user = Twitter::User.new(:id => 7_505_382, :entities => {:description => {:urls => urls_array}})
|
57
|
-
expect(user.description_uris).to be_an Array
|
58
|
-
expect(user.description_uris.first).to be_a Twitter::Entity::URI
|
59
|
-
expect(user.description_uris.first.indices).to eq([10, 33])
|
60
|
-
expect(user.description_uris.first.expanded_uri).to be_an Addressable::URI
|
61
|
-
end
|
62
|
-
it 'is empty when not set' do
|
63
|
-
user = Twitter::User.new(:id => 7_505_382, :entities => {:description => {:urls => []}})
|
64
|
-
expect(user.description_uris).to be_empty
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
describe '#description_uris?' do
|
69
|
-
it 'returns true when the tweet includes description URI entities' do
|
70
|
-
urls_array = [
|
71
|
-
{
|
72
|
-
:url => 'https://t.co/L2xIBazMPf',
|
73
|
-
:expanded_url => 'http://example.com/expanded',
|
74
|
-
:display_url => 'example.com/expanded…',
|
75
|
-
:indices => [10, 33],
|
76
|
-
}
|
77
|
-
]
|
78
|
-
user = Twitter::User.new(:id => 7_505_382, :entities => {:description => {:urls => urls_array}})
|
79
|
-
expect(user.description_uris?).to be true
|
80
|
-
end
|
81
|
-
it 'returns false when no entities are present' do
|
82
|
-
user = Twitter::User.new(:id => 7_505_382, :entities => {:description => {:urls => []}})
|
83
|
-
expect(user.description_uris?).to be false
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
describe '#entities?' do
|
88
|
-
it 'returns true if there are entities set' do
|
89
|
-
urls_array = [
|
90
|
-
{
|
91
|
-
:url => 'https://t.co/L2xIBazMPf',
|
92
|
-
:expanded_url => 'http://example.com/expanded',
|
93
|
-
:display_url => 'example.com/expanded…',
|
94
|
-
:indices => [10, 33],
|
95
|
-
}
|
96
|
-
]
|
97
|
-
user = Twitter::User.new(:id => 7_505_382, :entities => {:description => {:urls => urls_array}})
|
98
|
-
expect(user.entities?).to be true
|
99
|
-
end
|
100
|
-
it 'returns false if there are blank lists of entities set' do
|
101
|
-
user = Twitter::User.new(:id => 7_505_382, :entities => {:description => {:urls => []}})
|
102
|
-
expect(user.entities?).to be false
|
103
|
-
end
|
104
|
-
it 'returns false if there are no entities set' do
|
105
|
-
user = Twitter::User.new(:id => 7_505_382)
|
106
|
-
expect(user.entities?).to be false
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
describe '#profile_banner_uri' do
|
111
|
-
it 'accepts utf8 urls' do
|
112
|
-
user = Twitter::User.new(:id => 7_505_382, :profile_banner_url => 'https://si0.twimg.com/profile_banners/7_505_382/1348266581©_normal.png')
|
113
|
-
expect(user.profile_banner_uri).to be_an Addressable::URI
|
114
|
-
end
|
115
|
-
it 'returns a URI when profile_banner_url is set' do
|
116
|
-
user = Twitter::User.new(:id => 7_505_382, :profile_banner_url => 'https://si0.twimg.com/profile_banners/7_505_382/1348266581')
|
117
|
-
expect(user.profile_banner_uri).to be_an Addressable::URI
|
118
|
-
end
|
119
|
-
it 'returns nil when profile_banner_uri is not set' do
|
120
|
-
user = Twitter::User.new(:id => 7_505_382)
|
121
|
-
expect(user.profile_banner_uri).to be_nil
|
122
|
-
end
|
123
|
-
it 'returns the web-sized image' do
|
124
|
-
user = Twitter::User.new(:id => 7_505_382, :profile_banner_url => 'https://si0.twimg.com/profile_banners/7_505_382/1348266581')
|
125
|
-
expect(user.profile_banner_uri.to_s).to eq('http://si0.twimg.com/profile_banners/7_505_382/1348266581/web')
|
126
|
-
end
|
127
|
-
context 'with :web_retina passed' do
|
128
|
-
it 'returns the web retina-sized image' do
|
129
|
-
user = Twitter::User.new(:id => 7_505_382, :profile_banner_url => 'https://si0.twimg.com/profile_banners/7_505_382/1348266581')
|
130
|
-
expect(user.profile_banner_uri(:web_retina).to_s).to eq('http://si0.twimg.com/profile_banners/7_505_382/1348266581/web_retina')
|
131
|
-
end
|
132
|
-
end
|
133
|
-
context 'with :mobile passed' do
|
134
|
-
it 'returns the mobile-sized image' do
|
135
|
-
user = Twitter::User.new(:id => 7_505_382, :profile_banner_url => 'https://si0.twimg.com/profile_banners/7_505_382/1348266581')
|
136
|
-
expect(user.profile_banner_uri(:mobile).to_s).to eq('http://si0.twimg.com/profile_banners/7_505_382/1348266581/mobile')
|
137
|
-
end
|
138
|
-
end
|
139
|
-
context 'with :mobile_retina passed' do
|
140
|
-
it 'returns the mobile retina-sized image' do
|
141
|
-
user = Twitter::User.new(:id => 7_505_382, :profile_banner_url => 'https://si0.twimg.com/profile_banners/7_505_382/1348266581')
|
142
|
-
expect(user.profile_banner_uri(:mobile_retina).to_s).to eq('http://si0.twimg.com/profile_banners/7_505_382/1348266581/mobile_retina')
|
143
|
-
end
|
144
|
-
end
|
145
|
-
context 'with :ipad passed' do
|
146
|
-
it 'returns the mobile-sized image' do
|
147
|
-
user = Twitter::User.new(:id => 7_505_382, :profile_banner_url => 'https://si0.twimg.com/profile_banners/7_505_382/1348266581')
|
148
|
-
expect(user.profile_banner_uri(:ipad).to_s).to eq('http://si0.twimg.com/profile_banners/7_505_382/1348266581/ipad')
|
149
|
-
end
|
150
|
-
end
|
151
|
-
context 'with :ipad_retina passed' do
|
152
|
-
it 'returns the mobile retina-sized image' do
|
153
|
-
user = Twitter::User.new(:id => 7_505_382, :profile_banner_url => 'https://si0.twimg.com/profile_banners/7_505_382/1348266581')
|
154
|
-
expect(user.profile_banner_uri(:ipad_retina).to_s).to eq('http://si0.twimg.com/profile_banners/7_505_382/1348266581/ipad_retina')
|
155
|
-
end
|
156
|
-
end
|
157
|
-
end
|
158
|
-
|
159
|
-
describe '#profile_banner_uri_https' do
|
160
|
-
it 'accepts utf8 urls' do
|
161
|
-
user = Twitter::User.new(:id => 7_505_382, :profile_banner_url => 'https://si0.twimg.com/profile_banners/7_505_382/1348266581©_normal.png')
|
162
|
-
expect(user.profile_banner_uri_https).to be_an Addressable::URI
|
163
|
-
end
|
164
|
-
it 'returns a URI when profile_banner_url is set' do
|
165
|
-
user = Twitter::User.new(:id => 7_505_382, :profile_banner_url => 'https://si0.twimg.com/profile_banners/7_505_382/1348266581')
|
166
|
-
expect(user.profile_banner_uri_https).to be_an Addressable::URI
|
167
|
-
end
|
168
|
-
it 'returns nil when created_at is not set' do
|
169
|
-
user = Twitter::User.new(:id => 7_505_382)
|
170
|
-
expect(user.profile_banner_uri_https).to be_nil
|
171
|
-
end
|
172
|
-
it 'returns the web-sized image' do
|
173
|
-
user = Twitter::User.new(:id => 7_505_382, :profile_banner_url => 'https://si0.twimg.com/profile_banners/7_505_382/1348266581')
|
174
|
-
expect(user.profile_banner_uri_https.to_s).to eq('https://si0.twimg.com/profile_banners/7_505_382/1348266581/web')
|
175
|
-
end
|
176
|
-
context 'with :web_retina passed' do
|
177
|
-
it 'returns the web retina-sized image' do
|
178
|
-
user = Twitter::User.new(:id => 7_505_382, :profile_banner_url => 'https://si0.twimg.com/profile_banners/7_505_382/1348266581')
|
179
|
-
expect(user.profile_banner_uri_https(:web_retina).to_s).to eq('https://si0.twimg.com/profile_banners/7_505_382/1348266581/web_retina')
|
180
|
-
end
|
181
|
-
end
|
182
|
-
context 'with :mobile passed' do
|
183
|
-
it 'returns the mobile-sized image' do
|
184
|
-
user = Twitter::User.new(:id => 7_505_382, :profile_banner_url => 'https://si0.twimg.com/profile_banners/7_505_382/1348266581')
|
185
|
-
expect(user.profile_banner_uri_https(:mobile).to_s).to eq('https://si0.twimg.com/profile_banners/7_505_382/1348266581/mobile')
|
186
|
-
end
|
187
|
-
end
|
188
|
-
context 'with :mobile_retina passed' do
|
189
|
-
it 'returns the mobile retina-sized image' do
|
190
|
-
user = Twitter::User.new(:id => 7_505_382, :profile_banner_url => 'https://si0.twimg.com/profile_banners/7_505_382/1348266581')
|
191
|
-
expect(user.profile_banner_uri_https(:mobile_retina).to_s).to eq('https://si0.twimg.com/profile_banners/7_505_382/1348266581/mobile_retina')
|
192
|
-
end
|
193
|
-
end
|
194
|
-
context 'with :ipad passed' do
|
195
|
-
it 'returns the mobile-sized image' do
|
196
|
-
user = Twitter::User.new(:id => 7_505_382, :profile_banner_url => 'https://si0.twimg.com/profile_banners/7_505_382/1348266581')
|
197
|
-
expect(user.profile_banner_uri_https(:ipad).to_s).to eq('https://si0.twimg.com/profile_banners/7_505_382/1348266581/ipad')
|
198
|
-
end
|
199
|
-
end
|
200
|
-
context 'with :ipad_retina passed' do
|
201
|
-
it 'returns the mobile retina-sized image' do
|
202
|
-
user = Twitter::User.new(:id => 7_505_382, :profile_banner_url => 'https://si0.twimg.com/profile_banners/7_505_382/1348266581')
|
203
|
-
expect(user.profile_banner_uri_https(:ipad_retina).to_s).to eq('https://si0.twimg.com/profile_banners/7_505_382/1348266581/ipad_retina')
|
204
|
-
end
|
205
|
-
end
|
206
|
-
end
|
207
|
-
|
208
|
-
describe '#profile_banner_uri?' do
|
209
|
-
it 'returns true when profile_banner_url is set' do
|
210
|
-
user = Twitter::User.new(:id => 7_505_382, :profile_banner_url => 'https://si0.twimg.com/profile_banners/7_505_382/1348266581')
|
211
|
-
expect(user.profile_banner_uri?).to be true
|
212
|
-
end
|
213
|
-
it 'returns false when profile_banner_url is not set' do
|
214
|
-
user = Twitter::User.new(:id => 7_505_382)
|
215
|
-
expect(user.profile_banner_uri?).to be false
|
216
|
-
end
|
217
|
-
end
|
218
|
-
|
219
|
-
describe '#profile_image_uri' do
|
220
|
-
it 'accepts utf8 urls' do
|
221
|
-
user = Twitter::User.new(:id => 7_505_382, :profile_image_url_https => 'https://si0.twimg.com/profile_images/7_505_382/1348266581©_normal.png')
|
222
|
-
expect(user.profile_image_uri).to be_an Addressable::URI
|
223
|
-
end
|
224
|
-
it 'returns a URI when profile_image_url_https is set' do
|
225
|
-
user = Twitter::User.new(:id => 7_505_382, :profile_image_url_https => 'https://a0.twimg.com/profile_images/1759857427/image1326743606_normal.png')
|
226
|
-
expect(user.profile_image_uri).to be_an Addressable::URI
|
227
|
-
end
|
228
|
-
it 'returns nil when created_at is not set' do
|
229
|
-
user = Twitter::User.new(:id => 7_505_382)
|
230
|
-
expect(user.profile_image_uri).to be_nil
|
231
|
-
end
|
232
|
-
it 'returns the normal-sized image' do
|
233
|
-
user = Twitter::User.new(:id => 7_505_382, :profile_image_url_https => 'https://a0.twimg.com/profile_images/1759857427/image1326743606_normal.png')
|
234
|
-
expect(user.profile_image_uri.to_s).to eq('http://a0.twimg.com/profile_images/1759857427/image1326743606_normal.png')
|
235
|
-
end
|
236
|
-
context 'with :original passed' do
|
237
|
-
it 'returns the original image' do
|
238
|
-
user = Twitter::User.new(:id => 7_505_382, :profile_image_url_https => 'https://a0.twimg.com/profile_images/1759857427/image1326743606_normal.png')
|
239
|
-
expect(user.profile_image_uri(:original).to_s).to eq('http://a0.twimg.com/profile_images/1759857427/image1326743606.png')
|
240
|
-
end
|
241
|
-
end
|
242
|
-
context 'with :bigger passed' do
|
243
|
-
it 'returns the bigger-sized image' do
|
244
|
-
user = Twitter::User.new(:id => 7_505_382, :profile_image_url_https => 'https://a0.twimg.com/profile_images/1759857427/image1326743606_normal.png')
|
245
|
-
expect(user.profile_image_uri(:bigger).to_s).to eq('http://a0.twimg.com/profile_images/1759857427/image1326743606_bigger.png')
|
246
|
-
end
|
247
|
-
end
|
248
|
-
context 'with :mini passed' do
|
249
|
-
it 'returns the mini-sized image' do
|
250
|
-
user = Twitter::User.new(:id => 7_505_382, :profile_image_url_https => 'https://a0.twimg.com/profile_images/1759857427/image1326743606_normal.png')
|
251
|
-
expect(user.profile_image_uri(:mini).to_s).to eq('http://a0.twimg.com/profile_images/1759857427/image1326743606_mini.png')
|
252
|
-
end
|
253
|
-
end
|
254
|
-
context 'with capitalized file extension' do
|
255
|
-
it 'returns the correct image' do
|
256
|
-
user = Twitter::User.new(:id => 7_505_382, :profile_image_url_https => 'https://si0.twimg.com/profile_images/67759670/DSCN2136_normal.JPG')
|
257
|
-
expect(user.profile_image_uri(:original).to_s).to eq('http://si0.twimg.com/profile_images/67759670/DSCN2136.JPG')
|
258
|
-
expect(user.profile_image_uri(:bigger).to_s).to eq('http://si0.twimg.com/profile_images/67759670/DSCN2136_bigger.JPG')
|
259
|
-
expect(user.profile_image_uri(:mini).to_s).to eq('http://si0.twimg.com/profile_images/67759670/DSCN2136_mini.JPG')
|
260
|
-
end
|
261
|
-
end
|
262
|
-
end
|
263
|
-
|
264
|
-
describe '#profile_image_uri_https' do
|
265
|
-
it 'accepts utf8 urls' do
|
266
|
-
user = Twitter::User.new(:id => 7_505_382, :profile_image_url_https => 'https://si0.twimg.com/profile_images/7_505_382/1348266581©_normal.png')
|
267
|
-
expect(user.profile_image_uri_https).to be_an Addressable::URI
|
268
|
-
end
|
269
|
-
it 'returns a URI when profile_image_url_https is set' do
|
270
|
-
user = Twitter::User.new(:id => 7_505_382, :profile_image_url_https => 'https://a0.twimg.com/profile_images/1759857427/image1326743606_normal.png')
|
271
|
-
expect(user.profile_image_uri_https).to be_an Addressable::URI
|
272
|
-
end
|
273
|
-
it 'returns nil when created_at is not set' do
|
274
|
-
user = Twitter::User.new(:id => 7_505_382)
|
275
|
-
expect(user.profile_image_uri_https).to be_nil
|
276
|
-
end
|
277
|
-
it 'returns the normal-sized image' do
|
278
|
-
user = Twitter::User.new(:id => 7_505_382, :profile_image_url_https => 'https://a0.twimg.com/profile_images/1759857427/image1326743606_normal.png')
|
279
|
-
expect(user.profile_image_uri_https.to_s).to eq('https://a0.twimg.com/profile_images/1759857427/image1326743606_normal.png')
|
280
|
-
end
|
281
|
-
context 'with :original passed' do
|
282
|
-
it 'returns the original image' do
|
283
|
-
user = Twitter::User.new(:id => 7_505_382, :profile_image_url_https => 'https://a0.twimg.com/profile_images/1759857427/image1326743606_normal.png')
|
284
|
-
expect(user.profile_image_uri_https(:original).to_s).to eq('https://a0.twimg.com/profile_images/1759857427/image1326743606.png')
|
285
|
-
end
|
286
|
-
end
|
287
|
-
context 'with :bigger passed' do
|
288
|
-
it 'returns the bigger-sized image' do
|
289
|
-
user = Twitter::User.new(:id => 7_505_382, :profile_image_url_https => 'https://a0.twimg.com/profile_images/1759857427/image1326743606_normal.png')
|
290
|
-
expect(user.profile_image_uri_https(:bigger).to_s).to eq('https://a0.twimg.com/profile_images/1759857427/image1326743606_bigger.png')
|
291
|
-
end
|
292
|
-
end
|
293
|
-
context 'with :mini passed' do
|
294
|
-
it 'returns the mini-sized image' do
|
295
|
-
user = Twitter::User.new(:id => 7_505_382, :profile_image_url_https => 'https://a0.twimg.com/profile_images/1759857427/image1326743606_normal.png')
|
296
|
-
expect(user.profile_image_uri_https(:mini).to_s).to eq('https://a0.twimg.com/profile_images/1759857427/image1326743606_mini.png')
|
297
|
-
end
|
298
|
-
end
|
299
|
-
context 'with capitalized file extension' do
|
300
|
-
it 'returns the correct image' do
|
301
|
-
user = Twitter::User.new(:id => 7_505_382, :profile_image_url_https => 'https://si0.twimg.com/profile_images/67759670/DSCN2136_normal.JPG')
|
302
|
-
expect(user.profile_image_uri_https(:original).to_s).to eq('https://si0.twimg.com/profile_images/67759670/DSCN2136.JPG')
|
303
|
-
expect(user.profile_image_uri_https(:bigger).to_s).to eq('https://si0.twimg.com/profile_images/67759670/DSCN2136_bigger.JPG')
|
304
|
-
expect(user.profile_image_uri_https(:mini).to_s).to eq('https://si0.twimg.com/profile_images/67759670/DSCN2136_mini.JPG')
|
305
|
-
end
|
306
|
-
end
|
307
|
-
end
|
308
|
-
|
309
|
-
describe '#profile_image_uri?' do
|
310
|
-
it 'returns true when profile_image_url_https is set' do
|
311
|
-
user = Twitter::User.new(:id => 7_505_382, :profile_image_url_https => 'https://si0.twimg.com/profile_banners/7_505_382/1348266581')
|
312
|
-
expect(user.profile_image_uri?).to be true
|
313
|
-
end
|
314
|
-
it 'returns false when profile_image_url_https is not set' do
|
315
|
-
user = Twitter::User.new(:id => 7_505_382)
|
316
|
-
expect(user.profile_image_uri?).to be false
|
317
|
-
end
|
318
|
-
end
|
319
|
-
|
320
|
-
describe '#status' do
|
321
|
-
it 'returns a Status when status is set' do
|
322
|
-
user = Twitter::User.new(:id => 7_505_382, :status => {:id => 25_938_088_801})
|
323
|
-
expect(user.status).to be_a Twitter::Tweet
|
324
|
-
end
|
325
|
-
it 'returns nil when status is not set' do
|
326
|
-
user = Twitter::User.new(:id => 7_505_382)
|
327
|
-
expect(user.status).to be_nil
|
328
|
-
end
|
329
|
-
it 'has a user' do
|
330
|
-
user = Twitter::User.new(:id => 7_505_382, :status => {:id => 25_938_088_801})
|
331
|
-
expect(user.status.user).to be_a Twitter::User
|
332
|
-
expect(user.status.user.id).to eq(7_505_382)
|
333
|
-
end
|
334
|
-
end
|
335
|
-
|
336
|
-
describe '#status?' do
|
337
|
-
it 'returns true when status is set' do
|
338
|
-
user = Twitter::User.new(:id => 7_505_382, :status => {:id => 25_938_088_801})
|
339
|
-
expect(user.status?).to be true
|
340
|
-
end
|
341
|
-
it 'returns false when status is not set' do
|
342
|
-
user = Twitter::User.new(:id => 7_505_382)
|
343
|
-
expect(user.status?).to be false
|
344
|
-
end
|
345
|
-
end
|
346
|
-
|
347
|
-
describe '#uri' do
|
348
|
-
it 'returns the URI to the user' do
|
349
|
-
user = Twitter::User.new(:id => 7_505_382, :screen_name => 'sferik')
|
350
|
-
expect(user.uri).to be_an Addressable::URI
|
351
|
-
expect(user.uri.to_s).to eq('https://twitter.com/sferik')
|
352
|
-
end
|
353
|
-
it 'returns nil when the screen name is not set' do
|
354
|
-
user = Twitter::User.new(:id => 7_505_382)
|
355
|
-
expect(user.uri).to be_nil
|
356
|
-
end
|
357
|
-
end
|
358
|
-
|
359
|
-
describe '#website' do
|
360
|
-
it 'returns a URI when the url is set' do
|
361
|
-
user = Twitter::User.new(:id => 7_505_382, :url => 'https://github.com/sferik')
|
362
|
-
expect(user.website).to be_an Addressable::URI
|
363
|
-
expect(user.website.to_s).to eq('https://github.com/sferik')
|
364
|
-
end
|
365
|
-
it 'returns a URI when the tweet includes website URI entities' do
|
366
|
-
urls_array = [
|
367
|
-
{
|
368
|
-
:url => 'https://t.co/L2xIBazMPf',
|
369
|
-
:expanded_url => 'http://example.com/expanded',
|
370
|
-
:display_url => 'example.com/expanded…',
|
371
|
-
:indices => [0, 23],
|
372
|
-
}
|
373
|
-
]
|
374
|
-
user = Twitter::User.new(:id => 7_505_382, :entities => {:url => {:urls => urls_array}})
|
375
|
-
expect(user.website).to be_an Addressable::URI
|
376
|
-
expect(user.website.to_s).to eq('http://example.com/expanded')
|
377
|
-
end
|
378
|
-
it 'returns nil when the url is not set' do
|
379
|
-
user = Twitter::User.new(:id => 7_505_382)
|
380
|
-
expect(user.website).to be_nil
|
381
|
-
end
|
382
|
-
end
|
383
|
-
|
384
|
-
describe '#website?' do
|
385
|
-
it 'returns true when the url is set' do
|
386
|
-
user = Twitter::User.new(:id => 7_505_382, :url => 'https://github.com/sferik')
|
387
|
-
expect(user.website?).to be true
|
388
|
-
end
|
389
|
-
it 'returns true when the tweet includes website URI entities' do
|
390
|
-
urls_array = [
|
391
|
-
{
|
392
|
-
:url => 'https://t.co/L2xIBazMPf',
|
393
|
-
:expanded_url => 'http://example.com/expanded',
|
394
|
-
:display_url => 'example.com/expanded…',
|
395
|
-
:indices => [0, 23],
|
396
|
-
}
|
397
|
-
]
|
398
|
-
user = Twitter::User.new(:id => 7_505_382, :entities => {:url => {:urls => urls_array}})
|
399
|
-
expect(user.website?).to be true
|
400
|
-
end
|
401
|
-
it 'returns false when the url is not set' do
|
402
|
-
user = Twitter::User.new(:id => 7_505_382)
|
403
|
-
expect(user.website?).to be false
|
404
|
-
end
|
405
|
-
end
|
406
|
-
|
407
|
-
describe '#website_uris' do
|
408
|
-
it 'returns an array of Entity::URIs when website URI entities are set' do
|
409
|
-
urls_array = [
|
410
|
-
{
|
411
|
-
:url => 'https://t.co/L2xIBazMPf',
|
412
|
-
:expanded_url => 'http://example.com/expanded',
|
413
|
-
:display_url => 'example.com/expanded…',
|
414
|
-
:indices => [0, 23],
|
415
|
-
}
|
416
|
-
]
|
417
|
-
user = Twitter::User.new(:id => 7_505_382, :entities => {:url => {:urls => urls_array}})
|
418
|
-
expect(user.website_uris).to be_an Array
|
419
|
-
expect(user.website_uris.first).to be_a Twitter::Entity::URI
|
420
|
-
expect(user.website_uris.first.indices).to eq([0, 23])
|
421
|
-
expect(user.website_uris.first.expanded_uri).to be_an Addressable::URI
|
422
|
-
end
|
423
|
-
it 'is empty when not set' do
|
424
|
-
user = Twitter::User.new(:id => 7_505_382, :entities => {:url => {:urls => []}})
|
425
|
-
expect(user.website_uris).to be_empty
|
426
|
-
end
|
427
|
-
end
|
428
|
-
|
429
|
-
describe '#website_uris?' do
|
430
|
-
it 'returns true when the tweet includes website URI entities' do
|
431
|
-
urls_array = [
|
432
|
-
{
|
433
|
-
:url => 'https://t.co/L2xIBazMPf',
|
434
|
-
:expanded_url => 'http://example.com/expanded',
|
435
|
-
:display_url => 'example.com/expanded…',
|
436
|
-
:indices => [0, 23],
|
437
|
-
}
|
438
|
-
]
|
439
|
-
user = Twitter::User.new(:id => 7_505_382, :entities => {:url => {:urls => urls_array}})
|
440
|
-
expect(user.website_uris?).to be true
|
441
|
-
end
|
442
|
-
it 'returns false when no entities are present' do
|
443
|
-
user = Twitter::User.new(:id => 7_505_382, :entities => {})
|
444
|
-
expect(user.website_uris?).to be false
|
445
|
-
end
|
446
|
-
end
|
447
|
-
end
|
data/spec/twitter/utils_spec.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
require 'benchmark'
|
2
|
-
require 'helper'
|
3
|
-
|
4
|
-
describe Twitter::Utils do
|
5
|
-
describe '#pmap' do
|
6
|
-
it 'maps in parallel' do
|
7
|
-
delay = 0.1
|
8
|
-
array = (0..9).to_a
|
9
|
-
size = array.size
|
10
|
-
block = proc { |x| sleep(delay) && x + 1 }
|
11
|
-
block_without_sleep = proc { |x| x + 1 }
|
12
|
-
expected = array.collect(&block_without_sleep)
|
13
|
-
elapsed_time = Benchmark.realtime do
|
14
|
-
expect(subject.pmap(array, &block)).to eq(expected)
|
15
|
-
end
|
16
|
-
expect(elapsed_time).to be_between(delay, delay * size)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
describe '#flat_pmap' do
|
21
|
-
it 'flat maps in parallel' do
|
22
|
-
delay = 0.1
|
23
|
-
array = (0..4).to_a.combination(2).to_a
|
24
|
-
size = array.size
|
25
|
-
block = proc { |x| sleep(delay) && x.reverse }
|
26
|
-
block_without_sleep = proc { |x| x.reverse }
|
27
|
-
expected = array.collect(&block_without_sleep).flatten!(1)
|
28
|
-
elapsed_time = Benchmark.realtime do
|
29
|
-
expect(subject.flat_pmap(array, &block)).to eq(expected)
|
30
|
-
end
|
31
|
-
expect(elapsed_time).to be_between(delay, delay * size)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|