twitter 5.1.1 → 5.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data.tar.gz.sig +0 -0
- data/.yardopts +2 -0
- data/CHANGELOG.md +10 -1
- data/CONTRIBUTING.md +2 -2
- data/README.md +30 -20
- data/Rakefile +26 -5
- data/lib/twitter/arguments.rb +0 -1
- data/lib/twitter/base.rb +13 -16
- data/lib/twitter/basic_user.rb +3 -3
- data/lib/twitter/client.rb +7 -8
- data/lib/twitter/configuration.rb +5 -5
- data/lib/twitter/core_ext/enumerable.rb +0 -2
- data/lib/twitter/core_ext/kernel.rb +0 -2
- data/lib/twitter/creatable.rb +0 -1
- data/lib/twitter/cursor.rb +7 -10
- data/lib/twitter/direct_message.rb +1 -1
- data/lib/twitter/entity/uri.rb +2 -2
- data/lib/twitter/enumerable.rb +1 -2
- data/lib/twitter/error.rb +4 -6
- 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/factory.rb +2 -6
- data/lib/twitter/geo.rb +1 -1
- data/lib/twitter/geo/point.rb +3 -5
- 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 +4 -5
- 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 +4 -5
- 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 +13 -14
- data/lib/twitter/rest/api/favorites.rb +10 -11
- data/lib/twitter/rest/api/friends_and_followers.rb +36 -36
- data/lib/twitter/rest/api/help.rb +8 -9
- data/lib/twitter/rest/api/lists.rb +62 -63
- 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 +5 -6
- data/lib/twitter/rest/api/search.rb +2 -3
- 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 +15 -16
- data/lib/twitter/rest/api/undocumented.rb +6 -7
- data/lib/twitter/rest/api/users.rb +51 -52
- data/lib/twitter/rest/api/utils.rb +23 -30
- data/lib/twitter/rest/client.rb +8 -9
- data/lib/twitter/rest/request/multipart_with_file.rb +0 -1
- data/lib/twitter/rest/response/parse_error_json.rb +0 -2
- data/lib/twitter/rest/response/parse_json.rb +0 -2
- data/lib/twitter/rest/response/raise_error.rb +1 -3
- data/lib/twitter/search_results.rb +12 -15
- 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 +71 -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 -7
- 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 +16 -24
- data/lib/twitter/user.rb +30 -32
- data/lib/twitter/version.rb +2 -5
- 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 +27 -27
- data/spec/twitter/direct_message_spec.rb +36 -36
- data/spec/twitter/entity/uri_spec.rb +27 -27
- 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 +54 -54
- data/spec/twitter/media_factory_spec.rb +5 -5
- data/spec/twitter/null_object_spec.rb +6 -6
- data/spec/twitter/oembed_spec.rb +65 -65
- data/spec/twitter/place_spec.rb +89 -60
- 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 +349 -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 +40 -40
- data/spec/twitter/rest/api/search_spec.rb +16 -16
- 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 +284 -284
- 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 +44 -44
- 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 +53 -49
- 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 +20 -20
- data/spec/twitter/tweet_spec.rb +170 -173
- data/spec/twitter/user_spec.rb +179 -179
- data/twitter.gemspec +2 -2
- metadata +21 -4
- metadata.gz.sig +2 -1
|
@@ -2,23 +2,23 @@ require 'helper'
|
|
|
2
2
|
|
|
3
3
|
describe Twitter::Settings do
|
|
4
4
|
|
|
5
|
-
describe
|
|
6
|
-
it
|
|
7
|
-
settings = Twitter::Settings.new(:trend_location => {:countryCode =>
|
|
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
8
|
expect(settings.trend_location).to be_a Twitter::Place
|
|
9
9
|
end
|
|
10
|
-
it
|
|
10
|
+
it 'returns nil when trend_location is not set' do
|
|
11
11
|
settings = Twitter::Settings.new
|
|
12
12
|
expect(settings.trend_location).to be_nil
|
|
13
13
|
end
|
|
14
14
|
end
|
|
15
15
|
|
|
16
|
-
describe
|
|
17
|
-
it
|
|
18
|
-
settings = Twitter::Settings.new(:trend_location => {:countryCode =>
|
|
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
19
|
expect(settings.trend_location?).to be true
|
|
20
20
|
end
|
|
21
|
-
it
|
|
21
|
+
it 'returns false when trend_location is not set' do
|
|
22
22
|
settings = Twitter::Settings.new
|
|
23
23
|
expect(settings.trend_location?).to be false
|
|
24
24
|
end
|
data/spec/twitter/size_spec.rb
CHANGED
|
@@ -2,23 +2,23 @@ require 'helper'
|
|
|
2
2
|
|
|
3
3
|
describe Twitter::Size do
|
|
4
4
|
|
|
5
|
-
describe
|
|
6
|
-
it
|
|
5
|
+
describe '#==' do
|
|
6
|
+
it 'returns true for empty objects' do
|
|
7
7
|
size = Twitter::Size.new
|
|
8
8
|
other = Twitter::Size.new
|
|
9
9
|
expect(size == other).to be true
|
|
10
10
|
end
|
|
11
|
-
it
|
|
11
|
+
it 'returns true when objects height and width are the same' do
|
|
12
12
|
size = Twitter::Size.new(:h => 1, :w => 1, :resize => true)
|
|
13
13
|
other = Twitter::Size.new(:h => 1, :w => 1, :resize => false)
|
|
14
14
|
expect(size == other).to be true
|
|
15
15
|
end
|
|
16
|
-
it
|
|
16
|
+
it 'returns false when objects height or width are different' do
|
|
17
17
|
size = Twitter::Size.new(:h => 1, :w => 1)
|
|
18
18
|
other = Twitter::Size.new(:h => 1, :w => 2)
|
|
19
19
|
expect(size == other).to be false
|
|
20
20
|
end
|
|
21
|
-
it
|
|
21
|
+
it 'returns false when classes are different' do
|
|
22
22
|
size = Twitter::Size.new(:h => 1, :w => 1)
|
|
23
23
|
other = Twitter::Base.new(:h => 1, :w => 1)
|
|
24
24
|
expect(size == other).to be false
|
|
@@ -2,18 +2,18 @@ require 'helper'
|
|
|
2
2
|
|
|
3
3
|
describe Twitter::SourceUser do
|
|
4
4
|
|
|
5
|
-
describe
|
|
6
|
-
it
|
|
7
|
-
saved_search = Twitter::SourceUser.new(:id => 1, :name =>
|
|
8
|
-
other = Twitter::SourceUser.new(:id => 1, :name =>
|
|
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
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::SourceUser.new(:id => 1)
|
|
13
13
|
other = Twitter::SourceUser.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::SourceUser.new(:id => 1)
|
|
18
18
|
other = Twitter::Identity.new(:id => 1)
|
|
19
19
|
expect(saved_search == other).to be false
|
|
@@ -17,76 +17,80 @@ describe Twitter::Streaming::Client do
|
|
|
17
17
|
end
|
|
18
18
|
end
|
|
19
19
|
|
|
20
|
-
it
|
|
21
|
-
@client.connection = FakeConnection.new(fixture(
|
|
20
|
+
it '#before_request' do
|
|
21
|
+
@client.connection = FakeConnection.new(fixture('track_streaming.json'))
|
|
22
22
|
var = false
|
|
23
23
|
@client.before_request do
|
|
24
24
|
var = true
|
|
25
25
|
end
|
|
26
26
|
expect(var).to be false
|
|
27
|
-
@client.user{}
|
|
27
|
+
@client.user {}
|
|
28
28
|
expect(var).to be true
|
|
29
29
|
end
|
|
30
30
|
|
|
31
|
-
it
|
|
32
|
-
@client.connection = FakeConnection.new(fixture(
|
|
33
|
-
|
|
34
|
-
@client.filter(:track =>
|
|
35
|
-
|
|
31
|
+
it '#filter' do
|
|
32
|
+
@client.connection = FakeConnection.new(fixture('track_streaming.json'))
|
|
33
|
+
objects = []
|
|
34
|
+
@client.filter(:track => 'india') do |object|
|
|
35
|
+
objects << object
|
|
36
36
|
end
|
|
37
|
-
expect(
|
|
38
|
-
expect(
|
|
39
|
-
expect(
|
|
37
|
+
expect(objects.size).to eq(2)
|
|
38
|
+
expect(objects.first).to be_a Twitter::Tweet
|
|
39
|
+
expect(objects.first.text).to eq "The problem with your code is that it's doing exactly what you told it to do."
|
|
40
40
|
end
|
|
41
41
|
|
|
42
|
-
it
|
|
43
|
-
@client.connection = FakeConnection.new(fixture(
|
|
44
|
-
|
|
45
|
-
@client.firehose do |
|
|
46
|
-
|
|
42
|
+
it '#firehose' do
|
|
43
|
+
@client.connection = FakeConnection.new(fixture('track_streaming.json'))
|
|
44
|
+
objects = []
|
|
45
|
+
@client.firehose do |object|
|
|
46
|
+
objects << object
|
|
47
47
|
end
|
|
48
|
-
expect(
|
|
49
|
-
expect(
|
|
50
|
-
expect(
|
|
48
|
+
expect(objects.size).to eq(2)
|
|
49
|
+
expect(objects.first).to be_a Twitter::Tweet
|
|
50
|
+
expect(objects.first.text).to eq "The problem with your code is that it's doing exactly what you told it to do."
|
|
51
51
|
end
|
|
52
52
|
|
|
53
|
-
it
|
|
54
|
-
@client.connection = FakeConnection.new(fixture(
|
|
55
|
-
|
|
56
|
-
@client.sample do |
|
|
57
|
-
|
|
53
|
+
it '#sample' do
|
|
54
|
+
@client.connection = FakeConnection.new(fixture('track_streaming.json'))
|
|
55
|
+
objects = []
|
|
56
|
+
@client.sample do |object|
|
|
57
|
+
objects << object
|
|
58
58
|
end
|
|
59
|
-
expect(
|
|
60
|
-
expect(
|
|
61
|
-
expect(
|
|
59
|
+
expect(objects.size).to eq(2)
|
|
60
|
+
expect(objects.first).to be_a Twitter::Tweet
|
|
61
|
+
expect(objects.first.text).to eq "The problem with your code is that it's doing exactly what you told it to do."
|
|
62
62
|
end
|
|
63
63
|
|
|
64
|
-
it
|
|
65
|
-
@client.connection = FakeConnection.new(fixture(
|
|
66
|
-
|
|
67
|
-
@client.site(
|
|
68
|
-
|
|
64
|
+
it '#site' do
|
|
65
|
+
@client.connection = FakeConnection.new(fixture('track_streaming.json'))
|
|
66
|
+
objects = []
|
|
67
|
+
@client.site(7_505_382) do |object|
|
|
68
|
+
objects << object
|
|
69
69
|
end
|
|
70
|
-
expect(
|
|
71
|
-
expect(
|
|
72
|
-
expect(
|
|
70
|
+
expect(objects.size).to eq(2)
|
|
71
|
+
expect(objects.first).to be_a Twitter::Tweet
|
|
72
|
+
expect(objects.first.text).to eq "The problem with your code is that it's doing exactly what you told it to do."
|
|
73
73
|
end
|
|
74
74
|
|
|
75
|
-
it
|
|
76
|
-
@client.connection = FakeConnection.new(fixture(
|
|
77
|
-
|
|
78
|
-
@client.user do |
|
|
79
|
-
|
|
75
|
+
it '#user' do
|
|
76
|
+
@client.connection = FakeConnection.new(fixture('track_streaming_user.json'))
|
|
77
|
+
objects = []
|
|
78
|
+
@client.user do |object|
|
|
79
|
+
objects << object
|
|
80
80
|
end
|
|
81
|
-
expect(
|
|
82
|
-
expect(
|
|
83
|
-
expect(
|
|
84
|
-
expect(
|
|
85
|
-
expect(
|
|
86
|
-
expect(
|
|
87
|
-
expect(
|
|
88
|
-
expect(
|
|
89
|
-
expect(
|
|
81
|
+
expect(objects.size).to eq(6)
|
|
82
|
+
expect(objects[0]).to be_a Twitter::Streaming::FriendList
|
|
83
|
+
expect(objects[0]).to eq([488_736_931, 311_444_249])
|
|
84
|
+
expect(objects[1]).to be_a Twitter::Tweet
|
|
85
|
+
expect(objects[1].text).to eq("The problem with your code is that it's doing exactly what you told it to do.")
|
|
86
|
+
expect(objects[2]).to be_a Twitter::DirectMessage
|
|
87
|
+
expect(objects[2].text).to eq('hello bot')
|
|
88
|
+
expect(objects[3]).to be_a Twitter::Streaming::Event
|
|
89
|
+
expect(objects[3].name).to eq(:follow)
|
|
90
|
+
expect(objects[4]).to be_a Twitter::Streaming::DeletedTweet
|
|
91
|
+
expect(objects[4].id).to eq(272_691_609_211_117_568)
|
|
92
|
+
expect(objects[5]).to be_a Twitter::Streaming::StallWarning
|
|
93
|
+
expect(objects[5].code).to eq('FALLING_BEHIND')
|
|
90
94
|
end
|
|
91
95
|
|
|
92
96
|
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
|