twitter 5.0.0 → 5.4.1
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.
- data/.yardopts +4 -0
- data/CHANGELOG.md +47 -0
- data/CONTRIBUTING.md +5 -5
- data/README.md +57 -56
- data/Rakefile +26 -5
- data/lib/twitter/arguments.rb +1 -2
- data/lib/twitter/base.rb +15 -18
- data/lib/twitter/basic_user.rb +3 -3
- data/lib/twitter/client.rb +9 -10
- data/lib/twitter/configuration.rb +5 -5
- data/lib/twitter/creatable.rb +0 -1
- data/lib/twitter/cursor.rb +9 -36
- data/lib/twitter/direct_message.rb +1 -1
- data/lib/twitter/entity/uri.rb +2 -2
- data/lib/twitter/enumerable.rb +10 -1
- data/lib/twitter/error/already_favorited.rb +1 -1
- data/lib/twitter/error/already_posted.rb +1 -1
- data/lib/twitter/error/already_retweeted.rb +1 -1
- data/lib/twitter/error/too_many_requests.rb +2 -2
- data/lib/twitter/error.rb +6 -6
- data/lib/twitter/factory.rb +2 -6
- data/lib/twitter/geo/point.rb +3 -5
- data/lib/twitter/geo.rb +1 -1
- data/lib/twitter/geo_factory.rb +1 -5
- data/lib/twitter/geo_results.rb +5 -8
- data/lib/twitter/identity.rb +1 -2
- data/lib/twitter/list.rb +10 -11
- data/lib/twitter/media/photo.rb +1 -2
- data/lib/twitter/media_factory.rb +1 -5
- data/lib/twitter/null_object.rb +4 -6
- data/lib/twitter/oembed.rb +1 -1
- data/lib/twitter/place.rb +17 -6
- data/lib/twitter/profile_banner.rb +1 -3
- data/lib/twitter/rate_limit.rb +1 -3
- data/lib/twitter/relationship.rb +1 -2
- data/lib/twitter/rest/api/direct_messages.rb +15 -15
- data/lib/twitter/rest/api/favorites.rb +15 -15
- data/lib/twitter/rest/api/friends_and_followers.rb +37 -42
- data/lib/twitter/rest/api/help.rb +8 -9
- data/lib/twitter/rest/api/lists.rb +69 -69
- data/lib/twitter/rest/api/oauth.rb +3 -4
- data/lib/twitter/rest/api/places_and_geo.rb +9 -10
- data/lib/twitter/rest/api/saved_searches.rb +8 -8
- data/lib/twitter/rest/api/search.rb +10 -2
- data/lib/twitter/rest/api/spam_reporting.rb +1 -2
- data/lib/twitter/rest/api/suggested_users.rb +4 -5
- data/lib/twitter/rest/api/timelines.rb +17 -18
- data/lib/twitter/rest/api/trends.rb +10 -11
- data/lib/twitter/rest/api/tweets.rb +31 -20
- data/lib/twitter/rest/api/undocumented.rb +6 -7
- data/lib/twitter/rest/api/users.rb +53 -54
- data/lib/twitter/rest/api/utils.rb +28 -34
- data/lib/twitter/rest/client.rb +8 -9
- data/lib/twitter/rest/request/multipart_with_file.rb +7 -5
- data/lib/twitter/rest/response/parse_error_json.rb +0 -2
- data/lib/twitter/rest/response/parse_json.rb +2 -2
- data/lib/twitter/rest/response/raise_error.rb +1 -3
- data/lib/twitter/search_results.rb +38 -56
- data/lib/twitter/settings.rb +2 -2
- data/lib/twitter/size.rb +2 -2
- data/lib/twitter/source_user.rb +1 -1
- data/lib/twitter/streaming/client.rb +69 -18
- data/lib/twitter/streaming/connection.rb +1 -3
- data/lib/twitter/streaming/deleted_tweet.rb +8 -0
- data/lib/twitter/streaming/event.rb +8 -8
- data/lib/twitter/streaming/friend_list.rb +2 -9
- data/lib/twitter/streaming/message_parser.rb +13 -3
- data/lib/twitter/streaming/response.rb +0 -2
- data/lib/twitter/streaming/stall_warning.rb +7 -0
- data/lib/twitter/suggestion.rb +0 -1
- data/lib/twitter/token.rb +2 -3
- data/lib/twitter/trend_results.rb +5 -8
- data/lib/twitter/tweet.rb +17 -18
- data/lib/twitter/user.rb +33 -35
- data/lib/twitter/utils.rb +14 -0
- data/lib/twitter/version.rb +2 -5
- data/lib/twitter.rb +1 -1
- data/spec/fixtures/forbidden.json +1 -0
- data/spec/fixtures/search.json +1 -1
- data/spec/fixtures/search2.json +1 -0
- data/spec/fixtures/track_streaming_user.json +2 -1
- data/spec/helper.rb +6 -2
- data/spec/twitter/base_spec.rb +9 -9
- data/spec/twitter/basic_user_spec.rb +6 -6
- data/spec/twitter/configuration_spec.rb +4 -4
- data/spec/twitter/cursor_spec.rb +13 -51
- data/spec/twitter/direct_message_spec.rb +36 -36
- data/spec/twitter/entity/uri_spec.rb +29 -29
- data/spec/twitter/error_spec.rb +21 -21
- data/spec/twitter/geo/point_spec.rb +9 -9
- data/spec/twitter/geo/polygon_spec.rb +5 -5
- data/spec/twitter/geo_factory_spec.rb +7 -7
- data/spec/twitter/geo_results_spec.rb +11 -11
- data/spec/twitter/geo_spec.rb +5 -5
- data/spec/twitter/identifiable_spec.rb +9 -9
- data/spec/twitter/list_spec.rb +38 -38
- data/spec/twitter/media/photo_spec.rb +58 -58
- data/spec/twitter/media_factory_spec.rb +5 -5
- data/spec/twitter/null_object_spec.rb +6 -6
- data/spec/twitter/oembed_spec.rb +68 -68
- data/spec/twitter/place_spec.rb +91 -62
- data/spec/twitter/profile_banner_spec.rb +3 -3
- data/spec/twitter/rate_limit_spec.rb +18 -18
- data/spec/twitter/relationship_spec.rb +16 -16
- data/spec/twitter/rest/api/direct_messages_spec.rb +61 -61
- data/spec/twitter/rest/api/favorites_spec.rb +93 -93
- data/spec/twitter/rest/api/friends_and_followers_spec.rb +357 -349
- data/spec/twitter/rest/api/geo_spec.rb +33 -33
- data/spec/twitter/rest/api/help_spec.rb +24 -24
- data/spec/twitter/rest/api/lists_spec.rb +487 -487
- data/spec/twitter/rest/api/oauth_spec.rb +30 -30
- data/spec/twitter/rest/api/saved_searches_spec.rb +50 -40
- data/spec/twitter/rest/api/search_spec.rb +27 -26
- data/spec/twitter/rest/api/spam_reporting_spec.rb +9 -9
- data/spec/twitter/rest/api/suggested_users_spec.rb +23 -23
- data/spec/twitter/rest/api/timelines_spec.rb +58 -58
- data/spec/twitter/rest/api/trends_spec.rb +26 -26
- data/spec/twitter/rest/api/tweets_spec.rb +304 -266
- data/spec/twitter/rest/api/undocumented_spec.rb +51 -51
- data/spec/twitter/rest/api/users_spec.rb +360 -360
- data/spec/twitter/rest/client_spec.rb +99 -103
- data/spec/twitter/saved_search_spec.rb +16 -16
- data/spec/twitter/search_results_spec.rb +14 -110
- data/spec/twitter/settings_spec.rb +8 -8
- data/spec/twitter/size_spec.rb +5 -5
- data/spec/twitter/source_user_spec.rb +6 -6
- data/spec/twitter/streaming/client_spec.rb +85 -54
- data/spec/twitter/streaming/deleted_tweet_spec.rb +23 -0
- data/spec/twitter/streaming/event_spec.rb +20 -22
- data/spec/twitter/streaming/friend_list_spec.rb +11 -0
- data/spec/twitter/streaming/message_parser_spec.rb +54 -0
- data/spec/twitter/suggestion_spec.rb +11 -11
- data/spec/twitter/target_user_spec.rb +6 -6
- data/spec/twitter/token_spec.rb +4 -4
- data/spec/twitter/trend_results_spec.rb +30 -30
- data/spec/twitter/trend_spec.rb +21 -21
- data/spec/twitter/tweet_spec.rb +178 -164
- data/spec/twitter/user_spec.rb +190 -190
- data/twitter.gemspec +6 -6
- data.tar.gz.sig +0 -0
- metadata +44 -16
- metadata.gz.sig +0 -0
- data/lib/twitter/core_ext/enumerable.rb +0 -10
- data/lib/twitter/core_ext/kernel.rb +0 -10
- data/spec/twitter_spec.rb +0 -0
|
@@ -17,76 +17,107 @@ describe Twitter::Streaming::Client do
|
|
|
17
17
|
end
|
|
18
18
|
end
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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
|
|
25
30
|
end
|
|
26
|
-
expect(var).to be false
|
|
27
|
-
@client.user{}
|
|
28
|
-
expect(var).to be true
|
|
29
31
|
end
|
|
30
32
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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."
|
|
36
43
|
end
|
|
37
|
-
expect(tweets.size).to eq(2)
|
|
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
44
|
end
|
|
41
45
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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."
|
|
47
56
|
end
|
|
48
|
-
expect(tweets.size).to eq(2)
|
|
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
57
|
end
|
|
52
58
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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."
|
|
58
69
|
end
|
|
59
|
-
expect(tweets.size).to eq(2)
|
|
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
70
|
end
|
|
63
71
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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
|
|
69
97
|
end
|
|
70
|
-
expect(tweets.size).to eq(2)
|
|
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
98
|
end
|
|
74
99
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
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')
|
|
80
120
|
end
|
|
81
|
-
expect(items.size).to eq(5)
|
|
82
|
-
expect(items[0]).to be_a Twitter::Streaming::FriendList
|
|
83
|
-
expect(items[0].friend_ids).to eq([488736931,311444249])
|
|
84
|
-
expect(items[1]).to be_a Twitter::Tweet
|
|
85
|
-
expect(items[1].text).to eq "The problem with your code is that it's doing exactly what you told it to do."
|
|
86
|
-
expect(items[3]).to be_a Twitter::DirectMessage
|
|
87
|
-
expect(items[3].text).to eq "hello bot"
|
|
88
|
-
expect(items[4]).to be_a Twitter::Streaming::Event
|
|
89
|
-
expect(items[4].name).to be(:follow)
|
|
90
121
|
end
|
|
91
122
|
|
|
92
123
|
end
|
|
@@ -0,0 +1,23 @@
|
|
|
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,45 +1,43 @@
|
|
|
1
1
|
require 'helper'
|
|
2
2
|
|
|
3
3
|
describe Twitter::Streaming::Event do
|
|
4
|
-
|
|
4
|
+
|
|
5
|
+
describe '#initialize' do
|
|
5
6
|
before(:each) do
|
|
6
|
-
@data = {:event=>
|
|
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'}
|
|
7
8
|
end
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
it
|
|
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
|
|
12
13
|
expect(subject.name).to eq(:follow)
|
|
13
14
|
end
|
|
14
|
-
it
|
|
15
|
+
it 'should set the source to be the User' do
|
|
15
16
|
expect(subject.source).to be_a(Twitter::User)
|
|
16
|
-
expect(subject.source.id).to eq(
|
|
17
|
+
expect(subject.source.id).to eq(10_083_602)
|
|
17
18
|
end
|
|
18
|
-
it
|
|
19
|
+
it 'should set the target to be the User' do
|
|
19
20
|
expect(subject.target).to be_a(Twitter::User)
|
|
20
|
-
expect(subject.target.id).to eq(
|
|
21
|
+
expect(subject.target.id).to eq(1_292_911_088)
|
|
21
22
|
end
|
|
22
|
-
|
|
23
|
-
context "when target object is a list" do
|
|
23
|
+
context 'when target object is a list' do
|
|
24
24
|
before(:each) do
|
|
25
|
-
@data = {:event=>
|
|
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
26
|
end
|
|
27
|
-
|
|
28
|
-
it "should have the list object as the target object" do
|
|
27
|
+
it 'should have the list object as the target object' do
|
|
29
28
|
expect(subject.target_object).to be_a(Twitter::List)
|
|
30
|
-
expect(subject.target_object.full_name).to eq(
|
|
29
|
+
expect(subject.target_object.full_name).to eq('@adambird/lists/dev')
|
|
31
30
|
end
|
|
32
31
|
end
|
|
33
|
-
|
|
34
|
-
context "when target object is a tweet" do
|
|
32
|
+
context 'when target object is a tweet' do
|
|
35
33
|
before(:each) do
|
|
36
|
-
@data = {:event=>
|
|
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}}
|
|
37
35
|
end
|
|
38
|
-
|
|
39
|
-
it "should have the tweet as the target object" do
|
|
36
|
+
it 'should have the tweet as the target object' do
|
|
40
37
|
expect(subject.target_object).to be_a(Twitter::Tweet)
|
|
41
|
-
expect(subject.target_object.id).to eq(
|
|
38
|
+
expect(subject.target_object.id).to eq(394_454_214_132_256_768)
|
|
42
39
|
end
|
|
43
40
|
end
|
|
44
41
|
end
|
|
42
|
+
|
|
45
43
|
end
|
|
@@ -0,0 +1,54 @@
|
|
|
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
|
|
@@ -2,36 +2,36 @@ require 'helper'
|
|
|
2
2
|
|
|
3
3
|
describe Twitter::Suggestion do
|
|
4
4
|
|
|
5
|
-
describe
|
|
6
|
-
it
|
|
5
|
+
describe '#==' do
|
|
6
|
+
it 'returns true for empty objects' do
|
|
7
7
|
suggestion = Twitter::Suggestion.new
|
|
8
8
|
other = Twitter::Suggestion.new
|
|
9
9
|
expect(suggestion == other).to be true
|
|
10
10
|
end
|
|
11
|
-
it
|
|
12
|
-
suggestion = Twitter::Suggestion.new(:slug => 1, :name =>
|
|
13
|
-
other = Twitter::Suggestion.new(:slug => 1, :name =>
|
|
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
14
|
expect(suggestion == other).to be true
|
|
15
15
|
end
|
|
16
|
-
it
|
|
16
|
+
it 'returns false when objects slugs are different' do
|
|
17
17
|
suggestion = Twitter::Suggestion.new(:slug => 1)
|
|
18
18
|
other = Twitter::Suggestion.new(:slug => 2)
|
|
19
19
|
expect(suggestion == other).to be false
|
|
20
20
|
end
|
|
21
|
-
it
|
|
21
|
+
it 'returns false when classes are different' do
|
|
22
22
|
suggestion = Twitter::Suggestion.new(:slug => 1)
|
|
23
23
|
other = Twitter::Base.new(:slug => 1)
|
|
24
24
|
expect(suggestion == other).to be false
|
|
25
25
|
end
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
-
describe
|
|
29
|
-
it
|
|
30
|
-
users = Twitter::Suggestion.new(:users => [{:id =>
|
|
28
|
+
describe '#users' do
|
|
29
|
+
it 'returns a User when user is set' do
|
|
30
|
+
users = Twitter::Suggestion.new(:users => [{:id => 7_505_382}]).users
|
|
31
31
|
expect(users).to be_an Array
|
|
32
32
|
expect(users.first).to be_a Twitter::User
|
|
33
33
|
end
|
|
34
|
-
it
|
|
34
|
+
it 'is empty when not set' do
|
|
35
35
|
users = Twitter::Suggestion.new.users
|
|
36
36
|
expect(users).to be_empty
|
|
37
37
|
end
|
|
@@ -2,18 +2,18 @@ require 'helper'
|
|
|
2
2
|
|
|
3
3
|
describe Twitter::TargetUser do
|
|
4
4
|
|
|
5
|
-
describe
|
|
6
|
-
it
|
|
7
|
-
saved_search = Twitter::TargetUser.new(:id => 1, :name =>
|
|
8
|
-
other = Twitter::TargetUser.new(:id => 1, :name =>
|
|
5
|
+
describe '#==' do
|
|
6
|
+
it 'returns true when objects IDs are the same' do
|
|
7
|
+
saved_search = Twitter::TargetUser.new(:id => 1, :name => 'foo')
|
|
8
|
+
other = Twitter::TargetUser.new(:id => 1, :name => 'bar')
|
|
9
9
|
expect(saved_search == other).to be true
|
|
10
10
|
end
|
|
11
|
-
it
|
|
11
|
+
it 'returns false when objects IDs are different' do
|
|
12
12
|
saved_search = Twitter::TargetUser.new(:id => 1)
|
|
13
13
|
other = Twitter::TargetUser.new(:id => 2)
|
|
14
14
|
expect(saved_search == other).to be false
|
|
15
15
|
end
|
|
16
|
-
it
|
|
16
|
+
it 'returns false when classes are different' do
|
|
17
17
|
saved_search = Twitter::TargetUser.new(:id => 1)
|
|
18
18
|
other = Twitter::Identity.new(:id => 1)
|
|
19
19
|
expect(saved_search == other).to be false
|
data/spec/twitter/token_spec.rb
CHANGED
|
@@ -2,12 +2,12 @@ require 'helper'
|
|
|
2
2
|
|
|
3
3
|
describe Twitter::Token do
|
|
4
4
|
|
|
5
|
-
describe
|
|
6
|
-
it
|
|
7
|
-
token = Twitter::Token.new(:token_type =>
|
|
5
|
+
describe '#bearer?' do
|
|
6
|
+
it 'returns true when token is a bearer token' do
|
|
7
|
+
token = Twitter::Token.new(:token_type => 'bearer')
|
|
8
8
|
expect(token.bearer?).to be true
|
|
9
9
|
end
|
|
10
|
-
it
|
|
10
|
+
it 'returns false when token type is nil' do
|
|
11
11
|
token = Twitter::Token.new
|
|
12
12
|
expect(token.bearer?).to be false
|
|
13
13
|
end
|
|
@@ -2,85 +2,85 @@ require 'helper'
|
|
|
2
2
|
|
|
3
3
|
describe Twitter::TrendResults do
|
|
4
4
|
|
|
5
|
-
describe
|
|
6
|
-
it
|
|
7
|
-
trend_results = Twitter::TrendResults.new(:id => 1, :as_of =>
|
|
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
8
|
expect(trend_results.as_of).to be_a Time
|
|
9
9
|
end
|
|
10
|
-
it
|
|
10
|
+
it 'returns nil when as_of is not set' do
|
|
11
11
|
trend_results = Twitter::TrendResults.new(:id => 1)
|
|
12
12
|
expect(trend_results.as_of).to be_nil
|
|
13
13
|
end
|
|
14
14
|
end
|
|
15
15
|
|
|
16
|
-
describe
|
|
17
|
-
it
|
|
18
|
-
trend_results = Twitter::TrendResults.new(:id => 1, :as_of =>
|
|
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
19
|
expect(trend_results.as_of?).to be true
|
|
20
20
|
end
|
|
21
|
-
it
|
|
21
|
+
it 'returns false when as_of is not set' do
|
|
22
22
|
trend_results = Twitter::TrendResults.new(:id => 1)
|
|
23
23
|
expect(trend_results.as_of?).to be false
|
|
24
24
|
end
|
|
25
25
|
end
|
|
26
26
|
|
|
27
|
-
describe
|
|
28
|
-
it
|
|
29
|
-
trend_results = Twitter::TrendResults.new(:id => 1, :created_at =>
|
|
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
30
|
expect(trend_results.created_at).to be_a Time
|
|
31
31
|
end
|
|
32
|
-
it
|
|
32
|
+
it 'returns nil when created_at is not set' do
|
|
33
33
|
trend_results = Twitter::TrendResults.new(:id => 1)
|
|
34
34
|
expect(trend_results.created_at).to be_nil
|
|
35
35
|
end
|
|
36
36
|
end
|
|
37
37
|
|
|
38
|
-
describe
|
|
39
|
-
it
|
|
40
|
-
trend_results = Twitter::TrendResults.new(:id => 1, :created_at =>
|
|
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
41
|
expect(trend_results.created?).to be true
|
|
42
42
|
end
|
|
43
|
-
it
|
|
43
|
+
it 'returns false when created_at is not set' do
|
|
44
44
|
trend_results = Twitter::TrendResults.new(:id => 1)
|
|
45
45
|
expect(trend_results.created?).to be false
|
|
46
46
|
end
|
|
47
47
|
end
|
|
48
48
|
|
|
49
|
-
describe
|
|
49
|
+
describe '#each' do
|
|
50
50
|
before do
|
|
51
51
|
@trend_results = Twitter::TrendResults.new(:trends => [{:id => 1}, {:id => 2}, {:id => 3}, {:id => 4}, {:id => 5}, {:id => 6}])
|
|
52
52
|
end
|
|
53
|
-
it
|
|
53
|
+
it 'iterates' do
|
|
54
54
|
count = 0
|
|
55
|
-
@trend_results.each{count += 1}
|
|
55
|
+
@trend_results.each { count += 1 }
|
|
56
56
|
expect(count).to eq(6)
|
|
57
57
|
end
|
|
58
|
-
context
|
|
59
|
-
it
|
|
58
|
+
context 'with start' do
|
|
59
|
+
it 'iterates' do
|
|
60
60
|
count = 0
|
|
61
|
-
@trend_results.each(5){count += 1}
|
|
61
|
+
@trend_results.each(5) { count += 1 }
|
|
62
62
|
expect(count).to eq(1)
|
|
63
63
|
end
|
|
64
64
|
end
|
|
65
65
|
end
|
|
66
66
|
|
|
67
|
-
describe
|
|
68
|
-
it
|
|
69
|
-
trend_results = Twitter::TrendResults.new(:id => 1, :locations => [{:name =>
|
|
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
70
|
expect(trend_results.location).to be_a Twitter::Place
|
|
71
71
|
end
|
|
72
|
-
it
|
|
72
|
+
it 'returns nil when location is not set' do
|
|
73
73
|
trend_results = Twitter::TrendResults.new(:id => 1)
|
|
74
74
|
expect(trend_results.location).to be_nil
|
|
75
75
|
end
|
|
76
76
|
end
|
|
77
77
|
|
|
78
|
-
describe
|
|
79
|
-
it
|
|
80
|
-
trend_results = Twitter::TrendResults.new(:id => 1, :locations => [{:name =>
|
|
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
81
|
expect(trend_results.location?).to be true
|
|
82
82
|
end
|
|
83
|
-
it
|
|
83
|
+
it 'returns false when location is not set' do
|
|
84
84
|
trend_results = Twitter::TrendResults.new(:id => 1)
|
|
85
85
|
expect(trend_results.location?).to be false
|
|
86
86
|
end
|