ifttt-twitter 2.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gemtest +0 -0
- data/.gitignore +12 -0
- data/.rspec +2 -0
- data/.travis.yml +9 -0
- data/.yardopts +8 -0
- data/Gemfile +7 -0
- data/HISTORY.md +520 -0
- data/LICENSE.md +20 -0
- data/README.md +251 -0
- data/Rakefile +13 -0
- data/lib/twitter.rb +24 -0
- data/lib/twitter/action.rb +9 -0
- data/lib/twitter/action_factory.rb +28 -0
- data/lib/twitter/authenticatable.rb +24 -0
- data/lib/twitter/base.rb +40 -0
- data/lib/twitter/client.rb +126 -0
- data/lib/twitter/client/accounts.rb +180 -0
- data/lib/twitter/client/activity.rb +48 -0
- data/lib/twitter/client/block.rb +104 -0
- data/lib/twitter/client/direct_messages.rb +110 -0
- data/lib/twitter/client/favorites.rb +82 -0
- data/lib/twitter/client/friends_and_followers.rb +293 -0
- data/lib/twitter/client/help.rb +38 -0
- data/lib/twitter/client/legal.rb +32 -0
- data/lib/twitter/client/lists.rb +643 -0
- data/lib/twitter/client/local_trends.rb +46 -0
- data/lib/twitter/client/notification.rb +49 -0
- data/lib/twitter/client/places_and_geo.rb +113 -0
- data/lib/twitter/client/saved_searches.rb +73 -0
- data/lib/twitter/client/search.rb +94 -0
- data/lib/twitter/client/spam_reporting.rb +30 -0
- data/lib/twitter/client/suggested_users.rb +60 -0
- data/lib/twitter/client/timelines.rb +265 -0
- data/lib/twitter/client/trends.rb +55 -0
- data/lib/twitter/client/tweets.rb +191 -0
- data/lib/twitter/client/urls.rb +26 -0
- data/lib/twitter/client/users.rb +203 -0
- data/lib/twitter/config.rb +106 -0
- data/lib/twitter/configuration.rb +20 -0
- data/lib/twitter/connection.rb +43 -0
- data/lib/twitter/core_ext/hash.rb +81 -0
- data/lib/twitter/creatable.rb +14 -0
- data/lib/twitter/cursor.rb +44 -0
- data/lib/twitter/direct_message.rb +27 -0
- data/lib/twitter/error.rb +37 -0
- data/lib/twitter/error/bad_gateway.rb +7 -0
- data/lib/twitter/error/bad_request.rb +7 -0
- data/lib/twitter/error/client_error.rb +7 -0
- data/lib/twitter/error/enhance_your_calm.rb +13 -0
- data/lib/twitter/error/forbidden.rb +7 -0
- data/lib/twitter/error/internal_server_error.rb +7 -0
- data/lib/twitter/error/not_acceptable.rb +7 -0
- data/lib/twitter/error/not_found.rb +7 -0
- data/lib/twitter/error/server_error.rb +7 -0
- data/lib/twitter/error/service_unavailable.rb +7 -0
- data/lib/twitter/error/unauthorized.rb +7 -0
- data/lib/twitter/favorite.rb +28 -0
- data/lib/twitter/follow.rb +27 -0
- data/lib/twitter/geo_factory.rb +22 -0
- data/lib/twitter/language.rb +7 -0
- data/lib/twitter/list.rb +22 -0
- data/lib/twitter/list_member_added.rb +36 -0
- data/lib/twitter/media_factory.rb +21 -0
- data/lib/twitter/mention.rb +43 -0
- data/lib/twitter/metadata.rb +7 -0
- data/lib/twitter/oembed.rb +8 -0
- data/lib/twitter/photo.rb +24 -0
- data/lib/twitter/place.rb +36 -0
- data/lib/twitter/point.rb +27 -0
- data/lib/twitter/polygon.rb +14 -0
- data/lib/twitter/rate_limit_status.rb +15 -0
- data/lib/twitter/relationship.rb +18 -0
- data/lib/twitter/reply.rb +36 -0
- data/lib/twitter/request.rb +38 -0
- data/lib/twitter/request/gateway.rb +20 -0
- data/lib/twitter/request/multipart_with_file.rb +37 -0
- data/lib/twitter/request/oauth.rb +26 -0
- data/lib/twitter/request/phoenix.rb +22 -0
- data/lib/twitter/response/parse_json.rb +28 -0
- data/lib/twitter/response/raise_client_error.rb +49 -0
- data/lib/twitter/response/raise_server_error.rb +23 -0
- data/lib/twitter/retweet.rb +36 -0
- data/lib/twitter/saved_search.rb +16 -0
- data/lib/twitter/settings.rb +17 -0
- data/lib/twitter/size.rb +16 -0
- data/lib/twitter/status.rb +80 -0
- data/lib/twitter/suggestion.rb +22 -0
- data/lib/twitter/trend.rb +14 -0
- data/lib/twitter/user.rb +65 -0
- data/lib/twitter/version.rb +30 -0
- data/spec/faraday/request_spec.rb +25 -0
- data/spec/faraday/response_spec.rb +68 -0
- data/spec/fixtures/about_me.json +1 -0
- data/spec/fixtures/all.json +1 -0
- data/spec/fixtures/bad_gateway.json +1 -0
- data/spec/fixtures/bad_request.json +1 -0
- data/spec/fixtures/by_friends.json +1 -0
- data/spec/fixtures/category.json +1 -0
- data/spec/fixtures/configuration.json +1 -0
- data/spec/fixtures/contributees.json +1 -0
- data/spec/fixtures/contributors.json +1 -0
- data/spec/fixtures/direct_message.json +1 -0
- data/spec/fixtures/direct_messages.json +1 -0
- data/spec/fixtures/end_session.json +1 -0
- data/spec/fixtures/enhance_your_calm.text +11 -0
- data/spec/fixtures/false.json +1 -0
- data/spec/fixtures/favorites.json +1 -0
- data/spec/fixtures/forbidden.json +1 -0
- data/spec/fixtures/friendships.json +1 -0
- data/spec/fixtures/id_list.json +1 -0
- data/spec/fixtures/ids.json +1 -0
- data/spec/fixtures/image_facets.json +1 -0
- data/spec/fixtures/internal_server_error.json +1 -0
- data/spec/fixtures/languages.json +1 -0
- data/spec/fixtures/list.json +1 -0
- data/spec/fixtures/lists.json +1 -0
- data/spec/fixtures/locations.json +1 -0
- data/spec/fixtures/matching_trends.json +1 -0
- data/spec/fixtures/me.jpeg +0 -0
- data/spec/fixtures/media_timeline.json +1 -0
- data/spec/fixtures/members.json +1 -0
- data/spec/fixtures/n605431196_2079896_558_normal.jpg +0 -0
- data/spec/fixtures/no_user_matches.json +1 -0
- data/spec/fixtures/not_acceptable.json +1 -0
- data/spec/fixtures/not_found.json +1 -0
- data/spec/fixtures/oembed.json +1 -0
- data/spec/fixtures/pengwynn.json +1 -0
- data/spec/fixtures/phoenix_search.phoenix +1 -0
- data/spec/fixtures/place.json +1 -0
- data/spec/fixtures/places.json +1 -0
- data/spec/fixtures/privacy.json +1 -0
- data/spec/fixtures/profile_image.text +24 -0
- data/spec/fixtures/rate_limit_status.json +1 -0
- data/spec/fixtures/recommendations.json +1 -0
- data/spec/fixtures/relationship.json +1 -0
- data/spec/fixtures/resolve.json +1 -0
- data/spec/fixtures/retweet.json +1 -0
- data/spec/fixtures/retweeters_of.json +1 -0
- data/spec/fixtures/retweets.json +1 -0
- data/spec/fixtures/saved_search.json +1 -0
- data/spec/fixtures/saved_searches.json +1 -0
- data/spec/fixtures/search.json +1 -0
- data/spec/fixtures/service_unavailable.json +1 -0
- data/spec/fixtures/settings.json +1 -0
- data/spec/fixtures/sferik.json +1 -0
- data/spec/fixtures/status.json +1 -0
- data/spec/fixtures/status_with_media.json +104 -0
- data/spec/fixtures/statuses.json +1 -0
- data/spec/fixtures/suggestions.json +1 -0
- data/spec/fixtures/tos.json +1 -0
- data/spec/fixtures/totals.json +1 -0
- data/spec/fixtures/trends.json +1 -0
- data/spec/fixtures/trends_current.json +1 -0
- data/spec/fixtures/trends_daily.json +1 -0
- data/spec/fixtures/trends_weekly.json +1 -0
- data/spec/fixtures/true.json +1 -0
- data/spec/fixtures/unauthorized.json +1 -0
- data/spec/fixtures/user_search.json +1 -0
- data/spec/fixtures/user_timeline.json +1 -0
- data/spec/fixtures/users.json +1 -0
- data/spec/fixtures/users_list.json +1 -0
- data/spec/fixtures/video_facets.json +1 -0
- data/spec/fixtures/we_concept_bg2.png +0 -0
- data/spec/helper.rb +49 -0
- data/spec/twitter/action_factory_spec.rb +37 -0
- data/spec/twitter/action_spec.rb +16 -0
- data/spec/twitter/base_spec.rb +29 -0
- data/spec/twitter/client/accounts_spec.rb +181 -0
- data/spec/twitter/client/activity_spec.rb +43 -0
- data/spec/twitter/client/block_spec.rb +106 -0
- data/spec/twitter/client/direct_messages_spec.rb +98 -0
- data/spec/twitter/client/favorites_spec.rb +80 -0
- data/spec/twitter/client/friends_and_followers_spec.rb +478 -0
- data/spec/twitter/client/help_spec.rb +44 -0
- data/spec/twitter/client/legal_spec.rb +41 -0
- data/spec/twitter/client/lists_spec.rb +1104 -0
- data/spec/twitter/client/local_trends_spec.rb +58 -0
- data/spec/twitter/client/notification_spec.rb +47 -0
- data/spec/twitter/client/places_and_geo_spec.rb +100 -0
- data/spec/twitter/client/saved_searches_spec.rb +80 -0
- data/spec/twitter/client/search_spec.rb +92 -0
- data/spec/twitter/client/spam_reporting_spec.rb +28 -0
- data/spec/twitter/client/suggested_users_spec.rb +65 -0
- data/spec/twitter/client/timelines_spec.rb +231 -0
- data/spec/twitter/client/trends_spec.rb +51 -0
- data/spec/twitter/client/tweets_spec.rb +189 -0
- data/spec/twitter/client/urls_spec.rb +31 -0
- data/spec/twitter/client/users_spec.rb +323 -0
- data/spec/twitter/client_spec.rb +94 -0
- data/spec/twitter/configuration_spec.rb +17 -0
- data/spec/twitter/cursor_spec.rb +43 -0
- data/spec/twitter/direct_message_spec.rb +56 -0
- data/spec/twitter/favorite_spec.rb +29 -0
- data/spec/twitter/follow_spec.rb +29 -0
- data/spec/twitter/geo_factory_spec.rb +21 -0
- data/spec/twitter/list_spec.rb +34 -0
- data/spec/twitter/media_factory_spec.rb +17 -0
- data/spec/twitter/mention_spec.rb +52 -0
- data/spec/twitter/oembed_spec.rb +145 -0
- data/spec/twitter/photo_spec.rb +35 -0
- data/spec/twitter/place_spec.rb +75 -0
- data/spec/twitter/point_spec.rb +32 -0
- data/spec/twitter/polygon_spec.rb +18 -0
- data/spec/twitter/rate_limit_status_spec.rb +16 -0
- data/spec/twitter/relationship_spec.rb +27 -0
- data/spec/twitter/reply_spec.rb +41 -0
- data/spec/twitter/retweet_spec.rb +41 -0
- data/spec/twitter/saved_search_spec.rb +34 -0
- data/spec/twitter/settings_spec.rb +16 -0
- data/spec/twitter/size_spec.rb +18 -0
- data/spec/twitter/status_spec.rb +148 -0
- data/spec/twitter/suggestion_spec.rb +20 -0
- data/spec/twitter/trend_spec.rb +20 -0
- data/spec/twitter/user_spec.rb +50 -0
- data/spec/twitter_spec.rb +91 -0
- data/twitter.gemspec +42 -0
- metadata +564 -0
@@ -0,0 +1,231 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Twitter::Client do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@client = Twitter::Client.new
|
7
|
+
end
|
8
|
+
|
9
|
+
describe ".home_timeline" do
|
10
|
+
before do
|
11
|
+
stub_get("/1/statuses/home_timeline.json").
|
12
|
+
to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
13
|
+
end
|
14
|
+
it "should request the correct resource" do
|
15
|
+
@client.home_timeline
|
16
|
+
a_get("/1/statuses/home_timeline.json").
|
17
|
+
should have_been_made
|
18
|
+
end
|
19
|
+
it "should return the 20 most recent statuses, including retweets if they exist, posted by the authenticating user and the user's they follow" do
|
20
|
+
statuses = @client.home_timeline
|
21
|
+
statuses.should be_an Array
|
22
|
+
statuses.first.should be_a Twitter::Status
|
23
|
+
statuses.first.text.should == "Ruby is the best programming language for hiding the ugly bits."
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe ".mentions" do
|
28
|
+
before do
|
29
|
+
stub_get("/1/statuses/mentions.json").
|
30
|
+
to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
31
|
+
end
|
32
|
+
it "should request the correct resource" do
|
33
|
+
@client.mentions
|
34
|
+
a_get("/1/statuses/mentions.json").
|
35
|
+
should have_been_made
|
36
|
+
end
|
37
|
+
it "should return the 20 most recent mentions (status containing @username) for the authenticating user" do
|
38
|
+
statuses = @client.mentions
|
39
|
+
statuses.should be_an Array
|
40
|
+
statuses.first.should be_a Twitter::Status
|
41
|
+
statuses.first.text.should == "Ruby is the best programming language for hiding the ugly bits."
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe ".public_timeline" do
|
46
|
+
before do
|
47
|
+
stub_get("/1/statuses/public_timeline.json").
|
48
|
+
to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
49
|
+
end
|
50
|
+
it "should request the correct resource" do
|
51
|
+
@client.public_timeline
|
52
|
+
a_get("/1/statuses/public_timeline.json").
|
53
|
+
should have_been_made
|
54
|
+
end
|
55
|
+
it "should return the 20 most recent statuses, including retweets if they exist, from non-protected users" do
|
56
|
+
statuses = @client.public_timeline
|
57
|
+
statuses.should be_an Array
|
58
|
+
statuses.first.should be_a Twitter::Status
|
59
|
+
statuses.first.text.should == "Ruby is the best programming language for hiding the ugly bits."
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
describe ".retweeted_by" do
|
64
|
+
context "with a screen name passed" do
|
65
|
+
before do
|
66
|
+
stub_get("/1/statuses/retweeted_by_user.json").
|
67
|
+
with(:query => {:screen_name => "sferik"}).
|
68
|
+
to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
69
|
+
end
|
70
|
+
it "should request the correct resource" do
|
71
|
+
@client.retweeted_by("sferik")
|
72
|
+
a_get("/1/statuses/retweeted_by_user.json").
|
73
|
+
with(:query => {:screen_name => "sferik"}).
|
74
|
+
should have_been_made
|
75
|
+
end
|
76
|
+
it "should return the 20 most recent retweets posted by the authenticating user" do
|
77
|
+
statuses = @client.retweeted_by("sferik")
|
78
|
+
statuses.should be_an Array
|
79
|
+
statuses.first.should be_a Twitter::Status
|
80
|
+
statuses.first.text.should == "Ruby is the best programming language for hiding the ugly bits."
|
81
|
+
end
|
82
|
+
end
|
83
|
+
context "without a screen name passed" do
|
84
|
+
before do
|
85
|
+
stub_get("/1/statuses/retweeted_by_me.json").
|
86
|
+
to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
87
|
+
end
|
88
|
+
it "should request the correct resource" do
|
89
|
+
@client.retweeted_by
|
90
|
+
a_get("/1/statuses/retweeted_by_me.json").
|
91
|
+
should have_been_made
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
describe ".retweeted_to" do
|
97
|
+
context "with a screen name passed" do
|
98
|
+
before do
|
99
|
+
stub_get("/1/statuses/retweeted_to_user.json").
|
100
|
+
with(:query => {:screen_name => "sferik"}).
|
101
|
+
to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
102
|
+
end
|
103
|
+
it "should request the correct resource" do
|
104
|
+
@client.retweeted_to("sferik")
|
105
|
+
a_get("/1/statuses/retweeted_to_user.json").
|
106
|
+
with(:query => {:screen_name => "sferik"}).
|
107
|
+
should have_been_made
|
108
|
+
end
|
109
|
+
it "should return the 20 most recent retweets posted by users the authenticating user follow" do
|
110
|
+
statuses = @client.retweeted_to("sferik")
|
111
|
+
statuses.should be_an Array
|
112
|
+
statuses.first.should be_a Twitter::Status
|
113
|
+
statuses.first.text.should == "Ruby is the best programming language for hiding the ugly bits."
|
114
|
+
end
|
115
|
+
end
|
116
|
+
context "without a screen name passed" do
|
117
|
+
before do
|
118
|
+
stub_get("/1/statuses/retweeted_to_me.json").
|
119
|
+
to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
120
|
+
end
|
121
|
+
it "should request the correct resource" do
|
122
|
+
@client.retweeted_to
|
123
|
+
a_get("/1/statuses/retweeted_to_me.json").
|
124
|
+
should have_been_made
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
describe ".retweets_of_me" do
|
130
|
+
before do
|
131
|
+
stub_get("/1/statuses/retweets_of_me.json").
|
132
|
+
to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
133
|
+
end
|
134
|
+
it "should request the correct resource" do
|
135
|
+
@client.retweets_of_me
|
136
|
+
a_get("/1/statuses/retweets_of_me.json").
|
137
|
+
should have_been_made
|
138
|
+
end
|
139
|
+
it "should return the 20 most recent tweets of the authenticated user that have been retweeted by others" do
|
140
|
+
statuses = @client.retweets_of_me
|
141
|
+
statuses.should be_an Array
|
142
|
+
statuses.first.should be_a Twitter::Status
|
143
|
+
statuses.first.text.should == "Ruby is the best programming language for hiding the ugly bits."
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
describe ".user_timeline" do
|
148
|
+
context "with a screen name passed" do
|
149
|
+
before do
|
150
|
+
stub_get("/1/statuses/user_timeline.json").
|
151
|
+
with(:query => {:screen_name => "sferik"}).
|
152
|
+
to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
153
|
+
end
|
154
|
+
it "should request the correct resource" do
|
155
|
+
@client.user_timeline("sferik")
|
156
|
+
a_get("/1/statuses/user_timeline.json").
|
157
|
+
with(:query => {:screen_name => "sferik"}).
|
158
|
+
should have_been_made
|
159
|
+
end
|
160
|
+
it "should return the 20 most recent statuses posted by the user specified by screen name or user id" do
|
161
|
+
statuses = @client.user_timeline("sferik")
|
162
|
+
statuses.should be_an Array
|
163
|
+
statuses.first.should be_a Twitter::Status
|
164
|
+
statuses.first.text.should == "Ruby is the best programming language for hiding the ugly bits."
|
165
|
+
end
|
166
|
+
end
|
167
|
+
context "without a screen name passed" do
|
168
|
+
before do
|
169
|
+
stub_get("/1/statuses/user_timeline.json").
|
170
|
+
to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
171
|
+
end
|
172
|
+
it "should request the correct resource" do
|
173
|
+
@client.user_timeline
|
174
|
+
a_get("/1/statuses/user_timeline.json").
|
175
|
+
should have_been_made
|
176
|
+
end
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
describe ".media_timeline" do
|
181
|
+
context "with a screen name passed" do
|
182
|
+
before do
|
183
|
+
stub_get("/1/statuses/media_timeline.json").
|
184
|
+
with(:query => {:screen_name => "sferik"}).
|
185
|
+
to_return(:body => fixture("media_timeline.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
186
|
+
end
|
187
|
+
it "should request the correct resource" do
|
188
|
+
@client.media_timeline("sferik")
|
189
|
+
a_get("/1/statuses/media_timeline.json").
|
190
|
+
with(:query => {:screen_name => "sferik"}).
|
191
|
+
should have_been_made
|
192
|
+
end
|
193
|
+
it "should return the 20 most recent images posted by the user specified by screen name or user id" do
|
194
|
+
statuses = @client.media_timeline("sferik")
|
195
|
+
statuses.should be_an Array
|
196
|
+
statuses.first.should be_a Twitter::Status
|
197
|
+
statuses.first.text.should == "Google is throwing up a question mark for Sunday's weather in Boston. At least they're being honest. http://t.co/Jh7bAhS"
|
198
|
+
end
|
199
|
+
end
|
200
|
+
context "without a screen name passed" do
|
201
|
+
before do
|
202
|
+
stub_get("/1/statuses/media_timeline.json").
|
203
|
+
to_return(:body => fixture("media_timeline.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
204
|
+
end
|
205
|
+
it "should request the correct resource" do
|
206
|
+
@client.media_timeline
|
207
|
+
a_get("/1/statuses/media_timeline.json").
|
208
|
+
should have_been_made
|
209
|
+
end
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
213
|
+
describe ".network_timeline" do
|
214
|
+
before do
|
215
|
+
stub_get("/i/statuses/network_timeline.json").
|
216
|
+
to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
217
|
+
end
|
218
|
+
it "should request the correct resource" do
|
219
|
+
@client.network_timeline
|
220
|
+
a_get("/i/statuses/network_timeline.json").
|
221
|
+
should have_been_made
|
222
|
+
end
|
223
|
+
it "should return the 20 most recent tweets of the authenticated user that have been retweeted by others" do
|
224
|
+
statuses = @client.network_timeline
|
225
|
+
statuses.should be_an Array
|
226
|
+
statuses.first.should be_a Twitter::Status
|
227
|
+
statuses.first.text.should == "Ruby is the best programming language for hiding the ugly bits."
|
228
|
+
end
|
229
|
+
end
|
230
|
+
|
231
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Twitter::Client do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@client = Twitter::Client.new
|
7
|
+
end
|
8
|
+
|
9
|
+
describe ".trends_daily" do
|
10
|
+
before do
|
11
|
+
stub_get("/1/trends/daily.json").
|
12
|
+
with(:query => {:date => "2010-10-24"}).
|
13
|
+
to_return(:body => fixture("trends_daily.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
14
|
+
end
|
15
|
+
it "should request the correct resource" do
|
16
|
+
@client.trends_daily(Date.parse("2010-10-24"))
|
17
|
+
a_get("/1/trends/daily.json").
|
18
|
+
with(:query => {:date => "2010-10-24"}).
|
19
|
+
should have_been_made
|
20
|
+
end
|
21
|
+
it "should return the top 20 trending topics for each hour in a given day" do
|
22
|
+
trends = @client.trends_daily(Date.parse("2010-10-24"))
|
23
|
+
trends.should be_a Hash
|
24
|
+
trends["2010-10-24 17:00"].should be_an Array
|
25
|
+
trends["2010-10-24 17:00"].first.should be_a Twitter::Trend
|
26
|
+
trends["2010-10-24 17:00"].first.name.should == "#bigbangcomeback"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe ".trends_weekly" do
|
31
|
+
before do
|
32
|
+
stub_get("/1/trends/weekly.json").
|
33
|
+
with(:query => {:date => "2010-10-24"}).
|
34
|
+
to_return(:body => fixture("trends_weekly.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
35
|
+
end
|
36
|
+
it "should request the correct resource" do
|
37
|
+
@client.trends_weekly(Date.parse("2010-10-24"))
|
38
|
+
a_get("/1/trends/weekly.json").
|
39
|
+
with(:query => {:date => "2010-10-24"}).
|
40
|
+
should have_been_made
|
41
|
+
end
|
42
|
+
it "should return the top 30 trending topics for each day in a given week" do
|
43
|
+
trends = @client.trends_weekly(Date.parse("2010-10-24"))
|
44
|
+
trends.should be_a Hash
|
45
|
+
trends["2010-10-24"].should be_an Array
|
46
|
+
trends["2010-10-24"].first.should be_a Twitter::Trend
|
47
|
+
trends["2010-10-24"].first.name.should == "#youcantbeuglyand"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
@@ -0,0 +1,189 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Twitter::Client do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@client = Twitter::Client.new
|
7
|
+
end
|
8
|
+
|
9
|
+
describe ".retweeters_of" do
|
10
|
+
context "with ids_only passed" do
|
11
|
+
before do
|
12
|
+
stub_get("/1/statuses/27467028175/retweeted_by/ids.json").
|
13
|
+
to_return(:body => fixture("ids.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
14
|
+
end
|
15
|
+
it "should request the correct resource" do
|
16
|
+
@client.retweeters_of(27467028175, :ids_only => true)
|
17
|
+
a_get("/1/statuses/27467028175/retweeted_by/ids.json").
|
18
|
+
should have_been_made
|
19
|
+
end
|
20
|
+
it "should return an array of numeric user IDs of retweeters of a status" do
|
21
|
+
ids = @client.retweeters_of(27467028175, :ids_only => true)
|
22
|
+
ids.should be_an Array
|
23
|
+
ids.first.should == 47
|
24
|
+
end
|
25
|
+
end
|
26
|
+
context "without ids_only passed" do
|
27
|
+
before do
|
28
|
+
stub_get("/1/statuses/27467028175/retweeted_by.json").
|
29
|
+
to_return(:body => fixture("retweeters_of.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
30
|
+
end
|
31
|
+
it "should request the correct resource" do
|
32
|
+
@client.retweeters_of(27467028175)
|
33
|
+
a_get("/1/statuses/27467028175/retweeted_by.json").
|
34
|
+
should have_been_made
|
35
|
+
end
|
36
|
+
it "should return an array of user of retweeters of a status" do
|
37
|
+
users = @client.retweeters_of(27467028175)
|
38
|
+
users.should be_an Array
|
39
|
+
users.first.should be_a Twitter::User
|
40
|
+
users.first.name.should == "Dave W Baldwin"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe ".retweets" do
|
46
|
+
before do
|
47
|
+
stub_get("/1/statuses/retweets/28561922516.json").
|
48
|
+
to_return(:body => fixture("retweets.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
49
|
+
end
|
50
|
+
it "should request the correct resource" do
|
51
|
+
@client.retweets(28561922516)
|
52
|
+
a_get("/1/statuses/retweets/28561922516.json").
|
53
|
+
should have_been_made
|
54
|
+
end
|
55
|
+
it "should return up to 100 of the first retweets of a given tweet" do
|
56
|
+
statuses = @client.retweets(28561922516)
|
57
|
+
statuses.should be_an Array
|
58
|
+
statuses.first.should be_a Twitter::Status
|
59
|
+
statuses.first.text.should == "RT @gruber: As for the Series, I'm for the Giants. Fuck Texas, fuck Nolan Ryan, fuck George Bush."
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
describe ".status" do
|
64
|
+
before do
|
65
|
+
stub_get("/1/statuses/show/25938088801.json").
|
66
|
+
to_return(:body => fixture("status.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
67
|
+
end
|
68
|
+
it "should request the correct resource" do
|
69
|
+
@client.status(25938088801)
|
70
|
+
a_get("/1/statuses/show/25938088801.json").
|
71
|
+
should have_been_made
|
72
|
+
end
|
73
|
+
it "should return a single status" do
|
74
|
+
status = @client.status(25938088801)
|
75
|
+
status.should be_a Twitter::Status
|
76
|
+
status.text.should == "@noradio working on implementing #NewTwitter API methods in the twitter gem. Twurl is making it easy. Thank you!"
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
describe ".status_destroy" do
|
81
|
+
before do
|
82
|
+
stub_delete("/1/statuses/destroy/25938088801.json").
|
83
|
+
to_return(:body => fixture("status.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
84
|
+
end
|
85
|
+
it "should request the correct resource" do
|
86
|
+
@client.status_destroy(25938088801)
|
87
|
+
a_delete("/1/statuses/destroy/25938088801.json").
|
88
|
+
should have_been_made
|
89
|
+
end
|
90
|
+
it "should return a single status" do
|
91
|
+
status = @client.status_destroy(25938088801)
|
92
|
+
status.should be_a Twitter::Status
|
93
|
+
status.text.should == "@noradio working on implementing #NewTwitter API methods in the twitter gem. Twurl is making it easy. Thank you!"
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
describe ".retweet" do
|
98
|
+
before do
|
99
|
+
stub_post("/1/statuses/retweet/28561922516.json").
|
100
|
+
to_return(:body => fixture("retweet.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
101
|
+
end
|
102
|
+
it "should request the correct resource" do
|
103
|
+
@client.retweet(28561922516)
|
104
|
+
a_post("/1/statuses/retweet/28561922516.json").
|
105
|
+
should have_been_made
|
106
|
+
end
|
107
|
+
it "should return the original Tweet with retweet details embedded" do
|
108
|
+
status = @client.retweet(28561922516)
|
109
|
+
status.should be_a Twitter::Status
|
110
|
+
status.text.should == "As for the Series, I'm for the Giants. Fuck Texas, fuck Nolan Ryan, fuck George Bush."
|
111
|
+
status.retweeted_status.text.should == "RT @gruber: As for the Series, I'm for the Giants. Fuck Texas, fuck Nolan Ryan, fuck George Bush."
|
112
|
+
status.retweeted_status.id.should_not == status.id
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
describe ".update" do
|
117
|
+
before do
|
118
|
+
stub_post("/1/statuses/update.json").
|
119
|
+
with(:body => {:status => "@noradio working on implementing #NewTwitter API methods in the twitter gem. Twurl is making it easy. Thank you!"}).
|
120
|
+
to_return(:body => fixture("status.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
121
|
+
end
|
122
|
+
it "should request the correct resource" do
|
123
|
+
@client.update("@noradio working on implementing #NewTwitter API methods in the twitter gem. Twurl is making it easy. Thank you!")
|
124
|
+
a_post("/1/statuses/update.json").
|
125
|
+
with(:body => {:status => "@noradio working on implementing #NewTwitter API methods in the twitter gem. Twurl is making it easy. Thank you!"}).
|
126
|
+
should have_been_made
|
127
|
+
end
|
128
|
+
it "should return a single status" do
|
129
|
+
status = @client.update("@noradio working on implementing #NewTwitter API methods in the twitter gem. Twurl is making it easy. Thank you!")
|
130
|
+
status.should be_a Twitter::Status
|
131
|
+
status.text.should == "@noradio working on implementing #NewTwitter API methods in the twitter gem. Twurl is making it easy. Thank you!"
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
describe ".update_with_media" do
|
136
|
+
before do
|
137
|
+
stub_post("/1/statuses/update_with_media.json", Twitter.media_endpoint).
|
138
|
+
to_return(:body => fixture("status_with_media.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
139
|
+
end
|
140
|
+
it "should request the correct resource" do
|
141
|
+
@client.update_with_media("You always have options", fixture("me.jpeg"))
|
142
|
+
a_post("/1/statuses/update_with_media.json", Twitter.media_endpoint).
|
143
|
+
should have_been_made
|
144
|
+
end
|
145
|
+
it "should return a single status" do
|
146
|
+
status = @client.update_with_media("You always have options", fixture("me.jpeg"))
|
147
|
+
status.text.should include("You always have options")
|
148
|
+
end
|
149
|
+
it 'should return the media as an entity' do
|
150
|
+
status = @client.update_with_media("You always have options", fixture("me.jpeg"))
|
151
|
+
status.media.should be
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
describe ".oembed" do
|
156
|
+
context "with id passed" do
|
157
|
+
before do
|
158
|
+
stub_get("/1/statuses/oembed.json?id=25938088801").
|
159
|
+
to_return(:body => fixture("oembed.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
160
|
+
end
|
161
|
+
it "should request the correct resource" do
|
162
|
+
@client.oembed(25938088801)
|
163
|
+
a_get("/1/statuses/oembed.json?id=25938088801").
|
164
|
+
should have_been_made
|
165
|
+
end
|
166
|
+
it "should return an OEmbed instance" do
|
167
|
+
oembed = @client.oembed(25938088801)
|
168
|
+
oembed.should be_a Twitter::OEmbed
|
169
|
+
end
|
170
|
+
end
|
171
|
+
context "with url passed" do
|
172
|
+
before do
|
173
|
+
stub_get("/1/statuses/oembed.json?url=https%3A%2F%2Ftwitter.com%2F%23!%2Ftwitter%2Fstatus%2F25938088801").
|
174
|
+
to_return(:body => fixture("oembed.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
175
|
+
end
|
176
|
+
it "should request the correct resource" do
|
177
|
+
@client.oembed('https://twitter.com/#!/twitter/status/25938088801')
|
178
|
+
a_get("/1/statuses/oembed.json?url=https%3A%2F%2Ftwitter.com%2F%23!%2Ftwitter%2Fstatus%2F25938088801").
|
179
|
+
should have_been_made
|
180
|
+
end
|
181
|
+
it "should return an OEmbed instance" do
|
182
|
+
oembed = @client.oembed('https://twitter.com/#!/twitter/status/25938088801')
|
183
|
+
oembed.should be_a Twitter::OEmbed
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
end
|
188
|
+
|
189
|
+
end
|