twitter 5.1.1 → 5.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data.tar.gz.sig +0 -0
- data/.yardopts +2 -0
- data/CHANGELOG.md +10 -1
- data/CONTRIBUTING.md +2 -2
- data/README.md +30 -20
- data/Rakefile +26 -5
- data/lib/twitter/arguments.rb +0 -1
- data/lib/twitter/base.rb +13 -16
- data/lib/twitter/basic_user.rb +3 -3
- data/lib/twitter/client.rb +7 -8
- data/lib/twitter/configuration.rb +5 -5
- data/lib/twitter/core_ext/enumerable.rb +0 -2
- data/lib/twitter/core_ext/kernel.rb +0 -2
- data/lib/twitter/creatable.rb +0 -1
- data/lib/twitter/cursor.rb +7 -10
- data/lib/twitter/direct_message.rb +1 -1
- data/lib/twitter/entity/uri.rb +2 -2
- data/lib/twitter/enumerable.rb +1 -2
- data/lib/twitter/error.rb +4 -6
- data/lib/twitter/error/already_favorited.rb +1 -1
- data/lib/twitter/error/already_posted.rb +1 -1
- data/lib/twitter/error/already_retweeted.rb +1 -1
- data/lib/twitter/error/too_many_requests.rb +2 -2
- data/lib/twitter/factory.rb +2 -6
- data/lib/twitter/geo.rb +1 -1
- data/lib/twitter/geo/point.rb +3 -5
- data/lib/twitter/geo_factory.rb +1 -5
- data/lib/twitter/geo_results.rb +5 -8
- data/lib/twitter/identity.rb +1 -2
- data/lib/twitter/list.rb +4 -5
- data/lib/twitter/media/photo.rb +1 -2
- data/lib/twitter/media_factory.rb +1 -5
- data/lib/twitter/null_object.rb +4 -6
- data/lib/twitter/oembed.rb +1 -1
- data/lib/twitter/place.rb +4 -5
- data/lib/twitter/profile_banner.rb +1 -3
- data/lib/twitter/rate_limit.rb +1 -3
- data/lib/twitter/relationship.rb +1 -2
- data/lib/twitter/rest/api/direct_messages.rb +13 -14
- data/lib/twitter/rest/api/favorites.rb +10 -11
- data/lib/twitter/rest/api/friends_and_followers.rb +36 -36
- data/lib/twitter/rest/api/help.rb +8 -9
- data/lib/twitter/rest/api/lists.rb +62 -63
- data/lib/twitter/rest/api/oauth.rb +3 -4
- data/lib/twitter/rest/api/places_and_geo.rb +9 -10
- data/lib/twitter/rest/api/saved_searches.rb +5 -6
- data/lib/twitter/rest/api/search.rb +2 -3
- data/lib/twitter/rest/api/spam_reporting.rb +1 -2
- data/lib/twitter/rest/api/suggested_users.rb +4 -5
- data/lib/twitter/rest/api/timelines.rb +17 -18
- data/lib/twitter/rest/api/trends.rb +10 -11
- data/lib/twitter/rest/api/tweets.rb +15 -16
- data/lib/twitter/rest/api/undocumented.rb +6 -7
- data/lib/twitter/rest/api/users.rb +51 -52
- data/lib/twitter/rest/api/utils.rb +23 -30
- data/lib/twitter/rest/client.rb +8 -9
- data/lib/twitter/rest/request/multipart_with_file.rb +0 -1
- data/lib/twitter/rest/response/parse_error_json.rb +0 -2
- data/lib/twitter/rest/response/parse_json.rb +0 -2
- data/lib/twitter/rest/response/raise_error.rb +1 -3
- data/lib/twitter/search_results.rb +12 -15
- data/lib/twitter/settings.rb +2 -2
- data/lib/twitter/size.rb +2 -2
- data/lib/twitter/source_user.rb +1 -1
- data/lib/twitter/streaming/client.rb +71 -18
- data/lib/twitter/streaming/connection.rb +1 -3
- data/lib/twitter/streaming/deleted_tweet.rb +8 -0
- data/lib/twitter/streaming/event.rb +8 -8
- data/lib/twitter/streaming/friend_list.rb +2 -9
- data/lib/twitter/streaming/message_parser.rb +13 -7
- data/lib/twitter/streaming/response.rb +0 -2
- data/lib/twitter/streaming/stall_warning.rb +7 -0
- data/lib/twitter/suggestion.rb +0 -1
- data/lib/twitter/token.rb +2 -3
- data/lib/twitter/trend_results.rb +5 -8
- data/lib/twitter/tweet.rb +16 -24
- data/lib/twitter/user.rb +30 -32
- data/lib/twitter/version.rb +2 -5
- data/spec/fixtures/track_streaming_user.json +2 -1
- data/spec/helper.rb +6 -2
- data/spec/twitter/base_spec.rb +9 -9
- data/spec/twitter/basic_user_spec.rb +6 -6
- data/spec/twitter/configuration_spec.rb +4 -4
- data/spec/twitter/cursor_spec.rb +27 -27
- data/spec/twitter/direct_message_spec.rb +36 -36
- data/spec/twitter/entity/uri_spec.rb +27 -27
- data/spec/twitter/error_spec.rb +21 -21
- data/spec/twitter/geo/point_spec.rb +9 -9
- data/spec/twitter/geo/polygon_spec.rb +5 -5
- data/spec/twitter/geo_factory_spec.rb +7 -7
- data/spec/twitter/geo_results_spec.rb +11 -11
- data/spec/twitter/geo_spec.rb +5 -5
- data/spec/twitter/identifiable_spec.rb +9 -9
- data/spec/twitter/list_spec.rb +38 -38
- data/spec/twitter/media/photo_spec.rb +54 -54
- data/spec/twitter/media_factory_spec.rb +5 -5
- data/spec/twitter/null_object_spec.rb +6 -6
- data/spec/twitter/oembed_spec.rb +65 -65
- data/spec/twitter/place_spec.rb +89 -60
- data/spec/twitter/profile_banner_spec.rb +3 -3
- data/spec/twitter/rate_limit_spec.rb +18 -18
- data/spec/twitter/relationship_spec.rb +16 -16
- data/spec/twitter/rest/api/direct_messages_spec.rb +61 -61
- data/spec/twitter/rest/api/favorites_spec.rb +93 -93
- data/spec/twitter/rest/api/friends_and_followers_spec.rb +349 -349
- data/spec/twitter/rest/api/geo_spec.rb +33 -33
- data/spec/twitter/rest/api/help_spec.rb +24 -24
- data/spec/twitter/rest/api/lists_spec.rb +487 -487
- data/spec/twitter/rest/api/oauth_spec.rb +30 -30
- data/spec/twitter/rest/api/saved_searches_spec.rb +40 -40
- data/spec/twitter/rest/api/search_spec.rb +16 -16
- data/spec/twitter/rest/api/spam_reporting_spec.rb +9 -9
- data/spec/twitter/rest/api/suggested_users_spec.rb +23 -23
- data/spec/twitter/rest/api/timelines_spec.rb +58 -58
- data/spec/twitter/rest/api/trends_spec.rb +26 -26
- data/spec/twitter/rest/api/tweets_spec.rb +284 -284
- data/spec/twitter/rest/api/undocumented_spec.rb +51 -51
- data/spec/twitter/rest/api/users_spec.rb +360 -360
- data/spec/twitter/rest/client_spec.rb +99 -103
- data/spec/twitter/saved_search_spec.rb +16 -16
- data/spec/twitter/search_results_spec.rb +44 -44
- data/spec/twitter/settings_spec.rb +8 -8
- data/spec/twitter/size_spec.rb +5 -5
- data/spec/twitter/source_user_spec.rb +6 -6
- data/spec/twitter/streaming/client_spec.rb +53 -49
- data/spec/twitter/streaming/deleted_tweet_spec.rb +23 -0
- data/spec/twitter/streaming/event_spec.rb +20 -22
- data/spec/twitter/streaming/friend_list_spec.rb +11 -0
- data/spec/twitter/streaming/message_parser_spec.rb +54 -0
- data/spec/twitter/suggestion_spec.rb +11 -11
- data/spec/twitter/target_user_spec.rb +6 -6
- data/spec/twitter/token_spec.rb +4 -4
- data/spec/twitter/trend_results_spec.rb +30 -30
- data/spec/twitter/trend_spec.rb +20 -20
- data/spec/twitter/tweet_spec.rb +170 -173
- data/spec/twitter/user_spec.rb +179 -179
- data/twitter.gemspec +2 -2
- metadata +21 -4
- metadata.gz.sig +2 -1
data/spec/twitter/token_spec.rb
CHANGED
|
@@ -2,12 +2,12 @@ require 'helper'
|
|
|
2
2
|
|
|
3
3
|
describe Twitter::Token do
|
|
4
4
|
|
|
5
|
-
describe
|
|
6
|
-
it
|
|
7
|
-
token = Twitter::Token.new(:token_type =>
|
|
5
|
+
describe '#bearer?' do
|
|
6
|
+
it 'returns true when token is a bearer token' do
|
|
7
|
+
token = Twitter::Token.new(:token_type => 'bearer')
|
|
8
8
|
expect(token.bearer?).to be true
|
|
9
9
|
end
|
|
10
|
-
it
|
|
10
|
+
it 'returns false when token type is nil' do
|
|
11
11
|
token = Twitter::Token.new
|
|
12
12
|
expect(token.bearer?).to be false
|
|
13
13
|
end
|
|
@@ -2,85 +2,85 @@ require 'helper'
|
|
|
2
2
|
|
|
3
3
|
describe Twitter::TrendResults do
|
|
4
4
|
|
|
5
|
-
describe
|
|
6
|
-
it
|
|
7
|
-
trend_results = Twitter::TrendResults.new(:id => 1, :as_of =>
|
|
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
8
|
expect(trend_results.as_of).to be_a Time
|
|
9
9
|
end
|
|
10
|
-
it
|
|
10
|
+
it 'returns nil when as_of is not set' do
|
|
11
11
|
trend_results = Twitter::TrendResults.new(:id => 1)
|
|
12
12
|
expect(trend_results.as_of).to be_nil
|
|
13
13
|
end
|
|
14
14
|
end
|
|
15
15
|
|
|
16
|
-
describe
|
|
17
|
-
it
|
|
18
|
-
trend_results = Twitter::TrendResults.new(:id => 1, :as_of =>
|
|
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
19
|
expect(trend_results.as_of?).to be true
|
|
20
20
|
end
|
|
21
|
-
it
|
|
21
|
+
it 'returns false when as_of is not set' do
|
|
22
22
|
trend_results = Twitter::TrendResults.new(:id => 1)
|
|
23
23
|
expect(trend_results.as_of?).to be false
|
|
24
24
|
end
|
|
25
25
|
end
|
|
26
26
|
|
|
27
|
-
describe
|
|
28
|
-
it
|
|
29
|
-
trend_results = Twitter::TrendResults.new(:id => 1, :created_at =>
|
|
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
30
|
expect(trend_results.created_at).to be_a Time
|
|
31
31
|
end
|
|
32
|
-
it
|
|
32
|
+
it 'returns nil when created_at is not set' do
|
|
33
33
|
trend_results = Twitter::TrendResults.new(:id => 1)
|
|
34
34
|
expect(trend_results.created_at).to be_nil
|
|
35
35
|
end
|
|
36
36
|
end
|
|
37
37
|
|
|
38
|
-
describe
|
|
39
|
-
it
|
|
40
|
-
trend_results = Twitter::TrendResults.new(:id => 1, :created_at =>
|
|
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
41
|
expect(trend_results.created?).to be true
|
|
42
42
|
end
|
|
43
|
-
it
|
|
43
|
+
it 'returns false when created_at is not set' do
|
|
44
44
|
trend_results = Twitter::TrendResults.new(:id => 1)
|
|
45
45
|
expect(trend_results.created?).to be false
|
|
46
46
|
end
|
|
47
47
|
end
|
|
48
48
|
|
|
49
|
-
describe
|
|
49
|
+
describe '#each' do
|
|
50
50
|
before do
|
|
51
51
|
@trend_results = Twitter::TrendResults.new(:trends => [{:id => 1}, {:id => 2}, {:id => 3}, {:id => 4}, {:id => 5}, {:id => 6}])
|
|
52
52
|
end
|
|
53
|
-
it
|
|
53
|
+
it 'iterates' do
|
|
54
54
|
count = 0
|
|
55
|
-
@trend_results.each{count += 1}
|
|
55
|
+
@trend_results.each { count += 1 }
|
|
56
56
|
expect(count).to eq(6)
|
|
57
57
|
end
|
|
58
|
-
context
|
|
59
|
-
it
|
|
58
|
+
context 'with start' do
|
|
59
|
+
it 'iterates' do
|
|
60
60
|
count = 0
|
|
61
|
-
@trend_results.each(5){count += 1}
|
|
61
|
+
@trend_results.each(5) { count += 1 }
|
|
62
62
|
expect(count).to eq(1)
|
|
63
63
|
end
|
|
64
64
|
end
|
|
65
65
|
end
|
|
66
66
|
|
|
67
|
-
describe
|
|
68
|
-
it
|
|
69
|
-
trend_results = Twitter::TrendResults.new(:id => 1, :locations => [{:name =>
|
|
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
70
|
expect(trend_results.location).to be_a Twitter::Place
|
|
71
71
|
end
|
|
72
|
-
it
|
|
72
|
+
it 'returns nil when location is not set' do
|
|
73
73
|
trend_results = Twitter::TrendResults.new(:id => 1)
|
|
74
74
|
expect(trend_results.location).to be_nil
|
|
75
75
|
end
|
|
76
76
|
end
|
|
77
77
|
|
|
78
|
-
describe
|
|
79
|
-
it
|
|
80
|
-
trend_results = Twitter::TrendResults.new(:id => 1, :locations => [{:name =>
|
|
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
81
|
expect(trend_results.location?).to be true
|
|
82
82
|
end
|
|
83
|
-
it
|
|
83
|
+
it 'returns false when location is not set' do
|
|
84
84
|
trend_results = Twitter::TrendResults.new(:id => 1)
|
|
85
85
|
expect(trend_results.location?).to be false
|
|
86
86
|
end
|
data/spec/twitter/trend_spec.rb
CHANGED
|
@@ -2,47 +2,47 @@ require 'helper'
|
|
|
2
2
|
|
|
3
3
|
describe Twitter::Trend do
|
|
4
4
|
|
|
5
|
-
describe
|
|
6
|
-
it
|
|
5
|
+
describe '#==' do
|
|
6
|
+
it 'returns true for empty objects' do
|
|
7
7
|
trend = Twitter::Trend.new
|
|
8
8
|
other = Twitter::Trend.new
|
|
9
9
|
expect(trend == other).to be true
|
|
10
10
|
end
|
|
11
|
-
it
|
|
12
|
-
trend = Twitter::Trend.new(:name =>
|
|
13
|
-
other = Twitter::Trend.new(:name =>
|
|
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
14
|
expect(trend == other).to be true
|
|
15
15
|
end
|
|
16
|
-
it
|
|
17
|
-
trend = Twitter::Trend.new(:name =>
|
|
18
|
-
other = Twitter::Trend.new(:name =>
|
|
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
19
|
expect(trend == other).to be false
|
|
20
20
|
end
|
|
21
|
-
it
|
|
22
|
-
trend = Twitter::Trend.new(:name =>
|
|
23
|
-
other = Twitter::Base.new(:name =>
|
|
21
|
+
it 'returns false when classes are different' do
|
|
22
|
+
trend = Twitter::Trend.new(:name => '#sevenwordsaftersex')
|
|
23
|
+
other = Twitter::Base.new(:name => '#sevenwordsaftersex')
|
|
24
24
|
expect(trend == other).to be false
|
|
25
25
|
end
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
-
describe
|
|
29
|
-
it
|
|
30
|
-
trend = Twitter::Trend.new(:url =>
|
|
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
31
|
expect(trend.uri).to be_a Addressable::URI
|
|
32
|
-
expect(trend.uri.to_s).to eq(
|
|
32
|
+
expect(trend.uri.to_s).to eq('http://twitter.com/search/?q=%23sevenwordsaftersex')
|
|
33
33
|
end
|
|
34
|
-
it
|
|
34
|
+
it 'returns nil when the url is not set' do
|
|
35
35
|
trend = Twitter::Trend.new
|
|
36
36
|
expect(trend.uri).to be_nil
|
|
37
37
|
end
|
|
38
38
|
end
|
|
39
39
|
|
|
40
|
-
describe
|
|
41
|
-
it
|
|
42
|
-
trend = Twitter::Trend.new(:url =>
|
|
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
43
|
expect(trend.uri?).to be true
|
|
44
44
|
end
|
|
45
|
-
it
|
|
45
|
+
it 'returns false when the url is not set' do
|
|
46
46
|
trend = Twitter::Trend.new
|
|
47
47
|
expect(trend.uri?).to be false
|
|
48
48
|
end
|
data/spec/twitter/tweet_spec.rb
CHANGED
|
@@ -12,381 +12,378 @@ describe Twitter::Tweet do
|
|
|
12
12
|
$stderr = @old_stderr
|
|
13
13
|
end
|
|
14
14
|
|
|
15
|
-
describe
|
|
16
|
-
it
|
|
17
|
-
tweet = Twitter::Tweet.new(:id => 1, :text =>
|
|
18
|
-
other = Twitter::Tweet.new(:id => 1, :text =>
|
|
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
19
|
expect(tweet == other).to be true
|
|
20
20
|
end
|
|
21
|
-
it
|
|
21
|
+
it 'returns false when objects IDs are different' do
|
|
22
22
|
tweet = Twitter::Tweet.new(:id => 1)
|
|
23
23
|
other = Twitter::Tweet.new(:id => 2)
|
|
24
24
|
expect(tweet == other).to be false
|
|
25
25
|
end
|
|
26
|
-
it
|
|
26
|
+
it 'returns false when classes are different' do
|
|
27
27
|
tweet = Twitter::Tweet.new(:id => 1)
|
|
28
28
|
other = Twitter::Identity.new(:id => 1)
|
|
29
29
|
expect(tweet == other).to be false
|
|
30
30
|
end
|
|
31
31
|
end
|
|
32
32
|
|
|
33
|
-
describe
|
|
34
|
-
it
|
|
35
|
-
tweet = Twitter::Tweet.new(:id =>
|
|
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
36
|
expect(tweet.created_at).to be_a Time
|
|
37
37
|
end
|
|
38
|
-
it
|
|
39
|
-
tweet = Twitter::Tweet.new(:id =>
|
|
38
|
+
it 'returns nil when not set' do
|
|
39
|
+
tweet = Twitter::Tweet.new(:id => 28_669_546_014)
|
|
40
40
|
expect(tweet.created_at).to be_nil
|
|
41
41
|
end
|
|
42
42
|
end
|
|
43
43
|
|
|
44
|
-
describe
|
|
45
|
-
it
|
|
46
|
-
tweet = Twitter::Tweet.new(:id =>
|
|
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
47
|
expect(tweet.created?).to be true
|
|
48
48
|
end
|
|
49
|
-
it
|
|
50
|
-
tweet = Twitter::Tweet.new(:id =>
|
|
49
|
+
it 'returns false when created_at is not set' do
|
|
50
|
+
tweet = Twitter::Tweet.new(:id => 28_669_546_014)
|
|
51
51
|
expect(tweet.created?).to be false
|
|
52
52
|
end
|
|
53
53
|
end
|
|
54
54
|
|
|
55
|
-
describe
|
|
56
|
-
it
|
|
57
|
-
tweet = Twitter::Tweet.new(:id =>
|
|
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
58
|
expect(tweet.entities?).to be false
|
|
59
59
|
end
|
|
60
60
|
|
|
61
|
-
it
|
|
62
|
-
tweet = Twitter::Tweet.new(:id =>
|
|
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
63
|
expect(tweet.entities?).to be false
|
|
64
64
|
end
|
|
65
|
-
|
|
66
|
-
it "returns true if there are entities set" do
|
|
65
|
+
it 'returns true if there are entities set' do
|
|
67
66
|
urls_array = [
|
|
68
67
|
{
|
|
69
|
-
:url =>
|
|
70
|
-
:expanded_url =>
|
|
71
|
-
:display_url =>
|
|
68
|
+
:url => 'http://example.com/t.co',
|
|
69
|
+
:expanded_url => 'http://example.com/expanded',
|
|
70
|
+
:display_url => 'example.com/expanded…',
|
|
72
71
|
:indices => [10, 33],
|
|
73
72
|
}
|
|
74
73
|
]
|
|
75
|
-
tweet = Twitter::Tweet.new(:id =>
|
|
74
|
+
tweet = Twitter::Tweet.new(:id => 28_669_546_014, :entities => {:urls => urls_array})
|
|
76
75
|
expect(tweet.entities?).to be true
|
|
77
76
|
end
|
|
78
77
|
end
|
|
79
78
|
|
|
80
|
-
describe
|
|
81
|
-
it
|
|
82
|
-
tweet = Twitter::Tweet.new(:id =>
|
|
79
|
+
describe '#filter_level' do
|
|
80
|
+
it 'returns the filter level when filter_level is set' do
|
|
81
|
+
tweet = Twitter::Tweet.new(:id => 28_669_546_014, :filter_level => 'high')
|
|
83
82
|
expect(tweet.filter_level).to be_a String
|
|
84
|
-
expect(tweet.filter_level).to eq(
|
|
83
|
+
expect(tweet.filter_level).to eq('high')
|
|
85
84
|
end
|
|
86
|
-
it
|
|
87
|
-
tweet = Twitter::Tweet.new(:id =>
|
|
88
|
-
expect(tweet.filter_level).to eq(
|
|
85
|
+
it 'returns \'none\' when not set' do
|
|
86
|
+
tweet = Twitter::Tweet.new(:id => 28_669_546_014)
|
|
87
|
+
expect(tweet.filter_level).to eq('none')
|
|
89
88
|
end
|
|
90
89
|
end
|
|
91
90
|
|
|
92
|
-
describe
|
|
93
|
-
it
|
|
94
|
-
tweet = Twitter::Tweet.new(:id =>
|
|
91
|
+
describe '#full_text' do
|
|
92
|
+
it 'returns the text of a Tweet' do
|
|
93
|
+
tweet = Twitter::Tweet.new(:id => 28_669_546_014, :text => 'BOOSH')
|
|
95
94
|
expect(tweet.full_text).to be_a String
|
|
96
|
-
expect(tweet.full_text).to eq(
|
|
95
|
+
expect(tweet.full_text).to eq('BOOSH')
|
|
97
96
|
end
|
|
98
|
-
it
|
|
99
|
-
tweet = Twitter::Tweet.new(:id =>
|
|
97
|
+
it 'returns the text of a Tweet without a user' do
|
|
98
|
+
tweet = Twitter::Tweet.new(:id => 28_669_546_014, :text => 'BOOSH', :retweeted_status => {:id => 28_561_922_517, :text => 'BOOSH'})
|
|
100
99
|
expect(tweet.full_text).to be_a String
|
|
101
|
-
expect(tweet.full_text).to eq(
|
|
100
|
+
expect(tweet.full_text).to eq('BOOSH')
|
|
102
101
|
end
|
|
103
|
-
it
|
|
104
|
-
tweet = Twitter::Tweet.new(:id =>
|
|
102
|
+
it 'returns the full text of a retweeted Tweet' do
|
|
103
|
+
tweet = Twitter::Tweet.new(:id => 28_669_546_014, :text => 'RT @sferik: BOOSH', :retweeted_status => {:id => 25_938_088_801, :text => 'BOOSH'})
|
|
105
104
|
expect(tweet.full_text).to be_a String
|
|
106
|
-
expect(tweet.full_text).to eq(
|
|
105
|
+
expect(tweet.full_text).to eq('RT @sferik: BOOSH')
|
|
107
106
|
end
|
|
108
|
-
it
|
|
109
|
-
tweet = Twitter::Tweet.new(:id =>
|
|
107
|
+
it 'returns nil when retweeted_status is not set' do
|
|
108
|
+
tweet = Twitter::Tweet.new(:id => 28_669_546_014)
|
|
110
109
|
expect(tweet.full_text).to be_nil
|
|
111
110
|
end
|
|
112
111
|
end
|
|
113
112
|
|
|
114
|
-
describe
|
|
115
|
-
it
|
|
116
|
-
tweet = Twitter::Tweet.new(:id =>
|
|
113
|
+
describe '#geo' do
|
|
114
|
+
it 'returns a Twitter::Geo::Point when geo is set' do
|
|
115
|
+
tweet = Twitter::Tweet.new(:id => 28_669_546_014, :geo => {:id => 1, :type => 'Point'})
|
|
117
116
|
expect(tweet.geo).to be_a Twitter::Geo::Point
|
|
118
117
|
end
|
|
119
|
-
it
|
|
120
|
-
tweet = Twitter::Tweet.new(:id =>
|
|
118
|
+
it 'returns nil when geo is not set' do
|
|
119
|
+
tweet = Twitter::Tweet.new(:id => 28_669_546_014)
|
|
121
120
|
expect(tweet.geo).to be_nil
|
|
122
121
|
end
|
|
123
122
|
end
|
|
124
123
|
|
|
125
|
-
describe
|
|
126
|
-
it
|
|
127
|
-
tweet = Twitter::Tweet.new(:id =>
|
|
124
|
+
describe '#geo?' do
|
|
125
|
+
it 'returns true when geo is set' do
|
|
126
|
+
tweet = Twitter::Tweet.new(:id => 28_669_546_014, :geo => {:id => 1, :type => 'Point'})
|
|
128
127
|
expect(tweet.geo?).to be true
|
|
129
128
|
end
|
|
130
|
-
it
|
|
131
|
-
tweet = Twitter::Tweet.new(:id =>
|
|
129
|
+
it 'returns false when geo is not set' do
|
|
130
|
+
tweet = Twitter::Tweet.new(:id => 28_669_546_014)
|
|
132
131
|
expect(tweet.geo?).to be false
|
|
133
132
|
end
|
|
134
133
|
end
|
|
135
134
|
|
|
136
|
-
describe
|
|
137
|
-
it
|
|
135
|
+
describe '#hashtags' do
|
|
136
|
+
it 'returns an array of Entity::Hashtag when entities are set' do
|
|
138
137
|
hashtags_array = [
|
|
139
138
|
{
|
|
140
|
-
:text =>
|
|
139
|
+
:text => 'twitter',
|
|
141
140
|
:indices => [10, 33],
|
|
142
141
|
}
|
|
143
142
|
]
|
|
144
|
-
hashtags = Twitter::Tweet.new(:id =>
|
|
143
|
+
hashtags = Twitter::Tweet.new(:id => 28_669_546_014, :entities => {:hashtags => hashtags_array}).hashtags
|
|
145
144
|
expect(hashtags).to be_an Array
|
|
146
145
|
expect(hashtags.first).to be_a Twitter::Entity::Hashtag
|
|
147
146
|
expect(hashtags.first.indices).to eq([10, 33])
|
|
148
|
-
expect(hashtags.first.text).to eq(
|
|
147
|
+
expect(hashtags.first.text).to eq('twitter')
|
|
149
148
|
end
|
|
150
|
-
it
|
|
151
|
-
hashtags = Twitter::Tweet.new(:id =>
|
|
149
|
+
it 'is empty when not set' do
|
|
150
|
+
hashtags = Twitter::Tweet.new(:id => 28_669_546_014).hashtags
|
|
152
151
|
expect(hashtags).to be_empty
|
|
153
152
|
end
|
|
154
|
-
it
|
|
155
|
-
Twitter::Tweet.new(:id =>
|
|
153
|
+
it 'warns when not set' do
|
|
154
|
+
Twitter::Tweet.new(:id => 28_669_546_014).hashtags
|
|
156
155
|
expect($stderr.string).to match(/To get hashtags, you must pass `:include_entities => true` when requesting the Twitter::Tweet\./)
|
|
157
156
|
end
|
|
158
157
|
end
|
|
159
158
|
|
|
160
|
-
describe
|
|
161
|
-
it
|
|
162
|
-
media = Twitter::Tweet.new(:id =>
|
|
159
|
+
describe '#media' do
|
|
160
|
+
it 'returns media' do
|
|
161
|
+
media = Twitter::Tweet.new(:id => 28_669_546_014, :entities => {:media => [{:id => 1, :type => 'photo'}]}).media
|
|
163
162
|
expect(media).to be_an Array
|
|
164
163
|
expect(media.first).to be_a Twitter::Media::Photo
|
|
165
164
|
end
|
|
166
|
-
it
|
|
167
|
-
media = Twitter::Tweet.new(:id =>
|
|
165
|
+
it 'is empty when not set' do
|
|
166
|
+
media = Twitter::Tweet.new(:id => 28_669_546_014).media
|
|
168
167
|
expect(media).to be_empty
|
|
169
168
|
end
|
|
170
|
-
it
|
|
171
|
-
Twitter::Tweet.new(:id =>
|
|
169
|
+
it 'warns when not set' do
|
|
170
|
+
Twitter::Tweet.new(:id => 28_669_546_014).media
|
|
172
171
|
expect($stderr.string).to match(/To get media, you must pass `:include_entities => true` when requesting the Twitter::Tweet\./)
|
|
173
172
|
end
|
|
174
173
|
end
|
|
175
174
|
|
|
176
|
-
describe
|
|
177
|
-
it
|
|
178
|
-
tweet = Twitter::Tweet.new(:id =>
|
|
175
|
+
describe '#metadata' do
|
|
176
|
+
it 'returns a Twitter::Metadata when metadata is set' do
|
|
177
|
+
tweet = Twitter::Tweet.new(:id => 28_669_546_014, :metadata => {})
|
|
179
178
|
expect(tweet.metadata).to be_a Twitter::Metadata
|
|
180
179
|
end
|
|
181
|
-
it
|
|
182
|
-
tweet = Twitter::Tweet.new(:id =>
|
|
180
|
+
it 'returns nil when metadata is not set' do
|
|
181
|
+
tweet = Twitter::Tweet.new(:id => 28_669_546_014)
|
|
183
182
|
expect(tweet.metadata).to be_nil
|
|
184
183
|
end
|
|
185
184
|
end
|
|
186
185
|
|
|
187
|
-
describe
|
|
188
|
-
it
|
|
189
|
-
tweet = Twitter::Tweet.new(:id =>
|
|
186
|
+
describe '#metadata?' do
|
|
187
|
+
it 'returns true when metadata is set' do
|
|
188
|
+
tweet = Twitter::Tweet.new(:id => 28_669_546_014, :metadata => {})
|
|
190
189
|
expect(tweet.metadata?).to be true
|
|
191
190
|
end
|
|
192
|
-
it
|
|
193
|
-
tweet = Twitter::Tweet.new(:id =>
|
|
191
|
+
it 'returns false when metadata is not set' do
|
|
192
|
+
tweet = Twitter::Tweet.new(:id => 28_669_546_014)
|
|
194
193
|
expect(tweet.metadata?).to be false
|
|
195
194
|
end
|
|
196
195
|
end
|
|
197
196
|
|
|
198
|
-
describe
|
|
199
|
-
it
|
|
200
|
-
tweet = Twitter::Tweet.new(:id =>
|
|
197
|
+
describe '#place' do
|
|
198
|
+
it 'returns a Twitter::Place when place is set' do
|
|
199
|
+
tweet = Twitter::Tweet.new(:id => 28_669_546_014, :place => {:id => '247f43d441defc03'})
|
|
201
200
|
expect(tweet.place).to be_a Twitter::Place
|
|
202
201
|
end
|
|
203
|
-
it
|
|
204
|
-
tweet = Twitter::Tweet.new(:id =>
|
|
202
|
+
it 'returns nil when place is not set' do
|
|
203
|
+
tweet = Twitter::Tweet.new(:id => 28_669_546_014)
|
|
205
204
|
expect(tweet.place).to be_nil
|
|
206
205
|
end
|
|
207
206
|
end
|
|
208
207
|
|
|
209
|
-
describe
|
|
210
|
-
it
|
|
211
|
-
tweet = Twitter::Tweet.new(:id =>
|
|
208
|
+
describe '#place?' do
|
|
209
|
+
it 'returns true when place is set' do
|
|
210
|
+
tweet = Twitter::Tweet.new(:id => 28_669_546_014, :place => {:id => '247f43d441defc03'})
|
|
212
211
|
expect(tweet.place?).to be true
|
|
213
212
|
end
|
|
214
|
-
it
|
|
215
|
-
tweet = Twitter::Tweet.new(:id =>
|
|
213
|
+
it 'returns false when place is not set' do
|
|
214
|
+
tweet = Twitter::Tweet.new(:id => 28_669_546_014)
|
|
216
215
|
expect(tweet.place?).to be false
|
|
217
216
|
end
|
|
218
217
|
end
|
|
219
218
|
|
|
220
|
-
describe
|
|
221
|
-
it
|
|
222
|
-
tweet = Twitter::Tweet.new(:id =>
|
|
219
|
+
describe '#reply?' do
|
|
220
|
+
it 'returns true when there is an in-reply-to status' do
|
|
221
|
+
tweet = Twitter::Tweet.new(:id => 28_669_546_014, :in_reply_to_status_id => 114_749_583_439_036_416)
|
|
223
222
|
expect(tweet.reply?).to be true
|
|
224
223
|
end
|
|
225
|
-
it
|
|
226
|
-
tweet = Twitter::Tweet.new(:id =>
|
|
224
|
+
it 'returns false when in_reply_to_status_id is not set' do
|
|
225
|
+
tweet = Twitter::Tweet.new(:id => 28_669_546_014)
|
|
227
226
|
expect(tweet.reply?).to be false
|
|
228
227
|
end
|
|
229
228
|
end
|
|
230
229
|
|
|
231
|
-
describe
|
|
232
|
-
it
|
|
233
|
-
tweet = Twitter::Tweet.new(:id =>
|
|
230
|
+
describe '#retweet?' do
|
|
231
|
+
it 'returns true when there is a retweeted status' do
|
|
232
|
+
tweet = Twitter::Tweet.new(:id => 28_669_546_014, :retweeted_status => {:id => 25_938_088_801, :text => 'BOOSH'})
|
|
234
233
|
expect(tweet.retweet?).to be true
|
|
235
234
|
end
|
|
236
|
-
it
|
|
237
|
-
tweet = Twitter::Tweet.new(:id =>
|
|
235
|
+
it 'returns false when retweeted_status is not set' do
|
|
236
|
+
tweet = Twitter::Tweet.new(:id => 28_669_546_014)
|
|
238
237
|
expect(tweet.retweet?).to be false
|
|
239
238
|
end
|
|
240
239
|
end
|
|
241
240
|
|
|
242
|
-
describe
|
|
243
|
-
it
|
|
244
|
-
tweet = Twitter::Tweet.new(:id =>
|
|
241
|
+
describe '#retweeted_status' do
|
|
242
|
+
it 'returns a Tweet when retweeted_status is set' do
|
|
243
|
+
tweet = Twitter::Tweet.new(:id => 28_669_546_014, :retweeted_status => {:id => 25_938_088_801, :text => 'BOOSH'})
|
|
245
244
|
expect(tweet.retweeted_tweet).to be_a Twitter::Tweet
|
|
246
|
-
expect(tweet.retweeted_tweet.text).to eq(
|
|
245
|
+
expect(tweet.retweeted_tweet.text).to eq('BOOSH')
|
|
247
246
|
end
|
|
248
|
-
it
|
|
249
|
-
tweet = Twitter::Tweet.new(:id =>
|
|
247
|
+
it 'returns nil when retweeted_status is not set' do
|
|
248
|
+
tweet = Twitter::Tweet.new(:id => 28_669_546_014)
|
|
250
249
|
expect(tweet.retweeted_tweet).to be_nil
|
|
251
250
|
end
|
|
252
251
|
end
|
|
253
252
|
|
|
254
|
-
describe
|
|
255
|
-
it
|
|
256
|
-
tweet = Twitter::Tweet.new(:id =>
|
|
253
|
+
describe '#retweeted_status?' do
|
|
254
|
+
it 'returns true when retweeted_status is set' do
|
|
255
|
+
tweet = Twitter::Tweet.new(:id => 28_669_546_014, :retweeted_status => {:id => 25_938_088_801, :text => 'BOOSH'})
|
|
257
256
|
expect(tweet.retweeted_status?).to be true
|
|
258
257
|
end
|
|
259
|
-
it
|
|
260
|
-
tweet = Twitter::Tweet.new(:id =>
|
|
258
|
+
it 'returns false when retweeted_status is not set' do
|
|
259
|
+
tweet = Twitter::Tweet.new(:id => 28_669_546_014)
|
|
261
260
|
expect(tweet.retweeted_status?).to be false
|
|
262
261
|
end
|
|
263
262
|
end
|
|
264
263
|
|
|
265
|
-
describe
|
|
266
|
-
it
|
|
264
|
+
describe '#symbols' do
|
|
265
|
+
it 'returns an array of Entity::Symbol when symbols are set' do
|
|
267
266
|
symbols_array = [
|
|
268
|
-
{
|
|
269
|
-
{
|
|
267
|
+
{:text => 'PEP', :indices => [114, 118]},
|
|
268
|
+
{:text => 'COKE', :indices => [128, 133]}
|
|
270
269
|
]
|
|
271
|
-
symbols = Twitter::Tweet.new(:id =>
|
|
270
|
+
symbols = Twitter::Tweet.new(:id => 28_669_546_014, :entities => {:symbols => symbols_array}).symbols
|
|
272
271
|
expect(symbols).to be_an Array
|
|
273
272
|
expect(symbols.size).to eq(2)
|
|
274
273
|
expect(symbols.first).to be_a Twitter::Entity::Symbol
|
|
275
274
|
expect(symbols.first.indices).to eq([114, 118])
|
|
276
|
-
expect(symbols.first.text).to eq(
|
|
275
|
+
expect(symbols.first.text).to eq('PEP')
|
|
277
276
|
end
|
|
278
|
-
it
|
|
279
|
-
symbols = Twitter::Tweet.new(:id =>
|
|
277
|
+
it 'is empty when not set' do
|
|
278
|
+
symbols = Twitter::Tweet.new(:id => 28_669_546_014).symbols
|
|
280
279
|
expect(symbols).to be_empty
|
|
281
280
|
end
|
|
282
|
-
it
|
|
283
|
-
Twitter::Tweet.new(:id =>
|
|
281
|
+
it 'warns when not set' do
|
|
282
|
+
Twitter::Tweet.new(:id => 28_669_546_014).symbols
|
|
284
283
|
expect($stderr.string).to match(/To get symbols, you must pass `:include_entities => true` when requesting the Twitter::Tweet\./)
|
|
285
284
|
end
|
|
286
285
|
end
|
|
287
286
|
|
|
288
|
-
describe
|
|
289
|
-
it
|
|
287
|
+
describe '#uris' do
|
|
288
|
+
it 'returns an array of Entity::URIs when entities are set' do
|
|
290
289
|
urls_array = [
|
|
291
290
|
{
|
|
292
|
-
:url =>
|
|
293
|
-
:expanded_url =>
|
|
294
|
-
:display_url =>
|
|
291
|
+
:url => 'http://example.com/t.co',
|
|
292
|
+
:expanded_url => 'http://example.com/expanded',
|
|
293
|
+
:display_url => 'example.com/expanded…',
|
|
295
294
|
:indices => [10, 33],
|
|
296
295
|
}
|
|
297
296
|
]
|
|
298
|
-
tweet = Twitter::Tweet.new(:id =>
|
|
297
|
+
tweet = Twitter::Tweet.new(:id => 28_669_546_014, :entities => {:urls => urls_array})
|
|
299
298
|
expect(tweet.uris).to be_an Array
|
|
300
299
|
expect(tweet.uris.first).to be_a Twitter::Entity::URI
|
|
301
300
|
expect(tweet.uris.first.indices).to eq([10, 33])
|
|
302
301
|
expect(tweet.uris.first.display_uri).to be_a String
|
|
303
|
-
expect(tweet.uris.first.display_uri).to eq(
|
|
302
|
+
expect(tweet.uris.first.display_uri).to eq('example.com/expanded…')
|
|
304
303
|
end
|
|
305
|
-
it
|
|
306
|
-
tweet = Twitter::Tweet.new(:id =>
|
|
304
|
+
it 'is empty when not set' do
|
|
305
|
+
tweet = Twitter::Tweet.new(:id => 28_669_546_014)
|
|
307
306
|
expect(tweet.uris).to be_empty
|
|
308
307
|
end
|
|
309
|
-
it
|
|
310
|
-
Twitter::Tweet.new(:id =>
|
|
308
|
+
it 'warns when not set' do
|
|
309
|
+
Twitter::Tweet.new(:id => 28_669_546_014).urls
|
|
311
310
|
expect($stderr.string).to match(/To get urls, you must pass `:include_entities => true` when requesting the Twitter::Tweet\./)
|
|
312
311
|
end
|
|
313
|
-
|
|
314
|
-
it "can handle strange urls" do
|
|
312
|
+
it 'can handle strange urls' do
|
|
315
313
|
urls_array = [
|
|
316
314
|
{
|
|
317
|
-
:url =>
|
|
318
|
-
:expanded_url =>
|
|
319
|
-
:display_url =>
|
|
315
|
+
:url => 'http://with_underscore.example.com/t.co',
|
|
316
|
+
:expanded_url => 'http://with_underscore.example.com/expanded',
|
|
317
|
+
:display_url => 'with_underscore.example.com/expanded…',
|
|
320
318
|
:indices => [10, 33],
|
|
321
319
|
}
|
|
322
320
|
]
|
|
323
|
-
tweet = Twitter::Tweet.new(:id =>
|
|
321
|
+
tweet = Twitter::Tweet.new(:id => 28_669_546_014, :entities => {:urls => urls_array})
|
|
324
322
|
uri = tweet.uris.first
|
|
325
|
-
expect{ uri.url }.
|
|
326
|
-
expect{ uri.expanded_url }.
|
|
327
|
-
expect{ uri.display_url }.
|
|
323
|
+
expect { uri.url }.not_to raise_error
|
|
324
|
+
expect { uri.expanded_url }.not_to raise_error
|
|
325
|
+
expect { uri.display_url }.not_to raise_error
|
|
328
326
|
end
|
|
329
|
-
|
|
330
327
|
end
|
|
331
328
|
|
|
332
|
-
describe
|
|
333
|
-
it
|
|
334
|
-
tweet = Twitter::Tweet.new(:id =>
|
|
329
|
+
describe '#uri' do
|
|
330
|
+
it 'returns the URI to the tweet' do
|
|
331
|
+
tweet = Twitter::Tweet.new(:id => 28_669_546_014, :user => {:id => 7_505_382, :screen_name => 'sferik'})
|
|
335
332
|
expect(tweet.uri).to be_a Addressable::URI
|
|
336
|
-
expect(tweet.uri.to_s).to eq(
|
|
333
|
+
expect(tweet.uri.to_s).to eq('https://twitter.com/sferik/status/28669546014')
|
|
337
334
|
end
|
|
338
335
|
end
|
|
339
336
|
|
|
340
|
-
describe
|
|
341
|
-
it
|
|
342
|
-
tweet = Twitter::Tweet.new(:id =>
|
|
337
|
+
describe '#user' do
|
|
338
|
+
it 'returns a User when user is set' do
|
|
339
|
+
tweet = Twitter::Tweet.new(:id => 28_669_546_014, :user => {:id => 7_505_382})
|
|
343
340
|
expect(tweet.user).to be_a Twitter::User
|
|
344
341
|
end
|
|
345
|
-
it
|
|
346
|
-
tweet = Twitter::Tweet.new(:id =>
|
|
342
|
+
it 'returns nil when user is not set' do
|
|
343
|
+
tweet = Twitter::Tweet.new(:id => 28_669_546_014)
|
|
347
344
|
expect(tweet.user).to be_nil
|
|
348
345
|
end
|
|
349
|
-
it
|
|
350
|
-
tweet = Twitter::Tweet.new(:id =>
|
|
346
|
+
it 'has a status is set' do
|
|
347
|
+
tweet = Twitter::Tweet.new(:id => 28_669_546_014, :text => 'Tweet text.', :user => {:id => 7_505_382})
|
|
351
348
|
expect(tweet.user.status).to be_a Twitter::Tweet
|
|
352
|
-
expect(tweet.user.status.id).to eq
|
|
349
|
+
expect(tweet.user.status.id).to eq 28_669_546_014
|
|
353
350
|
end
|
|
354
351
|
end
|
|
355
352
|
|
|
356
|
-
describe
|
|
357
|
-
it
|
|
358
|
-
tweet = Twitter::Tweet.new(:id =>
|
|
353
|
+
describe '#user?' do
|
|
354
|
+
it 'returns true when status is set' do
|
|
355
|
+
tweet = Twitter::Tweet.new(:id => 28_669_546_014, :user => {:id => 7_505_382})
|
|
359
356
|
expect(tweet.user?).to be true
|
|
360
357
|
end
|
|
361
|
-
it
|
|
362
|
-
tweet = Twitter::Tweet.new(:id =>
|
|
358
|
+
it 'returns false when status is not set' do
|
|
359
|
+
tweet = Twitter::Tweet.new(:id => 28_669_546_014)
|
|
363
360
|
expect(tweet.user?).to be false
|
|
364
361
|
end
|
|
365
362
|
end
|
|
366
363
|
|
|
367
|
-
describe
|
|
368
|
-
it
|
|
364
|
+
describe '#user_mentions' do
|
|
365
|
+
it 'returns an array of Entity::UserMention when entities are set' do
|
|
369
366
|
user_mentions_array = [
|
|
370
367
|
{
|
|
371
|
-
:screen_name =>
|
|
372
|
-
:name =>
|
|
373
|
-
:id_str =>
|
|
368
|
+
:screen_name => 'sferik',
|
|
369
|
+
:name => 'Erik Michaels-Ober',
|
|
370
|
+
:id_str => '7_505_382',
|
|
374
371
|
:indices => [0, 6],
|
|
375
|
-
:id =>
|
|
372
|
+
:id => 7_505_382,
|
|
376
373
|
}
|
|
377
374
|
]
|
|
378
|
-
user_mentions = Twitter::Tweet.new(:id =>
|
|
375
|
+
user_mentions = Twitter::Tweet.new(:id => 28_669_546_014, :entities => {:user_mentions => user_mentions_array}).user_mentions
|
|
379
376
|
expect(user_mentions).to be_an Array
|
|
380
377
|
expect(user_mentions.first).to be_a Twitter::Entity::UserMention
|
|
381
378
|
expect(user_mentions.first.indices).to eq([0, 6])
|
|
382
|
-
expect(user_mentions.first.id).to eq(
|
|
379
|
+
expect(user_mentions.first.id).to eq(7_505_382)
|
|
383
380
|
end
|
|
384
|
-
it
|
|
385
|
-
user_mentions = Twitter::Tweet.new(:id =>
|
|
381
|
+
it 'is empty when not set' do
|
|
382
|
+
user_mentions = Twitter::Tweet.new(:id => 28_669_546_014).user_mentions
|
|
386
383
|
expect(user_mentions).to be_empty
|
|
387
384
|
end
|
|
388
|
-
it
|
|
389
|
-
Twitter::Tweet.new(:id =>
|
|
385
|
+
it 'warns when not set' do
|
|
386
|
+
Twitter::Tweet.new(:id => 28_669_546_014).user_mentions
|
|
390
387
|
expect($stderr.string).to match(/To get user mentions, you must pass `:include_entities => true` when requesting the Twitter::Tweet\./)
|
|
391
388
|
end
|
|
392
389
|
end
|