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::Action::Follow do
|
|
4
|
+
|
|
5
|
+
describe "#sources" do
|
|
6
|
+
it "returns a collection of users who followed a user" do
|
|
7
|
+
sources = Twitter::Action::Follow.new(:sources => [{:id => 7505382}]).sources
|
|
8
|
+
sources.should be_an Array
|
|
9
|
+
sources.first.should be_a Twitter::User
|
|
10
|
+
end
|
|
11
|
+
it "is empty when not set" do
|
|
12
|
+
sources = Twitter::Action::Follow.new.sources
|
|
13
|
+
sources.should be_empty
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
describe "#targets" do
|
|
18
|
+
it "returns a collection containing the followed user" do
|
|
19
|
+
targets = Twitter::Action::Follow.new(:targets => [{:id => 7505382}]).targets
|
|
20
|
+
targets.should be_an Array
|
|
21
|
+
targets.first.should be_a Twitter::User
|
|
22
|
+
end
|
|
23
|
+
it "is empty when not set" do
|
|
24
|
+
targets = Twitter::Action::Follow.new.targets
|
|
25
|
+
targets.should be_empty
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
require 'helper'
|
|
2
|
+
|
|
3
|
+
describe Twitter::Action::ListMemberAdded do
|
|
4
|
+
|
|
5
|
+
describe "#sources" do
|
|
6
|
+
it "returns a collection of users who added a user to a list" do
|
|
7
|
+
sources = Twitter::Action::ListMemberAdded.new(:sources => [{:id => 7505382}]).sources
|
|
8
|
+
sources.should be_an Array
|
|
9
|
+
sources.first.should be_a Twitter::User
|
|
10
|
+
end
|
|
11
|
+
it "is empty when not set" do
|
|
12
|
+
sources = Twitter::Action::ListMemberAdded.new.sources
|
|
13
|
+
sources.should be_empty
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
describe "#target_objects" do
|
|
18
|
+
it "returns a collection of lists that were added to" do
|
|
19
|
+
targets = Twitter::Action::ListMemberAdded.new(:target_objects => [{:id => 8863586}]).target_objects
|
|
20
|
+
targets.should be_an Array
|
|
21
|
+
targets.first.should be_a Twitter::List
|
|
22
|
+
end
|
|
23
|
+
it "is empty when not set" do
|
|
24
|
+
targets = Twitter::Action::ListMemberAdded.new.target_objects
|
|
25
|
+
targets.should be_empty
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
describe "#targets" do
|
|
30
|
+
it "returns a collection of users who were added to a list" do
|
|
31
|
+
targets = Twitter::Action::ListMemberAdded.new(:targets => [{:id => 7505382}]).targets
|
|
32
|
+
targets.should be_an Array
|
|
33
|
+
targets.first.should be_a Twitter::User
|
|
34
|
+
end
|
|
35
|
+
it "is empty when not set" do
|
|
36
|
+
targets = Twitter::Action::ListMemberAdded.new.targets
|
|
37
|
+
targets.should be_empty
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
end
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
require 'helper'
|
|
2
|
+
|
|
3
|
+
describe Twitter::Action::Mention do
|
|
4
|
+
|
|
5
|
+
describe "#sources" do
|
|
6
|
+
it "returns a collection of users who mentioned a user" do
|
|
7
|
+
sources = Twitter::Action::Mention.new(:sources => [{:id => 7505382}]).sources
|
|
8
|
+
sources.should be_an Array
|
|
9
|
+
sources.first.should be_a Twitter::User
|
|
10
|
+
end
|
|
11
|
+
it "is empty when not set" do
|
|
12
|
+
sources = Twitter::Action::Mention.new.sources
|
|
13
|
+
sources.should be_empty
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
describe "#source" do
|
|
18
|
+
it "returns the user who mentioned a user" do
|
|
19
|
+
source = Twitter::Action::Mention.new(:sources => [{:id => 7505382}]).source
|
|
20
|
+
source.should be_a Twitter::User
|
|
21
|
+
end
|
|
22
|
+
it "returns nil when not set" do
|
|
23
|
+
source = Twitter::Action::Mention.new.source
|
|
24
|
+
source.should be_nil
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
describe "#target_objects" do
|
|
29
|
+
it "returns a collection of Tweets that mention a user" do
|
|
30
|
+
targets = Twitter::Action::Mention.new(:target_objects => [{:id => 25938088801}]).target_objects
|
|
31
|
+
targets.should be_an Array
|
|
32
|
+
targets.first.should be_a Twitter::Tweet
|
|
33
|
+
end
|
|
34
|
+
it "is empty when not set" do
|
|
35
|
+
targets = Twitter::Action::Mention.new.target_objects
|
|
36
|
+
targets.should be_empty
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
describe "#targets" do
|
|
41
|
+
it "returns a collection containing the mentioned user" do
|
|
42
|
+
targets = Twitter::Action::Mention.new(:targets => [{:id => 7505382}]).targets
|
|
43
|
+
targets.should be_an Array
|
|
44
|
+
targets.first.should be_a Twitter::User
|
|
45
|
+
end
|
|
46
|
+
it "is empty when not set" do
|
|
47
|
+
targets = Twitter::Action::Mention.new.targets
|
|
48
|
+
targets.should be_empty
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
require 'helper'
|
|
2
|
+
|
|
3
|
+
describe Twitter::Action::Reply do
|
|
4
|
+
|
|
5
|
+
describe "#sources" do
|
|
6
|
+
it "returns a collection of users who replied to a user" do
|
|
7
|
+
sources = Twitter::Action::Reply.new(:sources => [{:id => 7505382}]).sources
|
|
8
|
+
sources.should be_an Array
|
|
9
|
+
sources.first.should be_a Twitter::User
|
|
10
|
+
end
|
|
11
|
+
it "is empty when not set" do
|
|
12
|
+
sources = Twitter::Action::Reply.new.sources
|
|
13
|
+
sources.should be_empty
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
describe "#target_objects" do
|
|
18
|
+
it "returns a collection of Tweets that reply to a user" do
|
|
19
|
+
targets = Twitter::Action::Reply.new(:target_objects => [{:id => 25938088801}]).target_objects
|
|
20
|
+
targets.should be_an Array
|
|
21
|
+
targets.first.should be_a Twitter::Tweet
|
|
22
|
+
end
|
|
23
|
+
it "is empty when not set" do
|
|
24
|
+
targets = Twitter::Action::Reply.new.target_objects
|
|
25
|
+
targets.should be_empty
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
describe "#targets" do
|
|
30
|
+
it "returns a collection that contains the replied-to status" do
|
|
31
|
+
targets = Twitter::Action::Reply.new(:targets => [{:id => 25938088801}]).targets
|
|
32
|
+
targets.should be_an Array
|
|
33
|
+
targets.first.should be_a Twitter::Tweet
|
|
34
|
+
end
|
|
35
|
+
it "is empty when not set" do
|
|
36
|
+
targets = Twitter::Action::Reply.new.targets
|
|
37
|
+
targets.should be_empty
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
require 'helper'
|
|
2
|
+
|
|
3
|
+
describe Twitter::Action::Retweet do
|
|
4
|
+
|
|
5
|
+
describe "#sources" do
|
|
6
|
+
it "returns a collection of users who retweeted a user" do
|
|
7
|
+
sources = Twitter::Action::Retweet.new(:sources => [{:id => 7505382}]).sources
|
|
8
|
+
sources.should be_an Array
|
|
9
|
+
sources.first.should be_a Twitter::User
|
|
10
|
+
end
|
|
11
|
+
it "is empty when not set" do
|
|
12
|
+
sources = Twitter::Action::Retweet.new.sources
|
|
13
|
+
sources.should be_empty
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
describe "#target_objects" do
|
|
18
|
+
it "returns a collection of retweets" do
|
|
19
|
+
targets = Twitter::Action::Retweet.new(:target_objects => [{:id => 25938088801}]).target_objects
|
|
20
|
+
targets.should be_an Array
|
|
21
|
+
targets.first.should be_a Twitter::Tweet
|
|
22
|
+
end
|
|
23
|
+
it "is empty when not set" do
|
|
24
|
+
targets = Twitter::Action::Retweet.new.target_objects
|
|
25
|
+
targets.should be_empty
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
describe "#targets" do
|
|
30
|
+
it "returns a collection containing the retweeted user" do
|
|
31
|
+
targets = Twitter::Action::Retweet.new(:targets => [{:id => 7505382}]).targets
|
|
32
|
+
targets.should be_an Array
|
|
33
|
+
targets.first.should be_a Twitter::User
|
|
34
|
+
end
|
|
35
|
+
it "is empty when not set" do
|
|
36
|
+
targets = Twitter::Action::Retweet.new.targets
|
|
37
|
+
targets.should be_empty
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
require 'helper'
|
|
2
|
+
|
|
3
|
+
describe Twitter::ActionFactory do
|
|
4
|
+
|
|
5
|
+
describe ".new" do
|
|
6
|
+
it "generates a Favorite" do
|
|
7
|
+
action = Twitter::ActionFactory.fetch_or_new(:action => 'favorite')
|
|
8
|
+
action.should be_a Twitter::Action::Favorite
|
|
9
|
+
end
|
|
10
|
+
it "generates a Follow" do
|
|
11
|
+
action = Twitter::ActionFactory.fetch_or_new(:action => 'follow')
|
|
12
|
+
action.should be_a Twitter::Action::Follow
|
|
13
|
+
end
|
|
14
|
+
it "generates a ListMemberAdded" do
|
|
15
|
+
action = Twitter::ActionFactory.fetch_or_new(:action => 'list_member_added')
|
|
16
|
+
action.should be_a Twitter::Action::ListMemberAdded
|
|
17
|
+
end
|
|
18
|
+
it "generates a Mention" do
|
|
19
|
+
action = Twitter::ActionFactory.fetch_or_new(:action => 'mention')
|
|
20
|
+
action.should be_a Twitter::Action::Mention
|
|
21
|
+
end
|
|
22
|
+
it "generates a Reply" do
|
|
23
|
+
action = Twitter::ActionFactory.fetch_or_new(:action => 'reply')
|
|
24
|
+
action.should be_a Twitter::Action::Reply
|
|
25
|
+
end
|
|
26
|
+
it "generates a Retweet" do
|
|
27
|
+
action = Twitter::ActionFactory.fetch_or_new(:action => 'retweet')
|
|
28
|
+
action.should be_a Twitter::Action::Retweet
|
|
29
|
+
end
|
|
30
|
+
it "raises an ArgumentError when action is not specified" do
|
|
31
|
+
lambda do
|
|
32
|
+
Twitter::ActionFactory.fetch_or_new
|
|
33
|
+
end.should raise_error(ArgumentError, "argument must have :action key")
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
require 'helper'
|
|
2
|
+
|
|
3
|
+
describe Twitter::Action do
|
|
4
|
+
|
|
5
|
+
describe "#created_at" do
|
|
6
|
+
it "returns a Time when created_at is set" do
|
|
7
|
+
user = Twitter::User.new(:id => 7505382, :created_at => "Mon Jul 16 12:59:01 +0000 2007")
|
|
8
|
+
user.created_at.should be_a Time
|
|
9
|
+
end
|
|
10
|
+
it "returns nil when created_at is not set" do
|
|
11
|
+
user = Twitter::User.new(:id => 7505382)
|
|
12
|
+
user.created_at.should be_nil
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
end
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
require 'helper'
|
|
2
|
+
|
|
3
|
+
describe Twitter::API do
|
|
4
|
+
|
|
5
|
+
before do
|
|
6
|
+
@client = Twitter::Client.new
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
describe "#verify_credentials" do
|
|
10
|
+
before do
|
|
11
|
+
stub_get("/1.1/account/verify_credentials.json").
|
|
12
|
+
to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
|
13
|
+
end
|
|
14
|
+
it "requests the correct resource" do
|
|
15
|
+
@client.verify_credentials
|
|
16
|
+
a_get("/1.1/account/verify_credentials.json").
|
|
17
|
+
should have_been_made
|
|
18
|
+
end
|
|
19
|
+
it "returns the requesting user" do
|
|
20
|
+
user = @client.verify_credentials
|
|
21
|
+
user.should be_a Twitter::User
|
|
22
|
+
user.id.should eq 7505382
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
describe "#update_delivery_device" do
|
|
27
|
+
before do
|
|
28
|
+
stub_post("/1.1/account/update_delivery_device.json").
|
|
29
|
+
with(:body => {:device => "sms"}).
|
|
30
|
+
to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
|
31
|
+
end
|
|
32
|
+
it "requests the correct resource" do
|
|
33
|
+
@client.update_delivery_device("sms")
|
|
34
|
+
a_post("/1.1/account/update_delivery_device.json").
|
|
35
|
+
with(:body => {:device => "sms"}).
|
|
36
|
+
should have_been_made
|
|
37
|
+
end
|
|
38
|
+
it "returns a user" do
|
|
39
|
+
user = @client.update_delivery_device("sms")
|
|
40
|
+
user.should be_a Twitter::User
|
|
41
|
+
user.id.should eq 7505382
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
describe "#update_profile" do
|
|
46
|
+
before do
|
|
47
|
+
stub_post("/1.1/account/update_profile.json").
|
|
48
|
+
with(:body => {:url => "http://github.com/sferik/"}).
|
|
49
|
+
to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
|
50
|
+
end
|
|
51
|
+
it "requests the correct resource" do
|
|
52
|
+
@client.update_profile(:url => "http://github.com/sferik/")
|
|
53
|
+
a_post("/1.1/account/update_profile.json").
|
|
54
|
+
with(:body => {:url => "http://github.com/sferik/"}).
|
|
55
|
+
should have_been_made
|
|
56
|
+
end
|
|
57
|
+
it "returns a user" do
|
|
58
|
+
user = @client.update_profile(:url => "http://github.com/sferik/")
|
|
59
|
+
user.should be_a Twitter::User
|
|
60
|
+
user.id.should eq 7505382
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
describe "#update_profile_background_image" do
|
|
65
|
+
before do
|
|
66
|
+
stub_post("/1.1/account/update_profile_background_image.json").
|
|
67
|
+
to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
|
68
|
+
end
|
|
69
|
+
it "requests the correct resource" do
|
|
70
|
+
@client.update_profile_background_image(fixture("we_concept_bg2.png"))
|
|
71
|
+
a_post("/1.1/account/update_profile_background_image.json").
|
|
72
|
+
should have_been_made
|
|
73
|
+
end
|
|
74
|
+
it "returns a user" do
|
|
75
|
+
user = @client.update_profile_background_image(fixture("we_concept_bg2.png"))
|
|
76
|
+
user.should be_a Twitter::User
|
|
77
|
+
user.id.should eq 7505382
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
describe "#update_profile_colors" do
|
|
82
|
+
before do
|
|
83
|
+
stub_post("/1.1/account/update_profile_colors.json").
|
|
84
|
+
with(:body => {:profile_background_color => "000000"}).
|
|
85
|
+
to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
|
86
|
+
end
|
|
87
|
+
it "requests the correct resource" do
|
|
88
|
+
@client.update_profile_colors(:profile_background_color => "000000")
|
|
89
|
+
a_post("/1.1/account/update_profile_colors.json").
|
|
90
|
+
with(:body => {:profile_background_color => "000000"}).
|
|
91
|
+
should have_been_made
|
|
92
|
+
end
|
|
93
|
+
it "returns a user" do
|
|
94
|
+
user = @client.update_profile_colors(:profile_background_color => "000000")
|
|
95
|
+
user.should be_a Twitter::User
|
|
96
|
+
user.id.should eq 7505382
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
describe "#update_profile_image" do
|
|
101
|
+
before do
|
|
102
|
+
stub_post("/1.1/account/update_profile_image.json").
|
|
103
|
+
to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
|
104
|
+
end
|
|
105
|
+
it "requests the correct resource" do
|
|
106
|
+
@client.update_profile_image(fixture("me.jpeg"))
|
|
107
|
+
a_post("/1.1/account/update_profile_image.json").
|
|
108
|
+
should have_been_made
|
|
109
|
+
end
|
|
110
|
+
it "returns a user" do
|
|
111
|
+
user = @client.update_profile_image(fixture("me.jpeg"))
|
|
112
|
+
user.should be_a Twitter::User
|
|
113
|
+
user.id.should eq 7505382
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
describe "#settings" do
|
|
118
|
+
before do
|
|
119
|
+
stub_get("/1.1/account/settings.json").
|
|
120
|
+
to_return(:body => fixture("settings.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
|
121
|
+
stub_post("/1.1/account/settings.json").
|
|
122
|
+
with(:body => {:trend_location_woeid => "23424803"}).
|
|
123
|
+
to_return(:body => fixture("settings.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
|
124
|
+
end
|
|
125
|
+
it "requests the correct resource on GET" do
|
|
126
|
+
@client.settings
|
|
127
|
+
a_get("/1.1/account/settings.json").
|
|
128
|
+
should have_been_made
|
|
129
|
+
end
|
|
130
|
+
it "returns settings" do
|
|
131
|
+
settings = @client.settings
|
|
132
|
+
settings.should be_a Twitter::Settings
|
|
133
|
+
settings.language.should eq 'en'
|
|
134
|
+
end
|
|
135
|
+
it "requests the correct resource on POST" do
|
|
136
|
+
@client.settings(:trend_location_woeid => "23424803")
|
|
137
|
+
a_post("/1.1/account/settings.json").
|
|
138
|
+
with(:body => {:trend_location_woeid => "23424803"}).
|
|
139
|
+
should have_been_made
|
|
140
|
+
end
|
|
141
|
+
it "returns settings" do
|
|
142
|
+
settings = @client.settings(:trend_location_woeid => "23424803")
|
|
143
|
+
settings.should be_a Twitter::Settings
|
|
144
|
+
settings.language.should eq 'en'
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
require 'helper'
|
|
2
|
+
|
|
3
|
+
describe Twitter::API do
|
|
4
|
+
|
|
5
|
+
before do
|
|
6
|
+
@client = Twitter::Client.new
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
describe "#activity_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 "requests the correct resource" do
|
|
15
|
+
@client.activity_about_me
|
|
16
|
+
a_get("/i/activity/about_me.json").
|
|
17
|
+
should have_been_made
|
|
18
|
+
end
|
|
19
|
+
it "returns activity about me" do
|
|
20
|
+
activity_about_me = @client.activity_about_me
|
|
21
|
+
activity_about_me.first.should be_a Twitter::Action::Mention
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
describe "#activity_by_friends" do
|
|
26
|
+
before do
|
|
27
|
+
stub_get("/i/activity/by_friends.json").
|
|
28
|
+
to_return(:body => fixture("by_friends.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
|
29
|
+
end
|
|
30
|
+
it "requests the correct resource" do
|
|
31
|
+
@client.activity_by_friends
|
|
32
|
+
a_get("/i/activity/by_friends.json").
|
|
33
|
+
should have_been_made
|
|
34
|
+
end
|
|
35
|
+
it "returns activity by friends" do
|
|
36
|
+
activity_by_friends = @client.activity_by_friends
|
|
37
|
+
activity_by_friends.first.should be_a Twitter::Action::Favorite
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
end
|