twitter 4.8.1 → 5.0.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/CHANGELOG.md +36 -0
- data/CONTRIBUTING.md +13 -15
- data/LICENSE.md +1 -1
- data/README.md +401 -261
- data/Rakefile +6 -0
- data/lib/twitter/arguments.rb +14 -0
- data/lib/twitter/base.rb +109 -89
- data/lib/twitter/client.rb +38 -115
- data/lib/twitter/configuration.rb +5 -2
- data/lib/twitter/core_ext/kernel.rb +5 -1
- data/lib/twitter/creatable.rb +7 -4
- data/lib/twitter/cursor.rb +57 -45
- data/lib/twitter/direct_message.rb +2 -11
- data/lib/twitter/entity/uri.rb +14 -0
- data/lib/twitter/enumerable.rb +15 -0
- data/lib/twitter/error/already_favorited.rb +1 -1
- data/lib/twitter/error/already_posted.rb +10 -0
- data/lib/twitter/error/already_retweeted.rb +1 -1
- data/lib/twitter/error/bad_gateway.rb +2 -3
- data/lib/twitter/error/bad_request.rb +2 -2
- data/lib/twitter/error/forbidden.rb +2 -2
- data/lib/twitter/error/gateway_timeout.rb +2 -3
- data/lib/twitter/error/internal_server_error.rb +2 -3
- data/lib/twitter/error/not_acceptable.rb +2 -2
- data/lib/twitter/error/not_found.rb +2 -2
- data/lib/twitter/error/service_unavailable.rb +2 -3
- data/lib/twitter/error/too_many_requests.rb +2 -2
- data/lib/twitter/error/unauthorized.rb +2 -2
- data/lib/twitter/error/unprocessable_entity.rb +2 -2
- data/lib/twitter/error.rb +65 -14
- data/lib/twitter/factory.rb +13 -12
- data/lib/twitter/geo.rb +2 -7
- data/lib/twitter/geo_factory.rb +11 -7
- data/lib/twitter/geo_results.rb +40 -0
- data/lib/twitter/identity.rb +4 -34
- data/lib/twitter/list.rb +21 -4
- data/lib/twitter/media/photo.rb +6 -4
- data/lib/twitter/media_factory.rb +11 -7
- data/lib/twitter/null_object.rb +25 -0
- data/lib/twitter/oembed.rb +3 -2
- data/lib/twitter/place.rb +15 -15
- data/lib/twitter/profile_banner.rb +3 -2
- data/lib/twitter/rate_limit.rb +4 -17
- data/lib/twitter/relationship.rb +2 -19
- data/lib/twitter/rest/api/direct_messages.rb +138 -0
- data/lib/twitter/rest/api/favorites.rb +115 -0
- data/lib/twitter/rest/api/friends_and_followers.rb +287 -0
- data/lib/twitter/rest/api/help.rb +58 -0
- data/lib/twitter/rest/api/lists.rb +498 -0
- data/lib/twitter/rest/api/oauth.rb +62 -0
- data/lib/twitter/rest/api/places_and_geo.rb +86 -0
- data/lib/twitter/rest/api/saved_searches.rb +93 -0
- data/lib/twitter/rest/api/search.rb +37 -0
- data/lib/twitter/rest/api/spam_reporting.rb +29 -0
- data/lib/twitter/rest/api/suggested_users.rb +51 -0
- data/lib/twitter/rest/api/timelines.rb +202 -0
- data/lib/twitter/rest/api/trends.rb +58 -0
- data/lib/twitter/rest/api/tweets.rb +291 -0
- data/lib/twitter/rest/api/undocumented.rb +52 -0
- data/lib/twitter/rest/api/users.rb +383 -0
- data/lib/twitter/rest/api/utils.rb +246 -0
- data/lib/twitter/rest/client.rb +175 -0
- data/lib/twitter/rest/request/multipart_with_file.rb +36 -0
- data/lib/twitter/rest/response/parse_error_json.rb +15 -0
- data/lib/twitter/rest/response/parse_json.rb +31 -0
- data/lib/twitter/{response → rest/response}/raise_error.rb +8 -11
- data/lib/twitter/search_results.rb +37 -21
- data/lib/twitter/settings.rb +1 -6
- data/lib/twitter/size.rb +2 -15
- data/lib/twitter/streaming/client.rb +89 -0
- data/lib/twitter/streaming/connection.rb +22 -0
- data/lib/twitter/streaming/event.rb +35 -0
- data/lib/twitter/streaming/friend_list.rb +13 -0
- data/lib/twitter/streaming/message_parser.rb +18 -0
- data/lib/twitter/streaming/response.rb +34 -0
- data/lib/twitter/suggestion.rb +5 -8
- data/lib/twitter/token.rb +11 -1
- data/lib/twitter/trend.rb +4 -8
- data/lib/twitter/trend_results.rb +65 -0
- data/lib/twitter/tweet.rb +43 -92
- data/lib/twitter/user.rb +72 -47
- data/lib/twitter/version.rb +4 -4
- data/lib/twitter.rb +4 -39
- data/spec/fixtures/already_posted.json +1 -0
- data/spec/fixtures/ids_list.json +1 -1
- data/spec/fixtures/ids_list2.json +1 -1
- data/spec/fixtures/request_token.txt +6 -0
- data/spec/fixtures/search.json +1 -1
- data/spec/fixtures/search_malformed.json +1 -1
- data/spec/fixtures/track_streaming.json +3 -0
- data/spec/fixtures/track_streaming_user.json +5 -0
- data/spec/helper.rb +8 -13
- data/spec/twitter/base_spec.rb +13 -103
- data/spec/twitter/basic_user_spec.rb +3 -3
- data/spec/twitter/configuration_spec.rb +1 -1
- data/spec/twitter/cursor_spec.rb +17 -35
- data/spec/twitter/direct_message_spec.rb +44 -11
- data/spec/twitter/entity/uri_spec.rb +75 -0
- data/spec/twitter/error_spec.rb +59 -11
- data/spec/twitter/geo/point_spec.rb +6 -6
- data/spec/twitter/geo/polygon_spec.rb +5 -5
- data/spec/twitter/geo_factory_spec.rb +4 -4
- data/spec/twitter/geo_results_spec.rb +35 -0
- data/spec/twitter/geo_spec.rb +6 -6
- data/spec/twitter/identifiable_spec.rb +5 -26
- data/spec/twitter/list_spec.rb +54 -11
- data/spec/twitter/media/photo_spec.rb +122 -6
- data/spec/twitter/media_factory_spec.rb +3 -3
- data/spec/twitter/null_object_spec.rb +27 -0
- data/spec/twitter/oembed_spec.rb +69 -45
- data/spec/twitter/place_spec.rb +84 -28
- data/spec/twitter/profile_banner_spec.rb +1 -1
- data/spec/twitter/rate_limit_spec.rb +8 -25
- data/spec/twitter/relationship_spec.rb +26 -12
- data/spec/twitter/{api → rest/api}/direct_messages_spec.rb +28 -15
- data/spec/twitter/{api → rest/api}/favorites_spec.rb +80 -7
- data/spec/twitter/{api → rest/api}/friends_and_followers_spec.rb +121 -152
- data/spec/twitter/{api → rest/api}/geo_spec.rb +9 -23
- data/spec/twitter/{api → rest/api}/help_spec.rb +6 -6
- data/spec/twitter/{api → rest/api}/lists_spec.rb +116 -95
- data/spec/twitter/{api → rest/api}/oauth_spec.rb +21 -10
- data/spec/twitter/{api → rest/api}/saved_searches_spec.rb +13 -13
- data/spec/twitter/{api → rest/api}/search_spec.rb +8 -9
- data/spec/twitter/{api → rest/api}/spam_reporting_spec.rb +3 -3
- data/spec/twitter/{api → rest/api}/suggested_users_spec.rb +5 -5
- data/spec/twitter/{api → rest/api}/timelines_spec.rb +9 -9
- data/spec/twitter/{api → rest/api}/trends_spec.rb +6 -6
- data/spec/twitter/rest/api/tweets_spec.rb +503 -0
- data/spec/twitter/{api → rest/api}/undocumented_spec.rb +19 -45
- data/spec/twitter/{api → rest/api}/users_spec.rb +64 -39
- data/spec/twitter/rest/client_spec.rb +193 -0
- data/spec/twitter/saved_search_spec.rb +14 -3
- data/spec/twitter/search_results_spec.rb +32 -45
- data/spec/twitter/settings_spec.rb +17 -6
- data/spec/twitter/size_spec.rb +5 -15
- data/spec/twitter/source_user_spec.rb +3 -3
- data/spec/twitter/streaming/client_spec.rb +92 -0
- data/spec/twitter/streaming/event_spec.rb +45 -0
- data/spec/twitter/suggestion_spec.rb +5 -15
- data/spec/twitter/target_user_spec.rb +3 -3
- data/spec/twitter/token_spec.rb +16 -0
- data/spec/twitter/trend_results_spec.rb +89 -0
- data/spec/twitter/trend_spec.rb +26 -13
- data/spec/twitter/tweet_spec.rb +137 -124
- data/spec/twitter/user_spec.rb +139 -80
- data/spec/twitter_spec.rb +0 -119
- data/twitter.gemspec +12 -6
- data.tar.gz.sig +0 -0
- metadata +197 -138
- metadata.gz.sig +0 -0
- data/lib/twitter/action/favorite.rb +0 -19
- data/lib/twitter/action/follow.rb +0 -30
- data/lib/twitter/action/list_member_added.rb +0 -39
- data/lib/twitter/action/mention.rb +0 -46
- data/lib/twitter/action/reply.rb +0 -27
- data/lib/twitter/action/retweet.rb +0 -27
- data/lib/twitter/action/tweet.rb +0 -20
- data/lib/twitter/action_factory.rb +0 -22
- data/lib/twitter/api/arguments.rb +0 -13
- data/lib/twitter/api/direct_messages.rb +0 -148
- data/lib/twitter/api/favorites.rb +0 -126
- data/lib/twitter/api/friends_and_followers.rb +0 -334
- data/lib/twitter/api/help.rb +0 -64
- data/lib/twitter/api/lists.rb +0 -618
- data/lib/twitter/api/oauth.rb +0 -44
- data/lib/twitter/api/places_and_geo.rb +0 -121
- data/lib/twitter/api/saved_searches.rb +0 -99
- data/lib/twitter/api/search.rb +0 -37
- data/lib/twitter/api/spam_reporting.rb +0 -30
- data/lib/twitter/api/suggested_users.rb +0 -55
- data/lib/twitter/api/timelines.rb +0 -214
- data/lib/twitter/api/trends.rb +0 -63
- data/lib/twitter/api/tweets.rb +0 -304
- data/lib/twitter/api/undocumented.rb +0 -97
- data/lib/twitter/api/users.rb +0 -439
- data/lib/twitter/api/utils.rb +0 -187
- data/lib/twitter/configurable.rb +0 -96
- data/lib/twitter/default.rb +0 -102
- data/lib/twitter/entity/url.rb +0 -9
- data/lib/twitter/error/client_error.rb +0 -35
- data/lib/twitter/error/decode_error.rb +0 -9
- data/lib/twitter/error/identity_map_key_error.rb +0 -9
- data/lib/twitter/error/server_error.rb +0 -28
- data/lib/twitter/exceptable.rb +0 -36
- data/lib/twitter/identity_map.rb +0 -22
- data/lib/twitter/request/multipart_with_file.rb +0 -34
- data/lib/twitter/response/parse_json.rb +0 -25
- data/spec/fixtures/about_me.json +0 -1
- data/spec/fixtures/activity_summary.json +0 -1
- data/spec/fixtures/bad_gateway.json +0 -1
- data/spec/fixtures/bad_request.json +0 -1
- data/spec/fixtures/by_friends.json +0 -1
- data/spec/fixtures/end_session.json +0 -1
- data/spec/fixtures/forbidden.json +0 -1
- data/spec/fixtures/internal_server_error.json +0 -1
- data/spec/fixtures/not_acceptable.json +0 -1
- data/spec/fixtures/phoenix_search.phoenix +0 -1
- data/spec/fixtures/resolve.json +0 -1
- data/spec/fixtures/service_unavailable.json +0 -1
- data/spec/fixtures/totals.json +0 -1
- data/spec/fixtures/trends.json +0 -1
- data/spec/fixtures/unauthorized.json +0 -1
- data/spec/fixtures/video_facets.json +0 -1
- data/spec/twitter/action/favorite_spec.rb +0 -29
- data/spec/twitter/action/follow_spec.rb +0 -29
- data/spec/twitter/action/list_member_added_spec.rb +0 -41
- data/spec/twitter/action/mention_spec.rb +0 -52
- data/spec/twitter/action/reply_spec.rb +0 -41
- data/spec/twitter/action/retweet_spec.rb +0 -41
- data/spec/twitter/action_factory_spec.rb +0 -35
- data/spec/twitter/action_spec.rb +0 -16
- data/spec/twitter/api/tweets_spec.rb +0 -285
- data/spec/twitter/client_spec.rb +0 -223
- data/spec/twitter/error/client_error_spec.rb +0 -23
- data/spec/twitter/error/server_error_spec.rb +0 -20
data/spec/twitter/tweet_spec.rb
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# coding: utf-8
|
|
1
2
|
require 'helper'
|
|
2
3
|
|
|
3
4
|
describe Twitter::Tweet do
|
|
@@ -15,17 +16,17 @@ describe Twitter::Tweet do
|
|
|
15
16
|
it "returns true when objects IDs are the same" do
|
|
16
17
|
tweet = Twitter::Tweet.new(:id => 1, :text => "foo")
|
|
17
18
|
other = Twitter::Tweet.new(:id => 1, :text => "bar")
|
|
18
|
-
expect(tweet == other).to
|
|
19
|
+
expect(tweet == other).to be true
|
|
19
20
|
end
|
|
20
21
|
it "returns false when objects IDs are different" do
|
|
21
22
|
tweet = Twitter::Tweet.new(:id => 1)
|
|
22
23
|
other = Twitter::Tweet.new(:id => 2)
|
|
23
|
-
expect(tweet == other).to
|
|
24
|
+
expect(tweet == other).to be false
|
|
24
25
|
end
|
|
25
26
|
it "returns false when classes are different" do
|
|
26
27
|
tweet = Twitter::Tweet.new(:id => 1)
|
|
27
28
|
other = Twitter::Identity.new(:id => 1)
|
|
28
|
-
expect(tweet == other).to
|
|
29
|
+
expect(tweet == other).to be false
|
|
29
30
|
end
|
|
30
31
|
end
|
|
31
32
|
|
|
@@ -40,82 +41,69 @@ describe Twitter::Tweet do
|
|
|
40
41
|
end
|
|
41
42
|
end
|
|
42
43
|
|
|
44
|
+
describe "#created?" do
|
|
45
|
+
it "returns true when created_at is set" do
|
|
46
|
+
tweet = Twitter::Tweet.new(:id => 28669546014, :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 => 28669546014)
|
|
51
|
+
expect(tweet.created?).to be false
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
43
55
|
describe "#entities?" do
|
|
44
56
|
it "returns false if there are no entities set" do
|
|
45
57
|
tweet = Twitter::Tweet.new(:id => 28669546014)
|
|
46
|
-
expect(tweet.entities?).to
|
|
58
|
+
expect(tweet.entities?).to be false
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
it "returns false if there are blank lists of entities set" do
|
|
62
|
+
tweet = Twitter::Tweet.new(:id => 28669546014, :entities => {:urls => []})
|
|
63
|
+
expect(tweet.entities?).to be false
|
|
47
64
|
end
|
|
48
65
|
|
|
49
66
|
it "returns true if there are entities set" do
|
|
50
67
|
urls_array = [
|
|
51
68
|
{
|
|
52
|
-
:url =>
|
|
53
|
-
:expanded_url =>
|
|
54
|
-
:display_url =>
|
|
69
|
+
:url => "http://example.com/t.co",
|
|
70
|
+
:expanded_url => "http://example.com/expanded",
|
|
71
|
+
:display_url => "example.com/expanded…",
|
|
55
72
|
:indices => [10, 33],
|
|
56
73
|
}
|
|
57
74
|
]
|
|
58
75
|
tweet = Twitter::Tweet.new(:id => 28669546014, :entities => {:urls => urls_array})
|
|
59
|
-
expect(tweet.entities?).to
|
|
60
|
-
end
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
describe "#favoriters_count" do
|
|
64
|
-
it "returns the count of favoriters when favoriters_count is set" do
|
|
65
|
-
tweet = Twitter::Tweet.new(:id => 28669546014, :favoriters_count => '1')
|
|
66
|
-
expect(tweet.favoriters_count).to be_an Integer
|
|
67
|
-
expect(tweet.favoriters_count).to eq 1
|
|
68
|
-
end
|
|
69
|
-
it "returns nil when not set" do
|
|
70
|
-
tweet = Twitter::Tweet.new(:id => 28669546014)
|
|
71
|
-
expect(tweet.favoriters_count).to be_nil
|
|
72
|
-
end
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
describe "#from_user" do
|
|
76
|
-
it "returns a screen name when from_user is set" do
|
|
77
|
-
tweet = Twitter::Tweet.new(:id => 28669546014, :from_user => 'sferik')
|
|
78
|
-
expect(tweet.from_user).to be_a String
|
|
79
|
-
expect(tweet.from_user).to eq "sferik"
|
|
80
|
-
end
|
|
81
|
-
it "returns a screen name when screen_name is set" do
|
|
82
|
-
tweet = Twitter::Tweet.new(:id => 28669546014, :user => {:id => 7505382, :screen_name => 'sferik'})
|
|
83
|
-
expect(tweet.from_user).to be_a String
|
|
84
|
-
expect(tweet.from_user).to eq "sferik"
|
|
85
|
-
end
|
|
86
|
-
it "returns nil when not set" do
|
|
87
|
-
tweet = Twitter::Tweet.new(:id => 28669546014)
|
|
88
|
-
expect(tweet.from_user).to be_nil
|
|
76
|
+
expect(tweet.entities?).to be true
|
|
89
77
|
end
|
|
90
78
|
end
|
|
91
79
|
|
|
92
80
|
describe "#filter_level" do
|
|
93
81
|
it "returns the filter level when filter_level is set" do
|
|
94
|
-
tweet = Twitter::Tweet.new(:id => 28669546014, :filter_level =>
|
|
82
|
+
tweet = Twitter::Tweet.new(:id => 28669546014, :filter_level => "high")
|
|
95
83
|
expect(tweet.filter_level).to be_a String
|
|
96
|
-
expect(tweet.filter_level).to eq
|
|
84
|
+
expect(tweet.filter_level).to eq("high")
|
|
97
85
|
end
|
|
98
86
|
it "returns \"none\" when not set" do
|
|
99
87
|
tweet = Twitter::Tweet.new(:id => 28669546014)
|
|
100
|
-
expect(tweet.filter_level).to eq
|
|
88
|
+
expect(tweet.filter_level).to eq("none")
|
|
101
89
|
end
|
|
102
90
|
end
|
|
103
91
|
|
|
104
92
|
describe "#full_text" do
|
|
105
93
|
it "returns the text of a Tweet" do
|
|
106
|
-
tweet = Twitter::Tweet.new(:id => 28669546014, :text =>
|
|
94
|
+
tweet = Twitter::Tweet.new(:id => 28669546014, :text => "BOOSH")
|
|
107
95
|
expect(tweet.full_text).to be_a String
|
|
108
|
-
expect(tweet.full_text).to eq
|
|
96
|
+
expect(tweet.full_text).to eq("BOOSH")
|
|
109
97
|
end
|
|
110
98
|
it "returns the text of a Tweet without a user" do
|
|
111
|
-
tweet = Twitter::Tweet.new(:id => 28669546014, :text =>
|
|
99
|
+
tweet = Twitter::Tweet.new(:id => 28669546014, :text => "BOOSH", :retweeted_status => {:id => 28561922517, :text => "BOOSH"})
|
|
112
100
|
expect(tweet.full_text).to be_a String
|
|
113
|
-
expect(tweet.full_text).to eq
|
|
101
|
+
expect(tweet.full_text).to eq("BOOSH")
|
|
114
102
|
end
|
|
115
103
|
it "returns the full text of a retweeted Tweet" do
|
|
116
|
-
tweet = Twitter::Tweet.new(:id => 28669546014, :text =>
|
|
104
|
+
tweet = Twitter::Tweet.new(:id => 28669546014, :text => "RT @sferik: BOOSH", :retweeted_status => {:id => 25938088801, :text => "BOOSH"})
|
|
117
105
|
expect(tweet.full_text).to be_a String
|
|
118
|
-
expect(tweet.full_text).to eq
|
|
106
|
+
expect(tweet.full_text).to eq("RT @sferik: BOOSH")
|
|
119
107
|
end
|
|
120
108
|
it "returns nil when retweeted_status is not set" do
|
|
121
109
|
tweet = Twitter::Tweet.new(:id => 28669546014)
|
|
@@ -124,29 +112,40 @@ describe Twitter::Tweet do
|
|
|
124
112
|
end
|
|
125
113
|
|
|
126
114
|
describe "#geo" do
|
|
127
|
-
it "returns a Twitter::Geo::Point when set" do
|
|
128
|
-
tweet = Twitter::Tweet.new(:id => 28669546014, :geo => {:id => 1, :type =>
|
|
115
|
+
it "returns a Twitter::Geo::Point when geo is set" do
|
|
116
|
+
tweet = Twitter::Tweet.new(:id => 28669546014, :geo => {:id => 1, :type => "Point"})
|
|
129
117
|
expect(tweet.geo).to be_a Twitter::Geo::Point
|
|
130
118
|
end
|
|
131
|
-
it "returns nil when not set" do
|
|
119
|
+
it "returns nil when geo is not set" do
|
|
132
120
|
tweet = Twitter::Tweet.new(:id => 28669546014)
|
|
133
121
|
expect(tweet.geo).to be_nil
|
|
134
122
|
end
|
|
135
123
|
end
|
|
136
124
|
|
|
125
|
+
describe "#geo?" do
|
|
126
|
+
it "returns true when geo is set" do
|
|
127
|
+
tweet = Twitter::Tweet.new(:id => 28669546014, :geo => {:id => 1, :type => "Point"})
|
|
128
|
+
expect(tweet.geo?).to be true
|
|
129
|
+
end
|
|
130
|
+
it "returns false when geo is not set" do
|
|
131
|
+
tweet = Twitter::Tweet.new(:id => 28669546014)
|
|
132
|
+
expect(tweet.geo?).to be false
|
|
133
|
+
end
|
|
134
|
+
end
|
|
135
|
+
|
|
137
136
|
describe "#hashtags" do
|
|
138
|
-
it "returns an
|
|
137
|
+
it "returns an array of Entity::Hashtag when entities are set" do
|
|
139
138
|
hashtags_array = [
|
|
140
139
|
{
|
|
141
|
-
:text =>
|
|
140
|
+
:text => "twitter",
|
|
142
141
|
:indices => [10, 33],
|
|
143
142
|
}
|
|
144
143
|
]
|
|
145
144
|
hashtags = Twitter::Tweet.new(:id => 28669546014, :entities => {:hashtags => hashtags_array}).hashtags
|
|
146
145
|
expect(hashtags).to be_an Array
|
|
147
146
|
expect(hashtags.first).to be_a Twitter::Entity::Hashtag
|
|
148
|
-
expect(hashtags.first.indices).to eq
|
|
149
|
-
expect(hashtags.first.text).to eq
|
|
147
|
+
expect(hashtags.first.indices).to eq([10, 33])
|
|
148
|
+
expect(hashtags.first.text).to eq("twitter")
|
|
150
149
|
end
|
|
151
150
|
it "is empty when not set" do
|
|
152
151
|
hashtags = Twitter::Tweet.new(:id => 28669546014).hashtags
|
|
@@ -160,7 +159,7 @@ describe Twitter::Tweet do
|
|
|
160
159
|
|
|
161
160
|
describe "#media" do
|
|
162
161
|
it "returns media" do
|
|
163
|
-
media = Twitter::Tweet.new(:id => 28669546014, :entities => {:media => [{:id => 1, :type =>
|
|
162
|
+
media = Twitter::Tweet.new(:id => 28669546014, :entities => {:media => [{:id => 1, :type => "photo"}]}).media
|
|
164
163
|
expect(media).to be_an Array
|
|
165
164
|
expect(media.first).to be_a Twitter::Media::Photo
|
|
166
165
|
end
|
|
@@ -175,66 +174,76 @@ describe Twitter::Tweet do
|
|
|
175
174
|
end
|
|
176
175
|
|
|
177
176
|
describe "#metadata" do
|
|
178
|
-
it "returns a
|
|
179
|
-
|
|
180
|
-
expect(metadata).to be_a Twitter::Metadata
|
|
177
|
+
it "returns a Twitter::Metadata when metadata is set" do
|
|
178
|
+
tweet = Twitter::Tweet.new(:id => 28669546014, :metadata => {})
|
|
179
|
+
expect(tweet.metadata).to be_a Twitter::Metadata
|
|
181
180
|
end
|
|
182
|
-
it "returns nil when
|
|
183
|
-
|
|
184
|
-
expect(metadata).to be_nil
|
|
181
|
+
it "returns nil when metadata is not set" do
|
|
182
|
+
tweet = Twitter::Tweet.new(:id => 28669546014)
|
|
183
|
+
expect(tweet.metadata).to be_nil
|
|
184
|
+
end
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
describe "#metadata?" do
|
|
188
|
+
it "returns true when metadata is set" do
|
|
189
|
+
tweet = Twitter::Tweet.new(:id => 28669546014, :metadata => {})
|
|
190
|
+
expect(tweet.metadata?).to be true
|
|
191
|
+
end
|
|
192
|
+
it "returns false when metadata is not set" do
|
|
193
|
+
tweet = Twitter::Tweet.new(:id => 28669546014)
|
|
194
|
+
expect(tweet.metadata?).to be false
|
|
185
195
|
end
|
|
186
196
|
end
|
|
187
197
|
|
|
188
198
|
describe "#place" do
|
|
189
|
-
it "returns a Twitter::Place when set" do
|
|
199
|
+
it "returns a Twitter::Place when place is set" do
|
|
190
200
|
tweet = Twitter::Tweet.new(:id => 28669546014, :place => {:id => "247f43d441defc03"})
|
|
191
201
|
expect(tweet.place).to be_a Twitter::Place
|
|
192
202
|
end
|
|
193
|
-
it "returns nil when not set" do
|
|
203
|
+
it "returns nil when place is not set" do
|
|
194
204
|
tweet = Twitter::Tweet.new(:id => 28669546014)
|
|
195
205
|
expect(tweet.place).to be_nil
|
|
196
206
|
end
|
|
197
207
|
end
|
|
198
208
|
|
|
199
|
-
describe "#
|
|
200
|
-
it "returns
|
|
201
|
-
tweet = Twitter::Tweet.new(:id => 28669546014, :
|
|
202
|
-
expect(tweet.
|
|
203
|
-
expect(tweet.repliers_count).to eq 1
|
|
209
|
+
describe "#place?" do
|
|
210
|
+
it "returns true when place is set" do
|
|
211
|
+
tweet = Twitter::Tweet.new(:id => 28669546014, :place => {:id => "247f43d441defc03"})
|
|
212
|
+
expect(tweet.place?).to be true
|
|
204
213
|
end
|
|
205
|
-
it "returns
|
|
214
|
+
it "returns false when place is not set" do
|
|
206
215
|
tweet = Twitter::Tweet.new(:id => 28669546014)
|
|
207
|
-
expect(tweet.
|
|
216
|
+
expect(tweet.place?).to be false
|
|
208
217
|
end
|
|
209
218
|
end
|
|
210
219
|
|
|
211
220
|
describe "#reply?" do
|
|
212
221
|
it "returns true when there is an in-reply-to status" do
|
|
213
222
|
tweet = Twitter::Tweet.new(:id => 28669546014, :in_reply_to_status_id => 114749583439036416)
|
|
214
|
-
expect(tweet.reply?).to
|
|
223
|
+
expect(tweet.reply?).to be true
|
|
215
224
|
end
|
|
216
225
|
it "returns false when in_reply_to_status_id is not set" do
|
|
217
226
|
tweet = Twitter::Tweet.new(:id => 28669546014)
|
|
218
|
-
expect(tweet.reply?).to
|
|
227
|
+
expect(tweet.reply?).to be false
|
|
219
228
|
end
|
|
220
229
|
end
|
|
221
230
|
|
|
222
231
|
describe "#retweet?" do
|
|
223
232
|
it "returns true when there is a retweeted status" do
|
|
224
|
-
tweet = Twitter::Tweet.new(:id => 28669546014, :retweeted_status => {:id =>
|
|
225
|
-
expect(tweet.retweet?).to
|
|
233
|
+
tweet = Twitter::Tweet.new(:id => 28669546014, :retweeted_status => {:id => 25938088801, :text => "BOOSH"})
|
|
234
|
+
expect(tweet.retweet?).to be true
|
|
226
235
|
end
|
|
227
236
|
it "returns false when retweeted_status is not set" do
|
|
228
237
|
tweet = Twitter::Tweet.new(:id => 28669546014)
|
|
229
|
-
expect(tweet.retweet?).to
|
|
238
|
+
expect(tweet.retweet?).to be false
|
|
230
239
|
end
|
|
231
240
|
end
|
|
232
241
|
|
|
233
242
|
describe "#retweeted_status" do
|
|
234
|
-
it "
|
|
235
|
-
tweet = Twitter::Tweet.new(:id => 28669546014, :retweeted_status => {:id =>
|
|
243
|
+
it "returns a Tweet when retweeted_status is set" do
|
|
244
|
+
tweet = Twitter::Tweet.new(:id => 28669546014, :retweeted_status => {:id => 25938088801, :text => "BOOSH"})
|
|
236
245
|
expect(tweet.retweeted_tweet).to be_a Twitter::Tweet
|
|
237
|
-
expect(tweet.retweeted_tweet.text).to eq
|
|
246
|
+
expect(tweet.retweeted_tweet.text).to eq("BOOSH")
|
|
238
247
|
end
|
|
239
248
|
it "returns nil when retweeted_status is not set" do
|
|
240
249
|
tweet = Twitter::Tweet.new(:id => 28669546014)
|
|
@@ -242,35 +251,29 @@ describe Twitter::Tweet do
|
|
|
242
251
|
end
|
|
243
252
|
end
|
|
244
253
|
|
|
245
|
-
describe "#
|
|
246
|
-
it "returns
|
|
247
|
-
tweet = Twitter::Tweet.new(:id => 28669546014, :
|
|
248
|
-
expect(tweet.
|
|
249
|
-
expect(tweet.retweeters_count).to eq 1
|
|
250
|
-
end
|
|
251
|
-
it "returns the count of favoriters when retweeters_count is set" do
|
|
252
|
-
tweet = Twitter::Tweet.new(:id => 28669546014, :retweeters_count => '1')
|
|
253
|
-
expect(tweet.retweeters_count).to be_an Integer
|
|
254
|
-
expect(tweet.retweeters_count).to eq 1
|
|
254
|
+
describe "#retweeted_status?" do
|
|
255
|
+
it "returns true when retweeted_status is set" do
|
|
256
|
+
tweet = Twitter::Tweet.new(:id => 28669546014, :retweeted_status => {:id => 25938088801, :text => "BOOSH"})
|
|
257
|
+
expect(tweet.retweeted_status?).to be true
|
|
255
258
|
end
|
|
256
|
-
it "returns
|
|
259
|
+
it "returns false when retweeted_status is not set" do
|
|
257
260
|
tweet = Twitter::Tweet.new(:id => 28669546014)
|
|
258
|
-
expect(tweet.
|
|
261
|
+
expect(tweet.retweeted_status?).to be false
|
|
259
262
|
end
|
|
260
263
|
end
|
|
261
264
|
|
|
262
265
|
describe "#symbols" do
|
|
263
|
-
it "returns an
|
|
266
|
+
it "returns an array of Entity::Symbol when symbols are set" do
|
|
264
267
|
symbols_array = [
|
|
265
|
-
{ :text =>
|
|
266
|
-
{ :text =>
|
|
268
|
+
{ :text => "PEP", :indices => [114, 118] },
|
|
269
|
+
{ :text => "COKE", :indices => [128, 133] }
|
|
267
270
|
]
|
|
268
271
|
symbols = Twitter::Tweet.new(:id => 28669546014, :entities => {:symbols => symbols_array}).symbols
|
|
269
272
|
expect(symbols).to be_an Array
|
|
270
|
-
expect(symbols.size).to eq
|
|
273
|
+
expect(symbols.size).to eq(2)
|
|
271
274
|
expect(symbols.first).to be_a Twitter::Entity::Symbol
|
|
272
|
-
expect(symbols.first.indices).to eq
|
|
273
|
-
expect(symbols.first.text).to eq
|
|
275
|
+
expect(symbols.first.indices).to eq([114, 118])
|
|
276
|
+
expect(symbols.first.text).to eq("PEP")
|
|
274
277
|
end
|
|
275
278
|
it "is empty when not set" do
|
|
276
279
|
symbols = Twitter::Tweet.new(:id => 28669546014).symbols
|
|
@@ -282,25 +285,26 @@ describe Twitter::Tweet do
|
|
|
282
285
|
end
|
|
283
286
|
end
|
|
284
287
|
|
|
285
|
-
describe "#
|
|
286
|
-
it "returns an
|
|
288
|
+
describe "#uris" do
|
|
289
|
+
it "returns an array of Entity::URIs when entities are set" do
|
|
287
290
|
urls_array = [
|
|
288
291
|
{
|
|
289
|
-
:url =>
|
|
290
|
-
:expanded_url =>
|
|
291
|
-
:display_url =>
|
|
292
|
+
:url => "http://example.com/t.co",
|
|
293
|
+
:expanded_url => "http://example.com/expanded",
|
|
294
|
+
:display_url => "example.com/expanded…",
|
|
292
295
|
:indices => [10, 33],
|
|
293
296
|
}
|
|
294
297
|
]
|
|
295
|
-
|
|
296
|
-
expect(
|
|
297
|
-
expect(
|
|
298
|
-
expect(
|
|
299
|
-
expect(
|
|
298
|
+
tweet = Twitter::Tweet.new(:id => 28669546014, :entities => {:urls => urls_array})
|
|
299
|
+
expect(tweet.uris).to be_an Array
|
|
300
|
+
expect(tweet.uris.first).to be_a Twitter::Entity::URI
|
|
301
|
+
expect(tweet.uris.first.indices).to eq([10, 33])
|
|
302
|
+
expect(tweet.uris.first.display_uri).to be_a String
|
|
303
|
+
expect(tweet.uris.first.display_uri).to eq("example.com/expanded…")
|
|
300
304
|
end
|
|
301
305
|
it "is empty when not set" do
|
|
302
|
-
|
|
303
|
-
expect(
|
|
306
|
+
tweet = Twitter::Tweet.new(:id => 28669546014)
|
|
307
|
+
expect(tweet.uris).to be_empty
|
|
304
308
|
end
|
|
305
309
|
it "warns when not set" do
|
|
306
310
|
Twitter::Tweet.new(:id => 28669546014).urls
|
|
@@ -308,39 +312,48 @@ describe Twitter::Tweet do
|
|
|
308
312
|
end
|
|
309
313
|
end
|
|
310
314
|
|
|
315
|
+
describe "#uri" do
|
|
316
|
+
it "returns the URI to the tweet" do
|
|
317
|
+
tweet = Twitter::Tweet.new(:id => 28669546014, :user => {:id => 7505382, :screen_name => "sferik"})
|
|
318
|
+
expect(tweet.uri).to be_a URI
|
|
319
|
+
expect(tweet.uri.to_s).to eq("https://twitter.com/sferik/status/28669546014")
|
|
320
|
+
end
|
|
321
|
+
end
|
|
322
|
+
|
|
311
323
|
describe "#user" do
|
|
312
324
|
it "returns a User when user is set" do
|
|
313
|
-
|
|
314
|
-
expect(user).to be_a Twitter::User
|
|
325
|
+
tweet = Twitter::Tweet.new(:id => 28669546014, :user => {:id => 7505382})
|
|
326
|
+
expect(tweet.user).to be_a Twitter::User
|
|
315
327
|
end
|
|
316
328
|
it "returns nil when user is not set" do
|
|
317
|
-
|
|
318
|
-
expect(user).to be_nil
|
|
329
|
+
tweet = Twitter::Tweet.new(:id => 28669546014)
|
|
330
|
+
expect(tweet.user).to be_nil
|
|
319
331
|
end
|
|
320
|
-
it "has a status
|
|
321
|
-
|
|
322
|
-
expect(user.status).to be_a Twitter::Tweet
|
|
332
|
+
it "has a status is set" do
|
|
333
|
+
tweet = Twitter::Tweet.new(:id => 28669546014, :text => "Tweet text.", :user => {:id => 7505382})
|
|
334
|
+
expect(tweet.user.status).to be_a Twitter::Tweet
|
|
335
|
+
expect(tweet.user.status.id).to eq 28669546014
|
|
323
336
|
end
|
|
324
337
|
end
|
|
325
338
|
|
|
326
339
|
describe "#user?" do
|
|
327
340
|
it "returns true when status is set" do
|
|
328
|
-
|
|
329
|
-
expect(user).to
|
|
341
|
+
tweet = Twitter::Tweet.new(:id => 28669546014, :user => {:id => 7505382})
|
|
342
|
+
expect(tweet.user?).to be true
|
|
330
343
|
end
|
|
331
344
|
it "returns false when status is not set" do
|
|
332
|
-
|
|
333
|
-
expect(user).to
|
|
345
|
+
tweet = Twitter::Tweet.new(:id => 28669546014)
|
|
346
|
+
expect(tweet.user?).to be false
|
|
334
347
|
end
|
|
335
348
|
end
|
|
336
349
|
|
|
337
350
|
describe "#user_mentions" do
|
|
338
|
-
it "returns an
|
|
351
|
+
it "returns an array of Entity::UserMention when entities are set" do
|
|
339
352
|
user_mentions_array = [
|
|
340
353
|
{
|
|
341
|
-
:screen_name =>
|
|
342
|
-
:name =>
|
|
343
|
-
:id_str =>
|
|
354
|
+
:screen_name => "sferik",
|
|
355
|
+
:name => "Erik Michaels-Ober",
|
|
356
|
+
:id_str => "7505382",
|
|
344
357
|
:indices => [0, 6],
|
|
345
358
|
:id => 7505382,
|
|
346
359
|
}
|
|
@@ -348,8 +361,8 @@ describe Twitter::Tweet do
|
|
|
348
361
|
user_mentions = Twitter::Tweet.new(:id => 28669546014, :entities => {:user_mentions => user_mentions_array}).user_mentions
|
|
349
362
|
expect(user_mentions).to be_an Array
|
|
350
363
|
expect(user_mentions.first).to be_a Twitter::Entity::UserMention
|
|
351
|
-
expect(user_mentions.first.indices).to eq
|
|
352
|
-
expect(user_mentions.first.id).to eq
|
|
364
|
+
expect(user_mentions.first.indices).to eq([0, 6])
|
|
365
|
+
expect(user_mentions.first.id).to eq(7505382)
|
|
353
366
|
end
|
|
354
367
|
it "is empty when not set" do
|
|
355
368
|
user_mentions = Twitter::Tweet.new(:id => 28669546014).user_mentions
|