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
@@ -6,21 +6,21 @@ describe Twitter::Geo::Polygon do
|
|
6
6
|
@polygon = Twitter::Geo::Polygon.new(:coordinates => [[[-122.40348192, 37.77752898], [-122.387436, 37.77752898], [-122.387436, 37.79448597], [-122.40348192, 37.79448597]]])
|
7
7
|
end
|
8
8
|
|
9
|
-
describe
|
10
|
-
it
|
9
|
+
describe '#==' do
|
10
|
+
it 'returns true for empty objects' do
|
11
11
|
polygon = Twitter::Geo::Polygon.new
|
12
12
|
other = Twitter::Geo::Polygon.new
|
13
13
|
expect(polygon == 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::Polygon.new(:coordinates => [[[-122.40348192, 37.77752898], [-122.387436, 37.77752898], [-122.387436, 37.79448597], [-122.40348192, 37.79448597]]])
|
17
17
|
expect(@polygon == other).to be true
|
18
18
|
end
|
19
|
-
it
|
19
|
+
it 'returns false when objects coordinates are different' do
|
20
20
|
other = Twitter::Geo::Polygon.new(:coordinates => [[[37.77752898, -122.40348192], [37.77752898, -122.387436], [37.79448597, -122.387436], [37.79448597, -122.40348192]]])
|
21
21
|
expect(@polygon == 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.40348192, 37.77752898], [-122.387436, 37.77752898], [-122.387436, 37.79448597], [-122.40348192, 37.79448597]]])
|
25
25
|
expect(@polygon == other).to be false
|
26
26
|
end
|
@@ -2,17 +2,17 @@ require 'helper'
|
|
2
2
|
|
3
3
|
describe Twitter::GeoFactory do
|
4
4
|
|
5
|
-
describe
|
6
|
-
it
|
7
|
-
geo = Twitter::GeoFactory.new(:type =>
|
5
|
+
describe '.new' do
|
6
|
+
it 'generates a Point' do
|
7
|
+
geo = Twitter::GeoFactory.new(:type => 'Point')
|
8
8
|
expect(geo).to be_a Twitter::Geo::Point
|
9
9
|
end
|
10
|
-
it
|
11
|
-
geo = Twitter::GeoFactory.new(:type =>
|
10
|
+
it 'generates a Polygon' do
|
11
|
+
geo = Twitter::GeoFactory.new(:type => 'Polygon')
|
12
12
|
expect(geo).to be_a Twitter::Geo::Polygon
|
13
13
|
end
|
14
|
-
it
|
15
|
-
expect{Twitter::GeoFactory.new}.to raise_error IndexError
|
14
|
+
it 'raises an IndexError when type is not specified' do
|
15
|
+
expect { Twitter::GeoFactory.new }.to raise_error IndexError
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
@@ -2,31 +2,31 @@ require 'helper'
|
|
2
2
|
|
3
3
|
describe Twitter::GeoResults do
|
4
4
|
|
5
|
-
describe
|
5
|
+
describe '#each' do
|
6
6
|
before do
|
7
7
|
@geo_results = Twitter::GeoResults.new(:result => {:places => [{:id => 1}, {:id => 2}, {:id => 3}, {:id => 4}, {:id => 5}, {:id => 6}]})
|
8
8
|
end
|
9
|
-
it
|
9
|
+
it 'iterates' do
|
10
10
|
count = 0
|
11
|
-
@geo_results.each{count += 1}
|
11
|
+
@geo_results.each { count += 1 }
|
12
12
|
expect(count).to eq(6)
|
13
13
|
end
|
14
|
-
context
|
15
|
-
it
|
14
|
+
context 'with start' do
|
15
|
+
it 'iterates' do
|
16
16
|
count = 0
|
17
|
-
@geo_results.each(5){count += 1}
|
17
|
+
@geo_results.each(5) { count += 1 }
|
18
18
|
expect(count).to eq(1)
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
describe
|
24
|
-
it
|
25
|
-
geo_results = Twitter::GeoResults.new(:result => {}, :token =>
|
23
|
+
describe '#token' do
|
24
|
+
it 'returns a String when token is set' do
|
25
|
+
geo_results = Twitter::GeoResults.new(:result => {}, :token => 'abc123')
|
26
26
|
expect(geo_results.token).to be_a String
|
27
|
-
expect(geo_results.token).to eq(
|
27
|
+
expect(geo_results.token).to eq('abc123')
|
28
28
|
end
|
29
|
-
it
|
29
|
+
it 'returns nil when token is not set' do
|
30
30
|
geo_results = Twitter::GeoResults.new(:result => {})
|
31
31
|
expect(geo_results.token).to be_nil
|
32
32
|
end
|
data/spec/twitter/geo_spec.rb
CHANGED
@@ -6,21 +6,21 @@ describe Twitter::Geo do
|
|
6
6
|
@geo = Twitter::Geo.new(:coordinates => [[[-122.40348192, 37.77752898], [-122.387436, 37.77752898], [-122.387436, 37.79448597], [-122.40348192, 37.79448597]]])
|
7
7
|
end
|
8
8
|
|
9
|
-
describe
|
10
|
-
it
|
9
|
+
describe '#==' do
|
10
|
+
it 'returns true for empty objects' do
|
11
11
|
geo = Twitter::Geo.new
|
12
12
|
other = Twitter::Geo.new
|
13
13
|
expect(geo == 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.new(:coordinates => [[[-122.40348192, 37.77752898], [-122.387436, 37.77752898], [-122.387436, 37.79448597], [-122.40348192, 37.79448597]]])
|
17
17
|
expect(@geo == other).to be true
|
18
18
|
end
|
19
|
-
it
|
19
|
+
it 'returns false when objects coordinates are different' do
|
20
20
|
other = Twitter::Geo.new(:coordinates => [[[37.77752898, -122.40348192], [37.77752898, -122.387436], [37.79448597, -122.387436], [37.79448597, -122.40348192]]])
|
21
21
|
expect(@geo == other).to be false
|
22
22
|
end
|
23
|
-
it
|
23
|
+
it 'returns true when classes are different' do
|
24
24
|
other = Twitter::Geo::Polygon.new(:coordinates => [[[-122.40348192, 37.77752898], [-122.387436, 37.77752898], [-122.387436, 37.79448597], [-122.40348192, 37.79448597]]])
|
25
25
|
expect(@geo == other).to be true
|
26
26
|
end
|
@@ -2,24 +2,24 @@ require 'helper'
|
|
2
2
|
|
3
3
|
describe Twitter::Identity do
|
4
4
|
|
5
|
-
describe
|
6
|
-
it
|
7
|
-
expect{Twitter::Identity.new}.to raise_error IndexError
|
5
|
+
describe '#initialize' do
|
6
|
+
it 'raises an IndexError when id is not specified' do
|
7
|
+
expect { Twitter::Identity.new }.to raise_error IndexError
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
|
-
describe
|
12
|
-
it
|
13
|
-
one = Twitter::Identity.new(:id => 1, :screen_name =>
|
14
|
-
two = Twitter::Identity.new(:id => 1, :screen_name =>
|
11
|
+
describe '#==' do
|
12
|
+
it 'returns true when objects IDs are the same' do
|
13
|
+
one = Twitter::Identity.new(:id => 1, :screen_name => 'sferik')
|
14
|
+
two = Twitter::Identity.new(:id => 1, :screen_name => 'garybernhardt')
|
15
15
|
expect(one == two).to be true
|
16
16
|
end
|
17
|
-
it
|
17
|
+
it 'returns false when objects IDs are different' do
|
18
18
|
one = Twitter::Identity.new(:id => 1)
|
19
19
|
two = Twitter::Identity.new(:id => 2)
|
20
20
|
expect(one == two).to be false
|
21
21
|
end
|
22
|
-
it
|
22
|
+
it 'returns false when classes are different' do
|
23
23
|
one = Twitter::Identity.new(:id => 1)
|
24
24
|
two = Twitter::Base.new(:id => 1)
|
25
25
|
expect(one == two).to be false
|
data/spec/twitter/list_spec.rb
CHANGED
@@ -2,85 +2,85 @@ require 'helper'
|
|
2
2
|
|
3
3
|
describe Twitter::List do
|
4
4
|
|
5
|
-
describe
|
6
|
-
it
|
7
|
-
list = Twitter::List.new(:id => 1, :slug =>
|
8
|
-
other = Twitter::List.new(:id => 1, :slug =>
|
5
|
+
describe '#==' do
|
6
|
+
it 'returns true when objects IDs are the same' do
|
7
|
+
list = Twitter::List.new(:id => 1, :slug => 'foo')
|
8
|
+
other = Twitter::List.new(:id => 1, :slug => 'bar')
|
9
9
|
expect(list == other).to be true
|
10
10
|
end
|
11
|
-
it
|
11
|
+
it 'returns false when objects IDs are different' do
|
12
12
|
list = Twitter::List.new(:id => 1)
|
13
13
|
other = Twitter::List.new(:id => 2)
|
14
14
|
expect(list == other).to be false
|
15
15
|
end
|
16
|
-
it
|
16
|
+
it 'returns false when classes are different' do
|
17
17
|
list = Twitter::List.new(:id => 1)
|
18
18
|
other = Twitter::Identity.new(:id => 1)
|
19
19
|
expect(list == other).to be false
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
describe
|
24
|
-
it
|
25
|
-
list = Twitter::List.new(:id =>
|
23
|
+
describe '#created_at' do
|
24
|
+
it 'returns a Time when created_at is set' do
|
25
|
+
list = Twitter::List.new(:id => 8_863_586, :created_at => 'Mon Jul 16 12:59:01 +0000 2007')
|
26
26
|
expect(list.created_at).to be_a Time
|
27
27
|
end
|
28
|
-
it
|
29
|
-
list = Twitter::List.new(:id =>
|
28
|
+
it 'returns nil when created_at is not set' do
|
29
|
+
list = Twitter::List.new(:id => 8_863_586)
|
30
30
|
expect(list.created_at).to be_nil
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
-
describe
|
35
|
-
it
|
36
|
-
list = Twitter::List.new(:id =>
|
34
|
+
describe '#created?' do
|
35
|
+
it 'returns true when created_at is set' do
|
36
|
+
list = Twitter::List.new(:id => 8_863_586, :created_at => 'Mon Jul 16 12:59:01 +0000 2007')
|
37
37
|
expect(list.created?).to be true
|
38
38
|
end
|
39
|
-
it
|
40
|
-
list = Twitter::List.new(:id =>
|
39
|
+
it 'returns false when created_at is not set' do
|
40
|
+
list = Twitter::List.new(:id => 8_863_586)
|
41
41
|
expect(list.created?).to be false
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
-
describe
|
46
|
-
it
|
47
|
-
list = Twitter::List.new(:id =>
|
48
|
-
expect(list.members_uri.to_s).to eq(
|
45
|
+
describe '#members_uri' do
|
46
|
+
it 'returns the URI to the list members' do
|
47
|
+
list = Twitter::List.new(:id => 8_863_586, :slug => 'presidents', :user => {:id => 7_505_382, :screen_name => 'sferik'})
|
48
|
+
expect(list.members_uri.to_s).to eq('https://twitter.com/sferik/presidents/members')
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
|
-
describe
|
53
|
-
it
|
54
|
-
list = Twitter::List.new(:id =>
|
55
|
-
expect(list.subscribers_uri.to_s).to eq(
|
52
|
+
describe '#subscribers_uri' do
|
53
|
+
it 'returns the URI to the list subscribers' do
|
54
|
+
list = Twitter::List.new(:id => 8_863_586, :slug => 'presidents', :user => {:id => 7_505_382, :screen_name => 'sferik'})
|
55
|
+
expect(list.subscribers_uri.to_s).to eq('https://twitter.com/sferik/presidents/subscribers')
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
|
-
describe
|
60
|
-
it
|
61
|
-
list = Twitter::List.new(:id =>
|
62
|
-
expect(list.uri.to_s).to eq(
|
59
|
+
describe '#uri' do
|
60
|
+
it 'returns the URI to the list' do
|
61
|
+
list = Twitter::List.new(:id => 8_863_586, :slug => 'presidents', :user => {:id => 7_505_382, :screen_name => 'sferik'})
|
62
|
+
expect(list.uri.to_s).to eq('https://twitter.com/sferik/presidents')
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
66
|
-
describe
|
67
|
-
it
|
68
|
-
list = Twitter::List.new(:id =>
|
66
|
+
describe '#user' do
|
67
|
+
it 'returns a User when user is set' do
|
68
|
+
list = Twitter::List.new(:id => 8_863_586, :user => {:id => 7_505_382})
|
69
69
|
expect(list.user).to be_a Twitter::User
|
70
70
|
end
|
71
|
-
it
|
72
|
-
list = Twitter::List.new(:id =>
|
71
|
+
it 'returns nil when status is not set' do
|
72
|
+
list = Twitter::List.new(:id => 8_863_586)
|
73
73
|
expect(list.user).to be_nil
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
77
|
-
describe
|
78
|
-
it
|
79
|
-
list = Twitter::List.new(:id =>
|
77
|
+
describe '#user?' do
|
78
|
+
it 'returns true when user is set' do
|
79
|
+
list = Twitter::List.new(:id => 8_863_586, :user => {:id => 7_505_382})
|
80
80
|
expect(list.user?).to be true
|
81
81
|
end
|
82
|
-
it
|
83
|
-
list = Twitter::List.new(:id =>
|
82
|
+
it 'returns false when user is not set' do
|
83
|
+
list = Twitter::List.new(:id => 8_863_586)
|
84
84
|
expect(list.user?).to be false
|
85
85
|
end
|
86
86
|
end
|
@@ -3,146 +3,146 @@ require 'helper'
|
|
3
3
|
|
4
4
|
describe Twitter::Media::Photo do
|
5
5
|
|
6
|
-
describe
|
7
|
-
it
|
6
|
+
describe '#==' do
|
7
|
+
it 'returns true when objects IDs are the same' do
|
8
8
|
photo = Twitter::Media::Photo.new(:id => 1)
|
9
9
|
other = Twitter::Media::Photo.new(:id => 1)
|
10
10
|
expect(photo == other).to be true
|
11
11
|
end
|
12
|
-
it
|
12
|
+
it 'returns false when objects IDs are different' do
|
13
13
|
photo = Twitter::Media::Photo.new(:id => 1)
|
14
14
|
other = Twitter::Media::Photo.new(:id => 2)
|
15
15
|
expect(photo == other).to be false
|
16
16
|
end
|
17
|
-
it
|
17
|
+
it 'returns false when classes are different' do
|
18
18
|
photo = Twitter::Media::Photo.new(:id => 1)
|
19
19
|
other = Twitter::Identity.new(:id => 1)
|
20
20
|
expect(photo == other).to be false
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
-
describe
|
25
|
-
it
|
26
|
-
sizes = Twitter::Media::Photo.new(:id =>
|
24
|
+
describe '#sizes' do
|
25
|
+
it 'returns a hash of Sizes when sizes is set' do
|
26
|
+
sizes = Twitter::Media::Photo.new(:id => 110_102_452_988_157_952, :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'}}).sizes
|
27
27
|
expect(sizes).to be_a Hash
|
28
28
|
expect(sizes[:small]).to be_a Twitter::Size
|
29
29
|
end
|
30
|
-
it
|
31
|
-
sizes = Twitter::Media::Photo.new(:id =>
|
30
|
+
it 'is empty when sizes is not set' do
|
31
|
+
sizes = Twitter::Media::Photo.new(:id => 110_102_452_988_157_952).sizes
|
32
32
|
expect(sizes).to be_empty
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
-
describe
|
37
|
-
it
|
38
|
-
photo = Twitter::Media::Photo.new(:id => 1, :display_url =>
|
36
|
+
describe '#display_uri' do
|
37
|
+
it 'returns a String when the display_url is set' do
|
38
|
+
photo = Twitter::Media::Photo.new(:id => 1, :display_url => 'example.com/expanded…')
|
39
39
|
expect(photo.display_uri).to be_a String
|
40
|
-
expect(photo.display_uri).to eq(
|
40
|
+
expect(photo.display_uri).to eq('example.com/expanded…')
|
41
41
|
end
|
42
|
-
it
|
42
|
+
it 'returns nil when the display_url is not set' do
|
43
43
|
photo = Twitter::Media::Photo.new(:id => 1)
|
44
44
|
expect(photo.display_uri).to be_nil
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
|
-
describe
|
49
|
-
it
|
50
|
-
photo = Twitter::Media::Photo.new(:id => 1, :display_url =>
|
48
|
+
describe '#display_uri?' do
|
49
|
+
it 'returns true when the display_url is set' do
|
50
|
+
photo = Twitter::Media::Photo.new(:id => 1, :display_url => 'example.com/expanded…')
|
51
51
|
expect(photo.display_uri?).to be true
|
52
52
|
end
|
53
|
-
it
|
53
|
+
it 'returns false when the display_url is not set' do
|
54
54
|
photo = Twitter::Media::Photo.new(:id => 1)
|
55
55
|
expect(photo.display_uri?).to be false
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
|
-
describe
|
60
|
-
it
|
61
|
-
photo = Twitter::Media::Photo.new(:id => 1, :expanded_url =>
|
59
|
+
describe '#expanded_uri' do
|
60
|
+
it 'returns a URI when the expanded_url is set' do
|
61
|
+
photo = Twitter::Media::Photo.new(:id => 1, :expanded_url => 'http://pbs.twimg.com/media/BQD6MPOCEAAbCH0.png')
|
62
62
|
expect(photo.expanded_uri).to be_a Addressable::URI
|
63
|
-
expect(photo.expanded_uri.to_s).to eq(
|
63
|
+
expect(photo.expanded_uri.to_s).to eq('http://pbs.twimg.com/media/BQD6MPOCEAAbCH0.png')
|
64
64
|
end
|
65
|
-
it
|
65
|
+
it 'returns nil when the expanded_url is not set' do
|
66
66
|
photo = Twitter::Media::Photo.new(:id => 1)
|
67
67
|
expect(photo.expanded_uri).to be_nil
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
|
-
describe
|
72
|
-
it
|
73
|
-
photo = Twitter::Media::Photo.new(:id => 1, :expanded_url =>
|
71
|
+
describe '#expanded_uri?' do
|
72
|
+
it 'returns true when the expanded_url is set' do
|
73
|
+
photo = Twitter::Media::Photo.new(:id => 1, :expanded_url => 'http://pbs.twimg.com/media/BQD6MPOCEAAbCH0.png')
|
74
74
|
expect(photo.expanded_uri?).to be true
|
75
75
|
end
|
76
|
-
it
|
76
|
+
it 'returns false when the expanded_url is not set' do
|
77
77
|
photo = Twitter::Media::Photo.new(:id => 1)
|
78
78
|
expect(photo.expanded_uri?).to be false
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
82
|
-
describe
|
83
|
-
it
|
84
|
-
photo = Twitter::Media::Photo.new(:id => 1, :media_url =>
|
82
|
+
describe '#media_uri' do
|
83
|
+
it 'returns a URI when the media_url is set' do
|
84
|
+
photo = Twitter::Media::Photo.new(:id => 1, :media_url => 'http://pbs.twimg.com/media/BQD6MPOCEAAbCH0.png')
|
85
85
|
expect(photo.media_uri).to be_a Addressable::URI
|
86
|
-
expect(photo.media_uri.to_s).to eq(
|
86
|
+
expect(photo.media_uri.to_s).to eq('http://pbs.twimg.com/media/BQD6MPOCEAAbCH0.png')
|
87
87
|
end
|
88
|
-
it
|
88
|
+
it 'returns nil when the media_url is not set' do
|
89
89
|
photo = Twitter::Media::Photo.new(:id => 1)
|
90
90
|
expect(photo.media_uri).to be_nil
|
91
91
|
end
|
92
92
|
end
|
93
93
|
|
94
|
-
describe
|
95
|
-
it
|
96
|
-
photo = Twitter::Media::Photo.new(:id => 1, :media_url =>
|
94
|
+
describe '#media_uri?' do
|
95
|
+
it 'returns true when the media_url is set' do
|
96
|
+
photo = Twitter::Media::Photo.new(:id => 1, :media_url => 'http://pbs.twimg.com/media/BQD6MPOCEAAbCH0.png')
|
97
97
|
expect(photo.media_uri?).to be true
|
98
98
|
end
|
99
|
-
it
|
99
|
+
it 'returns false when the media_url is not set' do
|
100
100
|
photo = Twitter::Media::Photo.new(:id => 1)
|
101
101
|
expect(photo.media_uri?).to be false
|
102
102
|
end
|
103
103
|
end
|
104
104
|
|
105
|
-
describe
|
106
|
-
it
|
107
|
-
photo = Twitter::Media::Photo.new(:id => 1, :media_url_https =>
|
105
|
+
describe '#media_uri_https' do
|
106
|
+
it 'returns a URI when the media_url_https is set' do
|
107
|
+
photo = Twitter::Media::Photo.new(:id => 1, :media_url_https => 'http://pbs.twimg.com/media/BQD6MPOCEAAbCH0.png')
|
108
108
|
expect(photo.media_uri_https).to be_a Addressable::URI
|
109
|
-
expect(photo.media_uri_https.to_s).to eq(
|
109
|
+
expect(photo.media_uri_https.to_s).to eq('http://pbs.twimg.com/media/BQD6MPOCEAAbCH0.png')
|
110
110
|
end
|
111
|
-
it
|
111
|
+
it 'returns nil when the media_url_https is not set' do
|
112
112
|
photo = Twitter::Media::Photo.new(:id => 1)
|
113
113
|
expect(photo.media_uri_https).to be_nil
|
114
114
|
end
|
115
115
|
end
|
116
116
|
|
117
|
-
describe
|
118
|
-
it
|
119
|
-
photo = Twitter::Media::Photo.new(:id => 1, :media_url_https =>
|
117
|
+
describe '#media_uri_https?' do
|
118
|
+
it 'returns true when the media_url_https is set' do
|
119
|
+
photo = Twitter::Media::Photo.new(:id => 1, :media_url_https => 'http://pbs.twimg.com/media/BQD6MPOCEAAbCH0.png')
|
120
120
|
expect(photo.media_uri_https?).to be true
|
121
121
|
end
|
122
|
-
it
|
122
|
+
it 'returns false when the media_url_https is not set' do
|
123
123
|
photo = Twitter::Media::Photo.new(:id => 1)
|
124
124
|
expect(photo.media_uri_https?).to be false
|
125
125
|
end
|
126
126
|
end
|
127
127
|
|
128
|
-
describe
|
129
|
-
it
|
130
|
-
photo = Twitter::Media::Photo.new(:id => 1, :url =>
|
128
|
+
describe '#uri' do
|
129
|
+
it 'returns a URI when the url is set' do
|
130
|
+
photo = Twitter::Media::Photo.new(:id => 1, :url => 'http://pbs.twimg.com/media/BQD6MPOCEAAbCH0.png')
|
131
131
|
expect(photo.uri).to be_a Addressable::URI
|
132
|
-
expect(photo.uri.to_s).to eq(
|
132
|
+
expect(photo.uri.to_s).to eq('http://pbs.twimg.com/media/BQD6MPOCEAAbCH0.png')
|
133
133
|
end
|
134
|
-
it
|
134
|
+
it 'returns nil when the url is not set' do
|
135
135
|
photo = Twitter::Media::Photo.new(:id => 1)
|
136
136
|
expect(photo.uri).to be_nil
|
137
137
|
end
|
138
138
|
end
|
139
139
|
|
140
|
-
describe
|
141
|
-
it
|
142
|
-
photo = Twitter::Media::Photo.new(:id => 1, :url =>
|
140
|
+
describe '#uri?' do
|
141
|
+
it 'returns true when the url is set' do
|
142
|
+
photo = Twitter::Media::Photo.new(:id => 1, :url => 'http://pbs.twimg.com/media/BQD6MPOCEAAbCH0.png')
|
143
143
|
expect(photo.uri?).to be true
|
144
144
|
end
|
145
|
-
it
|
145
|
+
it 'returns false when the url is not set' do
|
146
146
|
photo = Twitter::Media::Photo.new(:id => 1)
|
147
147
|
expect(photo.uri?).to be false
|
148
148
|
end
|