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,181 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Twitter::Client do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@client = Twitter::Client.new
|
7
|
+
end
|
8
|
+
|
9
|
+
describe ".rate_limit_status" do
|
10
|
+
before do
|
11
|
+
stub_get("/1/account/rate_limit_status.json").
|
12
|
+
to_return(:body => fixture("rate_limit_status.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
13
|
+
end
|
14
|
+
it "should request the correct resource" do
|
15
|
+
@client.rate_limit_status
|
16
|
+
a_get("/1/account/rate_limit_status.json").
|
17
|
+
should have_been_made
|
18
|
+
end
|
19
|
+
it "should return the remaining number of API requests available to the requesting user before the API limit is reached" do
|
20
|
+
rate_limit_status = @client.rate_limit_status
|
21
|
+
rate_limit_status.should be_a Twitter::RateLimitStatus
|
22
|
+
rate_limit_status.remaining_hits.should == 19993
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe ".verify_credentials" do
|
27
|
+
before do
|
28
|
+
stub_get("/1/account/verify_credentials.json").
|
29
|
+
to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
30
|
+
end
|
31
|
+
it "should request the correct resource" do
|
32
|
+
@client.verify_credentials
|
33
|
+
a_get("/1/account/verify_credentials.json").
|
34
|
+
should have_been_made
|
35
|
+
end
|
36
|
+
it "should return the requesting user" do
|
37
|
+
user = @client.verify_credentials
|
38
|
+
user.should be_a Twitter::User
|
39
|
+
user.name.should == "Erik Michaels-Ober"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe ".end_session" do
|
44
|
+
before do
|
45
|
+
stub_post("/1/account/end_session.json").
|
46
|
+
to_return(:body => fixture("end_session.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
47
|
+
end
|
48
|
+
it "should request the correct resource" do
|
49
|
+
@client.end_session
|
50
|
+
a_post("/1/account/end_session.json").
|
51
|
+
should have_been_made
|
52
|
+
end
|
53
|
+
it "should return a null cookie" do
|
54
|
+
end_session = @client.end_session
|
55
|
+
end_session['error'].should == "Logged out."
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
describe ".update_delivery_device" do
|
60
|
+
before do
|
61
|
+
stub_post("/1/account/update_delivery_device.json").
|
62
|
+
with(:body => {:device => "sms"}).
|
63
|
+
to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
64
|
+
end
|
65
|
+
it "should request the correct resource" do
|
66
|
+
@client.update_delivery_device("sms")
|
67
|
+
a_post("/1/account/update_delivery_device.json").
|
68
|
+
with(:body => {:device => "sms"}).
|
69
|
+
should have_been_made
|
70
|
+
end
|
71
|
+
it "should return a user" do
|
72
|
+
user = @client.update_delivery_device("sms")
|
73
|
+
user.should be_a Twitter::User
|
74
|
+
user.name.should == "Erik Michaels-Ober"
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
describe ".update_profile" do
|
79
|
+
before do
|
80
|
+
stub_post("/1/account/update_profile.json").
|
81
|
+
with(:body => {:url => "http://github.com/sferik/"}).
|
82
|
+
to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
83
|
+
end
|
84
|
+
it "should request the correct resource" do
|
85
|
+
@client.update_profile(:url => "http://github.com/sferik/")
|
86
|
+
a_post("/1/account/update_profile.json").
|
87
|
+
with(:body => {:url => "http://github.com/sferik/"}).
|
88
|
+
should have_been_made
|
89
|
+
end
|
90
|
+
it "should return a user" do
|
91
|
+
user = @client.update_profile(:url => "http://github.com/sferik/")
|
92
|
+
user.should be_a Twitter::User
|
93
|
+
user.name.should == "Erik Michaels-Ober"
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
describe ".update_profile_background_image" do
|
98
|
+
before do
|
99
|
+
stub_post("/1/account/update_profile_background_image.json").
|
100
|
+
to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
101
|
+
end
|
102
|
+
it "should request the correct resource" do
|
103
|
+
@client.update_profile_background_image(fixture("we_concept_bg2.png"))
|
104
|
+
a_post("/1/account/update_profile_background_image.json").
|
105
|
+
should have_been_made
|
106
|
+
end
|
107
|
+
it "should return a user" do
|
108
|
+
user = @client.update_profile_background_image(fixture("we_concept_bg2.png"))
|
109
|
+
user.should be_a Twitter::User
|
110
|
+
user.name.should == "Erik Michaels-Ober"
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
describe ".update_profile_colors" do
|
115
|
+
before do
|
116
|
+
stub_post("/1/account/update_profile_colors.json").
|
117
|
+
with(:body => {:profile_background_color => "000000"}).
|
118
|
+
to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
119
|
+
end
|
120
|
+
it "should request the correct resource" do
|
121
|
+
@client.update_profile_colors(:profile_background_color => "000000")
|
122
|
+
a_post("/1/account/update_profile_colors.json").
|
123
|
+
with(:body => {:profile_background_color => "000000"}).
|
124
|
+
should have_been_made
|
125
|
+
end
|
126
|
+
it "should return a user" do
|
127
|
+
user = @client.update_profile_colors(:profile_background_color => "000000")
|
128
|
+
user.should be_a Twitter::User
|
129
|
+
user.name.should == "Erik Michaels-Ober"
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
describe ".update_profile_image" do
|
134
|
+
before do
|
135
|
+
stub_post("/1/account/update_profile_image.json").
|
136
|
+
to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
137
|
+
end
|
138
|
+
it "should request the correct resource" do
|
139
|
+
@client.update_profile_image(fixture("me.jpeg"))
|
140
|
+
a_post("/1/account/update_profile_image.json").
|
141
|
+
should have_been_made
|
142
|
+
end
|
143
|
+
it "should return a user" do
|
144
|
+
user = @client.update_profile_image(fixture("me.jpeg"))
|
145
|
+
user.should be_a Twitter::User
|
146
|
+
user.name.should == "Erik Michaels-Ober"
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
describe ".settings" do
|
151
|
+
before do
|
152
|
+
stub_get("/1/account/settings.json").
|
153
|
+
to_return(:body => fixture("settings.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
154
|
+
stub_post("/1/account/settings.json").
|
155
|
+
with(:body => {:trend_location_woeid => "23424803"}).
|
156
|
+
to_return(:body => fixture("settings.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
157
|
+
end
|
158
|
+
it "should request the correct resource on GET" do
|
159
|
+
@client.settings
|
160
|
+
a_get("/1/account/settings.json").
|
161
|
+
should have_been_made
|
162
|
+
end
|
163
|
+
it "should return settings" do
|
164
|
+
settings = @client.settings
|
165
|
+
settings.should be_a Twitter::Settings
|
166
|
+
settings.language.should == 'en'
|
167
|
+
end
|
168
|
+
it "should request the correct resource on POST" do
|
169
|
+
@client.settings(:trend_location_woeid => "23424803")
|
170
|
+
a_post("/1/account/settings.json").
|
171
|
+
with(:body => {:trend_location_woeid => "23424803"}).
|
172
|
+
should have_been_made
|
173
|
+
end
|
174
|
+
it "should return settings" do
|
175
|
+
settings = @client.settings(:trend_location_woeid => "23424803")
|
176
|
+
settings.should be_a Twitter::Settings
|
177
|
+
settings.language.should == 'en'
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Twitter::Client do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@client = Twitter::Client.new
|
7
|
+
end
|
8
|
+
|
9
|
+
describe ".about_me" do
|
10
|
+
before do
|
11
|
+
stub_get("/i/activity/about_me.json").
|
12
|
+
to_return(:body => fixture("about_me.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
13
|
+
end
|
14
|
+
it "should request the correct resource" do
|
15
|
+
@client.activity_about_me
|
16
|
+
a_get("/i/activity/about_me.json").
|
17
|
+
with(:headers => {'X-Phx' => 'true'}).
|
18
|
+
should have_been_made
|
19
|
+
end
|
20
|
+
it "should return activity about me" do
|
21
|
+
activity_about_me = @client.activity_about_me
|
22
|
+
activity_about_me.first.should be_a Twitter::Mention
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe ".by_friends" do
|
27
|
+
before do
|
28
|
+
stub_get("/i/activity/by_friends.json").
|
29
|
+
to_return(:body => fixture("by_friends.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
30
|
+
end
|
31
|
+
it "should request the correct resource" do
|
32
|
+
@client.activity_by_friends
|
33
|
+
a_get("/i/activity/by_friends.json").
|
34
|
+
with(:headers => {'X-Phx' => 'true'}).
|
35
|
+
should have_been_made
|
36
|
+
end
|
37
|
+
it "should return activity by friends" do
|
38
|
+
activity_by_friends = @client.activity_by_friends
|
39
|
+
activity_by_friends.first.should be_a Twitter::Favorite
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
@@ -0,0 +1,106 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Twitter::Client do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@client = Twitter::Client.new
|
7
|
+
end
|
8
|
+
|
9
|
+
describe ".blocking" do
|
10
|
+
before do
|
11
|
+
stub_get("/1/blocks/blocking.json").
|
12
|
+
to_return(:body => fixture("users.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
13
|
+
end
|
14
|
+
it "should request the correct resource" do
|
15
|
+
@client.blocking
|
16
|
+
a_get("/1/blocks/blocking.json").
|
17
|
+
should have_been_made
|
18
|
+
end
|
19
|
+
it "should return an array of user objects that the authenticating user is blocking" do
|
20
|
+
users = @client.blocking
|
21
|
+
users.should be_an Array
|
22
|
+
users.first.should be_a Twitter::User
|
23
|
+
users.first.name.should == "Erik Michaels-Ober"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe ".blocked_ids" do
|
28
|
+
before do
|
29
|
+
stub_get("/1/blocks/blocking/ids.json").
|
30
|
+
to_return(:body => fixture("ids.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
31
|
+
end
|
32
|
+
it "should request the correct resource" do
|
33
|
+
@client.blocked_ids
|
34
|
+
a_get("/1/blocks/blocking/ids.json").
|
35
|
+
should have_been_made
|
36
|
+
end
|
37
|
+
it "should return an array of numeric user IDs the authenticating user is blocking" do
|
38
|
+
ids = @client.blocked_ids
|
39
|
+
ids.should be_an Array
|
40
|
+
ids.first.should == 47
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe ".block?" do
|
45
|
+
before do
|
46
|
+
stub_get("/1/blocks/exists.json").
|
47
|
+
with(:query => {:screen_name => "sferik"}).
|
48
|
+
to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
49
|
+
stub_get("/1/blocks/exists.json").
|
50
|
+
with(:query => {:screen_name => "pengwynn"}).
|
51
|
+
to_return(:body => fixture("not_found.json"), :status => 404, :headers => {:content_type => "application/json; charset=utf-8"})
|
52
|
+
end
|
53
|
+
it "should request the correct resource" do
|
54
|
+
@client.block?("sferik")
|
55
|
+
a_get("/1/blocks/exists.json").
|
56
|
+
with(:query => {:screen_name => "sferik"}).
|
57
|
+
should have_been_made
|
58
|
+
end
|
59
|
+
it "should return true if block exists" do
|
60
|
+
block = @client.block?("sferik")
|
61
|
+
block.should be_true
|
62
|
+
end
|
63
|
+
it "should return false if block does not exist" do
|
64
|
+
block = @client.block?("pengwynn")
|
65
|
+
block.should be_false
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
describe ".block" do
|
70
|
+
before do
|
71
|
+
stub_post("/1/blocks/create.json").
|
72
|
+
with(:body => {:screen_name => "sferik"}).
|
73
|
+
to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
74
|
+
end
|
75
|
+
it "should request the correct resource" do
|
76
|
+
@client.block("sferik")
|
77
|
+
a_post("/1/blocks/create.json").
|
78
|
+
should have_been_made
|
79
|
+
end
|
80
|
+
it "should return the blocked user" do
|
81
|
+
user = @client.block("sferik")
|
82
|
+
user.should be_a Twitter::User
|
83
|
+
user.name.should == "Erik Michaels-Ober"
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
describe ".unblock" do
|
88
|
+
before do
|
89
|
+
stub_delete("/1/blocks/destroy.json").
|
90
|
+
with(:query => {:screen_name => "sferik"}).
|
91
|
+
to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
92
|
+
end
|
93
|
+
it "should request the correct resource" do
|
94
|
+
@client.unblock("sferik")
|
95
|
+
a_delete("/1/blocks/destroy.json").
|
96
|
+
with(:query => {:screen_name => "sferik"}).
|
97
|
+
should have_been_made
|
98
|
+
end
|
99
|
+
it "should return the un-blocked user" do
|
100
|
+
user = @client.unblock("sferik")
|
101
|
+
user.should be_a Twitter::User
|
102
|
+
user.name.should == "Erik Michaels-Ober"
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
end
|
@@ -0,0 +1,98 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Twitter::Client do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@client = Twitter::Client.new
|
7
|
+
end
|
8
|
+
|
9
|
+
describe ".direct_messages" do
|
10
|
+
before do
|
11
|
+
stub_get("/1/direct_messages.json").
|
12
|
+
to_return(:body => fixture("direct_messages.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
13
|
+
end
|
14
|
+
it "should request the correct resource" do
|
15
|
+
@client.direct_messages
|
16
|
+
a_get("/1/direct_messages.json").
|
17
|
+
should have_been_made
|
18
|
+
end
|
19
|
+
it "should return the 20 most recent direct messages sent to the authenticating user" do
|
20
|
+
direct_messages = @client.direct_messages
|
21
|
+
direct_messages.should be_an Array
|
22
|
+
direct_messages.first.should be_an Twitter::DirectMessage
|
23
|
+
direct_messages.first.sender.name.should == "Erik Michaels-Ober"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe ".direct_messages_sent" do
|
28
|
+
before do
|
29
|
+
stub_get("/1/direct_messages/sent.json").
|
30
|
+
to_return(:body => fixture("direct_messages.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
31
|
+
end
|
32
|
+
it "should request the correct resource" do
|
33
|
+
@client.direct_messages_sent
|
34
|
+
a_get("/1/direct_messages/sent.json").
|
35
|
+
should have_been_made
|
36
|
+
end
|
37
|
+
it "should return the 20 most recent direct messages sent by the authenticating user" do
|
38
|
+
direct_messages = @client.direct_messages_sent
|
39
|
+
direct_messages.should be_an Array
|
40
|
+
direct_messages.first.should be_an Twitter::DirectMessage
|
41
|
+
direct_messages.first.sender.name.should == "Erik Michaels-Ober"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe ".direct_message_destroy" do
|
46
|
+
before do
|
47
|
+
stub_delete("/1/direct_messages/destroy/1825785544.json").
|
48
|
+
to_return(:body => fixture("direct_message.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
49
|
+
end
|
50
|
+
it "should request the correct resource" do
|
51
|
+
@client.direct_message_destroy(1825785544)
|
52
|
+
a_delete("/1/direct_messages/destroy/1825785544.json").
|
53
|
+
should have_been_made
|
54
|
+
end
|
55
|
+
it "should return the deleted message" do
|
56
|
+
direct_message = @client.direct_message_destroy(1825785544)
|
57
|
+
direct_message.should be_an Twitter::DirectMessage
|
58
|
+
direct_message.text.should == "Creating a fixture for the Twitter gem"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe ".direct_message_create" do
|
63
|
+
before do
|
64
|
+
stub_post("/1/direct_messages/new.json").
|
65
|
+
with(:body => {:screen_name => "pengwynn", :text => "Creating a fixture for the Twitter gem"}).
|
66
|
+
to_return(:body => fixture("direct_message.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
67
|
+
end
|
68
|
+
it "should request the correct resource" do
|
69
|
+
@client.direct_message_create("pengwynn", "Creating a fixture for the Twitter gem")
|
70
|
+
a_post("/1/direct_messages/new.json").
|
71
|
+
with(:body => {:screen_name => "pengwynn", :text => "Creating a fixture for the Twitter gem"}).
|
72
|
+
should have_been_made
|
73
|
+
end
|
74
|
+
it "should return the sent message" do
|
75
|
+
direct_message = @client.direct_message_create("pengwynn", "Creating a fixture for the Twitter gem")
|
76
|
+
direct_message.should be_an Twitter::DirectMessage
|
77
|
+
direct_message.text.should == "Creating a fixture for the Twitter gem"
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
describe ".direct_message" do
|
82
|
+
before do
|
83
|
+
stub_get("/1/direct_messages/show/1825786345.json").
|
84
|
+
to_return(:body => fixture("direct_message.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
85
|
+
end
|
86
|
+
it "should request the correct resource" do
|
87
|
+
@client.direct_message(1825786345)
|
88
|
+
a_get("/1/direct_messages/show/1825786345.json").
|
89
|
+
should have_been_made
|
90
|
+
end
|
91
|
+
it "should return the 20 most recent direct messages sent to the authenticating user" do
|
92
|
+
direct_messages = @client.direct_message(1825786345)
|
93
|
+
direct_messages.should be_an Twitter::DirectMessage
|
94
|
+
direct_messages.sender.name.should == "Erik Michaels-Ober"
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Twitter::Client do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@client = Twitter::Client.new
|
7
|
+
end
|
8
|
+
|
9
|
+
describe ".favorites" do
|
10
|
+
context "with a screen name passed" do
|
11
|
+
before do
|
12
|
+
stub_get("/1/favorites/sferik.json").
|
13
|
+
to_return(:body => fixture("favorites.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
14
|
+
end
|
15
|
+
it "should request the correct resource" do
|
16
|
+
@client.favorites("sferik")
|
17
|
+
a_get("/1/favorites/sferik.json").
|
18
|
+
should have_been_made
|
19
|
+
end
|
20
|
+
it "should return the 20 most recent favorite statuses for the authenticating user or user specified by the ID parameter" do
|
21
|
+
favorites = @client.favorites("sferik")
|
22
|
+
favorites.should be_an Array
|
23
|
+
favorites.first.should be_an Twitter::Status
|
24
|
+
favorites.first.user.name.should == "Zach Brock"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
context "without arguments passed" do
|
28
|
+
before do
|
29
|
+
stub_get("/1/favorites.json").
|
30
|
+
to_return(:body => fixture("favorites.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
31
|
+
end
|
32
|
+
it "should request the correct resource" do
|
33
|
+
@client.favorites
|
34
|
+
a_get("/1/favorites.json").
|
35
|
+
should have_been_made
|
36
|
+
end
|
37
|
+
it "should return the 20 most recent favorite statuses for the authenticating user or user specified by the ID parameter" do
|
38
|
+
favorites = @client.favorites
|
39
|
+
favorites.should be_an Array
|
40
|
+
favorites.first.should be_an Twitter::Status
|
41
|
+
favorites.first.user.name.should == "Zach Brock"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe ".favorite" do
|
47
|
+
before do
|
48
|
+
stub_post("/1/favorites/create/25938088801.json").
|
49
|
+
to_return(:body => fixture("status.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
50
|
+
end
|
51
|
+
it "should request the correct resource" do
|
52
|
+
@client.favorite(25938088801)
|
53
|
+
a_post("/1/favorites/create/25938088801.json").
|
54
|
+
should have_been_made
|
55
|
+
end
|
56
|
+
it "should return the favorite status when successful" do
|
57
|
+
status = @client.favorite(25938088801)
|
58
|
+
status.should be_an Twitter::Status
|
59
|
+
status.text.should == "@noradio working on implementing #NewTwitter API methods in the twitter gem. Twurl is making it easy. Thank you!"
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
describe ".unfavorite" do
|
64
|
+
before do
|
65
|
+
stub_delete("/1/favorites/destroy/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.unfavorite(25938088801)
|
70
|
+
a_delete("/1/favorites/destroy/25938088801.json").
|
71
|
+
should have_been_made
|
72
|
+
end
|
73
|
+
it "should return the un-favorite status when successful" do
|
74
|
+
status = @client.unfavorite(25938088801)
|
75
|
+
status.should be_an 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
|
+
end
|