twitter 4.8.1 → 5.0.0.rc.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (197) hide show
  1. data.tar.gz.sig +0 -0
  2. data/CHANGELOG.md +30 -0
  3. data/LICENSE.md +1 -1
  4. data/README.md +386 -266
  5. data/lib/twitter.rb +4 -39
  6. data/lib/twitter/arguments.rb +11 -0
  7. data/lib/twitter/base.rb +89 -68
  8. data/lib/twitter/client.rb +69 -110
  9. data/lib/twitter/configuration.rb +7 -3
  10. data/lib/twitter/creatable.rb +2 -4
  11. data/lib/twitter/cursor.rb +50 -42
  12. data/lib/twitter/direct_message.rb +2 -11
  13. data/lib/twitter/entity/uri.rb +13 -0
  14. data/lib/twitter/enumerable.rb +15 -0
  15. data/lib/twitter/error.rb +55 -7
  16. data/lib/twitter/error/already_favorited.rb +1 -1
  17. data/lib/twitter/error/already_posted.rb +10 -0
  18. data/lib/twitter/error/already_retweeted.rb +1 -1
  19. data/lib/twitter/error/bad_gateway.rb +2 -3
  20. data/lib/twitter/error/bad_request.rb +2 -2
  21. data/lib/twitter/error/forbidden.rb +2 -2
  22. data/lib/twitter/error/gateway_timeout.rb +2 -3
  23. data/lib/twitter/error/internal_server_error.rb +2 -3
  24. data/lib/twitter/error/not_acceptable.rb +2 -2
  25. data/lib/twitter/error/not_found.rb +2 -2
  26. data/lib/twitter/error/service_unavailable.rb +2 -3
  27. data/lib/twitter/error/too_many_requests.rb +2 -2
  28. data/lib/twitter/error/unauthorized.rb +2 -2
  29. data/lib/twitter/error/unprocessable_entity.rb +2 -2
  30. data/lib/twitter/factory.rb +2 -8
  31. data/lib/twitter/geo_factory.rb +2 -2
  32. data/lib/twitter/geo_results.rb +36 -0
  33. data/lib/twitter/identity.rb +0 -22
  34. data/lib/twitter/list.rb +18 -4
  35. data/lib/twitter/media/photo.rb +3 -3
  36. data/lib/twitter/media_factory.rb +2 -2
  37. data/lib/twitter/null_object.rb +24 -0
  38. data/lib/twitter/oembed.rb +3 -2
  39. data/lib/twitter/place.rb +15 -9
  40. data/lib/twitter/profile_banner.rb +5 -3
  41. data/lib/twitter/rate_limit.rb +1 -17
  42. data/lib/twitter/relationship.rb +2 -10
  43. data/lib/twitter/rest/api/direct_messages.rb +135 -0
  44. data/lib/twitter/rest/api/favorites.rb +120 -0
  45. data/lib/twitter/rest/api/friends_and_followers.rb +290 -0
  46. data/lib/twitter/rest/api/help.rb +58 -0
  47. data/lib/twitter/rest/api/lists.rb +491 -0
  48. data/lib/twitter/rest/api/oauth.rb +45 -0
  49. data/lib/twitter/rest/api/places_and_geo.rb +104 -0
  50. data/lib/twitter/rest/api/saved_searches.rb +91 -0
  51. data/lib/twitter/rest/api/search.rb +37 -0
  52. data/lib/twitter/rest/api/spam_reporting.rb +29 -0
  53. data/lib/twitter/rest/api/suggested_users.rb +51 -0
  54. data/lib/twitter/rest/api/timelines.rb +202 -0
  55. data/lib/twitter/rest/api/trends.rb +58 -0
  56. data/lib/twitter/rest/api/tweets.rb +293 -0
  57. data/lib/twitter/rest/api/undocumented.rb +52 -0
  58. data/lib/twitter/rest/api/users.rb +383 -0
  59. data/lib/twitter/rest/api/utils.rb +219 -0
  60. data/lib/twitter/rest/client.rb +193 -0
  61. data/lib/twitter/rest/request/multipart_with_file.rb +36 -0
  62. data/lib/twitter/rest/response/parse_json.rb +27 -0
  63. data/lib/twitter/{response → rest/response}/raise_error.rb +8 -11
  64. data/lib/twitter/search_results.rb +33 -21
  65. data/lib/twitter/settings.rb +1 -6
  66. data/lib/twitter/size.rb +1 -1
  67. data/lib/twitter/streaming/client.rb +77 -0
  68. data/lib/twitter/streaming/connection.rb +22 -0
  69. data/lib/twitter/streaming/response.rb +30 -0
  70. data/lib/twitter/suggestion.rb +4 -2
  71. data/lib/twitter/token.rb +8 -0
  72. data/lib/twitter/trend.rb +2 -1
  73. data/lib/twitter/trend_results.rb +59 -0
  74. data/lib/twitter/tweet.rb +41 -85
  75. data/lib/twitter/user.rb +51 -41
  76. data/lib/twitter/version.rb +4 -4
  77. data/spec/fixtures/already_posted.json +1 -0
  78. data/spec/fixtures/ids_list.json +1 -1
  79. data/spec/fixtures/ids_list2.json +1 -1
  80. data/spec/fixtures/search.json +1 -1
  81. data/spec/fixtures/search_malformed.json +1 -1
  82. data/spec/fixtures/track_streaming.json +3 -0
  83. data/spec/helper.rb +8 -13
  84. data/spec/twitter/base_spec.rb +25 -99
  85. data/spec/twitter/configuration_spec.rb +1 -1
  86. data/spec/twitter/cursor_spec.rb +13 -31
  87. data/spec/twitter/direct_message_spec.rb +41 -8
  88. data/spec/twitter/entity/uri_spec.rb +74 -0
  89. data/spec/twitter/error_spec.rb +59 -11
  90. data/spec/twitter/geo/point_spec.rb +1 -1
  91. data/spec/twitter/geo_factory_spec.rb +3 -3
  92. data/spec/twitter/geo_results_spec.rb +35 -0
  93. data/spec/twitter/identifiable_spec.rb +0 -21
  94. data/spec/twitter/list_spec.rb +51 -8
  95. data/spec/twitter/media/photo_spec.rb +118 -3
  96. data/spec/twitter/media_factory_spec.rb +2 -2
  97. data/spec/twitter/null_object_spec.rb +26 -0
  98. data/spec/twitter/oembed_spec.rb +69 -45
  99. data/spec/twitter/place_spec.rb +68 -12
  100. data/spec/twitter/profile_banner_spec.rb +1 -1
  101. data/spec/twitter/rate_limit_spec.rb +12 -12
  102. data/spec/twitter/relationship_spec.rb +31 -9
  103. data/spec/twitter/{api → rest/api}/direct_messages_spec.rb +22 -9
  104. data/spec/twitter/{api → rest/api}/favorites_spec.rb +80 -7
  105. data/spec/twitter/{api → rest/api}/friends_and_followers_spec.rb +104 -65
  106. data/spec/twitter/{api → rest/api}/geo_spec.rb +10 -10
  107. data/spec/twitter/{api → rest/api}/help_spec.rb +6 -6
  108. data/spec/twitter/{api → rest/api}/lists_spec.rb +77 -56
  109. data/spec/twitter/{api → rest/api}/oauth_spec.rb +6 -6
  110. data/spec/twitter/{api → rest/api}/saved_searches_spec.rb +7 -7
  111. data/spec/twitter/{api → rest/api}/search_spec.rb +8 -9
  112. data/spec/twitter/{api → rest/api}/spam_reporting_spec.rb +3 -3
  113. data/spec/twitter/{api → rest/api}/suggested_users_spec.rb +5 -5
  114. data/spec/twitter/{api → rest/api}/timelines_spec.rb +9 -9
  115. data/spec/twitter/{api → rest/api}/trends_spec.rb +6 -6
  116. data/spec/twitter/rest/api/tweets_spec.rb +503 -0
  117. data/spec/twitter/{api → rest/api}/undocumented_spec.rb +19 -45
  118. data/spec/twitter/{api → rest/api}/users_spec.rb +60 -35
  119. data/spec/twitter/rest/client_spec.rb +193 -0
  120. data/spec/twitter/saved_search_spec.rb +11 -0
  121. data/spec/twitter/search_results_spec.rb +29 -42
  122. data/spec/twitter/settings_spec.rb +17 -6
  123. data/spec/twitter/streaming/client_spec.rb +75 -0
  124. data/spec/twitter/token_spec.rb +16 -0
  125. data/spec/twitter/trend_results_spec.rb +89 -0
  126. data/spec/twitter/trend_spec.rb +23 -0
  127. data/spec/twitter/tweet_spec.rb +122 -115
  128. data/spec/twitter/user_spec.rb +136 -77
  129. data/spec/twitter_spec.rb +0 -119
  130. data/twitter.gemspec +8 -5
  131. metadata +148 -141
  132. metadata.gz.sig +0 -0
  133. data/lib/twitter/action/favorite.rb +0 -19
  134. data/lib/twitter/action/follow.rb +0 -30
  135. data/lib/twitter/action/list_member_added.rb +0 -39
  136. data/lib/twitter/action/mention.rb +0 -46
  137. data/lib/twitter/action/reply.rb +0 -27
  138. data/lib/twitter/action/retweet.rb +0 -27
  139. data/lib/twitter/action/tweet.rb +0 -20
  140. data/lib/twitter/action_factory.rb +0 -22
  141. data/lib/twitter/api/arguments.rb +0 -13
  142. data/lib/twitter/api/direct_messages.rb +0 -148
  143. data/lib/twitter/api/favorites.rb +0 -126
  144. data/lib/twitter/api/friends_and_followers.rb +0 -334
  145. data/lib/twitter/api/help.rb +0 -64
  146. data/lib/twitter/api/lists.rb +0 -618
  147. data/lib/twitter/api/oauth.rb +0 -44
  148. data/lib/twitter/api/places_and_geo.rb +0 -121
  149. data/lib/twitter/api/saved_searches.rb +0 -99
  150. data/lib/twitter/api/search.rb +0 -37
  151. data/lib/twitter/api/spam_reporting.rb +0 -30
  152. data/lib/twitter/api/suggested_users.rb +0 -55
  153. data/lib/twitter/api/timelines.rb +0 -214
  154. data/lib/twitter/api/trends.rb +0 -63
  155. data/lib/twitter/api/tweets.rb +0 -304
  156. data/lib/twitter/api/undocumented.rb +0 -97
  157. data/lib/twitter/api/users.rb +0 -439
  158. data/lib/twitter/api/utils.rb +0 -187
  159. data/lib/twitter/configurable.rb +0 -96
  160. data/lib/twitter/default.rb +0 -102
  161. data/lib/twitter/entity/url.rb +0 -9
  162. data/lib/twitter/error/client_error.rb +0 -35
  163. data/lib/twitter/error/decode_error.rb +0 -9
  164. data/lib/twitter/error/identity_map_key_error.rb +0 -9
  165. data/lib/twitter/error/server_error.rb +0 -28
  166. data/lib/twitter/exceptable.rb +0 -36
  167. data/lib/twitter/identity_map.rb +0 -22
  168. data/lib/twitter/request/multipart_with_file.rb +0 -34
  169. data/lib/twitter/response/parse_json.rb +0 -25
  170. data/spec/fixtures/about_me.json +0 -1
  171. data/spec/fixtures/activity_summary.json +0 -1
  172. data/spec/fixtures/bad_gateway.json +0 -1
  173. data/spec/fixtures/bad_request.json +0 -1
  174. data/spec/fixtures/by_friends.json +0 -1
  175. data/spec/fixtures/end_session.json +0 -1
  176. data/spec/fixtures/forbidden.json +0 -1
  177. data/spec/fixtures/internal_server_error.json +0 -1
  178. data/spec/fixtures/not_acceptable.json +0 -1
  179. data/spec/fixtures/phoenix_search.phoenix +0 -1
  180. data/spec/fixtures/resolve.json +0 -1
  181. data/spec/fixtures/service_unavailable.json +0 -1
  182. data/spec/fixtures/totals.json +0 -1
  183. data/spec/fixtures/trends.json +0 -1
  184. data/spec/fixtures/unauthorized.json +0 -1
  185. data/spec/fixtures/video_facets.json +0 -1
  186. data/spec/twitter/action/favorite_spec.rb +0 -29
  187. data/spec/twitter/action/follow_spec.rb +0 -29
  188. data/spec/twitter/action/list_member_added_spec.rb +0 -41
  189. data/spec/twitter/action/mention_spec.rb +0 -52
  190. data/spec/twitter/action/reply_spec.rb +0 -41
  191. data/spec/twitter/action/retweet_spec.rb +0 -41
  192. data/spec/twitter/action_factory_spec.rb +0 -35
  193. data/spec/twitter/action_spec.rb +0 -16
  194. data/spec/twitter/api/tweets_spec.rb +0 -285
  195. data/spec/twitter/client_spec.rb +0 -223
  196. data/spec/twitter/error/client_error_spec.rb +0 -23
  197. data/spec/twitter/error/server_error_spec.rb +0 -20
@@ -31,4 +31,15 @@ describe Twitter::SavedSearch do
31
31
  end
32
32
  end
33
33
 
34
+ describe "#created?" do
35
+ it "returns true when created_at is set" do
36
+ saved_search = Twitter::SavedSearch.new(:id => 16129012, :created_at => "Mon Jul 16 12:59:01 +0000 2007")
37
+ expect(saved_search.created?).to be_true
38
+ end
39
+ it "returns false when created_at is not set" do
40
+ saved_search = Twitter::SavedSearch.new(:id => 16129012)
41
+ expect(saved_search.created?).to be_false
42
+ end
43
+ end
44
+
34
45
  end
@@ -2,15 +2,21 @@ require 'helper'
2
2
 
3
3
  describe Twitter::SearchResults do
4
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
- expect(statuses).to be_an Array
9
- expect(statuses.first).to be_a Twitter::Tweet
10
- end
11
- it "is empty when not set" do
12
- statuses = Twitter::SearchResults.new.statuses
13
- expect(statuses).to be_empty
5
+ describe "#each" do
6
+ before do
7
+ @search_results = Twitter::SearchResults.new(:statuses => [{:id => 1}, {:id => 2}, {:id => 3}, {:id => 4}, {:id => 5}, {:id => 6}])
8
+ end
9
+ it "iterates" do
10
+ count = 0
11
+ @search_results.each{count += 1}
12
+ expect(count).to eq(6)
13
+ end
14
+ context "with start" do
15
+ it "iterates" do
16
+ count = 0
17
+ @search_results.each(5){count += 1}
18
+ expect(count).to eq(1)
19
+ end
14
20
  end
15
21
  end
16
22
 
@@ -18,7 +24,7 @@ describe Twitter::SearchResults do
18
24
  it "returns a number of seconds" do
19
25
  completed_in = Twitter::SearchResults.new(:search_metadata => {:completed_in => 0.029}).completed_in
20
26
  expect(completed_in).to be_a Float
21
- expect(completed_in).to eq 0.029
27
+ expect(completed_in).to eq(0.029)
22
28
  end
23
29
  it "is nil when not set" do
24
30
  completed_in = Twitter::SearchResults.new.completed_in
@@ -30,7 +36,7 @@ describe Twitter::SearchResults do
30
36
  it "returns an ID" do
31
37
  max_id = Twitter::SearchResults.new(:search_metadata => {:max_id => 250126199840518145}).max_id
32
38
  expect(max_id).to be_an Integer
33
- expect(max_id).to eq 250126199840518145
39
+ expect(max_id).to eq(250126199840518145)
34
40
  end
35
41
  it "is nil when not set" do
36
42
  max_id = Twitter::SearchResults.new.max_id
@@ -42,7 +48,7 @@ describe Twitter::SearchResults do
42
48
  it "returns page number" do
43
49
  page = Twitter::SearchResults.new(:search_metadata => {:page => 1}).page
44
50
  expect(page).to be_an Integer
45
- expect(page).to eq 1
51
+ expect(page).to eq(1)
46
52
  end
47
53
  it "is nil when not set" do
48
54
  page = Twitter::SearchResults.new.page
@@ -54,7 +60,7 @@ describe Twitter::SearchResults do
54
60
  it "returns the query" do
55
61
  query = Twitter::SearchResults.new(:search_metadata => {:query => "%23freebandnames"}).query
56
62
  expect(query).to be_a String
57
- expect(query).to eq "%23freebandnames"
63
+ expect(query).to eq("%23freebandnames")
58
64
  end
59
65
  it "is nil when not set" do
60
66
  query = Twitter::SearchResults.new.query
@@ -64,9 +70,9 @@ describe Twitter::SearchResults do
64
70
 
65
71
  describe "#results_per_page" do
66
72
  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
73
+ results_per_page = Twitter::SearchResults.new(:search_metadata => {:count => 4}).results_per_page
68
74
  expect(results_per_page).to be_an Integer
69
- expect(results_per_page).to eq 4
75
+ expect(results_per_page).to eq(4)
70
76
  end
71
77
  it "is nil when not set" do
72
78
  results_per_page = Twitter::SearchResults.new.results_per_page
@@ -74,22 +80,11 @@ describe Twitter::SearchResults do
74
80
  end
75
81
  end
76
82
 
77
- describe "#search_metadata?" do
78
- it "returns true when search_metadata is set" do
79
- search_metadata = Twitter::SearchResults.new(:search_metadata => {}).search_metadata?
80
- expect(search_metadata).to be_true
81
- end
82
- it "returns false when search_metadata is not set" do
83
- search_metadata = Twitter::SearchResults.new.search_metadata?
84
- expect(search_metadata).to be_false
85
- end
86
- end
87
-
88
83
  describe "#since_id" do
89
84
  it "returns an ID" do
90
85
  since_id = Twitter::SearchResults.new(:search_metadata => {:since_id => 250126199840518145}).since_id
91
86
  expect(since_id).to be_an Integer
92
- expect(since_id).to eq 250126199840518145
87
+ expect(since_id).to eq(250126199840518145)
93
88
  end
94
89
  it "is nil when not set" do
95
90
  since_id = Twitter::SearchResults.new.since_id
@@ -113,26 +108,18 @@ describe Twitter::SearchResults do
113
108
  end
114
109
 
115
110
  describe "#next_results" do
116
- let(:next_results) {Twitter::SearchResults.new(:search_metadata => {:next_results => "?max_id=249279667666817023&q=%23freebandnames&count=4&include_entities=1&result_type=mixed"}).next_results}
117
-
118
111
  it "returns a hash of query parameters" do
119
- expect(next_results).to be_a Hash
120
- end
121
-
122
- it "returns a max_id" do
123
- expect(next_results[:max_id]).to eq "249279667666817023"
112
+ search_results = Twitter::SearchResults.new(:search_metadata => {:next_results => "?max_id=249279667666817023&q=%23freebandnames&count=4&include_entities=1&result_type=mixed"})
113
+ expect(search_results.next_results).to be_a Hash
114
+ expect(search_results.next_results[:max_id]).to eq("249279667666817023")
124
115
  end
125
116
  end
126
117
 
127
- describe "#refresh_url" do
128
- let(:refresh_url) {Twitter::SearchResults.new(:search_metadata => {:refresh_url => "?since_id=249279667666817023&q=%23freebandnames&count=4&include_entities=1&result_type=recent"}).refresh_url}
129
-
118
+ describe "#refresh_results" do
130
119
  it "returns a hash of query parameters" do
131
- expect(refresh_url).to be_a Hash
132
- end
133
-
134
- it "returns a since_id" do
135
- expect(refresh_url[:since_id]).to eq "249279667666817023"
120
+ search_results = Twitter::SearchResults.new(:search_metadata => {:refresh_url => "?since_id=249279667666817023&q=%23freebandnames&count=4&include_entities=1&result_type=recent"})
121
+ expect(search_results.refresh_results).to be_a Hash
122
+ expect(search_results.refresh_results[:since_id]).to eq("249279667666817023")
136
123
  end
137
124
  end
138
125
 
@@ -3,13 +3,24 @@ require 'helper'
3
3
  describe Twitter::Settings do
4
4
 
5
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
- expect(place.trend_location).to be_a Twitter::Place
6
+ it "returns a Twitter::Place when trend_location is set" do
7
+ settings = 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
+ expect(settings.trend_location).to be_a Twitter::Place
9
9
  end
10
- it "returns nil when not set" do
11
- place = Twitter::Settings.new
12
- expect(place.trend_location).to be_nil
10
+ it "returns nil when trend_location is not set" do
11
+ settings = Twitter::Settings.new
12
+ expect(settings.trend_location).to be_nil
13
+ end
14
+ end
15
+
16
+ describe "#trend_location?" do
17
+ it "returns true when trend_location is set" do
18
+ settings = 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"})
19
+ expect(settings.trend_location?).to be_true
20
+ end
21
+ it "returns false when trend_location is not set" do
22
+ settings = Twitter::Settings.new
23
+ expect(settings.trend_location?).to be_false
13
24
  end
14
25
  end
15
26
 
@@ -0,0 +1,75 @@
1
+ require 'helper'
2
+
3
+ describe Twitter::Streaming::Client do
4
+ before do
5
+ @client = Twitter::Streaming::Client.new
6
+ end
7
+
8
+ class FakeConnection
9
+ def initialize(body)
10
+ @body = body
11
+ end
12
+
13
+ def stream(request, response)
14
+ @body.each_line do |line|
15
+ response.on_body(line)
16
+ end
17
+ end
18
+ end
19
+
20
+ it "supports tracking keywords" do
21
+ @client.connection = FakeConnection.new(fixture("track_streaming.json"))
22
+ tweets = []
23
+ @client.filter(:track => "india") do |tweet|
24
+ tweets << tweet
25
+ end
26
+ expect(tweets).to have(2).entries
27
+ expect(tweets.first).to be_a Twitter::Tweet
28
+ expect(tweets.first.text).to eq "The problem with your code is that it's doing exactly what you told it to do."
29
+ end
30
+
31
+ it "supports firehose" do
32
+ @client.connection = FakeConnection.new(fixture("track_streaming.json"))
33
+ tweets = []
34
+ @client.firehose do |tweet|
35
+ tweets << tweet
36
+ end
37
+ expect(tweets).to have(2).entries
38
+ expect(tweets.first).to be_a Twitter::Tweet
39
+ expect(tweets.first.text).to eq "The problem with your code is that it's doing exactly what you told it to do."
40
+ end
41
+
42
+ it "supports sample" do
43
+ @client.connection = FakeConnection.new(fixture("track_streaming.json"))
44
+ tweets = []
45
+ @client.sample do |tweet|
46
+ tweets << tweet
47
+ end
48
+ expect(tweets).to have(2).entries
49
+ expect(tweets.first).to be_a Twitter::Tweet
50
+ expect(tweets.first.text).to eq "The problem with your code is that it's doing exactly what you told it to do."
51
+ end
52
+
53
+ it "supports site streams" do
54
+ @client.connection = FakeConnection.new(fixture("track_streaming.json"))
55
+ tweets = []
56
+ @client.site(7505382) do |tweet|
57
+ tweets << tweet
58
+ end
59
+ expect(tweets).to have(2).entries
60
+ expect(tweets.first).to be_a Twitter::Tweet
61
+ expect(tweets.first.text).to eq "The problem with your code is that it's doing exactly what you told it to do."
62
+ end
63
+
64
+ it "supports user streams" do
65
+ @client.connection = FakeConnection.new(fixture("track_streaming.json"))
66
+ tweets = []
67
+ @client.user do |tweet|
68
+ tweets << tweet
69
+ end
70
+ expect(tweets).to have(2).entries
71
+ expect(tweets.first).to be_a Twitter::Tweet
72
+ expect(tweets.first.text).to eq "The problem with your code is that it's doing exactly what you told it to do."
73
+ end
74
+
75
+ end
@@ -0,0 +1,16 @@
1
+ require 'helper'
2
+
3
+ describe Twitter::Token do
4
+
5
+ describe "#bearer?" do
6
+ it "returns true when token is a bearer token" do
7
+ token = Twitter::Token.new(:token_type => "bearer")
8
+ expect(token.bearer?).to be_true
9
+ end
10
+ it "returns false when token type is nil" do
11
+ token = Twitter::Token.new
12
+ expect(token.bearer?).to be_false
13
+ end
14
+ end
15
+
16
+ end
@@ -0,0 +1,89 @@
1
+ require 'helper'
2
+
3
+ describe Twitter::TrendResults do
4
+
5
+ describe "#as_of" do
6
+ it "returns a Time when as_of is set" do
7
+ trend_results = Twitter::TrendResults.new(:id => 1, :as_of => "2012-08-24T23:25:43Z")
8
+ expect(trend_results.as_of).to be_a Time
9
+ end
10
+ it "returns nil when as_of is not set" do
11
+ trend_results = Twitter::TrendResults.new(:id => 1)
12
+ expect(trend_results.as_of).to be_nil
13
+ end
14
+ end
15
+
16
+ describe "#as_of?" do
17
+ it "returns true when as_of is set" do
18
+ trend_results = Twitter::TrendResults.new(:id => 1, :as_of => "2012-08-24T23:24:14Z")
19
+ expect(trend_results.as_of?).to be_true
20
+ end
21
+ it "returns false when as_of is not set" do
22
+ trend_results = Twitter::TrendResults.new(:id => 1)
23
+ expect(trend_results.as_of?).to be_false
24
+ end
25
+ end
26
+
27
+ describe "#created_at" do
28
+ it "returns a Time when created_at is set" do
29
+ trend_results = Twitter::TrendResults.new(:id => 1, :created_at => "2012-08-24T23:24:14Z")
30
+ expect(trend_results.created_at).to be_a Time
31
+ end
32
+ it "returns nil when created_at is not set" do
33
+ trend_results = Twitter::TrendResults.new(:id => 1)
34
+ expect(trend_results.created_at).to be_nil
35
+ end
36
+ end
37
+
38
+ describe "#created?" do
39
+ it "returns true when created_at is set" do
40
+ trend_results = Twitter::TrendResults.new(:id => 1, :created_at => "2012-08-24T23:24:14Z")
41
+ expect(trend_results.created?).to be_true
42
+ end
43
+ it "returns false when created_at is not set" do
44
+ trend_results = Twitter::TrendResults.new(:id => 1)
45
+ expect(trend_results.created?).to be_false
46
+ end
47
+ end
48
+
49
+ describe "#each" do
50
+ before do
51
+ @trend_results = Twitter::TrendResults.new(:trends => [{:id => 1}, {:id => 2}, {:id => 3}, {:id => 4}, {:id => 5}, {:id => 6}])
52
+ end
53
+ it "iterates" do
54
+ count = 0
55
+ @trend_results.each{count += 1}
56
+ expect(count).to eq(6)
57
+ end
58
+ context "with start" do
59
+ it "iterates" do
60
+ count = 0
61
+ @trend_results.each(5){count += 1}
62
+ expect(count).to eq(1)
63
+ end
64
+ end
65
+ end
66
+
67
+ describe "#location" do
68
+ it "returns a Twitter::Place when location is set" do
69
+ trend_results = Twitter::TrendResults.new(:id => 1, :locations => [{:name => "Worldwide", :woeid => 1}])
70
+ expect(trend_results.location).to be_a Twitter::Place
71
+ end
72
+ it "returns nil when location is not set" do
73
+ trend_results = Twitter::TrendResults.new(:id => 1)
74
+ expect(trend_results.location).to be_nil
75
+ end
76
+ end
77
+
78
+ describe "#location?" do
79
+ it "returns true when location is set" do
80
+ trend_results = Twitter::TrendResults.new(:id => 1, :locations => [{:name => "Worldwide", :woeid => 1}])
81
+ expect(trend_results.location?).to be_true
82
+ end
83
+ it "returns false when location is not set" do
84
+ trend_results = Twitter::TrendResults.new(:id => 1)
85
+ expect(trend_results.location?).to be_false
86
+ end
87
+ end
88
+
89
+ end
@@ -35,4 +35,27 @@ describe Twitter::Trend do
35
35
  end
36
36
  end
37
37
 
38
+ describe "#uri" do
39
+ it "returns a URI when the url is set" do
40
+ trend = Twitter::Trend.new(:url => "http://twitter.com/search/?q=%23sevenwordsaftersex")
41
+ expect(trend.uri).to be_a URI
42
+ expect(trend.uri.to_s).to eq("http://twitter.com/search/?q=%23sevenwordsaftersex")
43
+ end
44
+ it "returns nil when the url is not set" do
45
+ trend = Twitter::Trend.new
46
+ expect(trend.uri).to be_nil
47
+ end
48
+ end
49
+
50
+ describe "#uri?" do
51
+ it "returns true when the url is set" do
52
+ trend = Twitter::Trend.new(:url => "https://api.twitter.com/1.1/geo/id/247f43d441defc03.json")
53
+ expect(trend.uri?).to be_true
54
+ end
55
+ it "returns false when the url is not set" do
56
+ trend = Twitter::Trend.new
57
+ expect(trend.uri?).to be_false
58
+ end
59
+ end
60
+
38
61
  end
@@ -40,6 +40,17 @@ describe Twitter::Tweet do
40
40
  end
41
41
  end
42
42
 
43
+ describe "#created?" do
44
+ it "returns true when created_at is set" do
45
+ tweet = Twitter::Tweet.new(:id => 28669546014, :created_at => "Mon Jul 16 12:59:01 +0000 2007")
46
+ expect(tweet.created?).to be_true
47
+ end
48
+ it "returns false when created_at is not set" do
49
+ tweet = Twitter::Tweet.new(:id => 28669546014)
50
+ expect(tweet.created?).to be_false
51
+ end
52
+ end
53
+
43
54
  describe "#entities?" do
44
55
  it "returns false if there are no entities set" do
45
56
  tweet = Twitter::Tweet.new(:id => 28669546014)
@@ -49,9 +60,9 @@ describe Twitter::Tweet do
49
60
  it "returns true if there are entities set" do
50
61
  urls_array = [
51
62
  {
52
- :url => 'http://example.com/t.co',
53
- :expanded_url => 'http://example.com/expanded',
54
- :display_url => 'example.com/expanded',
63
+ :url => "http://example.com/t.co",
64
+ :expanded_url => "http://example.com/expanded",
65
+ :display_url => "example.com/expanded",
55
66
  :indices => [10, 33],
56
67
  }
57
68
  ]
@@ -60,62 +71,33 @@ describe Twitter::Tweet do
60
71
  end
61
72
  end
62
73
 
63
- describe "#favoriters_count" do
64
- it "returns the count of favoriters when favoriters_count is set" do
65
- tweet = Twitter::Tweet.new(:id => 28669546014, :favoriters_count => '1')
66
- expect(tweet.favoriters_count).to be_an Integer
67
- expect(tweet.favoriters_count).to eq 1
68
- end
69
- it "returns nil when not set" do
70
- tweet = Twitter::Tweet.new(:id => 28669546014)
71
- expect(tweet.favoriters_count).to be_nil
72
- end
73
- end
74
-
75
- describe "#from_user" do
76
- it "returns a screen name when from_user is set" do
77
- tweet = Twitter::Tweet.new(:id => 28669546014, :from_user => 'sferik')
78
- expect(tweet.from_user).to be_a String
79
- expect(tweet.from_user).to eq "sferik"
80
- end
81
- it "returns a screen name when screen_name is set" do
82
- tweet = Twitter::Tweet.new(:id => 28669546014, :user => {:id => 7505382, :screen_name => 'sferik'})
83
- expect(tweet.from_user).to be_a String
84
- expect(tweet.from_user).to eq "sferik"
85
- end
86
- it "returns nil when not set" do
87
- tweet = Twitter::Tweet.new(:id => 28669546014)
88
- expect(tweet.from_user).to be_nil
89
- end
90
- end
91
-
92
74
  describe "#filter_level" do
93
75
  it "returns the filter level when filter_level is set" do
94
- tweet = Twitter::Tweet.new(:id => 28669546014, :filter_level => 'high')
76
+ tweet = Twitter::Tweet.new(:id => 28669546014, :filter_level => "high")
95
77
  expect(tweet.filter_level).to be_a String
96
- expect(tweet.filter_level).to eq "high"
78
+ expect(tweet.filter_level).to eq("high")
97
79
  end
98
80
  it "returns \"none\" when not set" do
99
81
  tweet = Twitter::Tweet.new(:id => 28669546014)
100
- expect(tweet.filter_level).to eq "none"
82
+ expect(tweet.filter_level).to eq("none")
101
83
  end
102
84
  end
103
85
 
104
86
  describe "#full_text" do
105
87
  it "returns the text of a Tweet" do
106
- tweet = Twitter::Tweet.new(:id => 28669546014, :text => 'BOOSH')
88
+ tweet = Twitter::Tweet.new(:id => 28669546014, :text => "BOOSH")
107
89
  expect(tweet.full_text).to be_a String
108
- expect(tweet.full_text).to eq "BOOSH"
90
+ expect(tweet.full_text).to eq("BOOSH")
109
91
  end
110
92
  it "returns the text of a Tweet without a user" do
111
- tweet = Twitter::Tweet.new(:id => 28669546014, :text => 'BOOSH', :retweeted_status => {:id => 28561922517, :text => 'BOOSH'})
93
+ tweet = Twitter::Tweet.new(:id => 28669546014, :text => "BOOSH", :retweeted_status => {:id => 28561922517, :text => "BOOSH"})
112
94
  expect(tweet.full_text).to be_a String
113
- expect(tweet.full_text).to eq "BOOSH"
95
+ expect(tweet.full_text).to eq("BOOSH")
114
96
  end
115
97
  it "returns the full text of a retweeted Tweet" do
116
- tweet = Twitter::Tweet.new(:id => 28669546014, :text => 'RT @sferik: BOOSH', :retweeted_status => {:id => 28561922516, :text => 'BOOSH'})
98
+ tweet = Twitter::Tweet.new(:id => 28669546014, :text => "RT @sferik: BOOSH", :retweeted_status => {:id => 25938088801, :text => "BOOSH"})
117
99
  expect(tweet.full_text).to be_a String
118
- expect(tweet.full_text).to eq "RT @sferik: BOOSH"
100
+ expect(tweet.full_text).to eq("RT @sferik: BOOSH")
119
101
  end
120
102
  it "returns nil when retweeted_status is not set" do
121
103
  tweet = Twitter::Tweet.new(:id => 28669546014)
@@ -124,29 +106,40 @@ describe Twitter::Tweet do
124
106
  end
125
107
 
126
108
  describe "#geo" do
127
- it "returns a Twitter::Geo::Point when set" do
128
- tweet = Twitter::Tweet.new(:id => 28669546014, :geo => {:id => 1, :type => 'Point'})
109
+ it "returns a Twitter::Geo::Point when geo is set" do
110
+ tweet = Twitter::Tweet.new(:id => 28669546014, :geo => {:id => 1, :type => "Point"})
129
111
  expect(tweet.geo).to be_a Twitter::Geo::Point
130
112
  end
131
- it "returns nil when not set" do
113
+ it "returns nil when geo is not set" do
132
114
  tweet = Twitter::Tweet.new(:id => 28669546014)
133
115
  expect(tweet.geo).to be_nil
134
116
  end
135
117
  end
136
118
 
119
+ describe "#geo?" do
120
+ it "returns true when geo is set" do
121
+ tweet = Twitter::Tweet.new(:id => 28669546014, :geo => {:id => 1, :type => "Point"})
122
+ expect(tweet.geo?).to be_true
123
+ end
124
+ it "returns false when geo is not set" do
125
+ tweet = Twitter::Tweet.new(:id => 28669546014)
126
+ expect(tweet.geo?).to be_false
127
+ end
128
+ end
129
+
137
130
  describe "#hashtags" do
138
- it "returns an Array of Entity::Hashtag when entities are set" do
131
+ it "returns an array of Entity::Hashtag when entities are set" do
139
132
  hashtags_array = [
140
133
  {
141
- :text => 'twitter',
134
+ :text => "twitter",
142
135
  :indices => [10, 33],
143
136
  }
144
137
  ]
145
138
  hashtags = Twitter::Tweet.new(:id => 28669546014, :entities => {:hashtags => hashtags_array}).hashtags
146
139
  expect(hashtags).to be_an Array
147
140
  expect(hashtags.first).to be_a Twitter::Entity::Hashtag
148
- expect(hashtags.first.indices).to eq [10, 33]
149
- expect(hashtags.first.text).to eq 'twitter'
141
+ expect(hashtags.first.indices).to eq([10, 33])
142
+ expect(hashtags.first.text).to eq("twitter")
150
143
  end
151
144
  it "is empty when not set" do
152
145
  hashtags = Twitter::Tweet.new(:id => 28669546014).hashtags
@@ -160,7 +153,7 @@ describe Twitter::Tweet do
160
153
 
161
154
  describe "#media" do
162
155
  it "returns media" do
163
- media = Twitter::Tweet.new(:id => 28669546014, :entities => {:media => [{:id => 1, :type => 'photo'}]}).media
156
+ media = Twitter::Tweet.new(:id => 28669546014, :entities => {:media => [{:id => 1, :type => "photo"}]}).media
164
157
  expect(media).to be_an Array
165
158
  expect(media.first).to be_a Twitter::Media::Photo
166
159
  end
@@ -175,36 +168,46 @@ describe Twitter::Tweet do
175
168
  end
176
169
 
177
170
  describe "#metadata" do
178
- it "returns a User when user is set" do
179
- metadata = Twitter::Tweet.new(:id => 28669546014, :metadata => {}).metadata
180
- expect(metadata).to be_a Twitter::Metadata
171
+ it "returns a Twitter::Metadata when metadata is set" do
172
+ tweet = Twitter::Tweet.new(:id => 28669546014, :metadata => {})
173
+ expect(tweet.metadata).to be_a Twitter::Metadata
181
174
  end
182
- it "returns nil when user is not set" do
183
- metadata = Twitter::Tweet.new(:id => 28669546014).metadata
184
- expect(metadata).to be_nil
175
+ it "returns nil when metadata is not set" do
176
+ tweet = Twitter::Tweet.new(:id => 28669546014)
177
+ expect(tweet.metadata).to be_nil
178
+ end
179
+ end
180
+
181
+ describe "#metadata?" do
182
+ it "returns true when metadata is set" do
183
+ tweet = Twitter::Tweet.new(:id => 28669546014, :metadata => {})
184
+ expect(tweet.metadata?).to be_true
185
+ end
186
+ it "returns false when metadata is not set" do
187
+ tweet = Twitter::Tweet.new(:id => 28669546014)
188
+ expect(tweet.metadata?).to be_false
185
189
  end
186
190
  end
187
191
 
188
192
  describe "#place" do
189
- it "returns a Twitter::Place when set" do
193
+ it "returns a Twitter::Place when place is set" do
190
194
  tweet = Twitter::Tweet.new(:id => 28669546014, :place => {:id => "247f43d441defc03"})
191
195
  expect(tweet.place).to be_a Twitter::Place
192
196
  end
193
- it "returns nil when not set" do
197
+ it "returns nil when place is not set" do
194
198
  tweet = Twitter::Tweet.new(:id => 28669546014)
195
199
  expect(tweet.place).to be_nil
196
200
  end
197
201
  end
198
202
 
199
- describe "#repliers_count" do
200
- it "returns the count of favoriters when repliers_count is set" do
201
- tweet = Twitter::Tweet.new(:id => 28669546014, :repliers_count => '1')
202
- expect(tweet.repliers_count).to be_an Integer
203
- expect(tweet.repliers_count).to eq 1
203
+ describe "#place?" do
204
+ it "returns true when place is set" do
205
+ tweet = Twitter::Tweet.new(:id => 28669546014, :place => {:id => "247f43d441defc03"})
206
+ expect(tweet.place?).to be_true
204
207
  end
205
- it "returns nil when not set" do
208
+ it "returns false when place is not set" do
206
209
  tweet = Twitter::Tweet.new(:id => 28669546014)
207
- expect(tweet.repliers_count).to be_nil
210
+ expect(tweet.place?).to be_false
208
211
  end
209
212
  end
210
213
 
@@ -221,7 +224,7 @@ describe Twitter::Tweet do
221
224
 
222
225
  describe "#retweet?" do
223
226
  it "returns true when there is a retweeted status" do
224
- tweet = Twitter::Tweet.new(:id => 28669546014, :retweeted_status => {:id => 28561922516, :text => 'BOOSH'})
227
+ tweet = Twitter::Tweet.new(:id => 28669546014, :retweeted_status => {:id => 25938088801, :text => "BOOSH"})
225
228
  expect(tweet.retweet?).to be_true
226
229
  end
227
230
  it "returns false when retweeted_status is not set" do
@@ -231,10 +234,10 @@ describe Twitter::Tweet do
231
234
  end
232
235
 
233
236
  describe "#retweeted_status" do
234
- it "has text when retweeted_status is set" do
235
- tweet = Twitter::Tweet.new(:id => 28669546014, :retweeted_status => {:id => 28561922516, :text => 'BOOSH'})
237
+ it "returns a Tweet when retweeted_status is set" do
238
+ tweet = Twitter::Tweet.new(:id => 28669546014, :retweeted_status => {:id => 25938088801, :text => "BOOSH"})
236
239
  expect(tweet.retweeted_tweet).to be_a Twitter::Tweet
237
- expect(tweet.retweeted_tweet.text).to eq 'BOOSH'
240
+ expect(tweet.retweeted_tweet.text).to eq("BOOSH")
238
241
  end
239
242
  it "returns nil when retweeted_status is not set" do
240
243
  tweet = Twitter::Tweet.new(:id => 28669546014)
@@ -242,35 +245,29 @@ describe Twitter::Tweet do
242
245
  end
243
246
  end
244
247
 
245
- describe "#retweeters_count" do
246
- it "returns the count of favoriters when retweet_count is set" do
247
- tweet = Twitter::Tweet.new(:id => 28669546014, :retweet_count => '1')
248
- expect(tweet.retweeters_count).to be_an Integer
249
- expect(tweet.retweeters_count).to eq 1
250
- end
251
- it "returns the count of favoriters when retweeters_count is set" do
252
- tweet = Twitter::Tweet.new(:id => 28669546014, :retweeters_count => '1')
253
- expect(tweet.retweeters_count).to be_an Integer
254
- expect(tweet.retweeters_count).to eq 1
248
+ describe "#retweeted_status?" do
249
+ it "returns true when retweeted_status is set" do
250
+ tweet = Twitter::Tweet.new(:id => 28669546014, :retweeted_status => {:id => 25938088801, :text => "BOOSH"})
251
+ expect(tweet.retweeted_status?).to be_true
255
252
  end
256
- it "returns nil when not set" do
253
+ it "returns false when retweeted_status is not set" do
257
254
  tweet = Twitter::Tweet.new(:id => 28669546014)
258
- expect(tweet.retweeters_count).to be_nil
255
+ expect(tweet.retweeted_status?).to be_false
259
256
  end
260
257
  end
261
258
 
262
259
  describe "#symbols" do
263
- it "returns an Array of Entity::Symbol when symbols are set" do
260
+ it "returns an array of Entity::Symbol when symbols are set" do
264
261
  symbols_array = [
265
- { :text => 'PEP', :indices => [114, 118] },
266
- { :text => 'COKE', :indices => [128, 133] }
262
+ { :text => "PEP", :indices => [114, 118] },
263
+ { :text => "COKE", :indices => [128, 133] }
267
264
  ]
268
265
  symbols = Twitter::Tweet.new(:id => 28669546014, :entities => {:symbols => symbols_array}).symbols
269
266
  expect(symbols).to be_an Array
270
- expect(symbols.size).to eq 2
267
+ expect(symbols.size).to eq(2)
271
268
  expect(symbols.first).to be_a Twitter::Entity::Symbol
272
- expect(symbols.first.indices).to eq [114, 118]
273
- expect(symbols.first.text).to eq 'PEP'
269
+ expect(symbols.first.indices).to eq([114, 118])
270
+ expect(symbols.first.text).to eq("PEP")
274
271
  end
275
272
  it "is empty when not set" do
276
273
  symbols = Twitter::Tweet.new(:id => 28669546014).symbols
@@ -282,25 +279,26 @@ describe Twitter::Tweet do
282
279
  end
283
280
  end
284
281
 
285
- describe "#urls" do
286
- it "returns an Array of Entity::Url when entities are set" do
282
+ describe "#uris" do
283
+ it "returns an array of Entity::URIs when entities are set" do
287
284
  urls_array = [
288
285
  {
289
- :url => 'http://example.com/t.co',
290
- :expanded_url => 'http://example.com/expanded',
291
- :display_url => 'example.com/expanded',
286
+ :url => "http://example.com/t.co",
287
+ :expanded_url => "http://example.com/expanded",
288
+ :display_url => "example.com/expanded",
292
289
  :indices => [10, 33],
293
290
  }
294
291
  ]
295
- urls = Twitter::Tweet.new(:id => 28669546014, :entities => {:urls => urls_array}).urls
296
- expect(urls).to be_an Array
297
- expect(urls.first).to be_a Twitter::Entity::Url
298
- expect(urls.first.indices).to eq [10, 33]
299
- expect(urls.first.display_url).to eq 'example.com/expanded'
292
+ tweet = Twitter::Tweet.new(:id => 28669546014, :entities => {:urls => urls_array})
293
+ expect(tweet.uris).to be_an Array
294
+ expect(tweet.uris.first).to be_a Twitter::Entity::URI
295
+ expect(tweet.uris.first.indices).to eq([10, 33])
296
+ expect(tweet.uris.first.display_uri).to be_a URI
297
+ expect(tweet.uris.first.display_uri.to_s).to eq("example.com/expanded")
300
298
  end
301
299
  it "is empty when not set" do
302
- urls = Twitter::Tweet.new(:id => 28669546014).urls
303
- expect(urls).to be_empty
300
+ tweet = Twitter::Tweet.new(:id => 28669546014)
301
+ expect(tweet.uris).to be_empty
304
302
  end
305
303
  it "warns when not set" do
306
304
  Twitter::Tweet.new(:id => 28669546014).urls
@@ -308,39 +306,48 @@ describe Twitter::Tweet do
308
306
  end
309
307
  end
310
308
 
309
+ describe "#uri" do
310
+ it "returns the URI to the tweet" do
311
+ tweet = Twitter::Tweet.new(:id => 28669546014, :user => {:id => 7505382, :screen_name => "sferik"})
312
+ expect(tweet.uri).to be_a URI
313
+ expect(tweet.uri.to_s).to eq("https://twitter.com/sferik/status/28669546014")
314
+ end
315
+ end
316
+
311
317
  describe "#user" do
312
318
  it "returns a User when user is set" do
313
- user = Twitter::Tweet.new(:id => 28669546014, :user => {:id => 7505382}).user
314
- expect(user).to be_a Twitter::User
319
+ tweet = Twitter::Tweet.new(:id => 28669546014, :user => {:id => 7505382})
320
+ expect(tweet.user).to be_a Twitter::User
315
321
  end
316
322
  it "returns nil when user is not set" do
317
- user = Twitter::Tweet.new(:id => 28669546014).user
318
- expect(user).to be_nil
323
+ tweet = Twitter::Tweet.new(:id => 28669546014)
324
+ expect(tweet.user).to be_nil
319
325
  end
320
- it "has a status when status is set" do
321
- user = Twitter::Tweet.new(:id => 28669546014, :text => 'Tweet text.', :user => {:id => 7505382}).user
322
- expect(user.status).to be_a Twitter::Tweet
326
+ it "has a status is set" do
327
+ tweet = Twitter::Tweet.new(:id => 28669546014, :text => "Tweet text.", :user => {:id => 7505382})
328
+ expect(tweet.user.status).to be_a Twitter::Tweet
329
+ expect(tweet.user.status.id).to eq 28669546014
323
330
  end
324
331
  end
325
332
 
326
333
  describe "#user?" do
327
334
  it "returns true when status is set" do
328
- user = Twitter::Tweet.new(:id => 28669546014, :user => {:id => 7505382}).user?
329
- expect(user).to be_true
335
+ tweet = Twitter::Tweet.new(:id => 28669546014, :user => {:id => 7505382})
336
+ expect(tweet.user?).to be_true
330
337
  end
331
338
  it "returns false when status is not set" do
332
- user = Twitter::Tweet.new(:id => 28669546014).user?
333
- expect(user).to be_false
339
+ tweet = Twitter::Tweet.new(:id => 28669546014)
340
+ expect(tweet.user?).to be_false
334
341
  end
335
342
  end
336
343
 
337
344
  describe "#user_mentions" do
338
- it "returns an Array of Entity::UserMention when entities are set" do
345
+ it "returns an array of Entity::UserMention when entities are set" do
339
346
  user_mentions_array = [
340
347
  {
341
- :screen_name => 'sferik',
342
- :name => 'Erik Michaels-Ober',
343
- :id_str => '7505382',
348
+ :screen_name => "sferik",
349
+ :name => "Erik Michaels-Ober",
350
+ :id_str => "7505382",
344
351
  :indices => [0, 6],
345
352
  :id => 7505382,
346
353
  }
@@ -348,8 +355,8 @@ describe Twitter::Tweet do
348
355
  user_mentions = Twitter::Tweet.new(:id => 28669546014, :entities => {:user_mentions => user_mentions_array}).user_mentions
349
356
  expect(user_mentions).to be_an Array
350
357
  expect(user_mentions.first).to be_a Twitter::Entity::UserMention
351
- expect(user_mentions.first.indices).to eq [0, 6]
352
- expect(user_mentions.first.id).to eq 7505382
358
+ expect(user_mentions.first.indices).to eq([0, 6])
359
+ expect(user_mentions.first.id).to eq(7505382)
353
360
  end
354
361
  it "is empty when not set" do
355
362
  user_mentions = Twitter::Tweet.new(:id => 28669546014).user_mentions