twitter 5.1.1 → 5.2.0
Sign up to get free protection for your applications and to get access to all the features.
- 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,13 +2,13 @@ require 'helper'
|
|
2
2
|
|
3
3
|
describe Twitter::Configuration do
|
4
4
|
|
5
|
-
describe
|
6
|
-
it
|
7
|
-
photo_sizes = Twitter::Configuration.new(:photo_sizes => {:small => {:h => 226, :w => 340, :resize =>
|
5
|
+
describe '#photo_sizes' do
|
6
|
+
it 'returns a hash of sizes when photo_sizes is set' do
|
7
|
+
photo_sizes = Twitter::Configuration.new(:photo_sizes => {:small => {:h => 226, :w => 340, :resize => 'fit'}, :large => {:h => 466, :w => 700, :resize => 'fit'}, :medium => {:h => 399, :w => 600, :resize => 'fit'}, :thumb => {:h => 150, :w => 150, :resize => 'crop'}}).photo_sizes
|
8
8
|
expect(photo_sizes).to be_a Hash
|
9
9
|
expect(photo_sizes[:small]).to be_a Twitter::Size
|
10
10
|
end
|
11
|
-
it
|
11
|
+
it 'is empty when photo_sizes is not set' do
|
12
12
|
photo_sizes = Twitter::Configuration.new.photo_sizes
|
13
13
|
expect(photo_sizes).to be_empty
|
14
14
|
end
|
data/spec/twitter/cursor_spec.rb
CHANGED
@@ -2,64 +2,64 @@ require 'helper'
|
|
2
2
|
|
3
3
|
describe Twitter::Cursor do
|
4
4
|
|
5
|
-
describe
|
5
|
+
describe '#each' do
|
6
6
|
before do
|
7
|
-
@client = Twitter::REST::Client.new(:consumer_key =>
|
8
|
-
stub_get(
|
9
|
-
stub_get(
|
7
|
+
@client = Twitter::REST::Client.new(:consumer_key => 'CK', :consumer_secret => 'CS', :access_token => 'AT', :access_token_secret => 'AS')
|
8
|
+
stub_get('/1.1/followers/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'}).to_return(:body => fixture('ids_list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
9
|
+
stub_get('/1.1/followers/ids.json').with(:query => {:cursor => '1305102810874389703', :screen_name => 'sferik'}).to_return(:body => fixture('ids_list2.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
10
10
|
end
|
11
|
-
it
|
12
|
-
@client.follower_ids(
|
13
|
-
expect(a_get(
|
14
|
-
expect(a_get(
|
11
|
+
it 'requests the correct resources' do
|
12
|
+
@client.follower_ids('sferik').each {}
|
13
|
+
expect(a_get('/1.1/followers/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'})).to have_been_made
|
14
|
+
expect(a_get('/1.1/followers/ids.json').with(:query => {:cursor => '1305102810874389703', :screen_name => 'sferik'})).to have_been_made
|
15
15
|
end
|
16
|
-
it
|
16
|
+
it 'iterates' do
|
17
17
|
count = 0
|
18
|
-
@client.follower_ids(
|
18
|
+
@client.follower_ids('sferik').each { count += 1 }
|
19
19
|
expect(count).to eq(6)
|
20
20
|
end
|
21
|
-
context
|
22
|
-
it
|
21
|
+
context 'with start' do
|
22
|
+
it 'iterates' do
|
23
23
|
count = 0
|
24
|
-
@client.follower_ids(
|
24
|
+
@client.follower_ids('sferik').each(5) { count += 1 }
|
25
25
|
expect(count).to eq(1)
|
26
26
|
end
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
-
describe
|
31
|
-
context
|
30
|
+
describe '#first?' do
|
31
|
+
context 'when previous cursor equals zero' do
|
32
32
|
before do
|
33
|
-
@cursor = Twitter::Cursor.new({:previous_cursor => 0}, :ids, nil, Twitter::REST::Client.new, :get,
|
33
|
+
@cursor = Twitter::Cursor.new({:previous_cursor => 0}, :ids, nil, Twitter::REST::Client.new, :get, '/1.1/followers/ids.json', {})
|
34
34
|
end
|
35
|
-
it
|
35
|
+
it 'returns true' do
|
36
36
|
expect(@cursor.first?).to be true
|
37
37
|
end
|
38
38
|
end
|
39
|
-
context
|
39
|
+
context 'when previous cursor does not equal zero' do
|
40
40
|
before do
|
41
|
-
@cursor = Twitter::Cursor.new({:previous_cursor => 1}, :ids, nil, Twitter::REST::Client.new, :get,
|
41
|
+
@cursor = Twitter::Cursor.new({:previous_cursor => 1}, :ids, nil, Twitter::REST::Client.new, :get, '/1.1/followers/ids.json', {})
|
42
42
|
end
|
43
|
-
it
|
43
|
+
it 'returns true' do
|
44
44
|
expect(@cursor.first?).to be false
|
45
45
|
end
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
|
-
describe
|
50
|
-
context
|
49
|
+
describe '#last?' do
|
50
|
+
context 'when next cursor equals zero' do
|
51
51
|
before do
|
52
|
-
@cursor = Twitter::Cursor.new({:next_cursor => 0}, :ids, nil, Twitter::REST::Client.new, :get,
|
52
|
+
@cursor = Twitter::Cursor.new({:next_cursor => 0}, :ids, nil, Twitter::REST::Client.new, :get, '/1.1/followers/ids.json', {})
|
53
53
|
end
|
54
|
-
it
|
54
|
+
it 'returns true' do
|
55
55
|
expect(@cursor.last?).to be true
|
56
56
|
end
|
57
57
|
end
|
58
|
-
context
|
58
|
+
context 'when next cursor does not equal zero' do
|
59
59
|
before do
|
60
|
-
@cursor = Twitter::Cursor.new({:next_cursor => 1}, :ids, nil, Twitter::REST::Client.new, :get,
|
60
|
+
@cursor = Twitter::Cursor.new({:next_cursor => 1}, :ids, nil, Twitter::REST::Client.new, :get, '/1.1/followers/ids.json', {})
|
61
61
|
end
|
62
|
-
it
|
62
|
+
it 'returns false' do
|
63
63
|
expect(@cursor.last?).to be false
|
64
64
|
end
|
65
65
|
end
|
@@ -2,86 +2,86 @@ require 'helper'
|
|
2
2
|
|
3
3
|
describe Twitter::DirectMessage do
|
4
4
|
|
5
|
-
describe
|
6
|
-
it
|
7
|
-
direct_message = Twitter::DirectMessage.new(:id => 1, :text =>
|
8
|
-
other = Twitter::DirectMessage.new(:id => 1, :text =>
|
5
|
+
describe '#==' do
|
6
|
+
it 'returns true when objects IDs are the same' do
|
7
|
+
direct_message = Twitter::DirectMessage.new(:id => 1, :text => 'foo')
|
8
|
+
other = Twitter::DirectMessage.new(:id => 1, :text => 'bar')
|
9
9
|
expect(direct_message == other).to be true
|
10
10
|
end
|
11
|
-
it
|
11
|
+
it 'returns false when objects IDs are different' do
|
12
12
|
direct_message = Twitter::DirectMessage.new(:id => 1)
|
13
13
|
other = Twitter::DirectMessage.new(:id => 2)
|
14
14
|
expect(direct_message == other).to be false
|
15
15
|
end
|
16
|
-
it
|
16
|
+
it 'returns false when classes are different' do
|
17
17
|
direct_message = Twitter::DirectMessage.new(:id => 1)
|
18
18
|
other = Twitter::Identity.new(:id => 1)
|
19
19
|
expect(direct_message == other).to be false
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
describe
|
24
|
-
it
|
25
|
-
direct_message = Twitter::DirectMessage.new(:id =>
|
23
|
+
describe '#created_at' do
|
24
|
+
it 'returns a Time when created_at is set' do
|
25
|
+
direct_message = Twitter::DirectMessage.new(:id => 1_825_786_345, :created_at => 'Mon Jul 16 12:59:01 +0000 2007')
|
26
26
|
expect(direct_message.created_at).to be_a Time
|
27
27
|
end
|
28
|
-
it
|
29
|
-
direct_message = Twitter::DirectMessage.new(:id =>
|
28
|
+
it 'returns nil when created_at is not set' do
|
29
|
+
direct_message = Twitter::DirectMessage.new(:id => 1_825_786_345)
|
30
30
|
expect(direct_message.created_at).to be_nil
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
-
describe
|
35
|
-
it
|
36
|
-
direct_message = Twitter::DirectMessage.new(:id =>
|
34
|
+
describe '#created?' do
|
35
|
+
it 'returns true when created_at is set' do
|
36
|
+
direct_message = Twitter::DirectMessage.new(:id => 1_825_786_345, :created_at => 'Mon Jul 16 12:59:01 +0000 2007')
|
37
37
|
expect(direct_message.created?).to be true
|
38
38
|
end
|
39
|
-
it
|
40
|
-
direct_message = Twitter::DirectMessage.new(:id =>
|
39
|
+
it 'returns false when created_at is not set' do
|
40
|
+
direct_message = Twitter::DirectMessage.new(:id => 1_825_786_345)
|
41
41
|
expect(direct_message.created?).to be false
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
-
describe
|
46
|
-
it
|
47
|
-
direct_message = Twitter::DirectMessage.new(:id =>
|
45
|
+
describe '#recipient' do
|
46
|
+
it 'returns a User when recipient is set' do
|
47
|
+
direct_message = Twitter::DirectMessage.new(:id => 1_825_786_345, :recipient => {:id => 7_505_382})
|
48
48
|
expect(direct_message.recipient).to be_a Twitter::User
|
49
49
|
end
|
50
|
-
it
|
51
|
-
direct_message = Twitter::DirectMessage.new(:id =>
|
50
|
+
it 'returns nil when recipient is not set' do
|
51
|
+
direct_message = Twitter::DirectMessage.new(:id => 1_825_786_345)
|
52
52
|
expect(direct_message.recipient).to be_nil
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
|
-
describe
|
57
|
-
it
|
58
|
-
direct_message = Twitter::DirectMessage.new(:id =>
|
56
|
+
describe '#recipient?' do
|
57
|
+
it 'returns true when recipient is set' do
|
58
|
+
direct_message = Twitter::DirectMessage.new(:id => 1_825_786_345, :recipient => {:id => 7_505_382})
|
59
59
|
expect(direct_message.recipient?).to be true
|
60
60
|
end
|
61
|
-
it
|
62
|
-
direct_message = Twitter::DirectMessage.new(:id =>
|
61
|
+
it 'returns false when recipient is not set' do
|
62
|
+
direct_message = Twitter::DirectMessage.new(:id => 1_825_786_345)
|
63
63
|
expect(direct_message.recipient?).to be false
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
|
-
describe
|
68
|
-
it
|
69
|
-
direct_message = Twitter::DirectMessage.new(:id =>
|
67
|
+
describe '#sender' do
|
68
|
+
it 'returns a User when sender is set' do
|
69
|
+
direct_message = Twitter::DirectMessage.new(:id => 1_825_786_345, :sender => {:id => 7_505_382})
|
70
70
|
expect(direct_message.sender).to be_a Twitter::User
|
71
71
|
end
|
72
|
-
it
|
73
|
-
direct_message = Twitter::DirectMessage.new(:id =>
|
72
|
+
it 'returns nil when sender is not set' do
|
73
|
+
direct_message = Twitter::DirectMessage.new(:id => 1_825_786_345)
|
74
74
|
expect(direct_message.sender).to be_nil
|
75
75
|
end
|
76
76
|
end
|
77
77
|
|
78
|
-
describe
|
79
|
-
it
|
80
|
-
direct_message = Twitter::DirectMessage.new(:id =>
|
78
|
+
describe '#sender?' do
|
79
|
+
it 'returns true when sender is set' do
|
80
|
+
direct_message = Twitter::DirectMessage.new(:id => 1_825_786_345, :sender => {:id => 7_505_382})
|
81
81
|
expect(direct_message.sender?).to be true
|
82
82
|
end
|
83
|
-
it
|
84
|
-
direct_message = Twitter::DirectMessage.new(:id =>
|
83
|
+
it 'returns false when sender is not set' do
|
84
|
+
direct_message = Twitter::DirectMessage.new(:id => 1_825_786_345)
|
85
85
|
expect(direct_message.sender?).to be false
|
86
86
|
end
|
87
87
|
end
|
@@ -3,70 +3,70 @@ require 'helper'
|
|
3
3
|
|
4
4
|
describe Twitter::Entity::URI do
|
5
5
|
|
6
|
-
describe
|
7
|
-
it
|
8
|
-
uri = Twitter::Entity::URI.new(:display_url =>
|
6
|
+
describe '#display_uri' do
|
7
|
+
it 'returns a String when the display_url is set' do
|
8
|
+
uri = Twitter::Entity::URI.new(:display_url => 'example.com/expanded…')
|
9
9
|
expect(uri.display_uri).to be_a String
|
10
|
-
expect(uri.display_uri).to eq(
|
10
|
+
expect(uri.display_uri).to eq('example.com/expanded…')
|
11
11
|
end
|
12
|
-
it
|
12
|
+
it 'returns nil when the display_url is not set' do
|
13
13
|
uri = Twitter::Entity::URI.new
|
14
14
|
expect(uri.display_uri).to be_nil
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
-
describe
|
19
|
-
it
|
20
|
-
uri = Twitter::Entity::URI.new(:display_url =>
|
18
|
+
describe '#display_uri?' do
|
19
|
+
it 'returns true when the display_url is set' do
|
20
|
+
uri = Twitter::Entity::URI.new(:display_url => 'example.com/expanded…')
|
21
21
|
expect(uri.display_uri?).to be true
|
22
22
|
end
|
23
|
-
it
|
23
|
+
it 'returns false when the display_url is not set' do
|
24
24
|
uri = Twitter::Entity::URI.new
|
25
25
|
expect(uri.display_uri?).to be false
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
-
describe
|
30
|
-
it
|
31
|
-
uri = Twitter::Entity::URI.new(:expanded_url =>
|
29
|
+
describe '#expanded_uri' do
|
30
|
+
it 'returns a URI when the expanded_url is set' do
|
31
|
+
uri = Twitter::Entity::URI.new(:expanded_url => 'https://github.com/sferik')
|
32
32
|
expect(uri.expanded_uri).to be_a Addressable::URI
|
33
|
-
expect(uri.expanded_uri.to_s).to eq(
|
33
|
+
expect(uri.expanded_uri.to_s).to eq('https://github.com/sferik')
|
34
34
|
end
|
35
|
-
it
|
35
|
+
it 'returns nil when the expanded_url is not set' do
|
36
36
|
uri = Twitter::Entity::URI.new
|
37
37
|
expect(uri.expanded_uri).to be_nil
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
|
-
describe
|
42
|
-
it
|
43
|
-
uri = Twitter::Entity::URI.new(:expanded_url =>
|
41
|
+
describe '#expanded_uri?' do
|
42
|
+
it 'returns true when the expanded_url is set' do
|
43
|
+
uri = Twitter::Entity::URI.new(:expanded_url => 'https://github.com/sferik')
|
44
44
|
expect(uri.expanded_uri?).to be true
|
45
45
|
end
|
46
|
-
it
|
46
|
+
it 'returns false when the expanded_url is not set' do
|
47
47
|
uri = Twitter::Entity::URI.new
|
48
48
|
expect(uri.expanded_uri?).to be false
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
|
-
describe
|
53
|
-
it
|
54
|
-
uri = Twitter::Entity::URI.new(:url =>
|
52
|
+
describe '#uri' do
|
53
|
+
it 'returns a URI when the url is set' do
|
54
|
+
uri = Twitter::Entity::URI.new(:url => 'https://github.com/sferik')
|
55
55
|
expect(uri.uri).to be_a Addressable::URI
|
56
|
-
expect(uri.uri.to_s).to eq(
|
56
|
+
expect(uri.uri.to_s).to eq('https://github.com/sferik')
|
57
57
|
end
|
58
|
-
it
|
58
|
+
it 'returns nil when the url is not set' do
|
59
59
|
uri = Twitter::Entity::URI.new
|
60
60
|
expect(uri.uri).to be_nil
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
64
|
-
describe
|
65
|
-
it
|
66
|
-
uri = Twitter::Entity::URI.new(:url =>
|
64
|
+
describe '#uri?' do
|
65
|
+
it 'returns true when the url is set' do
|
66
|
+
uri = Twitter::Entity::URI.new(:url => 'https://github.com/sferik')
|
67
67
|
expect(uri.uri?).to be true
|
68
68
|
end
|
69
|
-
it
|
69
|
+
it 'returns false when the url is not set' do
|
70
70
|
uri = Twitter::Entity::URI.new
|
71
71
|
expect(uri.uri?).to be false
|
72
72
|
end
|
data/spec/twitter/error_spec.rb
CHANGED
@@ -3,61 +3,61 @@ require 'helper'
|
|
3
3
|
describe Twitter::Error do
|
4
4
|
|
5
5
|
before do
|
6
|
-
@client = Twitter::REST::Client.new(:consumer_key =>
|
6
|
+
@client = Twitter::REST::Client.new(:consumer_key => 'CK', :consumer_secret => 'CS', :access_token => 'AT', :access_token_secret => 'AS')
|
7
7
|
end
|
8
8
|
|
9
|
-
describe
|
10
|
-
it
|
11
|
-
error = Twitter::Error.new(Faraday::Error::ClientError.new(
|
12
|
-
expect(error.message).to eq(
|
9
|
+
describe '#message' do
|
10
|
+
it 'returns the message of the wrapped exception' do
|
11
|
+
error = Twitter::Error.new(Faraday::Error::ClientError.new('Oops'))
|
12
|
+
expect(error.message).to eq('Oops')
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
-
describe
|
17
|
-
it
|
18
|
-
error = Twitter::Error.new(Faraday::Error::ClientError.new(
|
16
|
+
describe '#rate_limit' do
|
17
|
+
it 'returns the wrapped exception' do
|
18
|
+
error = Twitter::Error.new(Faraday::Error::ClientError.new('Oops'))
|
19
19
|
expect(error.rate_limit).to be_a Twitter::RateLimit
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
describe
|
24
|
-
it
|
25
|
-
error = Twitter::Error.new(Faraday::Error::ClientError.new(
|
23
|
+
describe '#wrapped_exception' do
|
24
|
+
it 'returns the wrapped exception' do
|
25
|
+
error = Twitter::Error.new(Faraday::Error::ClientError.new('Oops'))
|
26
26
|
expect(error.wrapped_exception.class).to eq(Faraday::Error::ClientError)
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
30
|
Twitter::Error.errors.each do |status, exception|
|
31
31
|
|
32
|
-
[nil,
|
32
|
+
[nil, 'error', 'errors'].each do |body|
|
33
33
|
context "when HTTP status is #{status} and body is #{body.inspect}" do
|
34
34
|
before do
|
35
35
|
body_message = '{"' + body + '":"Client Error"}' unless body.nil?
|
36
|
-
stub_get(
|
36
|
+
stub_get('/1.1/statuses/user_timeline.json').with(:query => {:screen_name => 'sferik'}).to_return(:status => status, :body => body_message)
|
37
37
|
end
|
38
38
|
it "raises #{exception.name}" do
|
39
|
-
expect{@client.user_timeline(
|
39
|
+
expect { @client.user_timeline('sferik') }.to raise_error exception
|
40
40
|
end
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
44
|
context "when HTTP status is #{status} and body is errors" do
|
45
|
-
context
|
46
|
-
context
|
45
|
+
context 'when errors is an array of hashes' do
|
46
|
+
context 'when error code is nil' do
|
47
47
|
before do
|
48
48
|
body_message = '{"errors":[{"message":"Client Error"}]}'
|
49
|
-
stub_get(
|
49
|
+
stub_get('/1.1/statuses/user_timeline.json').with(:query => {:screen_name => 'sferik'}).to_return(:status => status, :body => body_message)
|
50
50
|
end
|
51
51
|
it "raises #{exception.name}" do
|
52
|
-
expect{@client.user_timeline(
|
52
|
+
expect { @client.user_timeline('sferik') }.to raise_error { |error| expect(error.code).to be_nil }
|
53
53
|
end
|
54
|
-
context
|
54
|
+
context 'when error code is 187' do
|
55
55
|
before do
|
56
56
|
body_message = '{"errors":[{"message":"Client Error","code":187}]}'
|
57
|
-
stub_get(
|
57
|
+
stub_get('/1.1/statuses/user_timeline.json').with(:query => {:screen_name => 'sferik'}).to_return(:status => status, :body => body_message)
|
58
58
|
end
|
59
59
|
it "raises #{exception.name}" do
|
60
|
-
expect{@client.user_timeline(
|
60
|
+
expect { @client.user_timeline('sferik') }.to raise_error { |error| expect(error.code).to eq(187) }
|
61
61
|
end
|
62
62
|
end
|
63
63
|
end
|
@@ -6,34 +6,34 @@ describe Twitter::Geo::Point do
|
|
6
6
|
@point = Twitter::Geo::Point.new(:coordinates => [-122.399983, 37.788299])
|
7
7
|
end
|
8
8
|
|
9
|
-
describe
|
10
|
-
it
|
9
|
+
describe '#==' do
|
10
|
+
it 'returns true for empty objects' do
|
11
11
|
point = Twitter::Geo::Point.new
|
12
12
|
other = Twitter::Geo::Point.new
|
13
13
|
expect(point == other).to be true
|
14
14
|
end
|
15
|
-
it
|
15
|
+
it 'returns true when objects coordinates are the same' do
|
16
16
|
other = Twitter::Geo::Point.new(:coordinates => [-122.399983, 37.788299])
|
17
17
|
expect(@point == other).to be true
|
18
18
|
end
|
19
|
-
it
|
19
|
+
it 'returns false when objects coordinates are different' do
|
20
20
|
other = Twitter::Geo::Point.new(:coordinates => [37.788299, -122.399983])
|
21
21
|
expect(@point == other).to be false
|
22
22
|
end
|
23
|
-
it
|
23
|
+
it 'returns false when classes are different' do
|
24
24
|
other = Twitter::Geo.new(:coordinates => [-122.399983, 37.788299])
|
25
25
|
expect(@point == other).to be false
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
-
describe
|
30
|
-
it
|
29
|
+
describe '#latitude' do
|
30
|
+
it 'returns the latitude' do
|
31
31
|
expect(@point.latitude).to eq(-122.399983)
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
-
describe
|
36
|
-
it
|
35
|
+
describe '#longitude' do
|
36
|
+
it 'returns the longitude' do
|
37
37
|
expect(@point.longitude).to eq(37.788299)
|
38
38
|
end
|
39
39
|
end
|