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
@@ -1,21 +0,0 @@
|
|
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
|
@@ -1,40 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
describe Twitter::Suggestion do
|
4
|
-
|
5
|
-
describe '#==' do
|
6
|
-
it 'returns true for empty objects' do
|
7
|
-
suggestion = Twitter::Suggestion.new
|
8
|
-
other = Twitter::Suggestion.new
|
9
|
-
expect(suggestion == other).to be true
|
10
|
-
end
|
11
|
-
it 'returns true when objects slugs are the same' do
|
12
|
-
suggestion = Twitter::Suggestion.new(:slug => 1, :name => 'foo')
|
13
|
-
other = Twitter::Suggestion.new(:slug => 1, :name => 'bar')
|
14
|
-
expect(suggestion == other).to be true
|
15
|
-
end
|
16
|
-
it 'returns false when objects slugs are different' do
|
17
|
-
suggestion = Twitter::Suggestion.new(:slug => 1)
|
18
|
-
other = Twitter::Suggestion.new(:slug => 2)
|
19
|
-
expect(suggestion == other).to be false
|
20
|
-
end
|
21
|
-
it 'returns false when classes are different' do
|
22
|
-
suggestion = Twitter::Suggestion.new(:slug => 1)
|
23
|
-
other = Twitter::Base.new(:slug => 1)
|
24
|
-
expect(suggestion == other).to be false
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
describe '#users' do
|
29
|
-
it 'returns a User when user is set' do
|
30
|
-
users = Twitter::Suggestion.new(:users => [{:id => 7_505_382}]).users
|
31
|
-
expect(users).to be_an Array
|
32
|
-
expect(users.first).to be_a Twitter::User
|
33
|
-
end
|
34
|
-
it 'is empty when not set' do
|
35
|
-
users = Twitter::Suggestion.new.users
|
36
|
-
expect(users).to be_empty
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
describe Twitter::TargetUser do
|
4
|
-
|
5
|
-
describe '#==' do
|
6
|
-
it 'returns true when objects IDs are the same' do
|
7
|
-
saved_search = Twitter::TargetUser.new(:id => 1, :name => 'foo')
|
8
|
-
other = Twitter::TargetUser.new(:id => 1, :name => 'bar')
|
9
|
-
expect(saved_search == other).to be true
|
10
|
-
end
|
11
|
-
it 'returns false when objects IDs are different' do
|
12
|
-
saved_search = Twitter::TargetUser.new(:id => 1)
|
13
|
-
other = Twitter::TargetUser.new(:id => 2)
|
14
|
-
expect(saved_search == other).to be false
|
15
|
-
end
|
16
|
-
it 'returns false when classes are different' do
|
17
|
-
saved_search = Twitter::TargetUser.new(:id => 1)
|
18
|
-
other = Twitter::Identity.new(:id => 1)
|
19
|
-
expect(saved_search == other).to be false
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|
data/spec/twitter/token_spec.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
describe Twitter::Token do
|
4
|
-
|
5
|
-
describe '#bearer?' do
|
6
|
-
it 'returns true when token is a bearer token' do
|
7
|
-
token = Twitter::Token.new(:token_type => 'bearer')
|
8
|
-
expect(token.bearer?).to be true
|
9
|
-
end
|
10
|
-
it 'returns false when token type is nil' do
|
11
|
-
token = Twitter::Token.new
|
12
|
-
expect(token.bearer?).to be false
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
end
|
@@ -1,89 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
describe Twitter::TrendResults do
|
4
|
-
|
5
|
-
describe '#as_of' do
|
6
|
-
it 'returns a Time when as_of is set' do
|
7
|
-
trend_results = Twitter::TrendResults.new(:id => 1, :as_of => '2012-08-24T23:25:43Z')
|
8
|
-
expect(trend_results.as_of).to be_a Time
|
9
|
-
end
|
10
|
-
it 'returns nil when as_of is not set' do
|
11
|
-
trend_results = Twitter::TrendResults.new(:id => 1)
|
12
|
-
expect(trend_results.as_of).to be_nil
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
describe '#as_of?' do
|
17
|
-
it 'returns true when as_of is set' do
|
18
|
-
trend_results = Twitter::TrendResults.new(:id => 1, :as_of => '2012-08-24T23:24:14Z')
|
19
|
-
expect(trend_results.as_of?).to be true
|
20
|
-
end
|
21
|
-
it 'returns false when as_of is not set' do
|
22
|
-
trend_results = Twitter::TrendResults.new(:id => 1)
|
23
|
-
expect(trend_results.as_of?).to be false
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
describe '#created_at' do
|
28
|
-
it 'returns a Time when created_at is set' do
|
29
|
-
trend_results = Twitter::TrendResults.new(:id => 1, :created_at => '2012-08-24T23:24:14Z')
|
30
|
-
expect(trend_results.created_at).to be_a Time
|
31
|
-
end
|
32
|
-
it 'returns nil when created_at is not set' do
|
33
|
-
trend_results = Twitter::TrendResults.new(:id => 1)
|
34
|
-
expect(trend_results.created_at).to be_nil
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
describe '#created?' do
|
39
|
-
it 'returns true when created_at is set' do
|
40
|
-
trend_results = Twitter::TrendResults.new(:id => 1, :created_at => '2012-08-24T23:24:14Z')
|
41
|
-
expect(trend_results.created?).to be true
|
42
|
-
end
|
43
|
-
it 'returns false when created_at is not set' do
|
44
|
-
trend_results = Twitter::TrendResults.new(:id => 1)
|
45
|
-
expect(trend_results.created?).to be false
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
describe '#each' do
|
50
|
-
before do
|
51
|
-
@trend_results = Twitter::TrendResults.new(:trends => [{:id => 1}, {:id => 2}, {:id => 3}, {:id => 4}, {:id => 5}, {:id => 6}])
|
52
|
-
end
|
53
|
-
it 'iterates' do
|
54
|
-
count = 0
|
55
|
-
@trend_results.each { count += 1 }
|
56
|
-
expect(count).to eq(6)
|
57
|
-
end
|
58
|
-
context 'with start' do
|
59
|
-
it 'iterates' do
|
60
|
-
count = 0
|
61
|
-
@trend_results.each(5) { count += 1 }
|
62
|
-
expect(count).to eq(1)
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
describe '#location' do
|
68
|
-
it 'returns a Twitter::Place when location is set' do
|
69
|
-
trend_results = Twitter::TrendResults.new(:id => 1, :locations => [{:name => 'Worldwide', :woeid => 1}])
|
70
|
-
expect(trend_results.location).to be_a Twitter::Place
|
71
|
-
end
|
72
|
-
it 'returns nil when location is not set' do
|
73
|
-
trend_results = Twitter::TrendResults.new(:id => 1)
|
74
|
-
expect(trend_results.location).to be_nil
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
describe '#location?' do
|
79
|
-
it 'returns true when location is set' do
|
80
|
-
trend_results = Twitter::TrendResults.new(:id => 1, :locations => [{:name => 'Worldwide', :woeid => 1}])
|
81
|
-
expect(trend_results.location?).to be true
|
82
|
-
end
|
83
|
-
it 'returns false when location is not set' do
|
84
|
-
trend_results = Twitter::TrendResults.new(:id => 1)
|
85
|
-
expect(trend_results.location?).to be false
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
end
|
data/spec/twitter/trend_spec.rb
DELETED
@@ -1,51 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
describe Twitter::Trend do
|
4
|
-
|
5
|
-
describe '#==' do
|
6
|
-
it 'returns true for empty objects' do
|
7
|
-
trend = Twitter::Trend.new
|
8
|
-
other = Twitter::Trend.new
|
9
|
-
expect(trend == other).to be true
|
10
|
-
end
|
11
|
-
it 'returns true when objects names are the same' do
|
12
|
-
trend = Twitter::Trend.new(:name => '#sevenwordsaftersex', :query => 'foo')
|
13
|
-
other = Twitter::Trend.new(:name => '#sevenwordsaftersex', :query => 'bar')
|
14
|
-
expect(trend == other).to be true
|
15
|
-
end
|
16
|
-
it 'returns false when objects names are different' do
|
17
|
-
trend = Twitter::Trend.new(:name => '#sevenwordsaftersex')
|
18
|
-
other = Twitter::Trend.new(:name => '#sixwordsaftersex')
|
19
|
-
expect(trend == other).to be false
|
20
|
-
end
|
21
|
-
it 'returns false when classes are different' do
|
22
|
-
trend = Twitter::Trend.new(:name => '#sevenwordsaftersex')
|
23
|
-
other = Twitter::Base.new(:name => '#sevenwordsaftersex')
|
24
|
-
expect(trend == other).to be false
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
describe '#uri' do
|
29
|
-
it 'returns a URI when the url is set' do
|
30
|
-
trend = Twitter::Trend.new(:url => 'http://twitter.com/search/?q=%23sevenwordsaftersex')
|
31
|
-
expect(trend.uri).to be_an Addressable::URI
|
32
|
-
expect(trend.uri.to_s).to eq('http://twitter.com/search/?q=%23sevenwordsaftersex')
|
33
|
-
end
|
34
|
-
it 'returns nil when the url is not set' do
|
35
|
-
trend = Twitter::Trend.new
|
36
|
-
expect(trend.uri).to be_nil
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
describe '#uri?' do
|
41
|
-
it 'returns true when the url is set' do
|
42
|
-
trend = Twitter::Trend.new(:url => 'https://api.twitter.com/1.1/geo/id/247f43d441defc03.json')
|
43
|
-
expect(trend.uri?).to be true
|
44
|
-
end
|
45
|
-
it 'returns false when the url is not set' do
|
46
|
-
trend = Twitter::Trend.new
|
47
|
-
expect(trend.uri?).to be false
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
end
|
data/spec/twitter/tweet_spec.rb
DELETED
@@ -1,456 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
require 'helper'
|
3
|
-
|
4
|
-
describe Twitter::Tweet do
|
5
|
-
|
6
|
-
before do
|
7
|
-
@old_stderr = $stderr
|
8
|
-
$stderr = StringIO.new
|
9
|
-
end
|
10
|
-
|
11
|
-
after do
|
12
|
-
$stderr = @old_stderr
|
13
|
-
end
|
14
|
-
|
15
|
-
describe '#==' do
|
16
|
-
it 'returns true when objects IDs are the same' do
|
17
|
-
tweet = Twitter::Tweet.new(:id => 1, :text => 'foo')
|
18
|
-
other = Twitter::Tweet.new(:id => 1, :text => 'bar')
|
19
|
-
expect(tweet == other).to be true
|
20
|
-
end
|
21
|
-
it 'returns false when objects IDs are different' do
|
22
|
-
tweet = Twitter::Tweet.new(:id => 1)
|
23
|
-
other = Twitter::Tweet.new(:id => 2)
|
24
|
-
expect(tweet == other).to be false
|
25
|
-
end
|
26
|
-
it 'returns false when classes are different' do
|
27
|
-
tweet = Twitter::Tweet.new(:id => 1)
|
28
|
-
other = Twitter::Identity.new(:id => 1)
|
29
|
-
expect(tweet == other).to be false
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
describe '#created_at' do
|
34
|
-
it 'returns a Time when set' do
|
35
|
-
tweet = Twitter::Tweet.new(:id => 28_669_546_014, :created_at => 'Mon Jul 16 12:59:01 +0000 2007')
|
36
|
-
expect(tweet.created_at).to be_a Time
|
37
|
-
end
|
38
|
-
it 'returns nil when not set' do
|
39
|
-
tweet = Twitter::Tweet.new(:id => 28_669_546_014)
|
40
|
-
expect(tweet.created_at).to be_nil
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
describe '#created?' do
|
45
|
-
it 'returns true when created_at is set' do
|
46
|
-
tweet = Twitter::Tweet.new(:id => 28_669_546_014, :created_at => 'Mon Jul 16 12:59:01 +0000 2007')
|
47
|
-
expect(tweet.created?).to be true
|
48
|
-
end
|
49
|
-
it 'returns false when created_at is not set' do
|
50
|
-
tweet = Twitter::Tweet.new(:id => 28_669_546_014)
|
51
|
-
expect(tweet.created?).to be false
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
describe '#entities?' do
|
56
|
-
it 'returns true if there are entities set' do
|
57
|
-
urls_array = [
|
58
|
-
{
|
59
|
-
:url => 'https://t.co/L2xIBazMPf',
|
60
|
-
:expanded_url => 'http://example.com/expanded',
|
61
|
-
:display_url => 'example.com/expanded…',
|
62
|
-
:indices => [10, 33],
|
63
|
-
}
|
64
|
-
]
|
65
|
-
tweet = Twitter::Tweet.new(:id => 28_669_546_014, :entities => {:urls => urls_array})
|
66
|
-
expect(tweet.entities?).to be true
|
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
|
76
|
-
end
|
77
|
-
|
78
|
-
describe '#filter_level' do
|
79
|
-
it 'returns the filter level when filter_level is set' do
|
80
|
-
tweet = Twitter::Tweet.new(:id => 28_669_546_014, :filter_level => 'high')
|
81
|
-
expect(tweet.filter_level).to be_a String
|
82
|
-
expect(tweet.filter_level).to eq('high')
|
83
|
-
end
|
84
|
-
it 'returns nil when not set' do
|
85
|
-
tweet = Twitter::Tweet.new(:id => 28_669_546_014)
|
86
|
-
expect(tweet.filter_level).to be_nil
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
describe '#full_text' do
|
91
|
-
it 'returns the text of a Tweet' do
|
92
|
-
tweet = Twitter::Tweet.new(:id => 28_669_546_014, :text => 'BOOSH')
|
93
|
-
expect(tweet.full_text).to be_a String
|
94
|
-
expect(tweet.full_text).to eq('BOOSH')
|
95
|
-
end
|
96
|
-
it 'returns the text of a Tweet without a user' do
|
97
|
-
tweet = Twitter::Tweet.new(:id => 28_669_546_014, :text => 'BOOSH', :retweeted_status => {:id => 28_561_922_517, :text => 'BOOSH'})
|
98
|
-
expect(tweet.full_text).to be_a String
|
99
|
-
expect(tweet.full_text).to eq('BOOSH')
|
100
|
-
end
|
101
|
-
it 'returns the full text of a retweeted Tweet' do
|
102
|
-
tweet = Twitter::Tweet.new(:id => 28_669_546_014, :text => 'RT @sferik: BOOSH', :retweeted_status => {:id => 25_938_088_801, :text => 'BOOSH'})
|
103
|
-
expect(tweet.full_text).to be_a String
|
104
|
-
expect(tweet.full_text).to eq('RT @sferik: BOOSH')
|
105
|
-
end
|
106
|
-
it 'returns nil when retweeted_status is not set' do
|
107
|
-
tweet = Twitter::Tweet.new(:id => 28_669_546_014)
|
108
|
-
expect(tweet.full_text).to be_nil
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
describe '#geo' do
|
113
|
-
it 'returns a Twitter::Geo::Point when geo is set' do
|
114
|
-
tweet = Twitter::Tweet.new(:id => 28_669_546_014, :geo => {:id => 1, :type => 'Point'})
|
115
|
-
expect(tweet.geo).to be_a Twitter::Geo::Point
|
116
|
-
end
|
117
|
-
it 'returns nil when geo is not set' do
|
118
|
-
tweet = Twitter::Tweet.new(:id => 28_669_546_014)
|
119
|
-
expect(tweet.geo).to be_nil
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
|
-
describe '#geo?' do
|
124
|
-
it 'returns true when geo is set' do
|
125
|
-
tweet = Twitter::Tweet.new(:id => 28_669_546_014, :geo => {:id => 1, :type => 'Point'})
|
126
|
-
expect(tweet.geo?).to be true
|
127
|
-
end
|
128
|
-
it 'returns false when geo is not set' do
|
129
|
-
tweet = Twitter::Tweet.new(:id => 28_669_546_014)
|
130
|
-
expect(tweet.geo?).to be false
|
131
|
-
end
|
132
|
-
end
|
133
|
-
|
134
|
-
describe '#hashtags' do
|
135
|
-
context 'when entities are set' do
|
136
|
-
let(:hashtags_array) do
|
137
|
-
[{
|
138
|
-
:text => 'twitter',
|
139
|
-
:indices => [10, 33],
|
140
|
-
}]
|
141
|
-
end
|
142
|
-
let(:subject) do
|
143
|
-
Twitter::Tweet.new(:id => 28_669_546_014, :entities => {:hashtags => hashtags_array})
|
144
|
-
end
|
145
|
-
it 'returns an array of Entity::Hashtag' do
|
146
|
-
hashtags = subject.hashtags
|
147
|
-
expect(hashtags).to be_an Array
|
148
|
-
expect(hashtags.first).to be_a Twitter::Entity::Hashtag
|
149
|
-
expect(hashtags.first.indices).to eq([10, 33])
|
150
|
-
expect(hashtags.first.text).to eq('twitter')
|
151
|
-
end
|
152
|
-
end
|
153
|
-
context 'when entities are set, but empty' do
|
154
|
-
subject { Twitter::Tweet.new(:id => 28_669_546_014, :entities => {:hashtags => []}) }
|
155
|
-
it 'is empty' do
|
156
|
-
expect(subject.hashtags).to be_empty
|
157
|
-
end
|
158
|
-
it 'does not warn' do
|
159
|
-
subject.hashtags
|
160
|
-
expect($stderr.string).to be_empty
|
161
|
-
end
|
162
|
-
end
|
163
|
-
context 'when entities are not set' do
|
164
|
-
subject { Twitter::Tweet.new(:id => 28_669_546_014) }
|
165
|
-
it 'is empty' do
|
166
|
-
expect(subject.hashtags).to be_empty
|
167
|
-
end
|
168
|
-
end
|
169
|
-
end
|
170
|
-
|
171
|
-
describe '#hashtags?' do
|
172
|
-
it 'returns true when the tweet includes hashtags entities' do
|
173
|
-
entities = {
|
174
|
-
:hashtags => [{:text => 'twitter', :indices => [10, 33]}]
|
175
|
-
}
|
176
|
-
tweet = Twitter::Tweet.new(:id => 28_669_546_014, :entities => entities)
|
177
|
-
expect(tweet.hashtags?).to be true
|
178
|
-
end
|
179
|
-
it 'returns false when no entities are present' do
|
180
|
-
tweet = Twitter::Tweet.new(:id => 28_669_546_014)
|
181
|
-
expect(tweet.hashtags?).to be false
|
182
|
-
end
|
183
|
-
end
|
184
|
-
|
185
|
-
describe '#media' do
|
186
|
-
it 'returns media' do
|
187
|
-
media = Twitter::Tweet.new(:id => 28_669_546_014, :entities => {:media => [{:id => 1, :type => 'photo'}]}).media
|
188
|
-
expect(media).to be_an Array
|
189
|
-
expect(media.first).to be_a Twitter::Media::Photo
|
190
|
-
end
|
191
|
-
it 'is empty when not set' do
|
192
|
-
media = Twitter::Tweet.new(:id => 28_669_546_014).media
|
193
|
-
expect(media).to be_empty
|
194
|
-
end
|
195
|
-
end
|
196
|
-
|
197
|
-
describe '#media?' do
|
198
|
-
it 'returns true when the tweet includes media entities' do
|
199
|
-
entities = {
|
200
|
-
:media => [{:id => '1', :type => 'photo'}]
|
201
|
-
}
|
202
|
-
tweet = Twitter::Tweet.new(:id => 28_669_546_014, :entities => entities)
|
203
|
-
expect(tweet.media?).to be true
|
204
|
-
end
|
205
|
-
it 'returns false when no entities are present' do
|
206
|
-
tweet = Twitter::Tweet.new(:id => 28_669_546_014)
|
207
|
-
expect(tweet.media?).to be false
|
208
|
-
end
|
209
|
-
end
|
210
|
-
|
211
|
-
describe '#metadata' do
|
212
|
-
it 'returns a Twitter::Metadata when metadata is set' do
|
213
|
-
tweet = Twitter::Tweet.new(:id => 28_669_546_014, :metadata => {:result_type => 'recent'})
|
214
|
-
expect(tweet.metadata).to be_a Twitter::Metadata
|
215
|
-
end
|
216
|
-
it 'returns nil when metadata is not set' do
|
217
|
-
tweet = Twitter::Tweet.new(:id => 28_669_546_014)
|
218
|
-
expect(tweet.metadata).to be_nil
|
219
|
-
end
|
220
|
-
end
|
221
|
-
|
222
|
-
describe '#metadata?' do
|
223
|
-
it 'returns true when metadata is set' do
|
224
|
-
tweet = Twitter::Tweet.new(:id => 28_669_546_014, :metadata => {:result_type => 'recent'})
|
225
|
-
expect(tweet.metadata?).to be true
|
226
|
-
end
|
227
|
-
it 'returns false when metadata is not set' do
|
228
|
-
tweet = Twitter::Tweet.new(:id => 28_669_546_014)
|
229
|
-
expect(tweet.metadata?).to be false
|
230
|
-
end
|
231
|
-
end
|
232
|
-
|
233
|
-
describe '#place' do
|
234
|
-
it 'returns a Twitter::Place when place is set' do
|
235
|
-
tweet = Twitter::Tweet.new(:id => 28_669_546_014, :place => {:id => '247f43d441defc03'})
|
236
|
-
expect(tweet.place).to be_a Twitter::Place
|
237
|
-
end
|
238
|
-
it 'returns nil when place is not set' do
|
239
|
-
tweet = Twitter::Tweet.new(:id => 28_669_546_014)
|
240
|
-
expect(tweet.place).to be_nil
|
241
|
-
end
|
242
|
-
end
|
243
|
-
|
244
|
-
describe '#place?' do
|
245
|
-
it 'returns true when place is set' do
|
246
|
-
tweet = Twitter::Tweet.new(:id => 28_669_546_014, :place => {:id => '247f43d441defc03'})
|
247
|
-
expect(tweet.place?).to be true
|
248
|
-
end
|
249
|
-
it 'returns false when place is not set' do
|
250
|
-
tweet = Twitter::Tweet.new(:id => 28_669_546_014)
|
251
|
-
expect(tweet.place?).to be false
|
252
|
-
end
|
253
|
-
end
|
254
|
-
|
255
|
-
describe '#reply?' do
|
256
|
-
it 'returns true when there is an in-reply-to user' do
|
257
|
-
tweet = Twitter::Tweet.new(:id => 28_669_546_014, :in_reply_to_user_id => 7_505_382)
|
258
|
-
expect(tweet.reply?).to be true
|
259
|
-
end
|
260
|
-
it 'returns false when in_reply_to_user_id is not set' do
|
261
|
-
tweet = Twitter::Tweet.new(:id => 28_669_546_014)
|
262
|
-
expect(tweet.reply?).to be false
|
263
|
-
end
|
264
|
-
end
|
265
|
-
|
266
|
-
describe '#retweet?' do
|
267
|
-
it 'returns true when there is a retweeted status' do
|
268
|
-
tweet = Twitter::Tweet.new(:id => 28_669_546_014, :retweeted_status => {:id => 25_938_088_801, :text => 'BOOSH'})
|
269
|
-
expect(tweet.retweet?).to be true
|
270
|
-
end
|
271
|
-
it 'returns false when retweeted_status is not set' do
|
272
|
-
tweet = Twitter::Tweet.new(:id => 28_669_546_014)
|
273
|
-
expect(tweet.retweet?).to be false
|
274
|
-
end
|
275
|
-
end
|
276
|
-
|
277
|
-
describe '#retweeted_status' do
|
278
|
-
it 'returns a Tweet when retweeted_status is set' do
|
279
|
-
tweet = Twitter::Tweet.new(:id => 28_669_546_014, :retweeted_status => {:id => 25_938_088_801, :text => 'BOOSH'})
|
280
|
-
expect(tweet.retweeted_tweet).to be_a Twitter::Tweet
|
281
|
-
expect(tweet.retweeted_tweet.text).to eq('BOOSH')
|
282
|
-
end
|
283
|
-
it 'returns nil when retweeted_status is not set' do
|
284
|
-
tweet = Twitter::Tweet.new(:id => 28_669_546_014)
|
285
|
-
expect(tweet.retweeted_tweet).to be_nil
|
286
|
-
end
|
287
|
-
end
|
288
|
-
|
289
|
-
describe '#retweeted_status?' do
|
290
|
-
it 'returns true when retweeted_status is set' do
|
291
|
-
tweet = Twitter::Tweet.new(:id => 28_669_546_014, :retweeted_status => {:id => 25_938_088_801, :text => 'BOOSH'})
|
292
|
-
expect(tweet.retweeted_status?).to be true
|
293
|
-
end
|
294
|
-
it 'returns false when retweeted_status is not set' do
|
295
|
-
tweet = Twitter::Tweet.new(:id => 28_669_546_014)
|
296
|
-
expect(tweet.retweeted_status?).to be false
|
297
|
-
end
|
298
|
-
end
|
299
|
-
|
300
|
-
describe '#symbols' do
|
301
|
-
it 'returns an array of Entity::Symbol when symbols are set' do
|
302
|
-
symbols_array = [
|
303
|
-
{:text => 'PEP', :indices => [114, 118]},
|
304
|
-
{:text => 'COKE', :indices => [128, 133]}
|
305
|
-
]
|
306
|
-
symbols = Twitter::Tweet.new(:id => 28_669_546_014, :entities => {:symbols => symbols_array}).symbols
|
307
|
-
expect(symbols).to be_an Array
|
308
|
-
expect(symbols.size).to eq(2)
|
309
|
-
expect(symbols.first).to be_a Twitter::Entity::Symbol
|
310
|
-
expect(symbols.first.indices).to eq([114, 118])
|
311
|
-
expect(symbols.first.text).to eq('PEP')
|
312
|
-
end
|
313
|
-
it 'is empty when not set' do
|
314
|
-
symbols = Twitter::Tweet.new(:id => 28_669_546_014).symbols
|
315
|
-
expect(symbols).to be_empty
|
316
|
-
end
|
317
|
-
end
|
318
|
-
|
319
|
-
describe '#symbols?' do
|
320
|
-
it 'returns true when the tweet includes symbols entities' do
|
321
|
-
entities = {
|
322
|
-
:symbols => [{:text => 'PEP'}]
|
323
|
-
}
|
324
|
-
tweet = Twitter::Tweet.new(:id => 28_669_546_014, :entities => entities)
|
325
|
-
expect(tweet.symbols?).to be true
|
326
|
-
end
|
327
|
-
it 'returns false when no entities are present' do
|
328
|
-
tweet = Twitter::Tweet.new(:id => 28_669_546_014)
|
329
|
-
expect(tweet.symbols?).to be false
|
330
|
-
end
|
331
|
-
end
|
332
|
-
|
333
|
-
describe '#uris' do
|
334
|
-
it 'returns an array of Entity::URIs when entities are set' do
|
335
|
-
urls_array = [
|
336
|
-
{
|
337
|
-
:url => 'https://t.co/L2xIBazMPf',
|
338
|
-
:expanded_url => 'http://example.com/expanded',
|
339
|
-
:display_url => 'example.com/expanded…',
|
340
|
-
:indices => [10, 33],
|
341
|
-
}
|
342
|
-
]
|
343
|
-
tweet = Twitter::Tweet.new(:id => 28_669_546_014, :entities => {:urls => urls_array})
|
344
|
-
expect(tweet.uris).to be_an Array
|
345
|
-
expect(tweet.uris.first).to be_a Twitter::Entity::URI
|
346
|
-
expect(tweet.uris.first.indices).to eq([10, 33])
|
347
|
-
expect(tweet.uris.first.display_uri).to be_a String
|
348
|
-
expect(tweet.uris.first.display_uri).to eq('example.com/expanded…')
|
349
|
-
end
|
350
|
-
it 'is empty when not set' do
|
351
|
-
tweet = Twitter::Tweet.new(:id => 28_669_546_014)
|
352
|
-
expect(tweet.uris).to be_empty
|
353
|
-
end
|
354
|
-
it 'can handle strange urls' do
|
355
|
-
urls_array = [
|
356
|
-
{
|
357
|
-
:url => 'https://t.co/L2xIBazMPf',
|
358
|
-
:expanded_url => 'http://with_underscore.example.com/expanded',
|
359
|
-
:display_url => 'with_underscore.example.com/expanded…',
|
360
|
-
:indices => [10, 33],
|
361
|
-
}
|
362
|
-
]
|
363
|
-
tweet = Twitter::Tweet.new(:id => 28_669_546_014, :entities => {:urls => urls_array})
|
364
|
-
uri = tweet.uris.first
|
365
|
-
expect { uri.url }.not_to raise_error
|
366
|
-
expect { uri.expanded_url }.not_to raise_error
|
367
|
-
expect { uri.display_url }.not_to raise_error
|
368
|
-
end
|
369
|
-
end
|
370
|
-
|
371
|
-
describe '#uri' do
|
372
|
-
it 'returns the URI to the tweet' do
|
373
|
-
tweet = Twitter::Tweet.new(:id => 28_669_546_014, :user => {:id => 7_505_382, :screen_name => 'sferik'})
|
374
|
-
expect(tweet.uri).to be_an Addressable::URI
|
375
|
-
expect(tweet.uri.to_s).to eq('https://twitter.com/sferik/status/28669546014')
|
376
|
-
end
|
377
|
-
end
|
378
|
-
|
379
|
-
describe '#uris?' do
|
380
|
-
it 'returns true when the tweet includes urls entities' do
|
381
|
-
entities = {
|
382
|
-
:urls => [{:url => 'https://t.co/L2xIBazMPf'}]
|
383
|
-
}
|
384
|
-
tweet = Twitter::Tweet.new(:id => 28_669_546_014, :entities => entities)
|
385
|
-
expect(tweet.uris?).to be true
|
386
|
-
end
|
387
|
-
it 'returns false when no entities are present' do
|
388
|
-
tweet = Twitter::Tweet.new(:id => 28_669_546_014)
|
389
|
-
expect(tweet.uris?).to be false
|
390
|
-
end
|
391
|
-
end
|
392
|
-
|
393
|
-
describe '#user' do
|
394
|
-
it 'returns a User when user is set' do
|
395
|
-
tweet = Twitter::Tweet.new(:id => 28_669_546_014, :user => {:id => 7_505_382})
|
396
|
-
expect(tweet.user).to be_a Twitter::User
|
397
|
-
end
|
398
|
-
it 'returns nil when user is not set' do
|
399
|
-
tweet = Twitter::Tweet.new(:id => 28_669_546_014)
|
400
|
-
expect(tweet.user).to be_nil
|
401
|
-
end
|
402
|
-
it 'has a status is set' do
|
403
|
-
tweet = Twitter::Tweet.new(:id => 28_669_546_014, :text => 'Tweet text.', :user => {:id => 7_505_382})
|
404
|
-
expect(tweet.user.status).to be_a Twitter::Tweet
|
405
|
-
expect(tweet.user.status.id).to eq 28_669_546_014
|
406
|
-
end
|
407
|
-
end
|
408
|
-
|
409
|
-
describe '#user?' do
|
410
|
-
it 'returns true when status is set' do
|
411
|
-
tweet = Twitter::Tweet.new(:id => 28_669_546_014, :user => {:id => 7_505_382})
|
412
|
-
expect(tweet.user?).to be true
|
413
|
-
end
|
414
|
-
it 'returns false when status is not set' do
|
415
|
-
tweet = Twitter::Tweet.new(:id => 28_669_546_014)
|
416
|
-
expect(tweet.user?).to be false
|
417
|
-
end
|
418
|
-
end
|
419
|
-
|
420
|
-
describe '#user_mentions' do
|
421
|
-
it 'returns an array of Entity::UserMention when entities are set' do
|
422
|
-
user_mentions_array = [
|
423
|
-
{
|
424
|
-
:screen_name => 'sferik',
|
425
|
-
:name => 'Erik Michaels-Ober',
|
426
|
-
:id_str => '7_505_382',
|
427
|
-
:indices => [0, 6],
|
428
|
-
:id => 7_505_382,
|
429
|
-
}
|
430
|
-
]
|
431
|
-
user_mentions = Twitter::Tweet.new(:id => 28_669_546_014, :entities => {:user_mentions => user_mentions_array}).user_mentions
|
432
|
-
expect(user_mentions).to be_an Array
|
433
|
-
expect(user_mentions.first).to be_a Twitter::Entity::UserMention
|
434
|
-
expect(user_mentions.first.indices).to eq([0, 6])
|
435
|
-
expect(user_mentions.first.id).to eq(7_505_382)
|
436
|
-
end
|
437
|
-
it 'is empty when not set' do
|
438
|
-
user_mentions = Twitter::Tweet.new(:id => 28_669_546_014).user_mentions
|
439
|
-
expect(user_mentions).to be_empty
|
440
|
-
end
|
441
|
-
end
|
442
|
-
|
443
|
-
describe '#user_mentions?' do
|
444
|
-
it 'returns true when the tweet includes user_mention entities' do
|
445
|
-
entities = {
|
446
|
-
:user_mentions => [{:screen_name => 'sferik'}]
|
447
|
-
}
|
448
|
-
tweet = Twitter::Tweet.new(:id => 28_669_546_014, :entities => entities)
|
449
|
-
expect(tweet.user_mentions?).to be true
|
450
|
-
end
|
451
|
-
it 'returns false when no entities are present' do
|
452
|
-
tweet = Twitter::Tweet.new(:id => 28_669_546_014)
|
453
|
-
expect(tweet.user_mentions?).to be false
|
454
|
-
end
|
455
|
-
end
|
456
|
-
end
|