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,17 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Twitter::Configuration do
|
4
|
+
|
5
|
+
describe "#photo_sizes" do
|
6
|
+
it "should return a hash of sizes when photo_sizes is set" do
|
7
|
+
photo_sizes = Twitter::Configuration.new('photo_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'}}).photo_sizes
|
8
|
+
photo_sizes.should be_a Hash
|
9
|
+
photo_sizes['small'].should be_a Twitter::Size
|
10
|
+
end
|
11
|
+
it "should be empty when photo_sizes is not set" do
|
12
|
+
photo_sizes = Twitter::Configuration.new().photo_sizes
|
13
|
+
photo_sizes.should be_empty
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Twitter::Cursor do
|
4
|
+
|
5
|
+
describe "#first?" do
|
6
|
+
context "when previous cursor equals zero" do
|
7
|
+
before do
|
8
|
+
@cursor = Twitter::Cursor.new({'previous_cursor' => 0}, 'ids')
|
9
|
+
end
|
10
|
+
it "should return true" do
|
11
|
+
@cursor.first?.should be_true
|
12
|
+
end
|
13
|
+
end
|
14
|
+
context "when previous cursor does not equal zero" do
|
15
|
+
before do
|
16
|
+
@cursor = Twitter::Cursor.new({'previous_cursor' => 1}, 'ids')
|
17
|
+
end
|
18
|
+
it "should return true" do
|
19
|
+
@cursor.first?.should be_false
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "#last?" do
|
25
|
+
context "when next cursor equals zero" do
|
26
|
+
before do
|
27
|
+
@cursor = Twitter::Cursor.new({'next_cursor' => 0}, 'ids')
|
28
|
+
end
|
29
|
+
it "should return true" do
|
30
|
+
@cursor.last?.should be_true
|
31
|
+
end
|
32
|
+
end
|
33
|
+
context "when next cursor does not equal zero" do
|
34
|
+
before do
|
35
|
+
@cursor = Twitter::Cursor.new({'next_cursor' => 1}, 'ids')
|
36
|
+
end
|
37
|
+
it "should return false" do
|
38
|
+
@cursor.last?.should be_false
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Twitter::DirectMessage do
|
4
|
+
|
5
|
+
describe "#==" do
|
6
|
+
it "should return true when ids and classes are equal" do
|
7
|
+
direct_message = Twitter::DirectMessage.new('id' => 1)
|
8
|
+
other = Twitter::DirectMessage.new('id' => 1)
|
9
|
+
(direct_message == other).should be_true
|
10
|
+
end
|
11
|
+
it "should return false when classes are not equal" do
|
12
|
+
direct_message = Twitter::DirectMessage.new('id' => 1)
|
13
|
+
other = Twitter::User.new('id' => 1)
|
14
|
+
(direct_message == other).should be_false
|
15
|
+
end
|
16
|
+
it "should return false when ids are not equal" do
|
17
|
+
direct_message = Twitter::DirectMessage.new('id' => 1)
|
18
|
+
other = Twitter::DirectMessage.new('id' => 2)
|
19
|
+
(direct_message == 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
|
+
direct_message = Twitter::DirectMessage.new('created_at' => "Mon Jul 16 12:59:01 +0000 2007")
|
26
|
+
direct_message.created_at.should be_a Time
|
27
|
+
end
|
28
|
+
it "should return nil when created_at is not set" do
|
29
|
+
direct_message = Twitter::DirectMessage.new
|
30
|
+
direct_message.created_at.should be_nil
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "#recipient" do
|
35
|
+
it "should return a User when recipient is set" do
|
36
|
+
recipient = Twitter::DirectMessage.new('recipient' => {}).recipient
|
37
|
+
recipient.should be_a Twitter::User
|
38
|
+
end
|
39
|
+
it "should return nil when status is not set" do
|
40
|
+
recipient = Twitter::DirectMessage.new.recipient
|
41
|
+
recipient.should be_nil
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe "#sender" do
|
46
|
+
it "should return a User when sender is set" do
|
47
|
+
sender = Twitter::DirectMessage.new('sender' => {}).sender
|
48
|
+
sender.should be_a Twitter::User
|
49
|
+
end
|
50
|
+
it "should return nil when status is not set" do
|
51
|
+
sender = Twitter::DirectMessage.new.sender
|
52
|
+
sender.should be_nil
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Twitter::Favorite do
|
4
|
+
|
5
|
+
describe "#sources" do
|
6
|
+
it "should return a collection of users who favorited a status" do
|
7
|
+
sources = Twitter::Favorite.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::Favorite.new.sources
|
13
|
+
sources.should be_empty
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "#targets" do
|
18
|
+
it "should return a collection containing the favorited status" do
|
19
|
+
targets = Twitter::Favorite.new('targets' => [{}]).targets
|
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::Favorite.new.targets
|
25
|
+
targets.should be_empty
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Twitter::Follow do
|
4
|
+
|
5
|
+
describe "#sources" do
|
6
|
+
it "should return a collection of users who followed a user" do
|
7
|
+
sources = Twitter::Follow.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::Follow.new.sources
|
13
|
+
sources.should be_empty
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "#targets" do
|
18
|
+
it "should return a collection containing the followed user" do
|
19
|
+
targets = Twitter::Follow.new('targets' => [{}]).targets
|
20
|
+
targets.should be_an Array
|
21
|
+
targets.first.should be_a Twitter::User
|
22
|
+
end
|
23
|
+
it "should be empty when not set" do
|
24
|
+
targets = Twitter::Follow.new.targets
|
25
|
+
targets.should be_empty
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Twitter::GeoFactory do
|
4
|
+
|
5
|
+
describe ".new" do
|
6
|
+
it "should generate a Point" do
|
7
|
+
geo = Twitter::GeoFactory.new('type' => 'Point')
|
8
|
+
geo.should be_a Twitter::Point
|
9
|
+
end
|
10
|
+
it "should generate a Polygon" do
|
11
|
+
geo = Twitter::GeoFactory.new('type' => 'Polygon')
|
12
|
+
geo.should be_a Twitter::Polygon
|
13
|
+
end
|
14
|
+
it "should raise an ArgumentError when type is not specified" do
|
15
|
+
lambda do
|
16
|
+
Twitter::GeoFactory.new({})
|
17
|
+
end.should raise_error(ArgumentError, "argument must have a 'type' key")
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Twitter::List do
|
4
|
+
|
5
|
+
describe "#==" do
|
6
|
+
it "should return true when ids and classes are equal" do
|
7
|
+
list = Twitter::List.new('id' => 1)
|
8
|
+
other = Twitter::List.new('id' => 1)
|
9
|
+
(list == other).should be_true
|
10
|
+
end
|
11
|
+
it "should return false when classes are not equal" do
|
12
|
+
list = Twitter::List.new('id' => 1)
|
13
|
+
other = Twitter::User.new('id' => 1)
|
14
|
+
(list == other).should be_false
|
15
|
+
end
|
16
|
+
it "should return false when ids are not equal" do
|
17
|
+
list = Twitter::List.new('id' => 1)
|
18
|
+
other = Twitter::List.new('id' => 2)
|
19
|
+
(list == other).should be_false
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "#user" do
|
24
|
+
it "should return a User when user is set" do
|
25
|
+
user = Twitter::List.new('user' => {}).user
|
26
|
+
user.should be_a Twitter::User
|
27
|
+
end
|
28
|
+
it "should return nil when status is not set" do
|
29
|
+
user = Twitter::List.new.user
|
30
|
+
user.should be_nil
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Twitter::MediaFactory do
|
4
|
+
|
5
|
+
describe ".new" do
|
6
|
+
it "should generate a Photo" do
|
7
|
+
media = Twitter::MediaFactory.new('type' => 'photo')
|
8
|
+
media.should be_a Twitter::Photo
|
9
|
+
end
|
10
|
+
it "should raise an ArgumentError when type is not specified" do
|
11
|
+
lambda do
|
12
|
+
Twitter::MediaFactory.new({})
|
13
|
+
end.should raise_error(ArgumentError, "argument must have a 'type' key")
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Twitter::Mention do
|
4
|
+
|
5
|
+
describe "#sources" do
|
6
|
+
it "should return a collection of users who mentioned a user" do
|
7
|
+
sources = Twitter::Mention.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::Mention.new.sources
|
13
|
+
sources.should be_empty
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "#source" do
|
18
|
+
it "should return the user who mentioned a user" do
|
19
|
+
source = Twitter::Mention.new('sources' => [{}]).source
|
20
|
+
source.should be_a Twitter::User
|
21
|
+
end
|
22
|
+
it "should be nil when not set" do
|
23
|
+
source = Twitter::Mention.new.source
|
24
|
+
source.should be_nil
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "#target_objects" do
|
29
|
+
it "should return a collection of statuses that mention a user" do
|
30
|
+
targets = Twitter::Mention.new('target_objects' => [{}]).target_objects
|
31
|
+
targets.should be_an Array
|
32
|
+
targets.first.should be_a Twitter::Status
|
33
|
+
end
|
34
|
+
it "should be empty when not set" do
|
35
|
+
targets = Twitter::Mention.new.target_objects
|
36
|
+
targets.should be_empty
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe "#targets" do
|
41
|
+
it "should return a collection containing the mentioned user" do
|
42
|
+
targets = Twitter::Mention.new('targets' => [{}]).targets
|
43
|
+
targets.should be_an Array
|
44
|
+
targets.first.should be_a Twitter::User
|
45
|
+
end
|
46
|
+
it "should be empty when not set" do
|
47
|
+
targets = Twitter::Mention.new.targets
|
48
|
+
targets.should be_empty
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
@@ -0,0 +1,145 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Twitter::OEmbed do
|
4
|
+
describe "#author_url" do
|
5
|
+
it "should return the author's url" do
|
6
|
+
oembed = Twitter::OEmbed.new('author_url' => 'https://twitter.com/sferik')
|
7
|
+
oembed.author_url.should == "https://twitter.com/sferik"
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should return nil when not set" do
|
11
|
+
author_url = Twitter::OEmbed.new.author_url
|
12
|
+
author_url.should be_nil
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "#author_name" do
|
17
|
+
it "should return the author's name" do
|
18
|
+
oembed = Twitter::OEmbed.new('author_name' => 'Erik Michaels-Ober')
|
19
|
+
oembed.author_name.should == "Erik Michaels-Ober"
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should return nil when not set" do
|
23
|
+
author_name = Twitter::OEmbed.new.author_name
|
24
|
+
author_name.should be_nil
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "#cache_age" do
|
29
|
+
it "should return the cache_age" do
|
30
|
+
oembed = Twitter::OEmbed.new('cache_age' => '31536000000')
|
31
|
+
oembed.cache_age.should == "31536000000"
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should return nil when not set" do
|
35
|
+
cache_age = Twitter::OEmbed.new.cache_age
|
36
|
+
cache_age.should be_nil
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe "#height" do
|
41
|
+
it "should return the height" do
|
42
|
+
oembed = Twitter::OEmbed.new('height' => 200)
|
43
|
+
oembed.height.should == 200
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should return it as a Fixnum" do
|
47
|
+
oembed = Twitter::OEmbed.new('height' => 200)
|
48
|
+
oembed.height.should be_a Fixnum
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should return nil when not set" do
|
52
|
+
height = Twitter::OEmbed.new.height
|
53
|
+
height.should be_nil
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe "#html" do
|
58
|
+
it "should return the html" do
|
59
|
+
oembed = Twitter::OEmbed.new('html' => '<blockquote>all my <b>witty tweet</b> stuff here</blockquote>')
|
60
|
+
oembed.html.should == "<blockquote>all my <b>witty tweet</b> stuff here</blockquote>"
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should return nil when not set" do
|
64
|
+
html = Twitter::OEmbed.new.html
|
65
|
+
html.should be_nil
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
describe "#provider_name" do
|
70
|
+
it "should return the provider_name" do
|
71
|
+
oembed = Twitter::OEmbed.new('provider_name' => 'Twitter')
|
72
|
+
oembed.provider_name.should == "Twitter"
|
73
|
+
end
|
74
|
+
|
75
|
+
it "should return nil when not set" do
|
76
|
+
provider_name = Twitter::OEmbed.new.provider_name
|
77
|
+
provider_name.should be_nil
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
describe "#provider_url" do
|
82
|
+
it "should return the provider_url" do
|
83
|
+
oembed = Twitter::OEmbed.new('provider_url' => 'http://twitter.com')
|
84
|
+
oembed.provider_url.should == "http://twitter.com"
|
85
|
+
end
|
86
|
+
|
87
|
+
it "should return nil when not set" do
|
88
|
+
provider_url = Twitter::OEmbed.new.provider_url
|
89
|
+
provider_url.should be_nil
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
describe "#type" do
|
94
|
+
it "should return the type" do
|
95
|
+
oembed = Twitter::OEmbed.new('type' => 'rich')
|
96
|
+
oembed.type.should == "rich"
|
97
|
+
end
|
98
|
+
|
99
|
+
it "should return nil when not set" do
|
100
|
+
type = Twitter::OEmbed.new.type
|
101
|
+
type.should be_nil
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
describe "#width" do
|
106
|
+
it "should return the width" do
|
107
|
+
oembed = Twitter::OEmbed.new('width' => 550)
|
108
|
+
oembed.width.should == 550
|
109
|
+
end
|
110
|
+
|
111
|
+
it "should return it as a Fixnum" do
|
112
|
+
oembed = Twitter::OEmbed.new('width' => 550)
|
113
|
+
oembed.width.should be_a Fixnum
|
114
|
+
end
|
115
|
+
|
116
|
+
it "should return nil when not set" do
|
117
|
+
width = Twitter::OEmbed.new.width
|
118
|
+
width.should be_nil
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
describe "#url" do
|
123
|
+
it "should return the url" do
|
124
|
+
oembed = Twitter::OEmbed.new('url' => 'https://twitter.com/twitterapi/status/133640144317198338')
|
125
|
+
oembed.url.should == "https://twitter.com/twitterapi/status/133640144317198338"
|
126
|
+
end
|
127
|
+
|
128
|
+
it "should return nil when not set" do
|
129
|
+
url = Twitter::OEmbed.new.url
|
130
|
+
url.should be_nil
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
describe "#version" do
|
135
|
+
it "should return the version" do
|
136
|
+
oembed = Twitter::OEmbed.new('version' => '1.0')
|
137
|
+
oembed.version.should == "1.0"
|
138
|
+
end
|
139
|
+
|
140
|
+
it "should return nil when not set" do
|
141
|
+
version = Twitter::OEmbed.new.version
|
142
|
+
version.should be_nil
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|