ifttt-twitter 2.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (217) hide show
  1. data/.gemtest +0 -0
  2. data/.gitignore +12 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +9 -0
  5. data/.yardopts +8 -0
  6. data/Gemfile +7 -0
  7. data/HISTORY.md +520 -0
  8. data/LICENSE.md +20 -0
  9. data/README.md +251 -0
  10. data/Rakefile +13 -0
  11. data/lib/twitter.rb +24 -0
  12. data/lib/twitter/action.rb +9 -0
  13. data/lib/twitter/action_factory.rb +28 -0
  14. data/lib/twitter/authenticatable.rb +24 -0
  15. data/lib/twitter/base.rb +40 -0
  16. data/lib/twitter/client.rb +126 -0
  17. data/lib/twitter/client/accounts.rb +180 -0
  18. data/lib/twitter/client/activity.rb +48 -0
  19. data/lib/twitter/client/block.rb +104 -0
  20. data/lib/twitter/client/direct_messages.rb +110 -0
  21. data/lib/twitter/client/favorites.rb +82 -0
  22. data/lib/twitter/client/friends_and_followers.rb +293 -0
  23. data/lib/twitter/client/help.rb +38 -0
  24. data/lib/twitter/client/legal.rb +32 -0
  25. data/lib/twitter/client/lists.rb +643 -0
  26. data/lib/twitter/client/local_trends.rb +46 -0
  27. data/lib/twitter/client/notification.rb +49 -0
  28. data/lib/twitter/client/places_and_geo.rb +113 -0
  29. data/lib/twitter/client/saved_searches.rb +73 -0
  30. data/lib/twitter/client/search.rb +94 -0
  31. data/lib/twitter/client/spam_reporting.rb +30 -0
  32. data/lib/twitter/client/suggested_users.rb +60 -0
  33. data/lib/twitter/client/timelines.rb +265 -0
  34. data/lib/twitter/client/trends.rb +55 -0
  35. data/lib/twitter/client/tweets.rb +191 -0
  36. data/lib/twitter/client/urls.rb +26 -0
  37. data/lib/twitter/client/users.rb +203 -0
  38. data/lib/twitter/config.rb +106 -0
  39. data/lib/twitter/configuration.rb +20 -0
  40. data/lib/twitter/connection.rb +43 -0
  41. data/lib/twitter/core_ext/hash.rb +81 -0
  42. data/lib/twitter/creatable.rb +14 -0
  43. data/lib/twitter/cursor.rb +44 -0
  44. data/lib/twitter/direct_message.rb +27 -0
  45. data/lib/twitter/error.rb +37 -0
  46. data/lib/twitter/error/bad_gateway.rb +7 -0
  47. data/lib/twitter/error/bad_request.rb +7 -0
  48. data/lib/twitter/error/client_error.rb +7 -0
  49. data/lib/twitter/error/enhance_your_calm.rb +13 -0
  50. data/lib/twitter/error/forbidden.rb +7 -0
  51. data/lib/twitter/error/internal_server_error.rb +7 -0
  52. data/lib/twitter/error/not_acceptable.rb +7 -0
  53. data/lib/twitter/error/not_found.rb +7 -0
  54. data/lib/twitter/error/server_error.rb +7 -0
  55. data/lib/twitter/error/service_unavailable.rb +7 -0
  56. data/lib/twitter/error/unauthorized.rb +7 -0
  57. data/lib/twitter/favorite.rb +28 -0
  58. data/lib/twitter/follow.rb +27 -0
  59. data/lib/twitter/geo_factory.rb +22 -0
  60. data/lib/twitter/language.rb +7 -0
  61. data/lib/twitter/list.rb +22 -0
  62. data/lib/twitter/list_member_added.rb +36 -0
  63. data/lib/twitter/media_factory.rb +21 -0
  64. data/lib/twitter/mention.rb +43 -0
  65. data/lib/twitter/metadata.rb +7 -0
  66. data/lib/twitter/oembed.rb +8 -0
  67. data/lib/twitter/photo.rb +24 -0
  68. data/lib/twitter/place.rb +36 -0
  69. data/lib/twitter/point.rb +27 -0
  70. data/lib/twitter/polygon.rb +14 -0
  71. data/lib/twitter/rate_limit_status.rb +15 -0
  72. data/lib/twitter/relationship.rb +18 -0
  73. data/lib/twitter/reply.rb +36 -0
  74. data/lib/twitter/request.rb +38 -0
  75. data/lib/twitter/request/gateway.rb +20 -0
  76. data/lib/twitter/request/multipart_with_file.rb +37 -0
  77. data/lib/twitter/request/oauth.rb +26 -0
  78. data/lib/twitter/request/phoenix.rb +22 -0
  79. data/lib/twitter/response/parse_json.rb +28 -0
  80. data/lib/twitter/response/raise_client_error.rb +49 -0
  81. data/lib/twitter/response/raise_server_error.rb +23 -0
  82. data/lib/twitter/retweet.rb +36 -0
  83. data/lib/twitter/saved_search.rb +16 -0
  84. data/lib/twitter/settings.rb +17 -0
  85. data/lib/twitter/size.rb +16 -0
  86. data/lib/twitter/status.rb +80 -0
  87. data/lib/twitter/suggestion.rb +22 -0
  88. data/lib/twitter/trend.rb +14 -0
  89. data/lib/twitter/user.rb +65 -0
  90. data/lib/twitter/version.rb +30 -0
  91. data/spec/faraday/request_spec.rb +25 -0
  92. data/spec/faraday/response_spec.rb +68 -0
  93. data/spec/fixtures/about_me.json +1 -0
  94. data/spec/fixtures/all.json +1 -0
  95. data/spec/fixtures/bad_gateway.json +1 -0
  96. data/spec/fixtures/bad_request.json +1 -0
  97. data/spec/fixtures/by_friends.json +1 -0
  98. data/spec/fixtures/category.json +1 -0
  99. data/spec/fixtures/configuration.json +1 -0
  100. data/spec/fixtures/contributees.json +1 -0
  101. data/spec/fixtures/contributors.json +1 -0
  102. data/spec/fixtures/direct_message.json +1 -0
  103. data/spec/fixtures/direct_messages.json +1 -0
  104. data/spec/fixtures/end_session.json +1 -0
  105. data/spec/fixtures/enhance_your_calm.text +11 -0
  106. data/spec/fixtures/false.json +1 -0
  107. data/spec/fixtures/favorites.json +1 -0
  108. data/spec/fixtures/forbidden.json +1 -0
  109. data/spec/fixtures/friendships.json +1 -0
  110. data/spec/fixtures/id_list.json +1 -0
  111. data/spec/fixtures/ids.json +1 -0
  112. data/spec/fixtures/image_facets.json +1 -0
  113. data/spec/fixtures/internal_server_error.json +1 -0
  114. data/spec/fixtures/languages.json +1 -0
  115. data/spec/fixtures/list.json +1 -0
  116. data/spec/fixtures/lists.json +1 -0
  117. data/spec/fixtures/locations.json +1 -0
  118. data/spec/fixtures/matching_trends.json +1 -0
  119. data/spec/fixtures/me.jpeg +0 -0
  120. data/spec/fixtures/media_timeline.json +1 -0
  121. data/spec/fixtures/members.json +1 -0
  122. data/spec/fixtures/n605431196_2079896_558_normal.jpg +0 -0
  123. data/spec/fixtures/no_user_matches.json +1 -0
  124. data/spec/fixtures/not_acceptable.json +1 -0
  125. data/spec/fixtures/not_found.json +1 -0
  126. data/spec/fixtures/oembed.json +1 -0
  127. data/spec/fixtures/pengwynn.json +1 -0
  128. data/spec/fixtures/phoenix_search.phoenix +1 -0
  129. data/spec/fixtures/place.json +1 -0
  130. data/spec/fixtures/places.json +1 -0
  131. data/spec/fixtures/privacy.json +1 -0
  132. data/spec/fixtures/profile_image.text +24 -0
  133. data/spec/fixtures/rate_limit_status.json +1 -0
  134. data/spec/fixtures/recommendations.json +1 -0
  135. data/spec/fixtures/relationship.json +1 -0
  136. data/spec/fixtures/resolve.json +1 -0
  137. data/spec/fixtures/retweet.json +1 -0
  138. data/spec/fixtures/retweeters_of.json +1 -0
  139. data/spec/fixtures/retweets.json +1 -0
  140. data/spec/fixtures/saved_search.json +1 -0
  141. data/spec/fixtures/saved_searches.json +1 -0
  142. data/spec/fixtures/search.json +1 -0
  143. data/spec/fixtures/service_unavailable.json +1 -0
  144. data/spec/fixtures/settings.json +1 -0
  145. data/spec/fixtures/sferik.json +1 -0
  146. data/spec/fixtures/status.json +1 -0
  147. data/spec/fixtures/status_with_media.json +104 -0
  148. data/spec/fixtures/statuses.json +1 -0
  149. data/spec/fixtures/suggestions.json +1 -0
  150. data/spec/fixtures/tos.json +1 -0
  151. data/spec/fixtures/totals.json +1 -0
  152. data/spec/fixtures/trends.json +1 -0
  153. data/spec/fixtures/trends_current.json +1 -0
  154. data/spec/fixtures/trends_daily.json +1 -0
  155. data/spec/fixtures/trends_weekly.json +1 -0
  156. data/spec/fixtures/true.json +1 -0
  157. data/spec/fixtures/unauthorized.json +1 -0
  158. data/spec/fixtures/user_search.json +1 -0
  159. data/spec/fixtures/user_timeline.json +1 -0
  160. data/spec/fixtures/users.json +1 -0
  161. data/spec/fixtures/users_list.json +1 -0
  162. data/spec/fixtures/video_facets.json +1 -0
  163. data/spec/fixtures/we_concept_bg2.png +0 -0
  164. data/spec/helper.rb +49 -0
  165. data/spec/twitter/action_factory_spec.rb +37 -0
  166. data/spec/twitter/action_spec.rb +16 -0
  167. data/spec/twitter/base_spec.rb +29 -0
  168. data/spec/twitter/client/accounts_spec.rb +181 -0
  169. data/spec/twitter/client/activity_spec.rb +43 -0
  170. data/spec/twitter/client/block_spec.rb +106 -0
  171. data/spec/twitter/client/direct_messages_spec.rb +98 -0
  172. data/spec/twitter/client/favorites_spec.rb +80 -0
  173. data/spec/twitter/client/friends_and_followers_spec.rb +478 -0
  174. data/spec/twitter/client/help_spec.rb +44 -0
  175. data/spec/twitter/client/legal_spec.rb +41 -0
  176. data/spec/twitter/client/lists_spec.rb +1104 -0
  177. data/spec/twitter/client/local_trends_spec.rb +58 -0
  178. data/spec/twitter/client/notification_spec.rb +47 -0
  179. data/spec/twitter/client/places_and_geo_spec.rb +100 -0
  180. data/spec/twitter/client/saved_searches_spec.rb +80 -0
  181. data/spec/twitter/client/search_spec.rb +92 -0
  182. data/spec/twitter/client/spam_reporting_spec.rb +28 -0
  183. data/spec/twitter/client/suggested_users_spec.rb +65 -0
  184. data/spec/twitter/client/timelines_spec.rb +231 -0
  185. data/spec/twitter/client/trends_spec.rb +51 -0
  186. data/spec/twitter/client/tweets_spec.rb +189 -0
  187. data/spec/twitter/client/urls_spec.rb +31 -0
  188. data/spec/twitter/client/users_spec.rb +323 -0
  189. data/spec/twitter/client_spec.rb +94 -0
  190. data/spec/twitter/configuration_spec.rb +17 -0
  191. data/spec/twitter/cursor_spec.rb +43 -0
  192. data/spec/twitter/direct_message_spec.rb +56 -0
  193. data/spec/twitter/favorite_spec.rb +29 -0
  194. data/spec/twitter/follow_spec.rb +29 -0
  195. data/spec/twitter/geo_factory_spec.rb +21 -0
  196. data/spec/twitter/list_spec.rb +34 -0
  197. data/spec/twitter/media_factory_spec.rb +17 -0
  198. data/spec/twitter/mention_spec.rb +52 -0
  199. data/spec/twitter/oembed_spec.rb +145 -0
  200. data/spec/twitter/photo_spec.rb +35 -0
  201. data/spec/twitter/place_spec.rb +75 -0
  202. data/spec/twitter/point_spec.rb +32 -0
  203. data/spec/twitter/polygon_spec.rb +18 -0
  204. data/spec/twitter/rate_limit_status_spec.rb +16 -0
  205. data/spec/twitter/relationship_spec.rb +27 -0
  206. data/spec/twitter/reply_spec.rb +41 -0
  207. data/spec/twitter/retweet_spec.rb +41 -0
  208. data/spec/twitter/saved_search_spec.rb +34 -0
  209. data/spec/twitter/settings_spec.rb +16 -0
  210. data/spec/twitter/size_spec.rb +18 -0
  211. data/spec/twitter/status_spec.rb +148 -0
  212. data/spec/twitter/suggestion_spec.rb +20 -0
  213. data/spec/twitter/trend_spec.rb +20 -0
  214. data/spec/twitter/user_spec.rb +50 -0
  215. data/spec/twitter_spec.rb +91 -0
  216. data/twitter.gemspec +42 -0
  217. 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