twitter 4.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 +673 -0
- data/LICENSE.md +20 -0
- data/README.md +415 -0
- data/Rakefile +11 -0
- data/lib/twitter.rb +29 -0
- data/lib/twitter/action/favorite.rb +19 -0
- data/lib/twitter/action/follow.rb +31 -0
- data/lib/twitter/action/list_member_added.rb +41 -0
- data/lib/twitter/action/mention.rb +48 -0
- data/lib/twitter/action/reply.rb +27 -0
- data/lib/twitter/action/retweet.rb +27 -0
- data/lib/twitter/action/tweet.rb +22 -0
- data/lib/twitter/action_factory.rb +22 -0
- data/lib/twitter/api.rb +2442 -0
- data/lib/twitter/base.rb +119 -0
- data/lib/twitter/basic_user.rb +8 -0
- data/lib/twitter/client.rb +96 -0
- data/lib/twitter/configurable.rb +67 -0
- data/lib/twitter/configuration.rb +20 -0
- data/lib/twitter/core_ext/array.rb +7 -0
- data/lib/twitter/core_ext/enumerable.rb +11 -0
- data/lib/twitter/core_ext/hash.rb +100 -0
- data/lib/twitter/core_ext/kernel.rb +15 -0
- data/lib/twitter/core_ext/string.rb +10 -0
- data/lib/twitter/creatable.rb +20 -0
- data/lib/twitter/cursor.rb +87 -0
- data/lib/twitter/default.rb +101 -0
- data/lib/twitter/direct_message.rb +21 -0
- data/lib/twitter/entity.rb +7 -0
- data/lib/twitter/entity/hashtag.rb +9 -0
- data/lib/twitter/entity/url.rb +9 -0
- data/lib/twitter/entity/user_mention.rb +9 -0
- data/lib/twitter/error.rb +34 -0
- data/lib/twitter/error/bad_gateway.rb +11 -0
- data/lib/twitter/error/bad_request.rb +10 -0
- data/lib/twitter/error/client_error.rb +35 -0
- data/lib/twitter/error/decode_error.rb +9 -0
- data/lib/twitter/error/forbidden.rb +10 -0
- data/lib/twitter/error/gateway_timeout.rb +11 -0
- data/lib/twitter/error/identity_map_key_error.rb +9 -0
- data/lib/twitter/error/internal_server_error.rb +11 -0
- data/lib/twitter/error/not_acceptable.rb +10 -0
- data/lib/twitter/error/not_found.rb +10 -0
- data/lib/twitter/error/rate_limited.rb +11 -0
- data/lib/twitter/error/server_error.rb +28 -0
- data/lib/twitter/error/service_unavailable.rb +11 -0
- data/lib/twitter/error/unauthorized.rb +10 -0
- data/lib/twitter/factory.rb +21 -0
- data/lib/twitter/geo.rb +15 -0
- data/lib/twitter/geo/point.rb +22 -0
- data/lib/twitter/geo/polygon.rb +8 -0
- data/lib/twitter/geo_factory.rb +18 -0
- data/lib/twitter/identity.rb +50 -0
- data/lib/twitter/identity_map.rb +22 -0
- data/lib/twitter/language.rb +7 -0
- data/lib/twitter/list.rb +18 -0
- data/lib/twitter/media/photo.rb +22 -0
- data/lib/twitter/media_factory.rb +17 -0
- data/lib/twitter/metadata.rb +7 -0
- data/lib/twitter/oembed.rb +8 -0
- data/lib/twitter/place.rb +34 -0
- data/lib/twitter/rate_limit.rb +45 -0
- data/lib/twitter/relationship.rb +36 -0
- data/lib/twitter/request/multipart_with_file.rb +41 -0
- data/lib/twitter/response/parse_json.rb +25 -0
- data/lib/twitter/response/raise_error.rb +30 -0
- data/lib/twitter/saved_search.rb +9 -0
- data/lib/twitter/search_results.rb +48 -0
- data/lib/twitter/settings.rb +17 -0
- data/lib/twitter/size.rb +24 -0
- data/lib/twitter/source_user.rb +15 -0
- data/lib/twitter/suggestion.rb +22 -0
- data/lib/twitter/target_user.rb +8 -0
- data/lib/twitter/trend.rb +14 -0
- data/lib/twitter/tweet.rb +145 -0
- data/lib/twitter/user.rb +97 -0
- data/lib/twitter/version.rb +18 -0
- data/spec/fixtures/about_me.json +1 -0
- data/spec/fixtures/activity_summary.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/favorites.json +1 -0
- data/spec/fixtures/following.json +1 -0
- data/spec/fixtures/forbidden.json +1 -0
- data/spec/fixtures/friendships.json +1 -0
- data/spec/fixtures/ids.json +1 -0
- data/spec/fixtures/ids_list.json +1 -0
- data/spec/fixtures/ids_list2.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/no_user_matches.json +1 -0
- data/spec/fixtures/not_acceptable.json +1 -0
- data/spec/fixtures/not_following.json +1 -0
- data/spec/fixtures/not_found.json +1 -0
- data/spec/fixtures/oembed.json +1 -0
- data/spec/fixtures/pbjt.gif +0 -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/related_results.json +1 -0
- data/spec/fixtures/resolve.json +1 -0
- data/spec/fixtures/retweet.json +1 -0
- data/spec/fixtures/retweeted_status.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/search_malformed.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/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/fixtures/wildcomet2.jpe +0 -0
- data/spec/helper.rb +53 -0
- data/spec/twitter/action/favorite_spec.rb +29 -0
- data/spec/twitter/action/follow_spec.rb +29 -0
- data/spec/twitter/action/list_member_added_spec.rb +41 -0
- data/spec/twitter/action/mention_spec.rb +52 -0
- data/spec/twitter/action/reply_spec.rb +41 -0
- data/spec/twitter/action/retweet_spec.rb +41 -0
- data/spec/twitter/action_factory_spec.rb +37 -0
- data/spec/twitter/action_spec.rb +16 -0
- data/spec/twitter/api/account_spec.rb +148 -0
- data/spec/twitter/api/activity_spec.rb +41 -0
- data/spec/twitter/api/blocks_spec.rb +167 -0
- data/spec/twitter/api/direct_messages_spec.rb +142 -0
- data/spec/twitter/api/friendships_spec.rb +567 -0
- data/spec/twitter/api/geo_spec.rb +100 -0
- data/spec/twitter/api/help_spec.rb +76 -0
- data/spec/twitter/api/lists_spec.rb +900 -0
- data/spec/twitter/api/report_spam_spec.rb +29 -0
- data/spec/twitter/api/saved_searches_spec.rb +100 -0
- data/spec/twitter/api/search_spec.rb +68 -0
- data/spec/twitter/api/statuses_spec.rb +559 -0
- data/spec/twitter/api/trends_spec.rb +80 -0
- data/spec/twitter/api/users_spec.rb +419 -0
- data/spec/twitter/base_spec.rb +113 -0
- data/spec/twitter/basic_user_spec.rb +23 -0
- data/spec/twitter/client_spec.rb +175 -0
- data/spec/twitter/configuration_spec.rb +17 -0
- data/spec/twitter/cursor_spec.rb +102 -0
- data/spec/twitter/direct_message_spec.rb +56 -0
- data/spec/twitter/error/client_error_spec.rb +40 -0
- data/spec/twitter/error/server_error_spec.rb +24 -0
- data/spec/twitter/error_spec.rb +20 -0
- data/spec/twitter/geo/point_spec.rb +41 -0
- data/spec/twitter/geo/polygon_spec.rb +29 -0
- data/spec/twitter/geo_factory_spec.rb +21 -0
- data/spec/twitter/geo_spec.rb +29 -0
- data/spec/twitter/identifiable_spec.rb +54 -0
- data/spec/twitter/list_spec.rb +45 -0
- data/spec/twitter/media/photo_spec.rb +35 -0
- data/spec/twitter/media_factory_spec.rb +17 -0
- data/spec/twitter/oembed_spec.rb +146 -0
- data/spec/twitter/place_spec.rb +75 -0
- data/spec/twitter/rate_limit_spec.rb +76 -0
- data/spec/twitter/relationship_spec.rb +35 -0
- data/spec/twitter/saved_search_spec.rb +34 -0
- data/spec/twitter/search_results_spec.rb +89 -0
- data/spec/twitter/settings_spec.rb +16 -0
- data/spec/twitter/size_spec.rb +38 -0
- data/spec/twitter/source_user_spec.rb +23 -0
- data/spec/twitter/suggestion_spec.rb +50 -0
- data/spec/twitter/target_user_spec.rb +23 -0
- data/spec/twitter/trend_spec.rb +38 -0
- data/spec/twitter/tweet_spec.rb +307 -0
- data/spec/twitter/user_spec.rb +127 -0
- data/spec/twitter_spec.rb +93 -0
- data/twitter.gemspec +30 -0
- metadata +584 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
require 'helper'
|
|
2
|
+
|
|
3
|
+
describe Twitter::API do
|
|
4
|
+
|
|
5
|
+
before do
|
|
6
|
+
@client = Twitter::Client.new
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
describe "#report_spam" do
|
|
10
|
+
before do
|
|
11
|
+
stub_post("/1.1/report_spam.json").
|
|
12
|
+
with(:body => {:screen_name => "sferik"}).
|
|
13
|
+
to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
|
14
|
+
end
|
|
15
|
+
it "requests the correct resource" do
|
|
16
|
+
@client.report_spam("sferik")
|
|
17
|
+
a_post("/1.1/report_spam.json").
|
|
18
|
+
with(:body => {:screen_name => "sferik"}).
|
|
19
|
+
should have_been_made
|
|
20
|
+
end
|
|
21
|
+
it "returns an array of users" do
|
|
22
|
+
users = @client.report_spam("sferik")
|
|
23
|
+
users.should be_an Array
|
|
24
|
+
users.first.should be_a Twitter::User
|
|
25
|
+
users.first.id.should eq 7505382
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
end
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
require 'helper'
|
|
2
|
+
|
|
3
|
+
describe Twitter::API do
|
|
4
|
+
|
|
5
|
+
before do
|
|
6
|
+
@client = Twitter::Client.new
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
describe "#saved_searches" do
|
|
10
|
+
context "with ids passed" do
|
|
11
|
+
before do
|
|
12
|
+
stub_get("/1.1/saved_searches/show/16129012.json").
|
|
13
|
+
to_return(:body => fixture("saved_search.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
|
14
|
+
end
|
|
15
|
+
it "requests the correct resource" do
|
|
16
|
+
@client.saved_searches(16129012)
|
|
17
|
+
a_get("/1.1/saved_searches/show/16129012.json").
|
|
18
|
+
should have_been_made
|
|
19
|
+
end
|
|
20
|
+
it "returns an array of saved searches" do
|
|
21
|
+
saved_searches = @client.saved_searches(16129012)
|
|
22
|
+
saved_searches.should be_an Array
|
|
23
|
+
saved_searches.first.should be_a Twitter::SavedSearch
|
|
24
|
+
saved_searches.first.name.should eq "twitter"
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
context "without ids passed" do
|
|
28
|
+
before do
|
|
29
|
+
stub_get("/1.1/saved_searches/list.json").
|
|
30
|
+
to_return(:body => fixture("saved_searches.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
|
31
|
+
end
|
|
32
|
+
it "requests the correct resource" do
|
|
33
|
+
@client.saved_searches
|
|
34
|
+
a_get("/1.1/saved_searches/list.json").
|
|
35
|
+
should have_been_made
|
|
36
|
+
end
|
|
37
|
+
it "returns the authenticated user's saved search queries" do
|
|
38
|
+
saved_searches = @client.saved_searches
|
|
39
|
+
saved_searches.should be_an Array
|
|
40
|
+
saved_searches.first.should be_a Twitter::SavedSearch
|
|
41
|
+
saved_searches.first.name.should eq "twitter"
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
describe "#saved_search" do
|
|
47
|
+
before do
|
|
48
|
+
stub_get("/1.1/saved_searches/show/16129012.json").
|
|
49
|
+
to_return(:body => fixture("saved_search.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
|
50
|
+
end
|
|
51
|
+
it "requests the correct resource" do
|
|
52
|
+
@client.saved_search(16129012)
|
|
53
|
+
a_get("/1.1/saved_searches/show/16129012.json").
|
|
54
|
+
should have_been_made
|
|
55
|
+
end
|
|
56
|
+
it "returns a saved search" do
|
|
57
|
+
saved_search = @client.saved_search(16129012)
|
|
58
|
+
saved_search.should be_a Twitter::SavedSearch
|
|
59
|
+
saved_search.name.should eq "twitter"
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
describe "#saved_search_create" do
|
|
64
|
+
before do
|
|
65
|
+
stub_post("/1.1/saved_searches/create.json").
|
|
66
|
+
with(:body => {:query => "twitter"}).
|
|
67
|
+
to_return(:body => fixture("saved_search.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
|
68
|
+
end
|
|
69
|
+
it "requests the correct resource" do
|
|
70
|
+
@client.saved_search_create("twitter")
|
|
71
|
+
a_post("/1.1/saved_searches/create.json").
|
|
72
|
+
with(:body => {:query => "twitter"}).
|
|
73
|
+
should have_been_made
|
|
74
|
+
end
|
|
75
|
+
it "returns the created saved search" do
|
|
76
|
+
saved_search = @client.saved_search_create("twitter")
|
|
77
|
+
saved_search.should be_a Twitter::SavedSearch
|
|
78
|
+
saved_search.name.should eq "twitter"
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
describe "#saved_search_destroy" do
|
|
83
|
+
before do
|
|
84
|
+
stub_post("/1.1/saved_searches/destroy/16129012.json").
|
|
85
|
+
to_return(:body => fixture("saved_search.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
|
86
|
+
end
|
|
87
|
+
it "requests the correct resource" do
|
|
88
|
+
@client.saved_search_destroy(16129012)
|
|
89
|
+
a_post("/1.1/saved_searches/destroy/16129012.json").
|
|
90
|
+
should have_been_made
|
|
91
|
+
end
|
|
92
|
+
it "returns an array of deleted saved searches" do
|
|
93
|
+
saved_searches = @client.saved_search_destroy(16129012)
|
|
94
|
+
saved_searches.should be_an Array
|
|
95
|
+
saved_searches.first.should be_a Twitter::SavedSearch
|
|
96
|
+
saved_searches.first.name.should eq "twitter"
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
end
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
require 'helper'
|
|
2
|
+
|
|
3
|
+
describe Twitter::API do
|
|
4
|
+
|
|
5
|
+
before do
|
|
6
|
+
@client = Twitter::Client.new
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
describe "#search" do
|
|
10
|
+
before do
|
|
11
|
+
stub_get("/1.1/search/tweets.json").
|
|
12
|
+
with(:query => {:q => "twitter"}).
|
|
13
|
+
to_return(:body => fixture("search.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
|
14
|
+
end
|
|
15
|
+
it "requests the correct resource" do
|
|
16
|
+
@client.search('twitter')
|
|
17
|
+
a_get("/1.1/search/tweets.json").
|
|
18
|
+
with(:query => {:q => "twitter"}).
|
|
19
|
+
should have_been_made
|
|
20
|
+
end
|
|
21
|
+
it "returns recent Tweets related to a query with images and videos embedded" do
|
|
22
|
+
search = @client.search('twitter')
|
|
23
|
+
search.should be_a Twitter::SearchResults
|
|
24
|
+
search.results.should be_an Array
|
|
25
|
+
search.results.first.should be_a Twitter::Tweet
|
|
26
|
+
search.results.first.text.should eq "Bubble Mailer #freebandnames"
|
|
27
|
+
end
|
|
28
|
+
it "returns the max_id value for a search result" do
|
|
29
|
+
search = @client.search('twitter')
|
|
30
|
+
search.max_id.should eq(250126199840518145)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
context "when search API responds a malformed result" do
|
|
34
|
+
before do
|
|
35
|
+
stub_get("/1.1/search/tweets.json").
|
|
36
|
+
with(:query => {:q => "twitter"}).
|
|
37
|
+
to_return(:body => fixture("/search_malformed.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
it "returns an empty array" do
|
|
41
|
+
search = @client.search('twitter')
|
|
42
|
+
search.results.should be_an Array
|
|
43
|
+
search.results.should be_empty
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
describe "#phoenix_search" do
|
|
49
|
+
before do
|
|
50
|
+
stub_get("/phoenix_search.phoenix").
|
|
51
|
+
with(:query => {:q => "twitter"}).
|
|
52
|
+
to_return(:body => fixture("phoenix_search.phoenix"), :headers => {:content_type => "application/json; charset=utf-8"})
|
|
53
|
+
end
|
|
54
|
+
it "requests the correct resource" do
|
|
55
|
+
@client.phoenix_search('twitter')
|
|
56
|
+
a_get("/phoenix_search.phoenix").
|
|
57
|
+
with(:query => {:q => "twitter"}).
|
|
58
|
+
should have_been_made
|
|
59
|
+
end
|
|
60
|
+
it "returns recent Tweets related to a query with images and videos embedded" do
|
|
61
|
+
search = @client.phoenix_search('twitter')
|
|
62
|
+
search.should be_an Array
|
|
63
|
+
search.first.should be_a Twitter::Tweet
|
|
64
|
+
search.first.text.should eq "looking at twitter trends just makes me realize how little i really understand about mankind."
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
end
|
|
@@ -0,0 +1,559 @@
|
|
|
1
|
+
require 'helper'
|
|
2
|
+
|
|
3
|
+
describe Twitter::API 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.1/favorites/list.json").
|
|
13
|
+
with(:query => {:screen_name => "sferik"}).
|
|
14
|
+
to_return(:body => fixture("favorites.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
|
15
|
+
end
|
|
16
|
+
it "requests the correct resource" do
|
|
17
|
+
@client.favorites("sferik")
|
|
18
|
+
a_get("/1.1/favorites/list.json").
|
|
19
|
+
with(:query => {:screen_name => "sferik"}).
|
|
20
|
+
should have_been_made
|
|
21
|
+
end
|
|
22
|
+
it "returns the 20 most recent favorite Tweets for the authenticating user or user specified by the ID parameter" do
|
|
23
|
+
favorites = @client.favorites("sferik")
|
|
24
|
+
favorites.should be_an Array
|
|
25
|
+
favorites.first.should be_a Twitter::Tweet
|
|
26
|
+
favorites.first.user.id.should eq 2404341
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
context "without arguments passed" do
|
|
30
|
+
before do
|
|
31
|
+
stub_get("/1.1/favorites/list.json").
|
|
32
|
+
to_return(:body => fixture("favorites.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
|
33
|
+
end
|
|
34
|
+
it "requests the correct resource" do
|
|
35
|
+
@client.favorites
|
|
36
|
+
a_get("/1.1/favorites/list.json").
|
|
37
|
+
should have_been_made
|
|
38
|
+
end
|
|
39
|
+
it "returns the 20 most recent favorite Tweets for the authenticating user or user specified by the ID parameter" do
|
|
40
|
+
favorites = @client.favorites
|
|
41
|
+
favorites.should be_an Array
|
|
42
|
+
favorites.first.should be_a Twitter::Tweet
|
|
43
|
+
favorites.first.user.id.should eq 2404341
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
describe "#favorite" do
|
|
49
|
+
before do
|
|
50
|
+
stub_post("/1.1/favorites/create.json").
|
|
51
|
+
with(:body => {:id => "25938088801"}).
|
|
52
|
+
to_return(:body => fixture("status.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
|
53
|
+
end
|
|
54
|
+
it "requests the correct resource" do
|
|
55
|
+
@client.favorite(25938088801)
|
|
56
|
+
a_post("/1.1/favorites/create.json").
|
|
57
|
+
with(:body => {:id => "25938088801"}).
|
|
58
|
+
should have_been_made
|
|
59
|
+
end
|
|
60
|
+
it "returns an array of favorited Tweets" do
|
|
61
|
+
tweets = @client.favorite(25938088801)
|
|
62
|
+
tweets.should be_an Array
|
|
63
|
+
tweets.first.should be_a Twitter::Tweet
|
|
64
|
+
tweets.first.text.should eq "@noradio working on implementing #NewTwitter API methods in the twitter gem. Twurl is making it easy. Thank you!"
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
describe "#unfavorite" do
|
|
69
|
+
before do
|
|
70
|
+
stub_post("/1.1/favorites/destroy.json").
|
|
71
|
+
with(:body => {:id => "25938088801"}).
|
|
72
|
+
to_return(:body => fixture("status.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
|
73
|
+
end
|
|
74
|
+
it "requests the correct resource" do
|
|
75
|
+
@client.unfavorite(25938088801)
|
|
76
|
+
a_post("/1.1/favorites/destroy.json").
|
|
77
|
+
with(:body => {:id => "25938088801"}).
|
|
78
|
+
should have_been_made
|
|
79
|
+
end
|
|
80
|
+
it "returns an array of un-favorited Tweets" do
|
|
81
|
+
tweets = @client.unfavorite(25938088801)
|
|
82
|
+
tweets.should be_an Array
|
|
83
|
+
tweets.first.should be_a Twitter::Tweet
|
|
84
|
+
tweets.first.text.should eq "@noradio working on implementing #NewTwitter API methods in the twitter gem. Twurl is making it easy. Thank you!"
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
describe "#home_timeline" do
|
|
89
|
+
before do
|
|
90
|
+
stub_get("/1.1/statuses/home_timeline.json").
|
|
91
|
+
to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
|
92
|
+
end
|
|
93
|
+
it "requests the correct resource" do
|
|
94
|
+
@client.home_timeline
|
|
95
|
+
a_get("/1.1/statuses/home_timeline.json").
|
|
96
|
+
should have_been_made
|
|
97
|
+
end
|
|
98
|
+
it "returns the 20 most recent Tweets, including retweets if they exist, posted by the authenticating user and the user's they follow" do
|
|
99
|
+
tweets = @client.home_timeline
|
|
100
|
+
tweets.should be_an Array
|
|
101
|
+
tweets.first.should be_a Twitter::Tweet
|
|
102
|
+
tweets.first.text.should eq "Happy Birthday @imdane. Watch out for those @rally pranksters!"
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
describe "#mentions_timeline" do
|
|
107
|
+
before do
|
|
108
|
+
stub_get("/1.1/statuses/mentions_timeline.json").
|
|
109
|
+
to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
|
110
|
+
end
|
|
111
|
+
it "requests the correct resource" do
|
|
112
|
+
@client.mentions_timeline
|
|
113
|
+
a_get("/1.1/statuses/mentions_timeline.json").
|
|
114
|
+
should have_been_made
|
|
115
|
+
end
|
|
116
|
+
it "returns the 20 most recent mentions (status containing @username) for the authenticating user" do
|
|
117
|
+
tweets = @client.mentions_timeline
|
|
118
|
+
tweets.should be_an Array
|
|
119
|
+
tweets.first.should be_a Twitter::Tweet
|
|
120
|
+
tweets.first.text.should eq "Happy Birthday @imdane. Watch out for those @rally pranksters!"
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
describe "#retweeted_by_user" do
|
|
125
|
+
before do
|
|
126
|
+
stub_get("/1.1/statuses/user_timeline.json").
|
|
127
|
+
with(:query => {:include_rts => "true", :screen_name => "sferik", :count => "200"}).
|
|
128
|
+
to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
|
129
|
+
stub_get("/1.1/statuses/user_timeline.json").
|
|
130
|
+
with(:query => {:include_rts => "true", :screen_name => "sferik", :count => "200", :max_id => "244102729860009983"}).
|
|
131
|
+
to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
|
132
|
+
end
|
|
133
|
+
it "requests the correct resource" do
|
|
134
|
+
@client.retweeted_by_user("sferik")
|
|
135
|
+
a_get("/1.1/statuses/user_timeline.json").
|
|
136
|
+
with(:query => {:include_rts => "true", :screen_name => "sferik", :count => "200"}).
|
|
137
|
+
should have_been_made
|
|
138
|
+
a_get("/1.1/statuses/user_timeline.json").
|
|
139
|
+
with(:query => {:include_rts => "true", :screen_name => "sferik", :count => "200", :max_id => "244102729860009983"}).
|
|
140
|
+
should have_been_made.times(3)
|
|
141
|
+
end
|
|
142
|
+
it "returns the 20 most recent retweets posted by the authenticating user" do
|
|
143
|
+
tweets = @client.retweeted_by_user("sferik")
|
|
144
|
+
tweets.should be_an Array
|
|
145
|
+
tweets.first.should be_a Twitter::Tweet
|
|
146
|
+
tweets.first.text.should eq "RT @olivercameron: Mosaic looks cool: http://t.co/A8013C9k"
|
|
147
|
+
end
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
describe "#retweeted_by_me" do
|
|
151
|
+
before do
|
|
152
|
+
stub_get("/1.1/statuses/user_timeline.json").
|
|
153
|
+
with(:query => {:include_rts => "true", :count => "200"}).
|
|
154
|
+
to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
|
155
|
+
stub_get("/1.1/statuses/user_timeline.json").
|
|
156
|
+
with(:query => {:include_rts => "true", :count => "200", :max_id => "244102729860009983"}).
|
|
157
|
+
to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
|
158
|
+
end
|
|
159
|
+
it "requests the correct resource" do
|
|
160
|
+
@client.retweeted_by_me
|
|
161
|
+
a_get("/1.1/statuses/user_timeline.json").
|
|
162
|
+
with(:query => {:include_rts => "true", :count => "200"}).
|
|
163
|
+
should have_been_made
|
|
164
|
+
a_get("/1.1/statuses/user_timeline.json").
|
|
165
|
+
with(:query => {:include_rts => "true", :count => "200", :max_id => "244102729860009983"}).
|
|
166
|
+
should have_been_made.times(3)
|
|
167
|
+
end
|
|
168
|
+
it "returns the 20 most recent retweets posted by the authenticating user" do
|
|
169
|
+
tweets = @client.retweeted_by_me
|
|
170
|
+
tweets.should be_an Array
|
|
171
|
+
tweets.first.should be_a Twitter::Tweet
|
|
172
|
+
tweets.first.text.should eq "RT @olivercameron: Mosaic looks cool: http://t.co/A8013C9k"
|
|
173
|
+
end
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
describe "#retweeted_to_me" do
|
|
177
|
+
before do
|
|
178
|
+
stub_get("/1.1/statuses/home_timeline.json").
|
|
179
|
+
with(:query => {:include_rts => "true", :count => "200"}).
|
|
180
|
+
to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
|
181
|
+
stub_get("/1.1/statuses/home_timeline.json").
|
|
182
|
+
with(:query => {:include_rts => "true", :count => "200", :max_id => "244102729860009983"}).
|
|
183
|
+
to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
|
184
|
+
end
|
|
185
|
+
it "requests the correct resource" do
|
|
186
|
+
@client.retweeted_to_me
|
|
187
|
+
stub_get("/1.1/statuses/home_timeline.json").
|
|
188
|
+
with(:query => {:include_rts => "true", :count => "200"}).
|
|
189
|
+
should have_been_made
|
|
190
|
+
stub_get("/1.1/statuses/home_timeline.json").
|
|
191
|
+
with(:query => {:include_rts => "true", :count => "200", :max_id => "244102729860009983"}).
|
|
192
|
+
should have_been_made.times(3)
|
|
193
|
+
end
|
|
194
|
+
it "returns the 20 most recent retweets posted by users the authenticating user follow" do
|
|
195
|
+
tweets = @client.retweeted_to_me
|
|
196
|
+
tweets.should be_an Array
|
|
197
|
+
tweets.first.should be_a Twitter::Tweet
|
|
198
|
+
tweets.first.text.should eq "RT @olivercameron: Mosaic looks cool: http://t.co/A8013C9k"
|
|
199
|
+
end
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
describe "#retweets_of_me" do
|
|
203
|
+
before do
|
|
204
|
+
stub_get("/1.1/statuses/user_timeline.json").
|
|
205
|
+
with(:query => {:include_rts => "false", :count => "200"}).
|
|
206
|
+
to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
|
207
|
+
stub_get("/1.1/statuses/user_timeline.json").
|
|
208
|
+
with(:query => {:include_rts => "false", :count => "200", :max_id => "244102490646278145"}).
|
|
209
|
+
to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
|
210
|
+
end
|
|
211
|
+
it "requests the correct resource" do
|
|
212
|
+
@client.retweets_of_me
|
|
213
|
+
a_get("/1.1/statuses/user_timeline.json").
|
|
214
|
+
with(:query => {:include_rts => "false", :count => "200"}).
|
|
215
|
+
should have_been_made
|
|
216
|
+
a_get("/1.1/statuses/user_timeline.json").
|
|
217
|
+
with(:query => {:include_rts => "false", :count => "200", :max_id => "244102490646278145"}).
|
|
218
|
+
should have_been_made
|
|
219
|
+
end
|
|
220
|
+
it "returns the 20 most recent tweets of the authenticated user that have been retweeted by others" do
|
|
221
|
+
tweets = @client.retweets_of_me
|
|
222
|
+
tweets.should be_an Array
|
|
223
|
+
tweets.first.should be_a Twitter::Tweet
|
|
224
|
+
tweets.first.text.should eq "RT @olivercameron: Mosaic looks cool: http://t.co/A8013C9k"
|
|
225
|
+
end
|
|
226
|
+
end
|
|
227
|
+
|
|
228
|
+
describe "#user_timeline" do
|
|
229
|
+
context "with a screen name passed" do
|
|
230
|
+
before do
|
|
231
|
+
stub_get("/1.1/statuses/user_timeline.json").
|
|
232
|
+
with(:query => {:screen_name => "sferik"}).
|
|
233
|
+
to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
|
234
|
+
end
|
|
235
|
+
it "requests the correct resource" do
|
|
236
|
+
@client.user_timeline("sferik")
|
|
237
|
+
a_get("/1.1/statuses/user_timeline.json").
|
|
238
|
+
with(:query => {:screen_name => "sferik"}).
|
|
239
|
+
should have_been_made
|
|
240
|
+
end
|
|
241
|
+
it "returns the 20 most recent Tweets posted by the user specified by screen name or user id" do
|
|
242
|
+
tweets = @client.user_timeline("sferik")
|
|
243
|
+
tweets.should be_an Array
|
|
244
|
+
tweets.first.should be_a Twitter::Tweet
|
|
245
|
+
tweets.first.text.should eq "Happy Birthday @imdane. Watch out for those @rally pranksters!"
|
|
246
|
+
end
|
|
247
|
+
end
|
|
248
|
+
context "without a screen name passed" do
|
|
249
|
+
before do
|
|
250
|
+
stub_get("/1.1/statuses/user_timeline.json").
|
|
251
|
+
to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
|
252
|
+
end
|
|
253
|
+
it "requests the correct resource" do
|
|
254
|
+
@client.user_timeline
|
|
255
|
+
a_get("/1.1/statuses/user_timeline.json").
|
|
256
|
+
should have_been_made
|
|
257
|
+
end
|
|
258
|
+
end
|
|
259
|
+
end
|
|
260
|
+
|
|
261
|
+
describe "#media_timeline" do
|
|
262
|
+
context "with a screen name passed" do
|
|
263
|
+
before do
|
|
264
|
+
stub_get("/1.1/statuses/media_timeline.json").
|
|
265
|
+
with(:query => {:screen_name => "sferik"}).
|
|
266
|
+
to_return(:body => fixture("media_timeline.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
|
267
|
+
end
|
|
268
|
+
it "requests the correct resource" do
|
|
269
|
+
@client.media_timeline("sferik")
|
|
270
|
+
a_get("/1.1/statuses/media_timeline.json").
|
|
271
|
+
with(:query => {:screen_name => "sferik"}).
|
|
272
|
+
should have_been_made
|
|
273
|
+
end
|
|
274
|
+
it "returns the 20 most recent images posted by the user specified by screen name or user id" do
|
|
275
|
+
tweets = @client.media_timeline("sferik")
|
|
276
|
+
tweets.should be_an Array
|
|
277
|
+
tweets.first.should be_a Twitter::Tweet
|
|
278
|
+
tweets.first.text.should eq "Google is throwing up a question mark for Sunday's weather in Boston. At least they're being honest. http://t.co/Jh7bAhS"
|
|
279
|
+
end
|
|
280
|
+
end
|
|
281
|
+
context "without a screen name passed" do
|
|
282
|
+
before do
|
|
283
|
+
stub_get("/1.1/statuses/media_timeline.json").
|
|
284
|
+
to_return(:body => fixture("media_timeline.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
|
285
|
+
end
|
|
286
|
+
it "requests the correct resource" do
|
|
287
|
+
@client.media_timeline
|
|
288
|
+
a_get("/1.1/statuses/media_timeline.json").
|
|
289
|
+
should have_been_made
|
|
290
|
+
end
|
|
291
|
+
end
|
|
292
|
+
end
|
|
293
|
+
|
|
294
|
+
describe "#retweeters_of" do
|
|
295
|
+
context "with ids_only passed" do
|
|
296
|
+
before do
|
|
297
|
+
stub_get("/1.1/statuses/retweets/28561922516.json").
|
|
298
|
+
to_return(:body => fixture("retweets.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
|
299
|
+
end
|
|
300
|
+
it "requests the correct resource" do
|
|
301
|
+
@client.retweeters_of(28561922516, :ids_only => true)
|
|
302
|
+
a_get("/1.1/statuses/retweets/28561922516.json").
|
|
303
|
+
should have_been_made
|
|
304
|
+
end
|
|
305
|
+
it "returns an array of numeric user IDs of retweeters of a Tweet" do
|
|
306
|
+
ids = @client.retweeters_of(28561922516, :ids_only => true)
|
|
307
|
+
ids.should be_an Array
|
|
308
|
+
ids.first.should eq 7505382
|
|
309
|
+
end
|
|
310
|
+
end
|
|
311
|
+
context "without ids_only passed" do
|
|
312
|
+
before do
|
|
313
|
+
stub_get("/1.1/statuses/retweets/28561922516.json").
|
|
314
|
+
to_return(:body => fixture("retweets.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
|
315
|
+
end
|
|
316
|
+
it "requests the correct resource" do
|
|
317
|
+
@client.retweeters_of(28561922516)
|
|
318
|
+
a_get("/1.1/statuses/retweets/28561922516.json").
|
|
319
|
+
should have_been_made
|
|
320
|
+
end
|
|
321
|
+
it "returns an array of user of retweeters of a Tweet" do
|
|
322
|
+
users = @client.retweeters_of(28561922516)
|
|
323
|
+
users.should be_an Array
|
|
324
|
+
users.first.should be_a Twitter::User
|
|
325
|
+
users.first.id.should eq 7505382
|
|
326
|
+
end
|
|
327
|
+
end
|
|
328
|
+
end
|
|
329
|
+
|
|
330
|
+
describe "#retweets" do
|
|
331
|
+
before do
|
|
332
|
+
stub_get("/1.1/statuses/retweets/28561922516.json").
|
|
333
|
+
to_return(:body => fixture("retweets.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
|
334
|
+
end
|
|
335
|
+
it "requests the correct resource" do
|
|
336
|
+
@client.retweets(28561922516)
|
|
337
|
+
a_get("/1.1/statuses/retweets/28561922516.json").
|
|
338
|
+
should have_been_made
|
|
339
|
+
end
|
|
340
|
+
it "returns up to 100 of the first retweets of a given tweet" do
|
|
341
|
+
tweets = @client.retweets(28561922516)
|
|
342
|
+
tweets.should be_an Array
|
|
343
|
+
tweets.first.should be_a Twitter::Tweet
|
|
344
|
+
tweets.first.text.should eq "RT @gruber: As for the Series, I'm for the Giants. Fuck Texas, fuck Nolan Ryan, fuck George Bush."
|
|
345
|
+
end
|
|
346
|
+
end
|
|
347
|
+
|
|
348
|
+
describe "#status" do
|
|
349
|
+
before do
|
|
350
|
+
stub_get("/1.1/statuses/show/25938088801.json").
|
|
351
|
+
to_return(:body => fixture("status.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
|
352
|
+
end
|
|
353
|
+
it "requests the correct resource" do
|
|
354
|
+
@client.status(25938088801)
|
|
355
|
+
a_get("/1.1/statuses/show/25938088801.json").
|
|
356
|
+
should have_been_made
|
|
357
|
+
end
|
|
358
|
+
it "returns a Tweet" do
|
|
359
|
+
tweet = @client.status(25938088801)
|
|
360
|
+
tweet.should be_a Twitter::Tweet
|
|
361
|
+
tweet.text.should eq "@noradio working on implementing #NewTwitter API methods in the twitter gem. Twurl is making it easy. Thank you!"
|
|
362
|
+
end
|
|
363
|
+
end
|
|
364
|
+
|
|
365
|
+
describe "#statuses" do
|
|
366
|
+
before do
|
|
367
|
+
stub_get("/1.1/statuses/show/25938088801.json").
|
|
368
|
+
to_return(:body => fixture("status.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
|
369
|
+
end
|
|
370
|
+
it "requests the correct resource" do
|
|
371
|
+
@client.statuses(25938088801)
|
|
372
|
+
a_get("/1.1/statuses/show/25938088801.json").
|
|
373
|
+
should have_been_made
|
|
374
|
+
end
|
|
375
|
+
it "returns an array of Tweets" do
|
|
376
|
+
tweets = @client.statuses(25938088801)
|
|
377
|
+
tweets.should be_an Array
|
|
378
|
+
tweets.first.should be_a Twitter::Tweet
|
|
379
|
+
tweets.first.text.should eq "@noradio working on implementing #NewTwitter API methods in the twitter gem. Twurl is making it easy. Thank you!"
|
|
380
|
+
end
|
|
381
|
+
end
|
|
382
|
+
|
|
383
|
+
describe "#status_activity" do
|
|
384
|
+
before do
|
|
385
|
+
stub_get("/i/statuses/25938088801/activity/summary.json").
|
|
386
|
+
to_return(:body => fixture("activity_summary.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
|
387
|
+
end
|
|
388
|
+
it "requests the correct resource" do
|
|
389
|
+
@client.status_activity(25938088801)
|
|
390
|
+
a_get("/i/statuses/25938088801/activity/summary.json").
|
|
391
|
+
should have_been_made
|
|
392
|
+
end
|
|
393
|
+
it "returns a Tweet" do
|
|
394
|
+
tweet = @client.status_activity(25938088801)
|
|
395
|
+
tweet.should be_a Twitter::Tweet
|
|
396
|
+
tweet.retweeters_count.should eq 1
|
|
397
|
+
end
|
|
398
|
+
end
|
|
399
|
+
|
|
400
|
+
describe "#statuses_activity" do
|
|
401
|
+
before do
|
|
402
|
+
stub_get("/i/statuses/25938088801/activity/summary.json").
|
|
403
|
+
to_return(:body => fixture("activity_summary.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
|
404
|
+
end
|
|
405
|
+
it "requests the correct resource" do
|
|
406
|
+
@client.statuses_activity(25938088801)
|
|
407
|
+
a_get("/i/statuses/25938088801/activity/summary.json").
|
|
408
|
+
should have_been_made
|
|
409
|
+
end
|
|
410
|
+
it "returns an array of Tweets" do
|
|
411
|
+
tweets = @client.statuses_activity(25938088801)
|
|
412
|
+
tweets.should be_an Array
|
|
413
|
+
tweets.first.should be_a Twitter::Tweet
|
|
414
|
+
tweets.first.retweeters_count.should eq 1
|
|
415
|
+
end
|
|
416
|
+
end
|
|
417
|
+
|
|
418
|
+
describe "#status_destroy" do
|
|
419
|
+
before do
|
|
420
|
+
stub_post("/1.1/statuses/destroy/25938088801.json").
|
|
421
|
+
to_return(:body => fixture("status.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
|
422
|
+
end
|
|
423
|
+
it "requests the correct resource" do
|
|
424
|
+
@client.status_destroy(25938088801)
|
|
425
|
+
a_post("/1.1/statuses/destroy/25938088801.json").
|
|
426
|
+
should have_been_made
|
|
427
|
+
end
|
|
428
|
+
it "returns an array of Tweets" do
|
|
429
|
+
tweets = @client.status_destroy(25938088801)
|
|
430
|
+
tweets.should be_an Array
|
|
431
|
+
tweets.first.should be_a Twitter::Tweet
|
|
432
|
+
tweets.first.text.should eq "@noradio working on implementing #NewTwitter API methods in the twitter gem. Twurl is making it easy. Thank you!"
|
|
433
|
+
end
|
|
434
|
+
end
|
|
435
|
+
|
|
436
|
+
describe "#retweet" do
|
|
437
|
+
before do
|
|
438
|
+
stub_post("/1.1/statuses/retweet/28561922516.json").
|
|
439
|
+
to_return(:body => fixture("retweet.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
|
440
|
+
end
|
|
441
|
+
it "requests the correct resource" do
|
|
442
|
+
@client.retweet(28561922516)
|
|
443
|
+
a_post("/1.1/statuses/retweet/28561922516.json").
|
|
444
|
+
should have_been_made
|
|
445
|
+
end
|
|
446
|
+
it "returns an array of Tweets with retweet details embedded" do
|
|
447
|
+
tweets = @client.retweet(28561922516)
|
|
448
|
+
tweets.should be_an Array
|
|
449
|
+
tweets.first.should be_a Twitter::Tweet
|
|
450
|
+
tweets.first.text.should eq "As for the Series, I'm for the Giants. Fuck Texas, fuck Nolan Ryan, fuck George Bush."
|
|
451
|
+
tweets.first.retweeted_tweet.text.should eq "RT @gruber: As for the Series, I'm for the Giants. Fuck Texas, fuck Nolan Ryan, fuck George Bush."
|
|
452
|
+
tweets.first.retweeted_tweet.id.should_not == tweets.first.id
|
|
453
|
+
end
|
|
454
|
+
end
|
|
455
|
+
|
|
456
|
+
describe "#tweet" do
|
|
457
|
+
before do
|
|
458
|
+
stub_post("/1.1/statuses/update.json").
|
|
459
|
+
with(:body => {:status => "@noradio working on implementing #NewTwitter API methods in the twitter gem. Twurl is making it easy. Thank you!"}).
|
|
460
|
+
to_return(:body => fixture("status.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
|
461
|
+
end
|
|
462
|
+
it "requests the correct resource" do
|
|
463
|
+
@client.update("@noradio working on implementing #NewTwitter API methods in the twitter gem. Twurl is making it easy. Thank you!")
|
|
464
|
+
a_post("/1.1/statuses/update.json").
|
|
465
|
+
with(:body => {:status => "@noradio working on implementing #NewTwitter API methods in the twitter gem. Twurl is making it easy. Thank you!"}).
|
|
466
|
+
should have_been_made
|
|
467
|
+
end
|
|
468
|
+
it "returns a Tweet" do
|
|
469
|
+
tweet = @client.update("@noradio working on implementing #NewTwitter API methods in the twitter gem. Twurl is making it easy. Thank you!")
|
|
470
|
+
tweet.should be_a Twitter::Tweet
|
|
471
|
+
tweet.text.should eq "@noradio working on implementing #NewTwitter API methods in the twitter gem. Twurl is making it easy. Thank you!"
|
|
472
|
+
end
|
|
473
|
+
end
|
|
474
|
+
|
|
475
|
+
describe "#update_with_media" do
|
|
476
|
+
before do
|
|
477
|
+
stub_post("/1.1/statuses/update_with_media.json").
|
|
478
|
+
to_return(:body => fixture("status_with_media.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
|
479
|
+
end
|
|
480
|
+
context "a gif image" do
|
|
481
|
+
it "requests the correct resource" do
|
|
482
|
+
@client.update_with_media("You always have options", fixture("pbjt.gif"))
|
|
483
|
+
a_post("/1.1/statuses/update_with_media.json").
|
|
484
|
+
should have_been_made
|
|
485
|
+
end
|
|
486
|
+
it "returns a Tweet" do
|
|
487
|
+
tweet = @client.update_with_media("You always have options", fixture("pbjt.gif"))
|
|
488
|
+
tweet.should be_a Twitter::Tweet
|
|
489
|
+
tweet.text.should eq "You always have options http://t.co/CBYa7Ri"
|
|
490
|
+
end
|
|
491
|
+
end
|
|
492
|
+
context "a jpe image" do
|
|
493
|
+
it "requests the correct resource" do
|
|
494
|
+
@client.update_with_media("You always have options", fixture("wildcomet2.jpe"))
|
|
495
|
+
a_post("/1.1/statuses/update_with_media.json").
|
|
496
|
+
should have_been_made
|
|
497
|
+
end
|
|
498
|
+
end
|
|
499
|
+
context "a jpeg image" do
|
|
500
|
+
it "requests the correct resource" do
|
|
501
|
+
@client.update_with_media("You always have options", fixture("me.jpeg"))
|
|
502
|
+
a_post("/1.1/statuses/update_with_media.json").
|
|
503
|
+
should have_been_made
|
|
504
|
+
end
|
|
505
|
+
end
|
|
506
|
+
context "a png image" do
|
|
507
|
+
it "requests the correct resource" do
|
|
508
|
+
@client.update_with_media("You always have options", fixture("we_concept_bg2.png"))
|
|
509
|
+
a_post("/1.1/statuses/update_with_media.json").
|
|
510
|
+
should have_been_made
|
|
511
|
+
end
|
|
512
|
+
end
|
|
513
|
+
context "a Tempfile" do
|
|
514
|
+
it "requests the correct resource" do
|
|
515
|
+
@client.update_with_media("You always have options", Tempfile.new("tmp"))
|
|
516
|
+
a_post("/1.1/statuses/update_with_media.json").
|
|
517
|
+
should have_been_made
|
|
518
|
+
end
|
|
519
|
+
end
|
|
520
|
+
end
|
|
521
|
+
|
|
522
|
+
describe "#oembed" do
|
|
523
|
+
before do
|
|
524
|
+
stub_get("/1.1/statuses/oembed.json").
|
|
525
|
+
with(:query => {:id => "25938088801"}).
|
|
526
|
+
to_return(:body => fixture("oembed.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
|
527
|
+
end
|
|
528
|
+
it "requests the correct resource" do
|
|
529
|
+
@client.oembed(25938088801)
|
|
530
|
+
a_get("/1.1/statuses/oembed.json").
|
|
531
|
+
with(:query => {:id => "25938088801"}).
|
|
532
|
+
should have_been_made
|
|
533
|
+
end
|
|
534
|
+
it "returns an array of OEmbed instances" do
|
|
535
|
+
oembed = @client.oembed(25938088801)
|
|
536
|
+
oembed.should be_a Twitter::OEmbed
|
|
537
|
+
end
|
|
538
|
+
end
|
|
539
|
+
|
|
540
|
+
describe "#oembeds" do
|
|
541
|
+
before do
|
|
542
|
+
stub_get("/1.1/statuses/oembed.json").
|
|
543
|
+
with(:query => {:id => "25938088801"}).
|
|
544
|
+
to_return(:body => fixture("oembed.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
|
545
|
+
end
|
|
546
|
+
it "requests the correct resource" do
|
|
547
|
+
@client.oembeds(25938088801)
|
|
548
|
+
a_get("/1.1/statuses/oembed.json").
|
|
549
|
+
with(:query => {:id => "25938088801"}).
|
|
550
|
+
should have_been_made
|
|
551
|
+
end
|
|
552
|
+
it "returns an array of OEmbed instances" do
|
|
553
|
+
oembeds = @client.oembeds(25938088801)
|
|
554
|
+
oembeds.should be_an Array
|
|
555
|
+
oembeds.first.should be_a Twitter::OEmbed
|
|
556
|
+
end
|
|
557
|
+
end
|
|
558
|
+
|
|
559
|
+
end
|