twitter 5.11.0 → 5.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (178) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +11 -1
  3. data/README.md +7 -5
  4. data/lib/twitter/arguments.rb +1 -0
  5. data/lib/twitter/base.rb +4 -5
  6. data/lib/twitter/basic_user.rb +1 -0
  7. data/lib/twitter/client.rb +10 -9
  8. data/lib/twitter/configuration.rb +4 -2
  9. data/lib/twitter/cursor.rb +3 -2
  10. data/lib/twitter/direct_message.rb +1 -0
  11. data/lib/twitter/entity.rb +1 -0
  12. data/lib/twitter/entity/hashtag.rb +1 -0
  13. data/lib/twitter/entity/symbol.rb +1 -0
  14. data/lib/twitter/entity/user_mention.rb +4 -1
  15. data/lib/twitter/error.rb +22 -19
  16. data/lib/twitter/geo.rb +1 -0
  17. data/lib/twitter/geo_results.rb +3 -2
  18. data/lib/twitter/identity.rb +1 -0
  19. data/lib/twitter/language.rb +1 -0
  20. data/lib/twitter/list.rb +12 -5
  21. data/lib/twitter/media/photo.rb +1 -0
  22. data/lib/twitter/metadata.rb +1 -0
  23. data/lib/twitter/null_object.rb +22 -0
  24. data/lib/twitter/oembed.rb +5 -2
  25. data/lib/twitter/place.rb +4 -1
  26. data/lib/twitter/profile.rb +1 -1
  27. data/lib/twitter/rest/client.rb +4 -4
  28. data/lib/twitter/rest/favorites.rb +4 -3
  29. data/lib/twitter/rest/lists.rb +18 -3
  30. data/lib/twitter/rest/request/multipart_with_file.rb +1 -1
  31. data/lib/twitter/rest/response/parse_json.rb +1 -1
  32. data/lib/twitter/rest/response/raise_error.rb +4 -5
  33. data/lib/twitter/rest/tweets.rb +2 -1
  34. data/lib/twitter/rest/users.rb +10 -7
  35. data/lib/twitter/saved_search.rb +1 -0
  36. data/lib/twitter/search_results.rb +3 -2
  37. data/lib/twitter/settings.rb +7 -3
  38. data/lib/twitter/size.rb +4 -1
  39. data/lib/twitter/streaming/deleted_tweet.rb +1 -0
  40. data/lib/twitter/streaming/event.rb +2 -2
  41. data/lib/twitter/streaming/message_parser.rb +1 -1
  42. data/lib/twitter/suggestion.rb +4 -1
  43. data/lib/twitter/token.rb +1 -0
  44. data/lib/twitter/trend.rb +1 -0
  45. data/lib/twitter/trend_results.rb +3 -2
  46. data/lib/twitter/tweet.rb +9 -6
  47. data/lib/twitter/user.rb +15 -13
  48. data/lib/twitter/utils.rb +2 -6
  49. data/lib/twitter/version.rb +1 -1
  50. data/twitter.gemspec +6 -9
  51. metadata +6 -259
  52. data/Rakefile +0 -37
  53. data/spec/fixtures/already_favorited.json +0 -1
  54. data/spec/fixtures/already_posted.json +0 -1
  55. data/spec/fixtures/already_retweeted.json +0 -1
  56. data/spec/fixtures/bearer_token.json +0 -1
  57. data/spec/fixtures/category.json +0 -1
  58. data/spec/fixtures/configuration.json +0 -1
  59. data/spec/fixtures/contributees.json +0 -1
  60. data/spec/fixtures/count.json +0 -1
  61. data/spec/fixtures/direct_message.json +0 -1
  62. data/spec/fixtures/direct_messages.json +0 -1
  63. data/spec/fixtures/empty.json +0 -0
  64. data/spec/fixtures/followers_list.json +0 -1
  65. data/spec/fixtures/followers_list2.json +0 -1
  66. data/spec/fixtures/following.json +0 -1
  67. data/spec/fixtures/forbidden.json +0 -1
  68. data/spec/fixtures/friends_list.json +0 -1
  69. data/spec/fixtures/friends_list2.json +0 -1
  70. data/spec/fixtures/friendships.json +0 -1
  71. data/spec/fixtures/ids.json +0 -1
  72. data/spec/fixtures/ids_list.json +0 -1
  73. data/spec/fixtures/ids_list2.json +0 -1
  74. data/spec/fixtures/languages.json +0 -1
  75. data/spec/fixtures/list.json +0 -1
  76. data/spec/fixtures/lists.json +0 -1
  77. data/spec/fixtures/locations.json +0 -1
  78. data/spec/fixtures/matching_trends.json +0 -1
  79. data/spec/fixtures/me.jpeg +0 -0
  80. data/spec/fixtures/members.json +0 -1
  81. data/spec/fixtures/memberships.json +0 -1
  82. data/spec/fixtures/memberships2.json +0 -1
  83. data/spec/fixtures/not_following.json +0 -1
  84. data/spec/fixtures/not_found.json +0 -1
  85. data/spec/fixtures/oembed.json +0 -1
  86. data/spec/fixtures/ownerships.json +0 -1
  87. data/spec/fixtures/pbjt.gif +0 -0
  88. data/spec/fixtures/pengwynn.json +0 -1
  89. data/spec/fixtures/place.json +0 -1
  90. data/spec/fixtures/places.json +0 -1
  91. data/spec/fixtures/privacy.json +0 -1
  92. data/spec/fixtures/profile_banner.json +0 -1
  93. data/spec/fixtures/request_token.txt +0 -6
  94. data/spec/fixtures/retweet.json +0 -1
  95. data/spec/fixtures/retweets.json +0 -1
  96. data/spec/fixtures/saved_search.json +0 -1
  97. data/spec/fixtures/saved_searches.json +0 -1
  98. data/spec/fixtures/search.json +0 -1
  99. data/spec/fixtures/search2.json +0 -1
  100. data/spec/fixtures/search_malformed.json +0 -1
  101. data/spec/fixtures/settings.json +0 -1
  102. data/spec/fixtures/sferik.json +0 -1
  103. data/spec/fixtures/status.json +0 -1
  104. data/spec/fixtures/statuses.json +0 -1
  105. data/spec/fixtures/subscriptions.json +0 -1
  106. data/spec/fixtures/subscriptions2.json +0 -1
  107. data/spec/fixtures/suggestions.json +0 -1
  108. data/spec/fixtures/tos.json +0 -1
  109. data/spec/fixtures/track_streaming.json +0 -3
  110. data/spec/fixtures/track_streaming_user.json +0 -6
  111. data/spec/fixtures/upload.json +0 -1
  112. data/spec/fixtures/user_search.json +0 -1
  113. data/spec/fixtures/user_timeline.json +0 -1
  114. data/spec/fixtures/users.json +0 -1
  115. data/spec/fixtures/users_list.json +0 -1
  116. data/spec/fixtures/users_list2.json +0 -1
  117. data/spec/fixtures/we_concept_bg2.png +0 -0
  118. data/spec/fixtures/wildcomet2.jpe +0 -0
  119. data/spec/helper.rb +0 -68
  120. data/spec/twitter/base_spec.rb +0 -39
  121. data/spec/twitter/basic_user_spec.rb +0 -23
  122. data/spec/twitter/configuration_spec.rb +0 -17
  123. data/spec/twitter/cursor_spec.rb +0 -30
  124. data/spec/twitter/direct_message_spec.rb +0 -232
  125. data/spec/twitter/entity/uri_spec.rb +0 -75
  126. data/spec/twitter/error_spec.rb +0 -52
  127. data/spec/twitter/geo/point_spec.rb +0 -41
  128. data/spec/twitter/geo/polygon_spec.rb +0 -29
  129. data/spec/twitter/geo_factory_spec.rb +0 -19
  130. data/spec/twitter/geo_results_spec.rb +0 -35
  131. data/spec/twitter/geo_spec.rb +0 -29
  132. data/spec/twitter/identifiable_spec.rb +0 -29
  133. data/spec/twitter/list_spec.rb +0 -88
  134. data/spec/twitter/media/photo_spec.rb +0 -151
  135. data/spec/twitter/media_factory_spec.rb +0 -15
  136. data/spec/twitter/oembed_spec.rb +0 -170
  137. data/spec/twitter/place_spec.rb +0 -168
  138. data/spec/twitter/profile_banner_spec.rb +0 -13
  139. data/spec/twitter/rate_limit_spec.rb +0 -59
  140. data/spec/twitter/relationship_spec.rb +0 -49
  141. data/spec/twitter/rest/client_spec.rb +0 -217
  142. data/spec/twitter/rest/direct_messages_spec.rb +0 -133
  143. data/spec/twitter/rest/favorites_spec.rb +0 -188
  144. data/spec/twitter/rest/friends_and_followers_spec.rb +0 -667
  145. data/spec/twitter/rest/geo_spec.rb +0 -68
  146. data/spec/twitter/rest/help_spec.rb +0 -68
  147. data/spec/twitter/rest/lists_spec.rb +0 -910
  148. data/spec/twitter/rest/media_spec.rb +0 -54
  149. data/spec/twitter/rest/oauth_spec.rb +0 -63
  150. data/spec/twitter/rest/saved_searches_spec.rb +0 -98
  151. data/spec/twitter/rest/search_spec.rb +0 -42
  152. data/spec/twitter/rest/spam_reporting_spec.rb +0 -25
  153. data/spec/twitter/rest/suggested_users_spec.rb +0 -59
  154. data/spec/twitter/rest/timelines_spec.rb +0 -138
  155. data/spec/twitter/rest/trends_spec.rb +0 -68
  156. data/spec/twitter/rest/tweets_spec.rb +0 -614
  157. data/spec/twitter/rest/undocumented_spec.rb +0 -103
  158. data/spec/twitter/rest/users_spec.rb +0 -797
  159. data/spec/twitter/saved_search_spec.rb +0 -45
  160. data/spec/twitter/search_results_spec.rb +0 -30
  161. data/spec/twitter/settings_spec.rb +0 -27
  162. data/spec/twitter/size_spec.rb +0 -28
  163. data/spec/twitter/source_user_spec.rb +0 -23
  164. data/spec/twitter/streaming/client_spec.rb +0 -123
  165. data/spec/twitter/streaming/connection_spec.rb +0 -32
  166. data/spec/twitter/streaming/deleted_tweet_spec.rb +0 -23
  167. data/spec/twitter/streaming/event_spec.rb +0 -43
  168. data/spec/twitter/streaming/friend_list_spec.rb +0 -11
  169. data/spec/twitter/streaming/message_parser_spec.rb +0 -54
  170. data/spec/twitter/streaming/response_spec.rb +0 -21
  171. data/spec/twitter/suggestion_spec.rb +0 -40
  172. data/spec/twitter/target_user_spec.rb +0 -23
  173. data/spec/twitter/token_spec.rb +0 -16
  174. data/spec/twitter/trend_results_spec.rb +0 -89
  175. data/spec/twitter/trend_spec.rb +0 -51
  176. data/spec/twitter/tweet_spec.rb +0 -456
  177. data/spec/twitter/user_spec.rb +0 -447
  178. data/spec/twitter/utils_spec.rb +0 -34
@@ -1,45 +0,0 @@
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
- expect(saved_search == other).to 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
- expect(saved_search == other).to 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
- expect(saved_search == other).to 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 => 16_129_012, :created_at => 'Mon Jul 16 12:59:01 +0000 2007')
26
- expect(saved_search.created_at).to be_a Time
27
- end
28
- it 'returns nil when created_at is not set' do
29
- saved_search = Twitter::SavedSearch.new(:id => 16_129_012)
30
- expect(saved_search.created_at).to be_nil
31
- end
32
- end
33
-
34
- describe '#created?' do
35
- it 'returns true when created_at is set' do
36
- saved_search = Twitter::SavedSearch.new(:id => 16_129_012, :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 => 16_129_012)
41
- expect(saved_search.created?).to be false
42
- end
43
- end
44
-
45
- end
@@ -1,30 +0,0 @@
1
- require 'helper'
2
-
3
- describe Twitter::SearchResults do
4
-
5
- describe '#each' do
6
- before do
7
- @client = Twitter::REST::Client.new(:consumer_key => 'CK', :consumer_secret => 'CS', :access_token => 'AT', :access_token_secret => 'AS')
8
- stub_get('/1.1/search/tweets.json').with(:query => {:q => '#freebandnames', :count => '100'}).to_return(:body => fixture('search.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
9
- stub_get('/1.1/search/tweets.json').with(:query => {:q => '#freebandnames', :count => '3', :include_entities => '1', :max_id => '414071361066532863'}).to_return(:body => fixture('search2.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
10
- end
11
- it 'requests the correct resources' do
12
- @client.search('#freebandnames').each {}
13
- expect(a_get('/1.1/search/tweets.json').with(:query => {:q => '#freebandnames', :count => '100'})).to have_been_made
14
- expect(a_get('/1.1/search/tweets.json').with(:query => {:q => '#freebandnames', :count => '3', :include_entities => '1', :max_id => '414071361066532863'})).to have_been_made
15
- end
16
- it 'iterates' do
17
- count = 0
18
- @client.search('#freebandnames').each { count += 1 }
19
- expect(count).to eq(6)
20
- end
21
- context 'with start' do
22
- it 'iterates' do
23
- count = 0
24
- @client.search('#freebandnames').each(5) { count += 1 }
25
- expect(count).to eq(1)
26
- end
27
- end
28
- end
29
-
30
- end
@@ -1,27 +0,0 @@
1
- require 'helper'
2
-
3
- describe Twitter::Settings do
4
-
5
- describe '#trend_location' do
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 => 2_487_956, :parentid => 23_424_977, :url => 'http://where.yahooapis.com/v1/place/2487956'}) # rubocop:disable SymbolName
8
- expect(settings.trend_location).to be_a Twitter::Place
9
- end
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 => 2_487_956, :parentid => 23_424_977, :url => 'http://where.yahooapis.com/v1/place/2487956'}) # rubocop:disable SymbolName
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
24
- end
25
- end
26
-
27
- end
@@ -1,28 +0,0 @@
1
- require 'helper'
2
-
3
- describe Twitter::Size do
4
-
5
- describe '#==' do
6
- it 'returns true for empty objects' do
7
- size = Twitter::Size.new
8
- other = Twitter::Size.new
9
- expect(size == other).to be true
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
- expect(size == other).to 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
- expect(size == other).to 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
- expect(size == other).to be false
25
- end
26
- end
27
-
28
- end
@@ -1,23 +0,0 @@
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
- expect(saved_search == other).to 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
- expect(saved_search == other).to 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
- expect(saved_search == other).to be false
20
- end
21
- end
22
-
23
- end
@@ -1,123 +0,0 @@
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(_, response)
14
- @body.each_line do |line|
15
- response.on_body(line)
16
- end
17
- end
18
- end
19
-
20
- describe '#before_request' do
21
- it 'runs before a request' do
22
- @client.connection = FakeConnection.new(fixture('track_streaming.json'))
23
- var = false
24
- @client.before_request do
25
- var = true
26
- end
27
- expect(var).to be false
28
- @client.user {}
29
- expect(var).to be true
30
- end
31
- end
32
-
33
- describe '#filter' do
34
- it 'returns an arary of Tweets' do
35
- @client.connection = FakeConnection.new(fixture('track_streaming.json'))
36
- objects = []
37
- @client.filter(:track => 'india') do |object|
38
- objects << object
39
- end
40
- expect(objects.size).to eq(2)
41
- expect(objects.first).to be_a Twitter::Tweet
42
- expect(objects.first.text).to eq "The problem with your code is that it's doing exactly what you told it to do."
43
- end
44
- end
45
-
46
- describe '#firehose' do
47
- it 'returns an arary of Tweets' do
48
- @client.connection = FakeConnection.new(fixture('track_streaming.json'))
49
- objects = []
50
- @client.firehose do |object|
51
- objects << object
52
- end
53
- expect(objects.size).to eq(2)
54
- expect(objects.first).to be_a Twitter::Tweet
55
- expect(objects.first.text).to eq "The problem with your code is that it's doing exactly what you told it to do."
56
- end
57
- end
58
-
59
- describe '#sample' do
60
- it 'returns an arary of Tweets' do
61
- @client.connection = FakeConnection.new(fixture('track_streaming.json'))
62
- objects = []
63
- @client.sample do |object|
64
- objects << object
65
- end
66
- expect(objects.size).to eq(2)
67
- expect(objects.first).to be_a Twitter::Tweet
68
- expect(objects.first.text).to eq "The problem with your code is that it's doing exactly what you told it to do."
69
- end
70
- end
71
-
72
- describe '#site' do
73
- context 'with a user ID passed' do
74
- it 'returns an arary of Tweets' do
75
- @client.connection = FakeConnection.new(fixture('track_streaming.json'))
76
- objects = []
77
- @client.site(7_505_382) do |object|
78
- objects << object
79
- end
80
- expect(objects.size).to eq(2)
81
- expect(objects.first).to be_a Twitter::Tweet
82
- expect(objects.first.text).to eq "The problem with your code is that it's doing exactly what you told it to do."
83
- end
84
- end
85
- context 'with a user object passed' do
86
- it 'returns an arary of Tweets' do
87
- @client.connection = FakeConnection.new(fixture('track_streaming.json'))
88
- objects = []
89
- user = Twitter::User.new(:id => 7_505_382)
90
- @client.site(user) do |object|
91
- objects << object
92
- end
93
- expect(objects.size).to eq(2)
94
- expect(objects.first).to be_a Twitter::Tweet
95
- expect(objects.first.text).to eq "The problem with your code is that it's doing exactly what you told it to do."
96
- end
97
- end
98
- end
99
-
100
- describe '#user' do
101
- it 'returns an arary of Tweets' do
102
- @client.connection = FakeConnection.new(fixture('track_streaming_user.json'))
103
- objects = []
104
- @client.user do |object|
105
- objects << object
106
- end
107
- expect(objects.size).to eq(6)
108
- expect(objects[0]).to be_a Twitter::Streaming::FriendList
109
- expect(objects[0]).to eq([488_736_931, 311_444_249])
110
- expect(objects[1]).to be_a Twitter::Tweet
111
- expect(objects[1].text).to eq("The problem with your code is that it's doing exactly what you told it to do.")
112
- expect(objects[2]).to be_a Twitter::DirectMessage
113
- expect(objects[2].text).to eq('hello bot')
114
- expect(objects[3]).to be_a Twitter::Streaming::Event
115
- expect(objects[3].name).to eq(:follow)
116
- expect(objects[4]).to be_a Twitter::Streaming::DeletedTweet
117
- expect(objects[4].id).to eq(272_691_609_211_117_568)
118
- expect(objects[5]).to be_a Twitter::Streaming::StallWarning
119
- expect(objects[5].code).to eq('FALLING_BEHIND')
120
- end
121
- end
122
-
123
- end
@@ -1,32 +0,0 @@
1
- require 'helper'
2
-
3
- describe Twitter::Streaming::Connection do
4
-
5
- describe 'initialize' do
6
- context 'no options provided' do
7
- subject(:connection) { Twitter::Streaming::Connection.new }
8
-
9
- it 'sets the default socket classes' do
10
- expect(connection.tcp_socket_class).to eq TCPSocket
11
- expect(connection.ssl_socket_class).to eq OpenSSL::SSL::SSLSocket
12
- end
13
- end
14
-
15
- context 'custom socket classes provided in opts' do
16
- class DummyTCPSocket; end
17
- class DummySSLSocket; end
18
-
19
- subject(:connection) do
20
- Twitter::Streaming::Connection.new(
21
- :tcp_socket_class => DummyTCPSocket,
22
- :ssl_socket_class => DummySSLSocket
23
- )
24
- end
25
-
26
- it 'sets the default socket classes' do
27
- expect(connection.tcp_socket_class).to eq DummyTCPSocket
28
- expect(connection.ssl_socket_class).to eq DummySSLSocket
29
- end
30
- end
31
- end
32
- end
@@ -1,23 +0,0 @@
1
- require 'helper'
2
-
3
- describe Twitter::Streaming::DeletedTweet do
4
-
5
- describe '#==' do
6
- it 'returns true when objects IDs are the same' do
7
- deleted_tweet = Twitter::Streaming::DeletedTweet.new(:id => 1)
8
- other = Twitter::Streaming::DeletedTweet.new(:id => 1)
9
- expect(deleted_tweet == other).to be true
10
- end
11
- it 'returns false when objects IDs are different' do
12
- deleted_tweet = Twitter::Streaming::DeletedTweet.new(:id => 1)
13
- other = Twitter::Streaming::DeletedTweet.new(:id => 2)
14
- expect(deleted_tweet == other).to be false
15
- end
16
- it 'returns false when classes are different' do
17
- deleted_tweet = Twitter::Streaming::DeletedTweet.new(:id => 1)
18
- other = Twitter::Identity.new(:id => 1)
19
- expect(deleted_tweet == other).to be false
20
- end
21
- end
22
-
23
- end
@@ -1,43 +0,0 @@
1
- require 'helper'
2
-
3
- describe Twitter::Streaming::Event do
4
-
5
- describe '#initialize' do
6
- before(:each) do
7
- @data = {:event => 'follow', :source => {:id => 10_083_602, :id_str => '10083602', :name => 'Adam Bird', :screen_name => 'adambird', :location => 'Nottingham, UK', :url => 'http://t.co/M1eaIKDQyz', :description => 'CEO @onediaryapp, ex @esendex CTO and co-founder, still cycling', :protected => false, :followers_count => 1295, :friends_count => 850, :listed_count => 53, :created_at => 'Fri Nov 09 00:35:12 +0000 2007', :favourites_count => 93, :utc_offset => 0, :time_zone => 'London', :geo_enabled => true, :verified => false, :statuses_count => 13_507, :lang => 'en', :contributors_enabled => false, :is_translator => false, :profile_background_color => 'C0DEED', :profile_background_image_url => 'http://abs.twimg.com/images/themes/theme1/bg.png', :profile_bacground_image_url_https => 'https://abs.twimg.com/images/themes/theme1/bg.png', :profile_background_tile => false, :profile_image_url => 'http://pbs.twimg.com/profile_images/378800000477232297/23d85bb78f71534eea1e1133fb771f86_normal.jpeg', :profile_image_url_https => 'https://pbs.twimg.com/profile_images/378800000477232297/23d85bb78f71534eea1e1133fb771f86_normal.jpeg', :profile_link_color => '0084B4', :profile_sidebar_border_color => 'C0DEED', :profile_sidebar_fill_color => 'DDEEF6', :profile_text_color => '333333', :profile_use_background_image => true, :default_profile => true, :default_profile_image => false, :following => false, :follow_request_sent => false, :notifications => false}, :target => {:id => 1_292_911_088, :id_str => '1292911088', :name => 'One Diary Bot', :screen_name => 'onediarybot', :location => nil, :url => 'http://t.co/etHGc0xHX4', :description => "I'm the One Diary bot, here to help you with your life including personal cycling weather forecasts.", :protected => false, :followers_count => 123, :friends_count => 157, :listed_count => 1, :created_at => 'Sat Mar 23 23:52:18 +0000 2013', :favourites_count => 0, :utc_offset => nil, :time_zone => nil, :geo_enabled => false, :verified => false, :statuses_count => 9637, :lang => 'en', :contributors_enabled => false, :is_translator => false, :profile_background_color => 'C0DEED', :profile_background_image_url => 'http://abs.twimg.com/images/themes/theme1/bg.png', :profile_background_image_url_https => 'https://abs.twimg.com/images/themes/theme1/bg.png', :profile_background_tile => false, :profile_image_url => 'http://pbs.twimg.com/profile_images/3651575369/090551d8dd92080198f707769239ff43_normal.jpeg', :profile_image_url_https => 'https://pbs.twimg.com/profile_images/3651575369/090551d8dd92080198f707769239ff43_normal.jpeg', :profile_link_color => '0084B4', :profile_sidebar_border_color => 'C0DEED', :profile_sidebar_fill_color => 'DDEEF6', :profile_text_color => '333333', :profile_use_background_image => true, :default_profile => true, :default_profile_image => false, :following => false, :follow_request_sent => false, :notifications => false}, :created_at => 'Sun Oct 27 20:44:19 +0000 2013'}
8
- end
9
- subject do
10
- Twitter::Streaming::Event.new(@data)
11
- end
12
- it 'should set the name to be a symbolised version of string string' do
13
- expect(subject.name).to eq(:follow)
14
- end
15
- it 'should set the source to be the User' do
16
- expect(subject.source).to be_a(Twitter::User)
17
- expect(subject.source.id).to eq(10_083_602)
18
- end
19
- it 'should set the target to be the User' do
20
- expect(subject.target).to be_a(Twitter::User)
21
- expect(subject.target.id).to eq(1_292_911_088)
22
- end
23
- context 'when target object is a list' do
24
- before(:each) do
25
- @data = {:event => 'list_member_added', :target_object => {:full_name => '@adambird/lists/dev', :user => {:default_profile_image => false, :profile_text_color => '333333', :created_at => 'Fri Nov 09 00:35:12 +0000 2007', :is_translator => false, :name => 'Adam Bird', :screen_name => 'adambird', :geo_enabled => true, :follow_request_sent => false, :profile_sidebar_border_color => 'C0DEED', :default_profile => true, :id => 10_083_602, :contributors_enabled => false, :followers_count => 1295, :lang => 'en', :profile_background_tile => false, :url => 'http://about.me/adambird', :profile_sidebar_fill_color => 'DDEEF6', :listed_count => 53, :utc_offset => 0, :location => 'Nottingham, UK', :time_zone => 'London', :profile_background_color => 'C0DEED', :following => false, :protected => false, :description => 'CEO @onediaryapp, ex @esendex CTO and co-founder, still cycling', :profile_image_url_https => 'https://pbs.twimg.com/profile_images/378800000477232297/23d85bb78f71534eea1e1133fb771f86_normal.jpeg', :profile_background_image_url => 'http://abs.twimg.com/images/themes/theme1/bg.png', :profile_link_color => '0084B4', :notifications => false, :profile_background_image_url_https => 'https://abs.twimg.com/images/themes/theme1/bg.png', :favourites_count => 93, :id_str => '10083602', :statuses_count => 13_507, :verified => false, :profile_image_url => 'http://pbs.twimg.com/profile_images/378800000477232297/23d85bb78f71534eea1e1133fb771f86_normal.jpeg', :profile_use_background_image => true, :friends_count => 851}, :uri => '/adambird/lists/dev', :subscriber_count => 0, :id_str => '60314359', :created_at => 'Sun Dec 04 19:54:20 +0000 2011', :id => 60_314_359, :following => false, :mode => 'public', :member_count => 13, :description => '', :slug => 'dev', :name => 'dev'}, :source => {:default_profile_image => false, :profile_text_color => '333333', :created_at => 'Fri Nov 09 00:35:12 +0000 2007', :is_translator => false, :name => 'Adam Bird', :screen_name => 'adambird', :geo_enabled => true, :follow_request_sent => false, :profile_sidebar_border_color => 'C0DEED', :default_profile => true, :id => 10_083_602, :contributors_enabled => false, :followers_count => 1295, :lang => 'en', :profile_background_tile => false, :url => 'http://about.me/adambird', :profile_sidebar_fill_color => 'DDEEF6', :listed_count => 53, :utc_offset => 0, :location => 'Nottingham, UK', :time_zone => 'London', :profile_background_color => 'C0DEED', :following => false, :protected => false, :description => 'CEO @onediaryapp, ex @esendex CTO and co-founder, still cycling', :profile_image_url_https => 'https://pbs.twimg.com/profile_images/378800000477232297/23d85bb78f71534eea1e1133fb771f86_normal.jpeg', :profile_background_image_url => 'http://abs.twimg.com/images/themes/theme1/bg.png', :profile_link_color => '0084B4', :notifications => false, :profile_background_image_url_https => 'https://abs.twimg.com/images/themes/theme1/bg.png', :favourites_count => 93, :id_str => '10083602', :statuses_count => 13_507, :verified => false, :profile_image_url => 'http://pbs.twimg.com/profile_images/378800000477232297/23d85bb78f71534eea1e1133fb771f86_normal.jpeg', :profile_use_background_image => true, :friends_count => 851}, :created_at => 'Sun Oct 27 20:54:51 +0000 2013', :target => {:default_profile_image => false, :profile_text_color => '333333', :created_at => 'Sat Mar 23 23:52:18 +0000 2013', :is_translator => false, :name => 'One Diary Bot', :screen_name => 'onediarybot', :geo_enabled => false, :follow_request_sent => false, :profile_sidebar_border_color => 'C0DEED', :default_profile => true, :id => 1_292_911_088, :contributors_enabled => false, :followers_count => 124, :lang => 'en', :profile_background_tile => false, :url => 'http://www.onediary.com', :profile_sidebar_fill_color => 'DDEEF6', :listed_count => 2, :utc_offset => nil, :location => nil, :time_zone => nil, :profile_background_color => 'C0DEED', :following => true, :protected => false, :description => "I'm the One Diary bot, here to help you with your life including personal cycling weather forecasts.", :profile_image_url_https => 'https://pbs.twimg.com/profile_images/3651575369/090551d8dd92080198f707769239ff43_normal.jpeg', :profile_background_image_url => 'http://abs.twimg.com/images/themes/theme1/bg.png', :profile_link_color => '0084B4', :notifications => false, :profile_background_image_url_https => 'https://abs.twimg.com/images/themes/theme1/bg.png', :favourites_count => 0, :id_str => '1292911088', :statuses_count => 9637, :verified => false, :profile_image_url => 'http://pbs.twimg.com/profile_images/3651575369/090551d8dd92080198f707769239ff43_normal.jpeg', :profile_use_background_image => true, :friends_count => 157}}
26
- end
27
- it 'should have the list object as the target object' do
28
- expect(subject.target_object).to be_a(Twitter::List)
29
- expect(subject.target_object.full_name).to eq('@adambird/lists/dev')
30
- end
31
- end
32
- context 'when target object is a tweet' do
33
- before(:each) do
34
- @data = {:event => 'favorite', :target_object => {:in_reply_to_status_id => 394_341_960_603_172_864, :favorited => true, :entities => {:hashtags => [], :urls => [], :user_mentions => [{:screen_name => 'darrenliddell', :id_str => '18845675', :id => 18_845_675, :indices => [0, 14], :name => 'Darren Liddell'}]}, :user => {:default_profile_image => false, :profile_text_color => '333333', :created_at => 'Sat Mar 23 23:52:18 +0000 2013', :is_translator => false, :name => 'One Diary Bot', :screen_name => 'onediarybot', :geo_enabled => false, :follow_request_sent => false, :profile_sidebar_border_color => 'C0DEED', :default_profile => true, :id => 1_292_911_088, :contributors_enabled => false, :followers_count => 124, :lang => 'en', :profile_background_tile => false, :url => 'http://www.onediary.com', :profile_sidebar_fill_color => 'DDEEF6', :listed_count => 1, :utc_offset => nil, :location => nil, :time_zone => nil, :profile_background_color => 'C0DEED', :following => true, :protected => false, :description => "I'm the One Diary bot, here to help you with your life including personal cycling weather forecasts.", :profile_background_image_url => 'http://abs.twimg.com/images/themes/theme1/bg.png', :profile_link_color => '0084B4', :notifications => false, :profile_background_image_url_https => 'https://abs.twimg.com/images/themes/theme1/bg.png', :favourites_count => 0, :id_str => '1292911088', :statuses_count => 9637, :verified => false, :profile_image_url => 'http://pbs.twimg.com/profile_images/3651575369/090551d8dd92080198f707769239ff43_normal.jpeg', :profile_use_background_image => true, :profile_image_url_https => 'https://pbs.twimg.com/profile_images/3651575369/090551d8dd92080198f707769239ff43_normal.jpeg', :friends_count => 157}, :in_reply_to_screen_name => 'darrenliddell', :place => nil, :coordinates => nil, :id_str => '394454214132256768', :source => 'web', :retweet_count => 0, :id => 394_454_214_132_256_768, :created_at => 'Sun Oct 27 13:23:07 +0000 2013', :in_reply_to_status_id_str => '394341960603172864', :retweeted => false, :in_reply_to_user_id => 18_845_675, :truncated => false, :contributors => nil, :geo => nil, :in_reply_to_user_id_str => '18845675', :text => '@darrenliddell my programmers thought that they had that one covered. I have admonished them.'}, :source => {:default_profile_image => false, :profile_text_color => '333333', :created_at => 'Fri Nov 09 00:35:12 +0000 2007', :is_translator => false, :name => 'Adam Bird', :screen_name => 'adambird', :geo_enabled => true, :follow_request_sent => false, :profile_sidebar_border_color => 'C0DEED', :default_profile => true, :id => 10_083_602, :contributors_enabled => false, :followers_count => 1295, :lang => 'en', :profile_background_tile => false, :url => 'http://about.me/adambird', :profile_sidebar_fill_color => 'DDEEF6', :listed_count => 53, :utc_offset => 0, :location => 'Nottingham, UK', :time_zone => 'London', :profile_background_color => 'C0DEED', :following => false, :protected => false, :description => 'CEO @onediaryapp, ex @esendex CTO and co-founder, still cycling', :profile_background_image_url => 'http://abs.twimg.com/images/themes/theme1/bg.png', :profile_link_color => '0084B4', :notifications => false, :profile_background_image_url_https => 'https://abs.twimg.com/images/themes/theme1/bg.png', :favourites_count => 93, :id_str => '10083602', :statuses_count => 13_507, :verified => false, :profile_image_url => 'http://pbs.twimg.com/profile_images/378800000477232297/23d85bb78f71534eea1e1133fb771f86_normal.jpeg', :profile_use_background_image => true, :profile_image_url_https => 'https://pbs.twimg.com/profile_images/378800000477232297/23d85bb78f71534eea1e1133fb771f86_normal.jpeg', :friends_count => 851}, :created_at => 'Sun Oct 27 21:05:35 +0000 2013', :target => {:default_profile_image => false, :profile_text_color => '333333', :created_at => 'Sat Mar 23 23:52:18 +0000 2013', :is_translator => false, :name => 'One Diary Bot', :screen_name => 'onediarybot', :geo_enabled => false, :follow_request_sent => false, :profile_sidebar_border_color => 'C0DEED', :default_profile => true, :id => 1_292_911_088, :contributors_enabled => false, :followers_count => 124, :lang => 'en', :profile_background_tile => false, :url => 'http://www.onediary.com', :profile_sidebar_fill_color => 'DDEEF6', :listed_count => 1, :utc_offset => nil, :location => nil, :time_zone => nil, :profile_background_color => 'C0DEED', :following => true, :protected => false, :description => "I'm the One Diary bot, here to help you with your life including personal cycling weather forecasts.", :profile_background_image_url => 'http://abs.twimg.com/images/themes/theme1/bg.png', :profile_link_color => '0084B4', :notifications => false, :profile_background_image_url_https => 'https://abs.twimg.com/images/themes/theme1/bg.png', :favourites_count => 0, :id_str => '1292911088', :statuses_count => 9637, :verified => false, :profile_image_url => 'http://pbs.twimg.com/profile_images/3651575369/090551d8dd92080198f707769239ff43_normal.jpeg', :profile_use_background_image => true, :profile_image_url_https => 'https://pbs.twimg.com/profile_images/3651575369/090551d8dd92080198f707769239ff43_normal.jpeg', :friends_count => 157}}
35
- end
36
- it 'should have the tweet as the target object' do
37
- expect(subject.target_object).to be_a(Twitter::Tweet)
38
- expect(subject.target_object.id).to eq(394_454_214_132_256_768)
39
- end
40
- end
41
- end
42
-
43
- end
@@ -1,11 +0,0 @@
1
- require 'helper'
2
-
3
- describe Twitter::Streaming::FriendList do
4
-
5
- it 'is an array' do
6
- friend_list = Twitter::Streaming::FriendList.new([1, 2, 3])
7
- expect(friend_list).to be_an Array
8
- expect(friend_list.first).to eq(1)
9
- end
10
-
11
- end
@@ -1,54 +0,0 @@
1
- require 'helper'
2
-
3
- describe Twitter::Streaming::MessageParser do
4
-
5
- subject do
6
- Twitter::Streaming::MessageParser
7
- end
8
-
9
- describe '.parse' do
10
- it 'returns a tweet if the data has an id' do
11
- data = {:id => 1}
12
- object = subject.parse(data)
13
- expect(object).to be_a Twitter::Tweet
14
- expect(object.id).to eq(1)
15
- end
16
- it 'returns an event if the data has an event' do
17
- data = {:event => 'favorite', :source => {:id => 1}, :target => {:id => 2}, :target_object => {:id => 1}}
18
- object = subject.parse(data)
19
- expect(object).to be_a Twitter::Streaming::Event
20
- expect(object.name).to eq(:favorite)
21
- expect(object.source).to be_a Twitter::User
22
- expect(object.source.id).to eq(1)
23
- expect(object.target).to be_a Twitter::User
24
- expect(object.target.id).to eq(2)
25
- expect(object.target_object).to be_a Twitter::Tweet
26
- expect(object.target_object.id).to eq(1)
27
- end
28
- it 'returns a direct message if the data has a direct_message' do
29
- data = {:direct_message => {:id => 1}}
30
- object = subject.parse(data)
31
- expect(object).to be_a Twitter::DirectMessage
32
- expect(object.id).to eq(1)
33
- end
34
- it 'returns a friend list if the data has friends' do
35
- data = {:friends => [1]}
36
- object = subject.parse(data)
37
- expect(object).to be_a Twitter::Streaming::FriendList
38
- expect(object.first).to eq(1)
39
- end
40
- it 'returns a deleted tweet if the data has a deleted status' do
41
- data = {:delete => {:status => {:id => 1}}}
42
- object = subject.parse(data)
43
- expect(object).to be_a Twitter::Streaming::DeletedTweet
44
- expect(object.id).to eq(1)
45
- end
46
- it 'returns a stall warning if the data has a warning' do
47
- data = {:warning => {:code => 'FALLING_BEHIND'}}
48
- object = subject.parse(data)
49
- expect(object).to be_a Twitter::Streaming::StallWarning
50
- expect(object.code).to eq('FALLING_BEHIND')
51
- end
52
- end
53
-
54
- end