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.
Files changed (210) hide show
  1. data/CHANGELOG.md +673 -0
  2. data/LICENSE.md +20 -0
  3. data/README.md +415 -0
  4. data/Rakefile +11 -0
  5. data/lib/twitter.rb +29 -0
  6. data/lib/twitter/action/favorite.rb +19 -0
  7. data/lib/twitter/action/follow.rb +31 -0
  8. data/lib/twitter/action/list_member_added.rb +41 -0
  9. data/lib/twitter/action/mention.rb +48 -0
  10. data/lib/twitter/action/reply.rb +27 -0
  11. data/lib/twitter/action/retweet.rb +27 -0
  12. data/lib/twitter/action/tweet.rb +22 -0
  13. data/lib/twitter/action_factory.rb +22 -0
  14. data/lib/twitter/api.rb +2442 -0
  15. data/lib/twitter/base.rb +119 -0
  16. data/lib/twitter/basic_user.rb +8 -0
  17. data/lib/twitter/client.rb +96 -0
  18. data/lib/twitter/configurable.rb +67 -0
  19. data/lib/twitter/configuration.rb +20 -0
  20. data/lib/twitter/core_ext/array.rb +7 -0
  21. data/lib/twitter/core_ext/enumerable.rb +11 -0
  22. data/lib/twitter/core_ext/hash.rb +100 -0
  23. data/lib/twitter/core_ext/kernel.rb +15 -0
  24. data/lib/twitter/core_ext/string.rb +10 -0
  25. data/lib/twitter/creatable.rb +20 -0
  26. data/lib/twitter/cursor.rb +87 -0
  27. data/lib/twitter/default.rb +101 -0
  28. data/lib/twitter/direct_message.rb +21 -0
  29. data/lib/twitter/entity.rb +7 -0
  30. data/lib/twitter/entity/hashtag.rb +9 -0
  31. data/lib/twitter/entity/url.rb +9 -0
  32. data/lib/twitter/entity/user_mention.rb +9 -0
  33. data/lib/twitter/error.rb +34 -0
  34. data/lib/twitter/error/bad_gateway.rb +11 -0
  35. data/lib/twitter/error/bad_request.rb +10 -0
  36. data/lib/twitter/error/client_error.rb +35 -0
  37. data/lib/twitter/error/decode_error.rb +9 -0
  38. data/lib/twitter/error/forbidden.rb +10 -0
  39. data/lib/twitter/error/gateway_timeout.rb +11 -0
  40. data/lib/twitter/error/identity_map_key_error.rb +9 -0
  41. data/lib/twitter/error/internal_server_error.rb +11 -0
  42. data/lib/twitter/error/not_acceptable.rb +10 -0
  43. data/lib/twitter/error/not_found.rb +10 -0
  44. data/lib/twitter/error/rate_limited.rb +11 -0
  45. data/lib/twitter/error/server_error.rb +28 -0
  46. data/lib/twitter/error/service_unavailable.rb +11 -0
  47. data/lib/twitter/error/unauthorized.rb +10 -0
  48. data/lib/twitter/factory.rb +21 -0
  49. data/lib/twitter/geo.rb +15 -0
  50. data/lib/twitter/geo/point.rb +22 -0
  51. data/lib/twitter/geo/polygon.rb +8 -0
  52. data/lib/twitter/geo_factory.rb +18 -0
  53. data/lib/twitter/identity.rb +50 -0
  54. data/lib/twitter/identity_map.rb +22 -0
  55. data/lib/twitter/language.rb +7 -0
  56. data/lib/twitter/list.rb +18 -0
  57. data/lib/twitter/media/photo.rb +22 -0
  58. data/lib/twitter/media_factory.rb +17 -0
  59. data/lib/twitter/metadata.rb +7 -0
  60. data/lib/twitter/oembed.rb +8 -0
  61. data/lib/twitter/place.rb +34 -0
  62. data/lib/twitter/rate_limit.rb +45 -0
  63. data/lib/twitter/relationship.rb +36 -0
  64. data/lib/twitter/request/multipart_with_file.rb +41 -0
  65. data/lib/twitter/response/parse_json.rb +25 -0
  66. data/lib/twitter/response/raise_error.rb +30 -0
  67. data/lib/twitter/saved_search.rb +9 -0
  68. data/lib/twitter/search_results.rb +48 -0
  69. data/lib/twitter/settings.rb +17 -0
  70. data/lib/twitter/size.rb +24 -0
  71. data/lib/twitter/source_user.rb +15 -0
  72. data/lib/twitter/suggestion.rb +22 -0
  73. data/lib/twitter/target_user.rb +8 -0
  74. data/lib/twitter/trend.rb +14 -0
  75. data/lib/twitter/tweet.rb +145 -0
  76. data/lib/twitter/user.rb +97 -0
  77. data/lib/twitter/version.rb +18 -0
  78. data/spec/fixtures/about_me.json +1 -0
  79. data/spec/fixtures/activity_summary.json +1 -0
  80. data/spec/fixtures/all.json +1 -0
  81. data/spec/fixtures/bad_gateway.json +1 -0
  82. data/spec/fixtures/bad_request.json +1 -0
  83. data/spec/fixtures/by_friends.json +1 -0
  84. data/spec/fixtures/category.json +1 -0
  85. data/spec/fixtures/configuration.json +1 -0
  86. data/spec/fixtures/contributees.json +1 -0
  87. data/spec/fixtures/contributors.json +1 -0
  88. data/spec/fixtures/direct_message.json +1 -0
  89. data/spec/fixtures/direct_messages.json +1 -0
  90. data/spec/fixtures/end_session.json +1 -0
  91. data/spec/fixtures/enhance_your_calm.text +11 -0
  92. data/spec/fixtures/favorites.json +1 -0
  93. data/spec/fixtures/following.json +1 -0
  94. data/spec/fixtures/forbidden.json +1 -0
  95. data/spec/fixtures/friendships.json +1 -0
  96. data/spec/fixtures/ids.json +1 -0
  97. data/spec/fixtures/ids_list.json +1 -0
  98. data/spec/fixtures/ids_list2.json +1 -0
  99. data/spec/fixtures/image_facets.json +1 -0
  100. data/spec/fixtures/internal_server_error.json +1 -0
  101. data/spec/fixtures/languages.json +1 -0
  102. data/spec/fixtures/list.json +1 -0
  103. data/spec/fixtures/lists.json +1 -0
  104. data/spec/fixtures/locations.json +1 -0
  105. data/spec/fixtures/matching_trends.json +1 -0
  106. data/spec/fixtures/me.jpeg +0 -0
  107. data/spec/fixtures/media_timeline.json +1 -0
  108. data/spec/fixtures/members.json +1 -0
  109. data/spec/fixtures/no_user_matches.json +1 -0
  110. data/spec/fixtures/not_acceptable.json +1 -0
  111. data/spec/fixtures/not_following.json +1 -0
  112. data/spec/fixtures/not_found.json +1 -0
  113. data/spec/fixtures/oembed.json +1 -0
  114. data/spec/fixtures/pbjt.gif +0 -0
  115. data/spec/fixtures/pengwynn.json +1 -0
  116. data/spec/fixtures/phoenix_search.phoenix +1 -0
  117. data/spec/fixtures/place.json +1 -0
  118. data/spec/fixtures/places.json +1 -0
  119. data/spec/fixtures/privacy.json +1 -0
  120. data/spec/fixtures/profile_image.text +24 -0
  121. data/spec/fixtures/rate_limit_status.json +1 -0
  122. data/spec/fixtures/recommendations.json +1 -0
  123. data/spec/fixtures/related_results.json +1 -0
  124. data/spec/fixtures/resolve.json +1 -0
  125. data/spec/fixtures/retweet.json +1 -0
  126. data/spec/fixtures/retweeted_status.json +1 -0
  127. data/spec/fixtures/retweeters_of.json +1 -0
  128. data/spec/fixtures/retweets.json +1 -0
  129. data/spec/fixtures/saved_search.json +1 -0
  130. data/spec/fixtures/saved_searches.json +1 -0
  131. data/spec/fixtures/search.json +1 -0
  132. data/spec/fixtures/search_malformed.json +1 -0
  133. data/spec/fixtures/service_unavailable.json +1 -0
  134. data/spec/fixtures/settings.json +1 -0
  135. data/spec/fixtures/sferik.json +1 -0
  136. data/spec/fixtures/status.json +1 -0
  137. data/spec/fixtures/status_with_media.json +104 -0
  138. data/spec/fixtures/statuses.json +1 -0
  139. data/spec/fixtures/suggestions.json +1 -0
  140. data/spec/fixtures/tos.json +1 -0
  141. data/spec/fixtures/totals.json +1 -0
  142. data/spec/fixtures/trends.json +1 -0
  143. data/spec/fixtures/trends_current.json +1 -0
  144. data/spec/fixtures/trends_daily.json +1 -0
  145. data/spec/fixtures/trends_weekly.json +1 -0
  146. data/spec/fixtures/unauthorized.json +1 -0
  147. data/spec/fixtures/user_search.json +1 -0
  148. data/spec/fixtures/user_timeline.json +1 -0
  149. data/spec/fixtures/users.json +1 -0
  150. data/spec/fixtures/users_list.json +1 -0
  151. data/spec/fixtures/video_facets.json +1 -0
  152. data/spec/fixtures/we_concept_bg2.png +0 -0
  153. data/spec/fixtures/wildcomet2.jpe +0 -0
  154. data/spec/helper.rb +53 -0
  155. data/spec/twitter/action/favorite_spec.rb +29 -0
  156. data/spec/twitter/action/follow_spec.rb +29 -0
  157. data/spec/twitter/action/list_member_added_spec.rb +41 -0
  158. data/spec/twitter/action/mention_spec.rb +52 -0
  159. data/spec/twitter/action/reply_spec.rb +41 -0
  160. data/spec/twitter/action/retweet_spec.rb +41 -0
  161. data/spec/twitter/action_factory_spec.rb +37 -0
  162. data/spec/twitter/action_spec.rb +16 -0
  163. data/spec/twitter/api/account_spec.rb +148 -0
  164. data/spec/twitter/api/activity_spec.rb +41 -0
  165. data/spec/twitter/api/blocks_spec.rb +167 -0
  166. data/spec/twitter/api/direct_messages_spec.rb +142 -0
  167. data/spec/twitter/api/friendships_spec.rb +567 -0
  168. data/spec/twitter/api/geo_spec.rb +100 -0
  169. data/spec/twitter/api/help_spec.rb +76 -0
  170. data/spec/twitter/api/lists_spec.rb +900 -0
  171. data/spec/twitter/api/report_spam_spec.rb +29 -0
  172. data/spec/twitter/api/saved_searches_spec.rb +100 -0
  173. data/spec/twitter/api/search_spec.rb +68 -0
  174. data/spec/twitter/api/statuses_spec.rb +559 -0
  175. data/spec/twitter/api/trends_spec.rb +80 -0
  176. data/spec/twitter/api/users_spec.rb +419 -0
  177. data/spec/twitter/base_spec.rb +113 -0
  178. data/spec/twitter/basic_user_spec.rb +23 -0
  179. data/spec/twitter/client_spec.rb +175 -0
  180. data/spec/twitter/configuration_spec.rb +17 -0
  181. data/spec/twitter/cursor_spec.rb +102 -0
  182. data/spec/twitter/direct_message_spec.rb +56 -0
  183. data/spec/twitter/error/client_error_spec.rb +40 -0
  184. data/spec/twitter/error/server_error_spec.rb +24 -0
  185. data/spec/twitter/error_spec.rb +20 -0
  186. data/spec/twitter/geo/point_spec.rb +41 -0
  187. data/spec/twitter/geo/polygon_spec.rb +29 -0
  188. data/spec/twitter/geo_factory_spec.rb +21 -0
  189. data/spec/twitter/geo_spec.rb +29 -0
  190. data/spec/twitter/identifiable_spec.rb +54 -0
  191. data/spec/twitter/list_spec.rb +45 -0
  192. data/spec/twitter/media/photo_spec.rb +35 -0
  193. data/spec/twitter/media_factory_spec.rb +17 -0
  194. data/spec/twitter/oembed_spec.rb +146 -0
  195. data/spec/twitter/place_spec.rb +75 -0
  196. data/spec/twitter/rate_limit_spec.rb +76 -0
  197. data/spec/twitter/relationship_spec.rb +35 -0
  198. data/spec/twitter/saved_search_spec.rb +34 -0
  199. data/spec/twitter/search_results_spec.rb +89 -0
  200. data/spec/twitter/settings_spec.rb +16 -0
  201. data/spec/twitter/size_spec.rb +38 -0
  202. data/spec/twitter/source_user_spec.rb +23 -0
  203. data/spec/twitter/suggestion_spec.rb +50 -0
  204. data/spec/twitter/target_user_spec.rb +23 -0
  205. data/spec/twitter/trend_spec.rb +38 -0
  206. data/spec/twitter/tweet_spec.rb +307 -0
  207. data/spec/twitter/user_spec.rb +127 -0
  208. data/spec/twitter_spec.rb +93 -0
  209. data/twitter.gemspec +30 -0
  210. metadata +584 -0
@@ -0,0 +1,75 @@
1
+ require 'helper'
2
+
3
+ describe Twitter::Place do
4
+
5
+ describe "#==" do
6
+ it "returns true when objects IDs are the same" do
7
+ place = Twitter::Place.new(:id => 1, :name => "foo")
8
+ other = Twitter::Place.new(:id => 1, :name => "bar")
9
+ (place == other).should be_true
10
+ end
11
+ it "returns false when objects IDs are different" do
12
+ place = Twitter::Place.new(:id => 1)
13
+ other = Twitter::Place.new(:id => 2)
14
+ (place == other).should be_false
15
+ end
16
+ it "returns false when classes are different" do
17
+ place = Twitter::Place.new(:id => 1)
18
+ other = Twitter::Identity.new(:id => 1)
19
+ (place == other).should be_false
20
+ end
21
+ end
22
+
23
+ describe "#bounding_box" do
24
+ it "returns a Twitter::Place when set" do
25
+ place = Twitter::Place.new(:id => "247f43d441defc03", :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::Geo::Polygon
27
+ end
28
+ it "returns nil when not set" do
29
+ place = Twitter::Place.new(:id => "247f43d441defc03")
30
+ place.bounding_box.should be_nil
31
+ end
32
+ end
33
+
34
+ describe "#country_code" do
35
+ it "returns a country code when set with country_code" do
36
+ place = Twitter::Place.new(:id => "247f43d441defc03", :country_code => 'US')
37
+ place.country_code.should eq 'US'
38
+ end
39
+ it "returns a country code when set with countryCode" do
40
+ place = Twitter::Place.new(:id => "247f43d441defc03", :countryCode => 'US')
41
+ place.country_code.should eq 'US'
42
+ end
43
+ it "returns nil when not set" do
44
+ place = Twitter::Place.new(:id => "247f43d441defc03")
45
+ place.country_code.should be_nil
46
+ end
47
+ end
48
+
49
+ describe "#parent_id" do
50
+ it "returns a parent ID when set with parentid" do
51
+ place = Twitter::Place.new(:id => "247f43d441defc03", :parentid => 1)
52
+ place.parent_id.should eq 1
53
+ end
54
+ it "returns nil when not set" do
55
+ place = Twitter::Place.new(:id => "247f43d441defc03")
56
+ place.parent_id.should be_nil
57
+ end
58
+ end
59
+
60
+ describe "#place_type" do
61
+ it "returns a place type when set with place_type" do
62
+ place = Twitter::Place.new(:id => "247f43d441defc03", :place_type => 'city')
63
+ place.place_type.should eq 'city'
64
+ end
65
+ it "returns a place type when set with placeType[name]" do
66
+ place = Twitter::Place.new(:id => "247f43d441defc03", :placeType => {:name => 'Town'})
67
+ place.place_type.should eq 'Town'
68
+ end
69
+ it "returns nil when not set" do
70
+ place = Twitter::Place.new(:id => "247f43d441defc03")
71
+ place.place_type.should be_nil
72
+ end
73
+ end
74
+
75
+ end
@@ -0,0 +1,76 @@
1
+ require 'helper'
2
+
3
+ describe Twitter::RateLimit do
4
+
5
+ describe "#limit" do
6
+ it "returns an Integer when x-rate-limit-limit header is set" do
7
+ rate_limit = Twitter::RateLimit.new('x-rate-limit-limit' => "150")
8
+ rate_limit.limit.should be_an Integer
9
+ rate_limit.limit.should eq 150
10
+ end
11
+ it "returns nil when x-rate-limit-limit header is not set" do
12
+ rate_limit = Twitter::RateLimit.new
13
+ rate_limit.limit.should be_nil
14
+ end
15
+ end
16
+
17
+ describe "#remaining" do
18
+ it "returns an Integer when x-rate-limit-remaining header is set" do
19
+ rate_limit = Twitter::RateLimit.new('x-rate-limit-remaining' => "149")
20
+ rate_limit.remaining.should be_an Integer
21
+ rate_limit.remaining.should eq 149
22
+ end
23
+ it "returns nil when x-rate-limit-remaining header is not set" do
24
+ rate_limit = Twitter::RateLimit.new
25
+ rate_limit.remaining.should be_nil
26
+ end
27
+ end
28
+
29
+ describe "#reset_at" do
30
+ it "returns a Time when x-rate-limit-reset header is set" do
31
+ rate_limit = Twitter::RateLimit.new('x-rate-limit-reset' => "1339019097")
32
+ rate_limit.reset_at.should be_a Time
33
+ rate_limit.reset_at.should eq Time.at(1339019097)
34
+ end
35
+ it "returns nil when x-rate-limit-reset header is not set" do
36
+ rate_limit = Twitter::RateLimit.new
37
+ rate_limit.reset_at.should be_nil
38
+ end
39
+ end
40
+
41
+ describe "#reset_in" do
42
+ before do
43
+ Timecop.freeze(Time.utc(2012, 6, 6, 17, 22, 0))
44
+ end
45
+ after do
46
+ Timecop.return
47
+ end
48
+ it "returns an Integer when x-rate-limit-reset header is set" do
49
+ rate_limit = Twitter::RateLimit.new('x-rate-limit-reset' => "1339019097")
50
+ rate_limit.reset_in.should be_an Integer
51
+ rate_limit.reset_in.should eq 15777
52
+ end
53
+ it "returns nil when x-rate-limit-reset header is not set" do
54
+ rate_limit = Twitter::RateLimit.new
55
+ rate_limit.reset_in.should be_nil
56
+ end
57
+ end
58
+
59
+ describe "#update" do
60
+ before do
61
+ Timecop.freeze(Time.utc(2012, 6, 6, 17, 22, 0))
62
+ end
63
+ after do
64
+ Timecop.return
65
+ end
66
+ it "updates a rate limit" do
67
+ rate_limit = Twitter::RateLimit.new('x-rate-limit-reset' => "1339019097")
68
+ rate_limit.reset_in.should be_an Integer
69
+ rate_limit.reset_in.should eq 15777
70
+ rate_limit.update({'x-rate-limit-reset' => "1339019098"})
71
+ rate_limit.reset_in.should be_an Integer
72
+ rate_limit.reset_in.should eq 15778
73
+ end
74
+ end
75
+
76
+ end
@@ -0,0 +1,35 @@
1
+ require 'helper'
2
+
3
+ describe Twitter::Relationship do
4
+
5
+ describe "#source" do
6
+ it "returns a User when source is set" do
7
+ source = Twitter::Relationship.new(:relationship => {:source => {:id => 7505382}}).source
8
+ source.should be_a Twitter::SourceUser
9
+ end
10
+ it "returns nil when source is not set" do
11
+ source = Twitter::Relationship.new(:relationship => {}).source
12
+ source.should be_nil
13
+ end
14
+ end
15
+
16
+ describe "#target" do
17
+ it "returns a User when target is set" do
18
+ target = Twitter::Relationship.new(:relationship => {:target => {:id => 7505382}}).target
19
+ target.should be_a Twitter::TargetUser
20
+ end
21
+ it "returns nil when target is not set" do
22
+ target = Twitter::Relationship.new(:relationship => {}).target
23
+ target.should be_nil
24
+ end
25
+ end
26
+
27
+ describe "#update" do
28
+ it "updates a relationship" do
29
+ relationship = Twitter::Relationship.new(:relationship => {:target => {:id => 7505382}})
30
+ relationship.update(:relationship => {:target => {:id => 14100886}})
31
+ relationship.target.id.should eq 14100886
32
+ end
33
+ end
34
+
35
+ end
@@ -0,0 +1,34 @@
1
+ require 'helper'
2
+
3
+ describe Twitter::SavedSearch do
4
+
5
+ describe "#==" do
6
+ it "returns true when objects IDs are the same" do
7
+ saved_search = Twitter::SavedSearch.new(:id => 1, :name => "foo")
8
+ other = Twitter::SavedSearch.new(:id => 1, :name => "bar")
9
+ (saved_search == other).should be_true
10
+ end
11
+ it "returns false when objects IDs are different" do
12
+ saved_search = Twitter::SavedSearch.new(:id => 1)
13
+ other = Twitter::SavedSearch.new(:id => 2)
14
+ (saved_search == other).should be_false
15
+ end
16
+ it "returns false when classes are different" do
17
+ saved_search = Twitter::SavedSearch.new(:id => 1)
18
+ other = Twitter::Identity.new(:id => 1)
19
+ (saved_search == other).should be_false
20
+ end
21
+ end
22
+
23
+ describe "#created_at" do
24
+ it "returns a Time when created_at is set" do
25
+ saved_search = Twitter::SavedSearch.new(:id => 16129012, :created_at => "Mon Jul 16 12:59:01 +0000 2007")
26
+ saved_search.created_at.should be_a Time
27
+ end
28
+ it "returns nil when created_at is not set" do
29
+ saved_search = Twitter::SavedSearch.new(:id => 16129012)
30
+ saved_search.created_at.should be_nil
31
+ end
32
+ end
33
+
34
+ end
@@ -0,0 +1,89 @@
1
+ require 'helper'
2
+
3
+ describe Twitter::SearchResults do
4
+
5
+ describe "#statuses" do
6
+ it "returns an array of Tweets" do
7
+ statuses = Twitter::SearchResults.new(:statuses => [{:id => 25938088801, :text => 'tweet!'}]).statuses
8
+ statuses.should be_an Array
9
+ statuses.first.should be_a Twitter::Tweet
10
+ end
11
+ it "is empty when not set" do
12
+ statuses = Twitter::SearchResults.new.statuses
13
+ statuses.should be_empty
14
+ end
15
+ end
16
+
17
+ describe "#completed_in" do
18
+ it "returns a number of seconds" do
19
+ completed_in = Twitter::SearchResults.new(:search_metadata => {:completed_in => 0.029}).completed_in
20
+ completed_in.should be_a Float
21
+ completed_in.should eq 0.029
22
+ end
23
+ it "is nil when not set" do
24
+ completed_in = Twitter::SearchResults.new.completed_in
25
+ completed_in.should be_nil
26
+ end
27
+ end
28
+
29
+ describe "#max_id" do
30
+ it "returns an ID" do
31
+ max_id = Twitter::SearchResults.new(:search_metadata => {:max_id => 250126199840518145}).max_id
32
+ max_id.should be_an Integer
33
+ max_id.should eq 250126199840518145
34
+ end
35
+ it "is nil when not set" do
36
+ max_id = Twitter::SearchResults.new.max_id
37
+ max_id.should be_nil
38
+ end
39
+ end
40
+
41
+ describe "#page" do
42
+ it "returns page number" do
43
+ page = Twitter::SearchResults.new(:search_metadata => {:page => 1}).page
44
+ page.should be_an Integer
45
+ page.should eq 1
46
+ end
47
+ it "is nil when not set" do
48
+ page = Twitter::SearchResults.new.page
49
+ page.should be_nil
50
+ end
51
+ end
52
+
53
+ describe "#query" do
54
+ it "returns the query" do
55
+ query = Twitter::SearchResults.new(:search_metadata => {:query => "%23freebandnames"}).query
56
+ query.should be_a String
57
+ query.should eq "%23freebandnames"
58
+ end
59
+ it "is nil when not set" do
60
+ query = Twitter::SearchResults.new.query
61
+ query.should be_nil
62
+ end
63
+ end
64
+
65
+ describe "#results_per_page" do
66
+ it "returns the number of results per page" do
67
+ results_per_page = Twitter::SearchResults.new(:search_metadata => {:results_per_page => 4}).results_per_page
68
+ results_per_page.should be_an Integer
69
+ results_per_page.should eq 4
70
+ end
71
+ it "is nil when not set" do
72
+ results_per_page = Twitter::SearchResults.new.results_per_page
73
+ results_per_page.should be_nil
74
+ end
75
+ end
76
+
77
+ describe "#since_id" do
78
+ it "returns an ID" do
79
+ since_id = Twitter::SearchResults.new(:search_metadata => {:since_id => 250126199840518145}).since_id
80
+ since_id.should be_an Integer
81
+ since_id.should eq 250126199840518145
82
+ end
83
+ it "is nil when not set" do
84
+ since_id = Twitter::SearchResults.new.since_id
85
+ since_id.should be_nil
86
+ end
87
+ end
88
+
89
+ end
@@ -0,0 +1,16 @@
1
+ require 'helper'
2
+
3
+ describe Twitter::Settings do
4
+
5
+ describe "#trend_location" do
6
+ it "returns 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 "returns 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,38 @@
1
+ require 'helper'
2
+
3
+ describe Twitter::Size do
4
+
5
+ describe "#==" do
6
+ it "returns false for empty objects" do
7
+ size = Twitter::Size.new
8
+ other = Twitter::Size.new
9
+ (size == other).should be_false
10
+ end
11
+ it "returns true when objects height and width are the same" do
12
+ size = Twitter::Size.new(:h => 1, :w => 1, :resize => true)
13
+ other = Twitter::Size.new(:h => 1, :w => 1, :resize => false)
14
+ (size == other).should be_true
15
+ end
16
+ it "returns false when objects height or width are different" do
17
+ size = Twitter::Size.new(:h => 1, :w => 1)
18
+ other = Twitter::Size.new(:h => 1, :w => 2)
19
+ (size == other).should be_false
20
+ end
21
+ it "returns false when classes are different" do
22
+ size = Twitter::Size.new(:h => 1, :w => 1)
23
+ other = Twitter::Base.new(:h => 1, :w => 1)
24
+ (size == other).should be_false
25
+ end
26
+ it "returns true when objects non-height and width attributes are the same" do
27
+ size = Twitter::Size.new(:resize => true)
28
+ other = Twitter::Size.new(:resize => true)
29
+ (size == other).should be_true
30
+ end
31
+ it "returns false when objects non-height and width attributes are different" do
32
+ size = Twitter::Size.new(:resize => true)
33
+ other = Twitter::Size.new(:resize => false)
34
+ (size == other).should be_false
35
+ end
36
+ end
37
+
38
+ end
@@ -0,0 +1,23 @@
1
+ require 'helper'
2
+
3
+ describe Twitter::SourceUser do
4
+
5
+ describe "#==" do
6
+ it "returns true when objects IDs are the same" do
7
+ saved_search = Twitter::SourceUser.new(:id => 1, :name => "foo")
8
+ other = Twitter::SourceUser.new(:id => 1, :name => "bar")
9
+ (saved_search == other).should be_true
10
+ end
11
+ it "returns false when objects IDs are different" do
12
+ saved_search = Twitter::SourceUser.new(:id => 1)
13
+ other = Twitter::SourceUser.new(:id => 2)
14
+ (saved_search == other).should be_false
15
+ end
16
+ it "returns false when classes are different" do
17
+ saved_search = Twitter::SourceUser.new(:id => 1)
18
+ other = Twitter::Identity.new(:id => 1)
19
+ (saved_search == other).should be_false
20
+ end
21
+ end
22
+
23
+ end
@@ -0,0 +1,50 @@
1
+ require 'helper'
2
+
3
+ describe Twitter::Suggestion do
4
+
5
+ describe "#==" do
6
+ it "returns false for empty objects" do
7
+ suggestion = Twitter::Suggestion.new
8
+ other = Twitter::Suggestion.new
9
+ (suggestion == other).should be_false
10
+ end
11
+ it "returns true when objects slugs are the same" do
12
+ suggestion = Twitter::Suggestion.new(:slug => 1, :name => "foo")
13
+ other = Twitter::Suggestion.new(:slug => 1, :name => "bar")
14
+ (suggestion == other).should be_true
15
+ end
16
+ it "returns false when objects slugs are different" do
17
+ suggestion = Twitter::Suggestion.new(:slug => 1)
18
+ other = Twitter::Suggestion.new(:slug => 2)
19
+ (suggestion == other).should be_false
20
+ end
21
+ it "returns false when classes are different" do
22
+ suggestion = Twitter::Suggestion.new(:slug => 1)
23
+ other = Twitter::Base.new(:slug => 1)
24
+ (suggestion == other).should be_false
25
+ end
26
+ it "returns true when objects non-slug attributes are the same" do
27
+ suggestion = Twitter::Suggestion.new(:name => "foo")
28
+ other = Twitter::Suggestion.new(:name => "foo")
29
+ (suggestion == other).should be_true
30
+ end
31
+ it "returns false when objects non-slug attributes are different" do
32
+ suggestion = Twitter::Suggestion.new(:name => "foo")
33
+ other = Twitter::Suggestion.new(:name => "bar")
34
+ (suggestion == other).should be_false
35
+ end
36
+ end
37
+
38
+ describe "#users" do
39
+ it "returns a User when user is set" do
40
+ users = Twitter::Suggestion.new(:users => [{:id => 7505382}]).users
41
+ users.should be_an Array
42
+ users.first.should be_a Twitter::User
43
+ end
44
+ it "is empty when not set" do
45
+ users = Twitter::Suggestion.new.users
46
+ users.should be_empty
47
+ end
48
+ end
49
+
50
+ end