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
|
@@ -2,15 +2,21 @@ require 'helper'
|
|
|
2
2
|
|
|
3
3
|
describe Twitter::SearchResults do
|
|
4
4
|
|
|
5
|
-
describe "#
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
5
|
+
describe "#each" do
|
|
6
|
+
before do
|
|
7
|
+
@search_results = Twitter::SearchResults.new(:statuses => [{:id => 1}, {:id => 2}, {:id => 3}, {:id => 4}, {:id => 5}, {:id => 6}])
|
|
8
|
+
end
|
|
9
|
+
it "iterates" do
|
|
10
|
+
count = 0
|
|
11
|
+
@search_results.each{count += 1}
|
|
12
|
+
expect(count).to eq(6)
|
|
13
|
+
end
|
|
14
|
+
context "with start" do
|
|
15
|
+
it "iterates" do
|
|
16
|
+
count = 0
|
|
17
|
+
@search_results.each(5){count += 1}
|
|
18
|
+
expect(count).to eq(1)
|
|
19
|
+
end
|
|
14
20
|
end
|
|
15
21
|
end
|
|
16
22
|
|
|
@@ -18,7 +24,7 @@ describe Twitter::SearchResults do
|
|
|
18
24
|
it "returns a number of seconds" do
|
|
19
25
|
completed_in = Twitter::SearchResults.new(:search_metadata => {:completed_in => 0.029}).completed_in
|
|
20
26
|
expect(completed_in).to be_a Float
|
|
21
|
-
expect(completed_in).to eq
|
|
27
|
+
expect(completed_in).to eq(0.029)
|
|
22
28
|
end
|
|
23
29
|
it "is nil when not set" do
|
|
24
30
|
completed_in = Twitter::SearchResults.new.completed_in
|
|
@@ -30,7 +36,7 @@ describe Twitter::SearchResults do
|
|
|
30
36
|
it "returns an ID" do
|
|
31
37
|
max_id = Twitter::SearchResults.new(:search_metadata => {:max_id => 250126199840518145}).max_id
|
|
32
38
|
expect(max_id).to be_an Integer
|
|
33
|
-
expect(max_id).to eq
|
|
39
|
+
expect(max_id).to eq(250126199840518145)
|
|
34
40
|
end
|
|
35
41
|
it "is nil when not set" do
|
|
36
42
|
max_id = Twitter::SearchResults.new.max_id
|
|
@@ -42,7 +48,7 @@ describe Twitter::SearchResults do
|
|
|
42
48
|
it "returns page number" do
|
|
43
49
|
page = Twitter::SearchResults.new(:search_metadata => {:page => 1}).page
|
|
44
50
|
expect(page).to be_an Integer
|
|
45
|
-
expect(page).to eq
|
|
51
|
+
expect(page).to eq(1)
|
|
46
52
|
end
|
|
47
53
|
it "is nil when not set" do
|
|
48
54
|
page = Twitter::SearchResults.new.page
|
|
@@ -54,7 +60,7 @@ describe Twitter::SearchResults do
|
|
|
54
60
|
it "returns the query" do
|
|
55
61
|
query = Twitter::SearchResults.new(:search_metadata => {:query => "%23freebandnames"}).query
|
|
56
62
|
expect(query).to be_a String
|
|
57
|
-
expect(query).to eq
|
|
63
|
+
expect(query).to eq("%23freebandnames")
|
|
58
64
|
end
|
|
59
65
|
it "is nil when not set" do
|
|
60
66
|
query = Twitter::SearchResults.new.query
|
|
@@ -64,9 +70,9 @@ describe Twitter::SearchResults do
|
|
|
64
70
|
|
|
65
71
|
describe "#results_per_page" do
|
|
66
72
|
it "returns the number of results per page" do
|
|
67
|
-
results_per_page = Twitter::SearchResults.new(:search_metadata => {:
|
|
73
|
+
results_per_page = Twitter::SearchResults.new(:search_metadata => {:count => 4}).results_per_page
|
|
68
74
|
expect(results_per_page).to be_an Integer
|
|
69
|
-
expect(results_per_page).to eq
|
|
75
|
+
expect(results_per_page).to eq(4)
|
|
70
76
|
end
|
|
71
77
|
it "is nil when not set" do
|
|
72
78
|
results_per_page = Twitter::SearchResults.new.results_per_page
|
|
@@ -74,22 +80,11 @@ describe Twitter::SearchResults do
|
|
|
74
80
|
end
|
|
75
81
|
end
|
|
76
82
|
|
|
77
|
-
describe "#search_metadata?" do
|
|
78
|
-
it "returns true when search_metadata is set" do
|
|
79
|
-
search_metadata = Twitter::SearchResults.new(:search_metadata => {}).search_metadata?
|
|
80
|
-
expect(search_metadata).to be_true
|
|
81
|
-
end
|
|
82
|
-
it "returns false when search_metadata is not set" do
|
|
83
|
-
search_metadata = Twitter::SearchResults.new.search_metadata?
|
|
84
|
-
expect(search_metadata).to be_false
|
|
85
|
-
end
|
|
86
|
-
end
|
|
87
|
-
|
|
88
83
|
describe "#since_id" do
|
|
89
84
|
it "returns an ID" do
|
|
90
85
|
since_id = Twitter::SearchResults.new(:search_metadata => {:since_id => 250126199840518145}).since_id
|
|
91
86
|
expect(since_id).to be_an Integer
|
|
92
|
-
expect(since_id).to eq
|
|
87
|
+
expect(since_id).to eq(250126199840518145)
|
|
93
88
|
end
|
|
94
89
|
it "is nil when not set" do
|
|
95
90
|
since_id = Twitter::SearchResults.new.since_id
|
|
@@ -100,39 +95,31 @@ describe Twitter::SearchResults do
|
|
|
100
95
|
describe "#next_results?" do
|
|
101
96
|
it "returns true when next_results is set" do
|
|
102
97
|
next_results = Twitter::SearchResults.new(:search_metadata => {:next_results => "?"}).next_results?
|
|
103
|
-
expect(next_results).to
|
|
98
|
+
expect(next_results).to be true
|
|
104
99
|
end
|
|
105
100
|
it "returns false when next_results is not set" do
|
|
106
101
|
next_results = Twitter::SearchResults.new(:search_metadata => {}).next_results?
|
|
107
|
-
expect(next_results).to
|
|
102
|
+
expect(next_results).to be false
|
|
108
103
|
end
|
|
109
104
|
it "returns false is search_metadata is not set" do
|
|
110
105
|
next_results = Twitter::SearchResults.new().next_results?
|
|
111
|
-
expect(next_results).to
|
|
106
|
+
expect(next_results).to be false
|
|
112
107
|
end
|
|
113
108
|
end
|
|
114
109
|
|
|
115
110
|
describe "#next_results" do
|
|
116
|
-
let(:next_results) {Twitter::SearchResults.new(:search_metadata => {:next_results => "?max_id=249279667666817023&q=%23freebandnames&count=4&include_entities=1&result_type=mixed"}).next_results}
|
|
117
|
-
|
|
118
111
|
it "returns a hash of query parameters" do
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
it "returns a max_id" do
|
|
123
|
-
expect(next_results[:max_id]).to eq "249279667666817023"
|
|
112
|
+
search_results = Twitter::SearchResults.new(:search_metadata => {:next_results => "?max_id=249279667666817023&q=%23freebandnames&count=4&include_entities=1&result_type=mixed"})
|
|
113
|
+
expect(search_results.next_results).to be_a Hash
|
|
114
|
+
expect(search_results.next_results[:max_id]).to eq("249279667666817023")
|
|
124
115
|
end
|
|
125
116
|
end
|
|
126
117
|
|
|
127
|
-
describe "#
|
|
128
|
-
let(:refresh_url) {Twitter::SearchResults.new(:search_metadata => {:refresh_url => "?since_id=249279667666817023&q=%23freebandnames&count=4&include_entities=1&result_type=recent"}).refresh_url}
|
|
129
|
-
|
|
118
|
+
describe "#refresh_results" do
|
|
130
119
|
it "returns a hash of query parameters" do
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
it "returns a since_id" do
|
|
135
|
-
expect(refresh_url[:since_id]).to eq "249279667666817023"
|
|
120
|
+
search_results = Twitter::SearchResults.new(:search_metadata => {:refresh_url => "?since_id=249279667666817023&q=%23freebandnames&count=4&include_entities=1&result_type=recent"})
|
|
121
|
+
expect(search_results.refresh_results).to be_a Hash
|
|
122
|
+
expect(search_results.refresh_results[:since_id]).to eq("249279667666817023")
|
|
136
123
|
end
|
|
137
124
|
end
|
|
138
125
|
|
|
@@ -3,13 +3,24 @@ require 'helper'
|
|
|
3
3
|
describe Twitter::Settings do
|
|
4
4
|
|
|
5
5
|
describe "#trend_location" do
|
|
6
|
-
it "returns a Twitter::Place when set" do
|
|
7
|
-
|
|
8
|
-
expect(
|
|
6
|
+
it "returns a Twitter::Place when trend_location is set" do
|
|
7
|
+
settings = Twitter::Settings.new(:trend_location => {:countryCode => "US", :name => "San Francisco", :country => "United States", :placeType => {:name => "Town", :code => 7}, :woeid => 2487956, :parentid => 23424977, :url => "http://where.yahooapis.com/v1/place/2487956"})
|
|
8
|
+
expect(settings.trend_location).to be_a Twitter::Place
|
|
9
9
|
end
|
|
10
|
-
it "returns nil when not set" do
|
|
11
|
-
|
|
12
|
-
expect(
|
|
10
|
+
it "returns nil when trend_location is not set" do
|
|
11
|
+
settings = Twitter::Settings.new
|
|
12
|
+
expect(settings.trend_location).to be_nil
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
describe "#trend_location?" do
|
|
17
|
+
it "returns true when trend_location is set" do
|
|
18
|
+
settings = Twitter::Settings.new(:trend_location => {:countryCode => "US", :name => "San Francisco", :country => "United States", :placeType => {:name => "Town", :code => 7}, :woeid => 2487956, :parentid => 23424977, :url => "http://where.yahooapis.com/v1/place/2487956"})
|
|
19
|
+
expect(settings.trend_location?).to be true
|
|
20
|
+
end
|
|
21
|
+
it "returns false when trend_location is not set" do
|
|
22
|
+
settings = Twitter::Settings.new
|
|
23
|
+
expect(settings.trend_location?).to be false
|
|
13
24
|
end
|
|
14
25
|
end
|
|
15
26
|
|
data/spec/twitter/size_spec.rb
CHANGED
|
@@ -3,35 +3,25 @@ require 'helper'
|
|
|
3
3
|
describe Twitter::Size do
|
|
4
4
|
|
|
5
5
|
describe "#==" do
|
|
6
|
-
it "returns
|
|
6
|
+
it "returns true for empty objects" do
|
|
7
7
|
size = Twitter::Size.new
|
|
8
8
|
other = Twitter::Size.new
|
|
9
|
-
expect(size == other).to
|
|
9
|
+
expect(size == other).to be true
|
|
10
10
|
end
|
|
11
11
|
it "returns true when objects height and width are the same" do
|
|
12
12
|
size = Twitter::Size.new(:h => 1, :w => 1, :resize => true)
|
|
13
13
|
other = Twitter::Size.new(:h => 1, :w => 1, :resize => false)
|
|
14
|
-
expect(size == other).to
|
|
14
|
+
expect(size == other).to be true
|
|
15
15
|
end
|
|
16
16
|
it "returns false when objects height or width are different" do
|
|
17
17
|
size = Twitter::Size.new(:h => 1, :w => 1)
|
|
18
18
|
other = Twitter::Size.new(:h => 1, :w => 2)
|
|
19
|
-
expect(size == other).to
|
|
19
|
+
expect(size == other).to be false
|
|
20
20
|
end
|
|
21
21
|
it "returns false when classes are different" do
|
|
22
22
|
size = Twitter::Size.new(:h => 1, :w => 1)
|
|
23
23
|
other = Twitter::Base.new(:h => 1, :w => 1)
|
|
24
|
-
expect(size == other).to
|
|
25
|
-
end
|
|
26
|
-
it "returns true when objects non-height and width attributes are the same" do
|
|
27
|
-
size = Twitter::Size.new(:resize => true)
|
|
28
|
-
other = Twitter::Size.new(:resize => true)
|
|
29
|
-
expect(size == other).to be_true
|
|
30
|
-
end
|
|
31
|
-
it "returns false when objects non-height and width attributes are different" do
|
|
32
|
-
size = Twitter::Size.new(:resize => true)
|
|
33
|
-
other = Twitter::Size.new(:resize => false)
|
|
34
|
-
expect(size == other).to be_false
|
|
24
|
+
expect(size == other).to be false
|
|
35
25
|
end
|
|
36
26
|
end
|
|
37
27
|
|
|
@@ -6,17 +6,17 @@ describe Twitter::SourceUser do
|
|
|
6
6
|
it "returns true when objects IDs are the same" do
|
|
7
7
|
saved_search = Twitter::SourceUser.new(:id => 1, :name => "foo")
|
|
8
8
|
other = Twitter::SourceUser.new(:id => 1, :name => "bar")
|
|
9
|
-
expect(saved_search == other).to
|
|
9
|
+
expect(saved_search == other).to be true
|
|
10
10
|
end
|
|
11
11
|
it "returns false when objects IDs are different" do
|
|
12
12
|
saved_search = Twitter::SourceUser.new(:id => 1)
|
|
13
13
|
other = Twitter::SourceUser.new(:id => 2)
|
|
14
|
-
expect(saved_search == other).to
|
|
14
|
+
expect(saved_search == other).to be false
|
|
15
15
|
end
|
|
16
16
|
it "returns false when classes are different" do
|
|
17
17
|
saved_search = Twitter::SourceUser.new(:id => 1)
|
|
18
18
|
other = Twitter::Identity.new(:id => 1)
|
|
19
|
-
expect(saved_search == other).to
|
|
19
|
+
expect(saved_search == other).to be false
|
|
20
20
|
end
|
|
21
21
|
end
|
|
22
22
|
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
require 'helper'
|
|
2
|
+
|
|
3
|
+
describe Twitter::Streaming::Client do
|
|
4
|
+
before do
|
|
5
|
+
@client = Twitter::Streaming::Client.new
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
class FakeConnection
|
|
9
|
+
def initialize(body)
|
|
10
|
+
@body = body
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def stream(request, response)
|
|
14
|
+
@body.each_line do |line|
|
|
15
|
+
response.on_body(line)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it "#before_request" do
|
|
21
|
+
@client.connection = FakeConnection.new(fixture("track_streaming.json"))
|
|
22
|
+
var = false
|
|
23
|
+
@client.before_request do
|
|
24
|
+
var = true
|
|
25
|
+
end
|
|
26
|
+
expect(var).to be false
|
|
27
|
+
@client.user{}
|
|
28
|
+
expect(var).to be true
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it "#filter" do
|
|
32
|
+
@client.connection = FakeConnection.new(fixture("track_streaming.json"))
|
|
33
|
+
tweets = []
|
|
34
|
+
@client.filter(:track => "india") do |tweet|
|
|
35
|
+
tweets << tweet
|
|
36
|
+
end
|
|
37
|
+
expect(tweets.size).to eq(2)
|
|
38
|
+
expect(tweets.first).to be_a Twitter::Tweet
|
|
39
|
+
expect(tweets.first.text).to eq "The problem with your code is that it's doing exactly what you told it to do."
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it "#firehose" do
|
|
43
|
+
@client.connection = FakeConnection.new(fixture("track_streaming.json"))
|
|
44
|
+
tweets = []
|
|
45
|
+
@client.firehose do |tweet|
|
|
46
|
+
tweets << tweet
|
|
47
|
+
end
|
|
48
|
+
expect(tweets.size).to eq(2)
|
|
49
|
+
expect(tweets.first).to be_a Twitter::Tweet
|
|
50
|
+
expect(tweets.first.text).to eq "The problem with your code is that it's doing exactly what you told it to do."
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
it "#sample" do
|
|
54
|
+
@client.connection = FakeConnection.new(fixture("track_streaming.json"))
|
|
55
|
+
tweets = []
|
|
56
|
+
@client.sample do |tweet|
|
|
57
|
+
tweets << tweet
|
|
58
|
+
end
|
|
59
|
+
expect(tweets.size).to eq(2)
|
|
60
|
+
expect(tweets.first).to be_a Twitter::Tweet
|
|
61
|
+
expect(tweets.first.text).to eq "The problem with your code is that it's doing exactly what you told it to do."
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
it "#site" do
|
|
65
|
+
@client.connection = FakeConnection.new(fixture("track_streaming.json"))
|
|
66
|
+
tweets = []
|
|
67
|
+
@client.site(7505382) do |tweet|
|
|
68
|
+
tweets << tweet
|
|
69
|
+
end
|
|
70
|
+
expect(tweets.size).to eq(2)
|
|
71
|
+
expect(tweets.first).to be_a Twitter::Tweet
|
|
72
|
+
expect(tweets.first.text).to eq "The problem with your code is that it's doing exactly what you told it to do."
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
it "#user" do
|
|
76
|
+
@client.connection = FakeConnection.new(fixture("track_streaming_user.json"))
|
|
77
|
+
items = []
|
|
78
|
+
@client.user do |item|
|
|
79
|
+
items << item
|
|
80
|
+
end
|
|
81
|
+
expect(items.size).to eq(5)
|
|
82
|
+
expect(items[0]).to be_a Twitter::Streaming::FriendList
|
|
83
|
+
expect(items[0].friend_ids).to eq([488736931,311444249])
|
|
84
|
+
expect(items[1]).to be_a Twitter::Tweet
|
|
85
|
+
expect(items[1].text).to eq "The problem with your code is that it's doing exactly what you told it to do."
|
|
86
|
+
expect(items[3]).to be_a Twitter::DirectMessage
|
|
87
|
+
expect(items[3].text).to eq "hello bot"
|
|
88
|
+
expect(items[4]).to be_a Twitter::Streaming::Event
|
|
89
|
+
expect(items[4].name).to be(:follow)
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
require 'helper'
|
|
2
|
+
|
|
3
|
+
describe Twitter::Streaming::Event do
|
|
4
|
+
describe "#initialize" do
|
|
5
|
+
before(:each) do
|
|
6
|
+
@data = {:event=>"follow", :source=>{:id=>10083602, :id_str=>"10083602", :name=>"Adam Bird", :screen_name=>"adambird", :location=>"Nottingham, UK", :url=>"http://t.co/M1eaIKDQyz", :description=>"CEO @onediaryapp, ex @esendex CTO and co-founder, still cycling", :protected=>false, :followers_count=>1295, :friends_count=>850, :listed_count=>53, :created_at=>"Fri Nov 09 00:35:12 +0000 2007", :favourites_count=>93, :utc_offset=>0, :time_zone=>"London", :geo_enabled=>true, :verified=>false, :statuses_count=>13507, :lang=>"en", :contributors_enabled=>false, :is_translator=>false, :profile_background_color=>"C0DEED", :profile_background_image_url=>"http://abs.twimg.com/images/themes/theme1/bg.png", :profile_background_image_url_https=>"https://abs.twimg.com/images/themes/theme1/bg.png", :profile_background_tile=>false, :profile_image_url=>"http://pbs.twimg.com/profile_images/378800000477232297/23d85bb78f71534eea1e1133fb771f86_normal.jpeg", :profile_image_url_https=>"https://pbs.twimg.com/profile_images/378800000477232297/23d85bb78f71534eea1e1133fb771f86_normal.jpeg", :profile_link_color=>"0084B4", :profile_sidebar_border_color=>"C0DEED", :profile_sidebar_fill_color=>"DDEEF6", :profile_text_color=>"333333", :profile_use_background_image=>true, :default_profile=>true, :default_profile_image=>false, :following=>false, :follow_request_sent=>false, :notifications=>false}, :target=>{:id=>1292911088, :id_str=>"1292911088", :name=>"One Diary Bot", :screen_name=>"onediarybot", :location=>nil, :url=>"http://t.co/etHGc0xHX4", :description=>"I'm the One Diary bot, here to help you with your life including personal cycling weather forecasts.", :protected=>false, :followers_count=>123, :friends_count=>157, :listed_count=>1, :created_at=>"Sat Mar 23 23:52:18 +0000 2013", :favourites_count=>0, :utc_offset=>nil, :time_zone=>nil, :geo_enabled=>false, :verified=>false, :statuses_count=>9637, :lang=>"en", :contributors_enabled=>false, :is_translator=>false, :profile_background_color=>"C0DEED", :profile_background_image_url=>"http://abs.twimg.com/images/themes/theme1/bg.png", :profile_background_image_url_https=>"https://abs.twimg.com/images/themes/theme1/bg.png", :profile_background_tile=>false, :profile_image_url=>"http://pbs.twimg.com/profile_images/3651575369/090551d8dd92080198f707769239ff43_normal.jpeg", :profile_image_url_https=>"https://pbs.twimg.com/profile_images/3651575369/090551d8dd92080198f707769239ff43_normal.jpeg", :profile_link_color=>"0084B4", :profile_sidebar_border_color=>"C0DEED", :profile_sidebar_fill_color=>"DDEEF6", :profile_text_color=>"333333", :profile_use_background_image=>true, :default_profile=>true, :default_profile_image=>false, :following=>false, :follow_request_sent=>false, :notifications=>false}, :created_at=>"Sun Oct 27 20:44:19 +0000 2013"}
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
subject { Twitter::Streaming::Event.new(@data) }
|
|
10
|
+
|
|
11
|
+
it "should set the name to be a symbolised version of string string" do
|
|
12
|
+
expect(subject.name).to eq(:follow)
|
|
13
|
+
end
|
|
14
|
+
it "should set the source to be the User" do
|
|
15
|
+
expect(subject.source).to be_a(Twitter::User)
|
|
16
|
+
expect(subject.source.id).to eq(10083602)
|
|
17
|
+
end
|
|
18
|
+
it "should set the target to be the User" do
|
|
19
|
+
expect(subject.target).to be_a(Twitter::User)
|
|
20
|
+
expect(subject.target.id).to eq(1292911088)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
context "when target object is a list" do
|
|
24
|
+
before(:each) do
|
|
25
|
+
@data = {:event=>"list_member_added", :target_object=>{:full_name=>"@adambird/lists/dev", :user=>{:default_profile_image=>false, :profile_text_color=>"333333", :created_at=>"Fri Nov 09 00:35:12 +0000 2007", :is_translator=>false, :name=>"Adam Bird", :screen_name=>"adambird", :geo_enabled=>true, :follow_request_sent=>false, :profile_sidebar_border_color=>"C0DEED", :default_profile=>true, :id=>10083602, :contributors_enabled=>false, :followers_count=>1295, :lang=>"en", :profile_background_tile=>false, :url=>"http://about.me/adambird", :profile_sidebar_fill_color=>"DDEEF6", :listed_count=>53, :utc_offset=>0, :location=>"Nottingham, UK", :time_zone=>"London", :profile_background_color=>"C0DEED", :following=>false, :protected=>false, :description=>"CEO @onediaryapp, ex @esendex CTO and co-founder, still cycling", :profile_image_url_https=>"https://pbs.twimg.com/profile_images/378800000477232297/23d85bb78f71534eea1e1133fb771f86_normal.jpeg", :profile_background_image_url=>"http://abs.twimg.com/images/themes/theme1/bg.png", :profile_link_color=>"0084B4", :notifications=>false, :profile_background_image_url_https=>"https://abs.twimg.com/images/themes/theme1/bg.png", :favourites_count=>93, :id_str=>"10083602", :statuses_count=>13507, :verified=>false, :profile_image_url=>"http://pbs.twimg.com/profile_images/378800000477232297/23d85bb78f71534eea1e1133fb771f86_normal.jpeg", :profile_use_background_image=>true, :friends_count=>851}, :uri=>"/adambird/lists/dev", :subscriber_count=>0, :id_str=>"60314359", :created_at=>"Sun Dec 04 19:54:20 +0000 2011", :id=>60314359, :following=>false, :mode=>"public", :member_count=>13, :description=>"", :slug=>"dev", :name=>"dev"}, :source=>{:default_profile_image=>false, :profile_text_color=>"333333", :created_at=>"Fri Nov 09 00:35:12 +0000 2007", :is_translator=>false, :name=>"Adam Bird", :screen_name=>"adambird", :geo_enabled=>true, :follow_request_sent=>false, :profile_sidebar_border_color=>"C0DEED", :default_profile=>true, :id=>10083602, :contributors_enabled=>false, :followers_count=>1295, :lang=>"en", :profile_background_tile=>false, :url=>"http://about.me/adambird", :profile_sidebar_fill_color=>"DDEEF6", :listed_count=>53, :utc_offset=>0, :location=>"Nottingham, UK", :time_zone=>"London", :profile_background_color=>"C0DEED", :following=>false, :protected=>false, :description=>"CEO @onediaryapp, ex @esendex CTO and co-founder, still cycling", :profile_image_url_https=>"https://pbs.twimg.com/profile_images/378800000477232297/23d85bb78f71534eea1e1133fb771f86_normal.jpeg", :profile_background_image_url=>"http://abs.twimg.com/images/themes/theme1/bg.png", :profile_link_color=>"0084B4", :notifications=>false, :profile_background_image_url_https=>"https://abs.twimg.com/images/themes/theme1/bg.png", :favourites_count=>93, :id_str=>"10083602", :statuses_count=>13507, :verified=>false, :profile_image_url=>"http://pbs.twimg.com/profile_images/378800000477232297/23d85bb78f71534eea1e1133fb771f86_normal.jpeg", :profile_use_background_image=>true, :friends_count=>851}, :created_at=>"Sun Oct 27 20:54:51 +0000 2013", :target=>{:default_profile_image=>false, :profile_text_color=>"333333", :created_at=>"Sat Mar 23 23:52:18 +0000 2013", :is_translator=>false, :name=>"One Diary Bot", :screen_name=>"onediarybot", :geo_enabled=>false, :follow_request_sent=>false, :profile_sidebar_border_color=>"C0DEED", :default_profile=>true, :id=>1292911088, :contributors_enabled=>false, :followers_count=>124, :lang=>"en", :profile_background_tile=>false, :url=>"http://www.onediary.com", :profile_sidebar_fill_color=>"DDEEF6", :listed_count=>2, :utc_offset=>nil, :location=>nil, :time_zone=>nil, :profile_background_color=>"C0DEED", :following=>true, :protected=>false, :description=>"I'm the One Diary bot, here to help you with your life including personal cycling weather forecasts.", :profile_image_url_https=>"https://pbs.twimg.com/profile_images/3651575369/090551d8dd92080198f707769239ff43_normal.jpeg", :profile_background_image_url=>"http://abs.twimg.com/images/themes/theme1/bg.png", :profile_link_color=>"0084B4", :notifications=>false, :profile_background_image_url_https=>"https://abs.twimg.com/images/themes/theme1/bg.png", :favourites_count=>0, :id_str=>"1292911088", :statuses_count=>9637, :verified=>false, :profile_image_url=>"http://pbs.twimg.com/profile_images/3651575369/090551d8dd92080198f707769239ff43_normal.jpeg", :profile_use_background_image=>true, :friends_count=>157}}
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it "should have the list object as the target object" do
|
|
29
|
+
expect(subject.target_object).to be_a(Twitter::List)
|
|
30
|
+
expect(subject.target_object.full_name).to eq("@adambird/lists/dev")
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
context "when target object is a tweet" do
|
|
35
|
+
before(:each) do
|
|
36
|
+
@data = {:event=>"favorite", :target_object=>{:in_reply_to_status_id=>394341960603172864, :favorited=>true, :entities=>{:hashtags=>[], :urls=>[], :user_mentions=>[{:screen_name=>"darrenliddell", :id_str=>"18845675", :id=>18845675, :indices=>[0, 14], :name=>"Darren Liddell"}]}, :user=>{:default_profile_image=>false, :profile_text_color=>"333333", :created_at=>"Sat Mar 23 23:52:18 +0000 2013", :is_translator=>false, :name=>"One Diary Bot", :screen_name=>"onediarybot", :geo_enabled=>false, :follow_request_sent=>false, :profile_sidebar_border_color=>"C0DEED", :default_profile=>true, :id=>1292911088, :contributors_enabled=>false, :followers_count=>124, :lang=>"en", :profile_background_tile=>false, :url=>"http://www.onediary.com", :profile_sidebar_fill_color=>"DDEEF6", :listed_count=>1, :utc_offset=>nil, :location=>nil, :time_zone=>nil, :profile_background_color=>"C0DEED", :following=>true, :protected=>false, :description=>"I'm the One Diary bot, here to help you with your life including personal cycling weather forecasts.", :profile_background_image_url=>"http://abs.twimg.com/images/themes/theme1/bg.png", :profile_link_color=>"0084B4", :notifications=>false, :profile_background_image_url_https=>"https://abs.twimg.com/images/themes/theme1/bg.png", :favourites_count=>0, :id_str=>"1292911088", :statuses_count=>9637, :verified=>false, :profile_image_url=>"http://pbs.twimg.com/profile_images/3651575369/090551d8dd92080198f707769239ff43_normal.jpeg", :profile_use_background_image=>true, :profile_image_url_https=>"https://pbs.twimg.com/profile_images/3651575369/090551d8dd92080198f707769239ff43_normal.jpeg", :friends_count=>157}, :in_reply_to_screen_name=>"darrenliddell", :place=>nil, :coordinates=>nil, :id_str=>"394454214132256768", :source=>"web", :retweet_count=>0, :id=>394454214132256768, :created_at=>"Sun Oct 27 13:23:07 +0000 2013", :in_reply_to_status_id_str=>"394341960603172864", :retweeted=>false, :in_reply_to_user_id=>18845675, :truncated=>false, :contributors=>nil, :geo=>nil, :in_reply_to_user_id_str=>"18845675", :text=>"@darrenliddell my programmers thought that they had that one covered. I have admonished them."}, :source=>{:default_profile_image=>false, :profile_text_color=>"333333", :created_at=>"Fri Nov 09 00:35:12 +0000 2007", :is_translator=>false, :name=>"Adam Bird", :screen_name=>"adambird", :geo_enabled=>true, :follow_request_sent=>false, :profile_sidebar_border_color=>"C0DEED", :default_profile=>true, :id=>10083602, :contributors_enabled=>false, :followers_count=>1295, :lang=>"en", :profile_background_tile=>false, :url=>"http://about.me/adambird", :profile_sidebar_fill_color=>"DDEEF6", :listed_count=>53, :utc_offset=>0, :location=>"Nottingham, UK", :time_zone=>"London", :profile_background_color=>"C0DEED", :following=>false, :protected=>false, :description=>"CEO @onediaryapp, ex @esendex CTO and co-founder, still cycling", :profile_background_image_url=>"http://abs.twimg.com/images/themes/theme1/bg.png", :profile_link_color=>"0084B4", :notifications=>false, :profile_background_image_url_https=>"https://abs.twimg.com/images/themes/theme1/bg.png", :favourites_count=>93, :id_str=>"10083602", :statuses_count=>13507, :verified=>false, :profile_image_url=>"http://pbs.twimg.com/profile_images/378800000477232297/23d85bb78f71534eea1e1133fb771f86_normal.jpeg", :profile_use_background_image=>true, :profile_image_url_https=>"https://pbs.twimg.com/profile_images/378800000477232297/23d85bb78f71534eea1e1133fb771f86_normal.jpeg", :friends_count=>851}, :created_at=>"Sun Oct 27 21:05:35 +0000 2013", :target=>{:default_profile_image=>false, :profile_text_color=>"333333", :created_at=>"Sat Mar 23 23:52:18 +0000 2013", :is_translator=>false, :name=>"One Diary Bot", :screen_name=>"onediarybot", :geo_enabled=>false, :follow_request_sent=>false, :profile_sidebar_border_color=>"C0DEED", :default_profile=>true, :id=>1292911088, :contributors_enabled=>false, :followers_count=>124, :lang=>"en", :profile_background_tile=>false, :url=>"http://www.onediary.com", :profile_sidebar_fill_color=>"DDEEF6", :listed_count=>1, :utc_offset=>nil, :location=>nil, :time_zone=>nil, :profile_background_color=>"C0DEED", :following=>true, :protected=>false, :description=>"I'm the One Diary bot, here to help you with your life including personal cycling weather forecasts.", :profile_background_image_url=>"http://abs.twimg.com/images/themes/theme1/bg.png", :profile_link_color=>"0084B4", :notifications=>false, :profile_background_image_url_https=>"https://abs.twimg.com/images/themes/theme1/bg.png", :favourites_count=>0, :id_str=>"1292911088", :statuses_count=>9637, :verified=>false, :profile_image_url=>"http://pbs.twimg.com/profile_images/3651575369/090551d8dd92080198f707769239ff43_normal.jpeg", :profile_use_background_image=>true, :profile_image_url_https=>"https://pbs.twimg.com/profile_images/3651575369/090551d8dd92080198f707769239ff43_normal.jpeg", :friends_count=>157}}
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
it "should have the tweet as the target object" do
|
|
40
|
+
expect(subject.target_object).to be_a(Twitter::Tweet)
|
|
41
|
+
expect(subject.target_object.id).to eq(394454214132256768)
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -3,35 +3,25 @@ require 'helper'
|
|
|
3
3
|
describe Twitter::Suggestion do
|
|
4
4
|
|
|
5
5
|
describe "#==" do
|
|
6
|
-
it "returns
|
|
6
|
+
it "returns true for empty objects" do
|
|
7
7
|
suggestion = Twitter::Suggestion.new
|
|
8
8
|
other = Twitter::Suggestion.new
|
|
9
|
-
expect(suggestion == other).to
|
|
9
|
+
expect(suggestion == other).to be true
|
|
10
10
|
end
|
|
11
11
|
it "returns true when objects slugs are the same" do
|
|
12
12
|
suggestion = Twitter::Suggestion.new(:slug => 1, :name => "foo")
|
|
13
13
|
other = Twitter::Suggestion.new(:slug => 1, :name => "bar")
|
|
14
|
-
expect(suggestion == other).to
|
|
14
|
+
expect(suggestion == other).to be true
|
|
15
15
|
end
|
|
16
16
|
it "returns false when objects slugs are different" do
|
|
17
17
|
suggestion = Twitter::Suggestion.new(:slug => 1)
|
|
18
18
|
other = Twitter::Suggestion.new(:slug => 2)
|
|
19
|
-
expect(suggestion == other).to
|
|
19
|
+
expect(suggestion == other).to be false
|
|
20
20
|
end
|
|
21
21
|
it "returns false when classes are different" do
|
|
22
22
|
suggestion = Twitter::Suggestion.new(:slug => 1)
|
|
23
23
|
other = Twitter::Base.new(:slug => 1)
|
|
24
|
-
expect(suggestion == other).to
|
|
25
|
-
end
|
|
26
|
-
it "returns true when objects non-slug attributes are the same" do
|
|
27
|
-
suggestion = Twitter::Suggestion.new(:name => "foo")
|
|
28
|
-
other = Twitter::Suggestion.new(:name => "foo")
|
|
29
|
-
expect(suggestion == other).to be_true
|
|
30
|
-
end
|
|
31
|
-
it "returns false when objects non-slug attributes are different" do
|
|
32
|
-
suggestion = Twitter::Suggestion.new(:name => "foo")
|
|
33
|
-
other = Twitter::Suggestion.new(:name => "bar")
|
|
34
|
-
expect(suggestion == other).to be_false
|
|
24
|
+
expect(suggestion == other).to be false
|
|
35
25
|
end
|
|
36
26
|
end
|
|
37
27
|
|
|
@@ -6,17 +6,17 @@ describe Twitter::TargetUser do
|
|
|
6
6
|
it "returns true when objects IDs are the same" do
|
|
7
7
|
saved_search = Twitter::TargetUser.new(:id => 1, :name => "foo")
|
|
8
8
|
other = Twitter::TargetUser.new(:id => 1, :name => "bar")
|
|
9
|
-
expect(saved_search == other).to
|
|
9
|
+
expect(saved_search == other).to be true
|
|
10
10
|
end
|
|
11
11
|
it "returns false when objects IDs are different" do
|
|
12
12
|
saved_search = Twitter::TargetUser.new(:id => 1)
|
|
13
13
|
other = Twitter::TargetUser.new(:id => 2)
|
|
14
|
-
expect(saved_search == other).to
|
|
14
|
+
expect(saved_search == other).to be false
|
|
15
15
|
end
|
|
16
16
|
it "returns false when classes are different" do
|
|
17
17
|
saved_search = Twitter::TargetUser.new(:id => 1)
|
|
18
18
|
other = Twitter::Identity.new(:id => 1)
|
|
19
|
-
expect(saved_search == other).to
|
|
19
|
+
expect(saved_search == other).to be false
|
|
20
20
|
end
|
|
21
21
|
end
|
|
22
22
|
|
|
@@ -0,0 +1,16 @@
|
|
|
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
|
|
@@ -0,0 +1,89 @@
|
|
|
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
CHANGED
|
@@ -3,35 +3,48 @@ require 'helper'
|
|
|
3
3
|
describe Twitter::Trend do
|
|
4
4
|
|
|
5
5
|
describe "#==" do
|
|
6
|
-
it "returns
|
|
6
|
+
it "returns true for empty objects" do
|
|
7
7
|
trend = Twitter::Trend.new
|
|
8
8
|
other = Twitter::Trend.new
|
|
9
|
-
expect(trend == other).to
|
|
9
|
+
expect(trend == other).to be true
|
|
10
10
|
end
|
|
11
11
|
it "returns true when objects names are the same" do
|
|
12
12
|
trend = Twitter::Trend.new(:name => "#sevenwordsaftersex", :query => "foo")
|
|
13
13
|
other = Twitter::Trend.new(:name => "#sevenwordsaftersex", :query => "bar")
|
|
14
|
-
expect(trend == other).to
|
|
14
|
+
expect(trend == other).to be true
|
|
15
15
|
end
|
|
16
16
|
it "returns false when objects names are different" do
|
|
17
17
|
trend = Twitter::Trend.new(:name => "#sevenwordsaftersex")
|
|
18
18
|
other = Twitter::Trend.new(:name => "#sixwordsaftersex")
|
|
19
|
-
expect(trend == other).to
|
|
19
|
+
expect(trend == other).to be false
|
|
20
20
|
end
|
|
21
21
|
it "returns false when classes are different" do
|
|
22
22
|
trend = Twitter::Trend.new(:name => "#sevenwordsaftersex")
|
|
23
23
|
other = Twitter::Base.new(:name => "#sevenwordsaftersex")
|
|
24
|
-
expect(trend == other).to
|
|
24
|
+
expect(trend == other).to be false
|
|
25
25
|
end
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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_a 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
|
|
30
37
|
end
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
|
35
48
|
end
|
|
36
49
|
end
|
|
37
50
|
|