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,35 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Twitter::Photo do
|
4
|
+
|
5
|
+
describe "#==" do
|
6
|
+
it "should return true when ids and classes are equal" do
|
7
|
+
photo = Twitter::Photo.new('id' => 1)
|
8
|
+
other = Twitter::Photo.new('id' => 1)
|
9
|
+
(photo == other).should be_true
|
10
|
+
end
|
11
|
+
it "should return false when classes are not equal" do
|
12
|
+
photo = Twitter::Photo.new('id' => 1)
|
13
|
+
other = Twitter::User.new('id' => 1)
|
14
|
+
(photo == other).should be_false
|
15
|
+
end
|
16
|
+
it "should return false when ids are not equal" do
|
17
|
+
photo = Twitter::Photo.new('id' => 1)
|
18
|
+
other = Twitter::Photo.new('id' => 2)
|
19
|
+
(photo == other).should be_false
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "#sizes" do
|
24
|
+
it "should return a hash of Sizes when sizes is set" do
|
25
|
+
sizes = Twitter::Photo.new('sizes' => {'small' => {'h' => 226, 'w' => 340, 'resize' => 'fit'}, 'large' => {'h' => 466, 'w' => 700, 'resize' => 'fit'}, 'medium' => {'h' => 399, 'w' => 600, 'resize' => 'fit'}, 'thumb' => {'h' => 150, 'w' => 150, 'resize' => 'crop'}}).sizes
|
26
|
+
sizes.should be_a Hash
|
27
|
+
sizes['small'].should be_a Twitter::Size
|
28
|
+
end
|
29
|
+
it "should be empty when sizes is not set" do
|
30
|
+
sizes = Twitter::Photo.new.sizes
|
31
|
+
sizes.should be_empty
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Twitter::Place do
|
4
|
+
|
5
|
+
describe "#==" do
|
6
|
+
it "should return true when ids and classes are equal" do
|
7
|
+
place = Twitter::Place.new('id' => 1)
|
8
|
+
other = Twitter::Place.new('id' => 1)
|
9
|
+
(place == other).should be_true
|
10
|
+
end
|
11
|
+
it "should return false when classes are not equal" do
|
12
|
+
place = Twitter::Place.new('id' => 1)
|
13
|
+
other = Twitter::User.new('id' => 1)
|
14
|
+
(place == other).should be_false
|
15
|
+
end
|
16
|
+
it "should return false when ids are not equal" do
|
17
|
+
place = Twitter::Place.new('id' => 1)
|
18
|
+
other = Twitter::Place.new('id' => 2)
|
19
|
+
(place == other).should be_false
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "#bounding_box" do
|
24
|
+
it "should return a Twitter::Place when set" do
|
25
|
+
place = Twitter::Place.new('bounding_box' => {'type' => 'Polygon', 'coordinates' => [[[-122.40348192, 37.77752898], [-122.387436, 37.77752898], [-122.387436, 37.79448597], [-122.40348192, 37.79448597]]]})
|
26
|
+
place.bounding_box.should be_a Twitter::Polygon
|
27
|
+
end
|
28
|
+
it "should return nil when not set" do
|
29
|
+
place = Twitter::Place.new
|
30
|
+
place.bounding_box.should be_nil
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "#country_code" do
|
35
|
+
it "should return a country code when set with country_code" do
|
36
|
+
place = Twitter::Place.new('country_code' => 'US')
|
37
|
+
place.country_code.should == 'US'
|
38
|
+
end
|
39
|
+
it "should return a country code when set with countryCode" do
|
40
|
+
place = Twitter::Place.new('countryCode' => 'US')
|
41
|
+
place.country_code.should == 'US'
|
42
|
+
end
|
43
|
+
it "should return nil when not set" do
|
44
|
+
place = Twitter::Place.new
|
45
|
+
place.country_code.should be_nil
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe "#parent_id" do
|
50
|
+
it "should return a parent ID when set with parentid" do
|
51
|
+
place = Twitter::Place.new('parentid' => 1)
|
52
|
+
place.parent_id.should == 1
|
53
|
+
end
|
54
|
+
it "should return nil when not set" do
|
55
|
+
place = Twitter::Place.new
|
56
|
+
place.parent_id.should be_nil
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe "#place_type" do
|
61
|
+
it "should return a place type when set with place_type" do
|
62
|
+
place = Twitter::Place.new('place_type' => 'city')
|
63
|
+
place.place_type.should == 'city'
|
64
|
+
end
|
65
|
+
it "should return a place type when set with placeType[name]" do
|
66
|
+
place = Twitter::Place.new('placeType' => {'name' => 'Town'})
|
67
|
+
place.place_type.should == 'Town'
|
68
|
+
end
|
69
|
+
it "should return nil when not set" do
|
70
|
+
place = Twitter::Place.new
|
71
|
+
place.place_type.should be_nil
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Twitter::Point do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@point = Twitter::Point.new('coordinates' => [-122.399983, 37.788299])
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "#==" do
|
10
|
+
it "should return true when coordinates are equal" do
|
11
|
+
other = Twitter::Point.new('coordinates' => [-122.399983, 37.788299])
|
12
|
+
(@point == other).should be_true
|
13
|
+
end
|
14
|
+
it "should return false when coordinates are not equal" do
|
15
|
+
other = Twitter::Point.new('coordinates' => [37.788299, -122.399983])
|
16
|
+
(@point == other).should be_false
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "#latitude" do
|
21
|
+
it "should return the latitude" do
|
22
|
+
@point.latitude.should == -122.399983
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe "#longitude" do
|
27
|
+
it "should return the longitude" do
|
28
|
+
@point.longitude.should == 37.788299
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
describe Twitter::Polygon do
|
2
|
+
|
3
|
+
before do
|
4
|
+
@polygon = Twitter::Polygon.new('coordinates' => [[[-122.40348192, 37.77752898], [-122.387436, 37.77752898], [-122.387436, 37.79448597], [-122.40348192, 37.79448597]]])
|
5
|
+
end
|
6
|
+
|
7
|
+
describe "#==" do
|
8
|
+
it "should return true when coordinates are equal" do
|
9
|
+
other = Twitter::Polygon.new('coordinates' => [[[-122.40348192, 37.77752898], [-122.387436, 37.77752898], [-122.387436, 37.79448597], [-122.40348192, 37.79448597]]])
|
10
|
+
(@polygon == other).should be_true
|
11
|
+
end
|
12
|
+
it "should return false when coordinates are not equal" do
|
13
|
+
other = Twitter::Polygon.new('coordinates' => [[[37.77752898, -122.40348192], [37.77752898, -122.387436], [37.79448597, -122.387436], [37.79448597, -122.40348192]]])
|
14
|
+
(@polygon == other).should be_false
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Twitter::RateLimitStatus do
|
4
|
+
|
5
|
+
describe "#reset_time" do
|
6
|
+
it "should return a Time when reset_time is set" do
|
7
|
+
rate_limit_status = Twitter::RateLimitStatus.new('reset_time' => "Mon Jul 16 12:59:01 +0000 2007")
|
8
|
+
rate_limit_status.reset_time.should be_a Time
|
9
|
+
end
|
10
|
+
it "should return nil when reset_time is not set" do
|
11
|
+
rate_limit_status = Twitter::RateLimitStatus.new
|
12
|
+
rate_limit_status.reset_time.should be_nil
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Twitter::Relationship do
|
4
|
+
|
5
|
+
describe "#source" do
|
6
|
+
it "should return a User when source is set" do
|
7
|
+
source = Twitter::Relationship.new('source' => {}).source
|
8
|
+
source.should be_a Twitter::User
|
9
|
+
end
|
10
|
+
it "should return nil when source is not set" do
|
11
|
+
source = Twitter::Relationship.new.source
|
12
|
+
source.should be_nil
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "#target" do
|
17
|
+
it "should return a User when target is set" do
|
18
|
+
target = Twitter::Relationship.new('target' => {}).target
|
19
|
+
target.should be_a Twitter::User
|
20
|
+
end
|
21
|
+
it "should return nil when target is not set" do
|
22
|
+
target = Twitter::Relationship.new.target
|
23
|
+
target.should be_nil
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Twitter::Reply do
|
4
|
+
|
5
|
+
describe "#sources" do
|
6
|
+
it "should return a collection of users who replied to a user" do
|
7
|
+
sources = Twitter::Reply.new('sources' => [{}]).sources
|
8
|
+
sources.should be_an Array
|
9
|
+
sources.first.should be_a Twitter::User
|
10
|
+
end
|
11
|
+
it "should be empty when not set" do
|
12
|
+
sources = Twitter::Reply.new.sources
|
13
|
+
sources.should be_empty
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "#target_objects" do
|
18
|
+
it "should return a collection of statuses that reply to a user" do
|
19
|
+
targets = Twitter::Reply.new('target_objects' => [{}]).target_objects
|
20
|
+
targets.should be_an Array
|
21
|
+
targets.first.should be_a Twitter::Status
|
22
|
+
end
|
23
|
+
it "should be empty when not set" do
|
24
|
+
targets = Twitter::Reply.new.target_objects
|
25
|
+
targets.should be_empty
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe "#targets" do
|
30
|
+
it "should return a collection that contains the replied-to status" do
|
31
|
+
targets = Twitter::Reply.new('targets' => [{}]).targets
|
32
|
+
targets.should be_an Array
|
33
|
+
targets.first.should be_a Twitter::Status
|
34
|
+
end
|
35
|
+
it "should be empty when not set" do
|
36
|
+
targets = Twitter::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::Retweet do
|
4
|
+
|
5
|
+
describe "#sources" do
|
6
|
+
it "should return a collection of users who retweeted a user" do
|
7
|
+
sources = Twitter::Retweet.new('sources' => [{}]).sources
|
8
|
+
sources.should be_an Array
|
9
|
+
sources.first.should be_a Twitter::User
|
10
|
+
end
|
11
|
+
it "should be empty when not set" do
|
12
|
+
sources = Twitter::Retweet.new.sources
|
13
|
+
sources.should be_empty
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "#target_objects" do
|
18
|
+
it "should return a collection of retweets" do
|
19
|
+
targets = Twitter::Retweet.new('target_objects' => [{}]).target_objects
|
20
|
+
targets.should be_an Array
|
21
|
+
targets.first.should be_a Twitter::Status
|
22
|
+
end
|
23
|
+
it "should be empty when not set" do
|
24
|
+
targets = Twitter::Retweet.new.target_objects
|
25
|
+
targets.should be_empty
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe "#targets" do
|
30
|
+
it "should return a collection containing the retweeted user" do
|
31
|
+
targets = Twitter::Retweet.new('targets' => [{}]).targets
|
32
|
+
targets.should be_an Array
|
33
|
+
targets.first.should be_a Twitter::User
|
34
|
+
end
|
35
|
+
it "should be empty when not set" do
|
36
|
+
targets = Twitter::Retweet.new.targets
|
37
|
+
targets.should be_empty
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Twitter::SavedSearch do
|
4
|
+
|
5
|
+
describe "#==" do
|
6
|
+
it "should return true when ids and classes are equal" do
|
7
|
+
saved_search = Twitter::SavedSearch.new('id' => 1)
|
8
|
+
other = Twitter::SavedSearch.new('id' => 1)
|
9
|
+
(saved_search == other).should be_true
|
10
|
+
end
|
11
|
+
it "should return false when classes are not equal" do
|
12
|
+
saved_search = Twitter::SavedSearch.new('id' => 1)
|
13
|
+
other = Twitter::User.new('id' => 1)
|
14
|
+
(saved_search == other).should be_false
|
15
|
+
end
|
16
|
+
it "should return false when ids are not equal" do
|
17
|
+
saved_search = Twitter::SavedSearch.new('id' => 1)
|
18
|
+
other = Twitter::SavedSearch.new('id' => 2)
|
19
|
+
(saved_search == other).should be_false
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "#created_at" do
|
24
|
+
it "should return a Time when created_at is set" do
|
25
|
+
saved_search = Twitter::SavedSearch.new('created_at' => "Mon Jul 16 12:59:01 +0000 2007")
|
26
|
+
saved_search.created_at.should be_a Time
|
27
|
+
end
|
28
|
+
it "should return nil when created_at is not set" do
|
29
|
+
saved_search = Twitter::SavedSearch.new
|
30
|
+
saved_search.created_at.should be_nil
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Twitter::Settings do
|
4
|
+
|
5
|
+
describe "#trend_location" do
|
6
|
+
it "should return a Twitter::Place when set" do
|
7
|
+
place = Twitter::Settings.new('trend_location' => [{'countryCode' => 'US', 'name' => 'San Francisco', 'country' => 'United States', 'placeType' => {'name' => 'Town', 'code' => 7}, 'woeid' => 2487956, 'parentid' => 23424977, 'url' => 'http://where.yahooapis.com/v1/place/2487956'}])
|
8
|
+
place.trend_location.should be_a Twitter::Place
|
9
|
+
end
|
10
|
+
it "should return nil when not set" do
|
11
|
+
place = Twitter::Settings.new
|
12
|
+
place.trend_location.should be_nil
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Twitter::Size do
|
4
|
+
|
5
|
+
describe "#==" do
|
6
|
+
it "should return true when height and width are equal" do
|
7
|
+
size = Twitter::Size.new('h' => 1, 'w' => 1)
|
8
|
+
other = Twitter::Size.new('h' => 1, 'w' => 1)
|
9
|
+
(size == other).should be_true
|
10
|
+
end
|
11
|
+
it "should return false when height and width are not equal" do
|
12
|
+
size = Twitter::Size.new('h' => 1, 'w' => 1)
|
13
|
+
other = Twitter::Size.new('h' => 1, 'w' => 2)
|
14
|
+
(size == other).should be_false
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
@@ -0,0 +1,148 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Twitter::Status do
|
4
|
+
|
5
|
+
describe "#==" do
|
6
|
+
it "should return true when ids and classes are equal" do
|
7
|
+
status = Twitter::Status.new('id' => 1)
|
8
|
+
other = Twitter::Status.new('id' => 1)
|
9
|
+
(status == other).should be_true
|
10
|
+
end
|
11
|
+
it "should return false when classes are not equal" do
|
12
|
+
status = Twitter::Status.new('id' => 1)
|
13
|
+
other = Twitter::User.new('id' => 1)
|
14
|
+
(status == other).should be_false
|
15
|
+
end
|
16
|
+
it "should return false when ids are not equal" do
|
17
|
+
status = Twitter::Status.new('id' => 1)
|
18
|
+
other = Twitter::Status.new('id' => 2)
|
19
|
+
(status == other).should be_false
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "#expanded_urls" do
|
24
|
+
it "should return the expanded urls" do
|
25
|
+
urls = [{'expanded_url' => 'http://example.com'}]
|
26
|
+
expanded_urls = Twitter::Status.new('entities' => {'urls' => urls}).expanded_urls
|
27
|
+
expanded_urls.should be_an Array
|
28
|
+
expanded_urls.first.should == "http://example.com"
|
29
|
+
end
|
30
|
+
it "should return nil when not set" do
|
31
|
+
expanded_urls = Twitter::Status.new.expanded_urls
|
32
|
+
expanded_urls.should be_nil
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe "#created_at" do
|
37
|
+
it "should return a Time when set" do
|
38
|
+
status = Twitter::Status.new('created_at' => "Mon Jul 16 12:59:01 +0000 2007")
|
39
|
+
status.created_at.should be_a Time
|
40
|
+
end
|
41
|
+
it "should return nil when not set" do
|
42
|
+
status = Twitter::Status.new
|
43
|
+
status.created_at.should be_nil
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe "#geo" do
|
48
|
+
it "should return a Twitter::Point when set" do
|
49
|
+
status = Twitter::Status.new('geo' => {'type' => 'Point'})
|
50
|
+
status.geo.should be_a Twitter::Point
|
51
|
+
end
|
52
|
+
it "should return nil when not set" do
|
53
|
+
status = Twitter::Status.new
|
54
|
+
status.geo.should be_nil
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe "#media" do
|
59
|
+
it "should return media" do
|
60
|
+
media = Twitter::Status.new('entities' => {'media' => [{'type' => 'photo'}]}).media
|
61
|
+
media.should be_an Array
|
62
|
+
media.first.should be_a Twitter::Photo
|
63
|
+
end
|
64
|
+
it "should return nil when not set" do
|
65
|
+
media = Twitter::Status.new.media
|
66
|
+
media.should be_nil
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
describe "#metadata" do
|
71
|
+
it "should return a User when user is set" do
|
72
|
+
metadata = Twitter::Status.new('metadata' => {}).metadata
|
73
|
+
metadata.should be_a Twitter::Metadata
|
74
|
+
end
|
75
|
+
it "should return nil when user is not set" do
|
76
|
+
metadata = Twitter::Status.new.metadata
|
77
|
+
metadata.should be_nil
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
describe "#place" do
|
82
|
+
it "should return a Twitter::Place when set" do
|
83
|
+
status = Twitter::Status.new('place' => {})
|
84
|
+
status.place.should be_a Twitter::Place
|
85
|
+
end
|
86
|
+
it "should return nil when not set" do
|
87
|
+
status = Twitter::Status.new
|
88
|
+
status.place.should be_nil
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
describe "#user" do
|
93
|
+
it "should return a User when user is set" do
|
94
|
+
user = Twitter::Status.new('user' => {}).user
|
95
|
+
user.should be_a Twitter::User
|
96
|
+
end
|
97
|
+
it "should return nil when user is not set" do
|
98
|
+
user = Twitter::Status.new.user
|
99
|
+
user.should be_nil
|
100
|
+
end
|
101
|
+
it "should have a status when status is set" do
|
102
|
+
user = Twitter::Status.new('text' => 'Tweet text.', 'user' => {}).user
|
103
|
+
user.status.should be_a Twitter::Status
|
104
|
+
user.status.text.should == 'Tweet text.'
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
describe "#retweeted_status" do
|
109
|
+
before do
|
110
|
+
@a_retweeted_status = Twitter::Status.new('retweeted_status' => {'text' => 'BOOSH'})
|
111
|
+
end
|
112
|
+
it "should return a Status when retweeted_status is set" do
|
113
|
+
@a_retweeted_status.retweeted_status.should be_a Twitter::Status
|
114
|
+
end
|
115
|
+
it "should return nil when a retweeted_status is NOT set" do
|
116
|
+
status = Twitter::Status.new
|
117
|
+
status.retweeted_status.should be_nil
|
118
|
+
end
|
119
|
+
it "should have text when retweeted_status is set" do
|
120
|
+
status = Twitter::Status.new('retweeted_status' => {'text' => 'BOOSH'})
|
121
|
+
status.retweeted_status.text.should == 'BOOSH'
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
describe "#oembed" do
|
126
|
+
before do
|
127
|
+
stub_get("/1/statuses/oembed.json?id=25938088801").
|
128
|
+
to_return(:body => fixture("oembed.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
129
|
+
@status = Twitter::Status.new('id' => 25938088801)
|
130
|
+
end
|
131
|
+
it "should request the correct resource" do
|
132
|
+
@status.oembed
|
133
|
+
a_get("/1/statuses/oembed.json?id=25938088801").
|
134
|
+
should have_been_made
|
135
|
+
end
|
136
|
+
it "should return an OEmbed instance" do
|
137
|
+
oembed = @status.oembed
|
138
|
+
oembed.should be_a Twitter::OEmbed
|
139
|
+
end
|
140
|
+
context "without an id" do
|
141
|
+
it "should return nil" do
|
142
|
+
status = Twitter::Status.new
|
143
|
+
status.oembed.should be_nil
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
end
|