twitter 5.11.0 → 5.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (178) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +11 -1
  3. data/README.md +7 -5
  4. data/lib/twitter/arguments.rb +1 -0
  5. data/lib/twitter/base.rb +4 -5
  6. data/lib/twitter/basic_user.rb +1 -0
  7. data/lib/twitter/client.rb +10 -9
  8. data/lib/twitter/configuration.rb +4 -2
  9. data/lib/twitter/cursor.rb +3 -2
  10. data/lib/twitter/direct_message.rb +1 -0
  11. data/lib/twitter/entity.rb +1 -0
  12. data/lib/twitter/entity/hashtag.rb +1 -0
  13. data/lib/twitter/entity/symbol.rb +1 -0
  14. data/lib/twitter/entity/user_mention.rb +4 -1
  15. data/lib/twitter/error.rb +22 -19
  16. data/lib/twitter/geo.rb +1 -0
  17. data/lib/twitter/geo_results.rb +3 -2
  18. data/lib/twitter/identity.rb +1 -0
  19. data/lib/twitter/language.rb +1 -0
  20. data/lib/twitter/list.rb +12 -5
  21. data/lib/twitter/media/photo.rb +1 -0
  22. data/lib/twitter/metadata.rb +1 -0
  23. data/lib/twitter/null_object.rb +22 -0
  24. data/lib/twitter/oembed.rb +5 -2
  25. data/lib/twitter/place.rb +4 -1
  26. data/lib/twitter/profile.rb +1 -1
  27. data/lib/twitter/rest/client.rb +4 -4
  28. data/lib/twitter/rest/favorites.rb +4 -3
  29. data/lib/twitter/rest/lists.rb +18 -3
  30. data/lib/twitter/rest/request/multipart_with_file.rb +1 -1
  31. data/lib/twitter/rest/response/parse_json.rb +1 -1
  32. data/lib/twitter/rest/response/raise_error.rb +4 -5
  33. data/lib/twitter/rest/tweets.rb +2 -1
  34. data/lib/twitter/rest/users.rb +10 -7
  35. data/lib/twitter/saved_search.rb +1 -0
  36. data/lib/twitter/search_results.rb +3 -2
  37. data/lib/twitter/settings.rb +7 -3
  38. data/lib/twitter/size.rb +4 -1
  39. data/lib/twitter/streaming/deleted_tweet.rb +1 -0
  40. data/lib/twitter/streaming/event.rb +2 -2
  41. data/lib/twitter/streaming/message_parser.rb +1 -1
  42. data/lib/twitter/suggestion.rb +4 -1
  43. data/lib/twitter/token.rb +1 -0
  44. data/lib/twitter/trend.rb +1 -0
  45. data/lib/twitter/trend_results.rb +3 -2
  46. data/lib/twitter/tweet.rb +9 -6
  47. data/lib/twitter/user.rb +15 -13
  48. data/lib/twitter/utils.rb +2 -6
  49. data/lib/twitter/version.rb +1 -1
  50. data/twitter.gemspec +6 -9
  51. metadata +6 -259
  52. data/Rakefile +0 -37
  53. data/spec/fixtures/already_favorited.json +0 -1
  54. data/spec/fixtures/already_posted.json +0 -1
  55. data/spec/fixtures/already_retweeted.json +0 -1
  56. data/spec/fixtures/bearer_token.json +0 -1
  57. data/spec/fixtures/category.json +0 -1
  58. data/spec/fixtures/configuration.json +0 -1
  59. data/spec/fixtures/contributees.json +0 -1
  60. data/spec/fixtures/count.json +0 -1
  61. data/spec/fixtures/direct_message.json +0 -1
  62. data/spec/fixtures/direct_messages.json +0 -1
  63. data/spec/fixtures/empty.json +0 -0
  64. data/spec/fixtures/followers_list.json +0 -1
  65. data/spec/fixtures/followers_list2.json +0 -1
  66. data/spec/fixtures/following.json +0 -1
  67. data/spec/fixtures/forbidden.json +0 -1
  68. data/spec/fixtures/friends_list.json +0 -1
  69. data/spec/fixtures/friends_list2.json +0 -1
  70. data/spec/fixtures/friendships.json +0 -1
  71. data/spec/fixtures/ids.json +0 -1
  72. data/spec/fixtures/ids_list.json +0 -1
  73. data/spec/fixtures/ids_list2.json +0 -1
  74. data/spec/fixtures/languages.json +0 -1
  75. data/spec/fixtures/list.json +0 -1
  76. data/spec/fixtures/lists.json +0 -1
  77. data/spec/fixtures/locations.json +0 -1
  78. data/spec/fixtures/matching_trends.json +0 -1
  79. data/spec/fixtures/me.jpeg +0 -0
  80. data/spec/fixtures/members.json +0 -1
  81. data/spec/fixtures/memberships.json +0 -1
  82. data/spec/fixtures/memberships2.json +0 -1
  83. data/spec/fixtures/not_following.json +0 -1
  84. data/spec/fixtures/not_found.json +0 -1
  85. data/spec/fixtures/oembed.json +0 -1
  86. data/spec/fixtures/ownerships.json +0 -1
  87. data/spec/fixtures/pbjt.gif +0 -0
  88. data/spec/fixtures/pengwynn.json +0 -1
  89. data/spec/fixtures/place.json +0 -1
  90. data/spec/fixtures/places.json +0 -1
  91. data/spec/fixtures/privacy.json +0 -1
  92. data/spec/fixtures/profile_banner.json +0 -1
  93. data/spec/fixtures/request_token.txt +0 -6
  94. data/spec/fixtures/retweet.json +0 -1
  95. data/spec/fixtures/retweets.json +0 -1
  96. data/spec/fixtures/saved_search.json +0 -1
  97. data/spec/fixtures/saved_searches.json +0 -1
  98. data/spec/fixtures/search.json +0 -1
  99. data/spec/fixtures/search2.json +0 -1
  100. data/spec/fixtures/search_malformed.json +0 -1
  101. data/spec/fixtures/settings.json +0 -1
  102. data/spec/fixtures/sferik.json +0 -1
  103. data/spec/fixtures/status.json +0 -1
  104. data/spec/fixtures/statuses.json +0 -1
  105. data/spec/fixtures/subscriptions.json +0 -1
  106. data/spec/fixtures/subscriptions2.json +0 -1
  107. data/spec/fixtures/suggestions.json +0 -1
  108. data/spec/fixtures/tos.json +0 -1
  109. data/spec/fixtures/track_streaming.json +0 -3
  110. data/spec/fixtures/track_streaming_user.json +0 -6
  111. data/spec/fixtures/upload.json +0 -1
  112. data/spec/fixtures/user_search.json +0 -1
  113. data/spec/fixtures/user_timeline.json +0 -1
  114. data/spec/fixtures/users.json +0 -1
  115. data/spec/fixtures/users_list.json +0 -1
  116. data/spec/fixtures/users_list2.json +0 -1
  117. data/spec/fixtures/we_concept_bg2.png +0 -0
  118. data/spec/fixtures/wildcomet2.jpe +0 -0
  119. data/spec/helper.rb +0 -68
  120. data/spec/twitter/base_spec.rb +0 -39
  121. data/spec/twitter/basic_user_spec.rb +0 -23
  122. data/spec/twitter/configuration_spec.rb +0 -17
  123. data/spec/twitter/cursor_spec.rb +0 -30
  124. data/spec/twitter/direct_message_spec.rb +0 -232
  125. data/spec/twitter/entity/uri_spec.rb +0 -75
  126. data/spec/twitter/error_spec.rb +0 -52
  127. data/spec/twitter/geo/point_spec.rb +0 -41
  128. data/spec/twitter/geo/polygon_spec.rb +0 -29
  129. data/spec/twitter/geo_factory_spec.rb +0 -19
  130. data/spec/twitter/geo_results_spec.rb +0 -35
  131. data/spec/twitter/geo_spec.rb +0 -29
  132. data/spec/twitter/identifiable_spec.rb +0 -29
  133. data/spec/twitter/list_spec.rb +0 -88
  134. data/spec/twitter/media/photo_spec.rb +0 -151
  135. data/spec/twitter/media_factory_spec.rb +0 -15
  136. data/spec/twitter/oembed_spec.rb +0 -170
  137. data/spec/twitter/place_spec.rb +0 -168
  138. data/spec/twitter/profile_banner_spec.rb +0 -13
  139. data/spec/twitter/rate_limit_spec.rb +0 -59
  140. data/spec/twitter/relationship_spec.rb +0 -49
  141. data/spec/twitter/rest/client_spec.rb +0 -217
  142. data/spec/twitter/rest/direct_messages_spec.rb +0 -133
  143. data/spec/twitter/rest/favorites_spec.rb +0 -188
  144. data/spec/twitter/rest/friends_and_followers_spec.rb +0 -667
  145. data/spec/twitter/rest/geo_spec.rb +0 -68
  146. data/spec/twitter/rest/help_spec.rb +0 -68
  147. data/spec/twitter/rest/lists_spec.rb +0 -910
  148. data/spec/twitter/rest/media_spec.rb +0 -54
  149. data/spec/twitter/rest/oauth_spec.rb +0 -63
  150. data/spec/twitter/rest/saved_searches_spec.rb +0 -98
  151. data/spec/twitter/rest/search_spec.rb +0 -42
  152. data/spec/twitter/rest/spam_reporting_spec.rb +0 -25
  153. data/spec/twitter/rest/suggested_users_spec.rb +0 -59
  154. data/spec/twitter/rest/timelines_spec.rb +0 -138
  155. data/spec/twitter/rest/trends_spec.rb +0 -68
  156. data/spec/twitter/rest/tweets_spec.rb +0 -614
  157. data/spec/twitter/rest/undocumented_spec.rb +0 -103
  158. data/spec/twitter/rest/users_spec.rb +0 -797
  159. data/spec/twitter/saved_search_spec.rb +0 -45
  160. data/spec/twitter/search_results_spec.rb +0 -30
  161. data/spec/twitter/settings_spec.rb +0 -27
  162. data/spec/twitter/size_spec.rb +0 -28
  163. data/spec/twitter/source_user_spec.rb +0 -23
  164. data/spec/twitter/streaming/client_spec.rb +0 -123
  165. data/spec/twitter/streaming/connection_spec.rb +0 -32
  166. data/spec/twitter/streaming/deleted_tweet_spec.rb +0 -23
  167. data/spec/twitter/streaming/event_spec.rb +0 -43
  168. data/spec/twitter/streaming/friend_list_spec.rb +0 -11
  169. data/spec/twitter/streaming/message_parser_spec.rb +0 -54
  170. data/spec/twitter/streaming/response_spec.rb +0 -21
  171. data/spec/twitter/suggestion_spec.rb +0 -40
  172. data/spec/twitter/target_user_spec.rb +0 -23
  173. data/spec/twitter/token_spec.rb +0 -16
  174. data/spec/twitter/trend_results_spec.rb +0 -89
  175. data/spec/twitter/trend_spec.rb +0 -51
  176. data/spec/twitter/tweet_spec.rb +0 -456
  177. data/spec/twitter/user_spec.rb +0 -447
  178. data/spec/twitter/utils_spec.rb +0 -34
@@ -1,75 +0,0 @@
1
- # coding: utf-8
2
- require 'helper'
3
-
4
- describe Twitter::Entity::URI do
5
-
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
- expect(uri.display_uri).to be_a String
10
- expect(uri.display_uri).to eq('example.com/expanded…')
11
- end
12
- it 'returns nil when the display_url is not set' do
13
- uri = Twitter::Entity::URI.new
14
- expect(uri.display_uri).to be_nil
15
- end
16
- end
17
-
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
- expect(uri.display_uri?).to be true
22
- end
23
- it 'returns false when the display_url is not set' do
24
- uri = Twitter::Entity::URI.new
25
- expect(uri.display_uri?).to be false
26
- end
27
- end
28
-
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
- expect(uri.expanded_uri).to be_an Addressable::URI
33
- expect(uri.expanded_uri.to_s).to eq('https://github.com/sferik')
34
- end
35
- it 'returns nil when the expanded_url is not set' do
36
- uri = Twitter::Entity::URI.new
37
- expect(uri.expanded_uri).to be_nil
38
- end
39
- end
40
-
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
- expect(uri.expanded_uri?).to be true
45
- end
46
- it 'returns false when the expanded_url is not set' do
47
- uri = Twitter::Entity::URI.new
48
- expect(uri.expanded_uri?).to be false
49
- end
50
- end
51
-
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
- expect(uri.uri).to be_an Addressable::URI
56
- expect(uri.uri.to_s).to eq('https://github.com/sferik')
57
- end
58
- it 'returns nil when the url is not set' do
59
- uri = Twitter::Entity::URI.new
60
- expect(uri.uri).to be_nil
61
- end
62
- end
63
-
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
- expect(uri.uri?).to be true
68
- end
69
- it 'returns false when the url is not set' do
70
- uri = Twitter::Entity::URI.new
71
- expect(uri.uri?).to be false
72
- end
73
- end
74
-
75
- end
@@ -1,52 +0,0 @@
1
- require 'helper'
2
-
3
- describe Twitter::Error do
4
-
5
- before do
6
- @client = Twitter::REST::Client.new(:consumer_key => 'CK', :consumer_secret => 'CS', :access_token => 'AT', :access_token_secret => 'AS')
7
- end
8
-
9
- describe '#code' do
10
- it 'returns the error code' do
11
- error = Twitter::Error.new('execution expired', {}, 123)
12
- expect(error.code).to eq(123)
13
- end
14
- end
15
-
16
- describe '#message' do
17
- it 'returns the error message' do
18
- error = Twitter::Error.new('execution expired')
19
- expect(error.message).to eq('execution expired')
20
- end
21
- end
22
-
23
- describe '#rate_limit' do
24
- it 'returns a rate limit object' do
25
- error = Twitter::Error.new('execution expired')
26
- expect(error.rate_limit).to be_a Twitter::RateLimit
27
- end
28
- end
29
-
30
- [nil, 'error', 'errors'].each do |key|
31
- context "when JSON body contains #{key.inspect}" do
32
- before do
33
- body = "{\"#{key}\":\"Internal Server Error\"}" unless body.nil?
34
- stub_get('/1.1/statuses/user_timeline.json').with(:query => {:screen_name => 'sferik'}).to_return(:status => 500, :body => body, :headers => {:content_type => 'application/json; charset=utf-8'})
35
- end
36
- it 'raises an exception with the proper message' do
37
- expect { @client.user_timeline('sferik') }.to raise_error(Twitter::Error::InternalServerError)
38
- end
39
- end
40
- end
41
-
42
- Twitter::Error.errors.each do |status, exception|
43
- context "when HTTP status is #{status}" do
44
- before do
45
- stub_get('/1.1/statuses/user_timeline.json').with(:query => {:screen_name => 'sferik'}).to_return(:status => status, :body => '{}', :headers => {:content_type => 'application/json; charset=utf-8'})
46
- end
47
- it "raises #{exception}" do
48
- expect { @client.user_timeline('sferik') }.to raise_error(exception)
49
- end
50
- end
51
- end
52
- end
@@ -1,41 +0,0 @@
1
- require 'helper'
2
-
3
- describe Twitter::Geo::Point do
4
-
5
- before do
6
- @point = Twitter::Geo::Point.new(:coordinates => [-122.399983, 37.788299])
7
- end
8
-
9
- describe '#==' do
10
- it 'returns true for empty objects' do
11
- point = Twitter::Geo::Point.new
12
- other = Twitter::Geo::Point.new
13
- expect(point == other).to be true
14
- end
15
- it 'returns true when objects coordinates are the same' do
16
- other = Twitter::Geo::Point.new(:coordinates => [-122.399983, 37.788299])
17
- expect(@point == other).to be true
18
- end
19
- it 'returns false when objects coordinates are different' do
20
- other = Twitter::Geo::Point.new(:coordinates => [37.788299, -122.399983])
21
- expect(@point == other).to be false
22
- end
23
- it 'returns false when classes are different' do
24
- other = Twitter::Geo.new(:coordinates => [-122.399983, 37.788299])
25
- expect(@point == other).to be false
26
- end
27
- end
28
-
29
- describe '#latitude' do
30
- it 'returns the latitude' do
31
- expect(@point.latitude).to eq(-122.399983)
32
- end
33
- end
34
-
35
- describe '#longitude' do
36
- it 'returns the longitude' do
37
- expect(@point.longitude).to eq(37.788299)
38
- end
39
- end
40
-
41
- end
@@ -1,29 +0,0 @@
1
- require 'helper'
2
-
3
- describe Twitter::Geo::Polygon do
4
-
5
- before do
6
- @polygon = Twitter::Geo::Polygon.new(:coordinates => [[[-122.40348192, 37.77752898], [-122.387436, 37.77752898], [-122.387436, 37.79448597], [-122.40348192, 37.79448597]]])
7
- end
8
-
9
- describe '#==' do
10
- it 'returns true for empty objects' do
11
- polygon = Twitter::Geo::Polygon.new
12
- other = Twitter::Geo::Polygon.new
13
- expect(polygon == other).to be true
14
- end
15
- it 'returns true when objects coordinates are the same' do
16
- other = Twitter::Geo::Polygon.new(:coordinates => [[[-122.40348192, 37.77752898], [-122.387436, 37.77752898], [-122.387436, 37.79448597], [-122.40348192, 37.79448597]]])
17
- expect(@polygon == other).to be true
18
- end
19
- it 'returns false when objects coordinates are different' do
20
- other = Twitter::Geo::Polygon.new(:coordinates => [[[37.77752898, -122.40348192], [37.77752898, -122.387436], [37.79448597, -122.387436], [37.79448597, -122.40348192]]])
21
- expect(@polygon == other).to be false
22
- end
23
- it 'returns false when classes are different' do
24
- other = Twitter::Geo.new(:coordinates => [[[-122.40348192, 37.77752898], [-122.387436, 37.77752898], [-122.387436, 37.79448597], [-122.40348192, 37.79448597]]])
25
- expect(@polygon == other).to be false
26
- end
27
- end
28
-
29
- end
@@ -1,19 +0,0 @@
1
- require 'helper'
2
-
3
- describe Twitter::GeoFactory do
4
-
5
- describe '.new' do
6
- it 'generates a Point' do
7
- geo = Twitter::GeoFactory.new(:type => 'Point')
8
- expect(geo).to be_a Twitter::Geo::Point
9
- end
10
- it 'generates a Polygon' do
11
- geo = Twitter::GeoFactory.new(:type => 'Polygon')
12
- expect(geo).to be_a Twitter::Geo::Polygon
13
- end
14
- it 'raises an IndexError when type is not specified' do
15
- expect { Twitter::GeoFactory.new }.to raise_error(IndexError)
16
- end
17
- end
18
-
19
- end
@@ -1,35 +0,0 @@
1
- require 'helper'
2
-
3
- describe Twitter::GeoResults do
4
-
5
- describe '#each' do
6
- before do
7
- @geo_results = Twitter::GeoResults.new(:result => {:places => [{:id => 1}, {:id => 2}, {:id => 3}, {:id => 4}, {:id => 5}, {:id => 6}]})
8
- end
9
- it 'iterates' do
10
- count = 0
11
- @geo_results.each { count += 1 }
12
- expect(count).to eq(6)
13
- end
14
- context 'with start' do
15
- it 'iterates' do
16
- count = 0
17
- @geo_results.each(5) { count += 1 }
18
- expect(count).to eq(1)
19
- end
20
- end
21
- end
22
-
23
- describe '#token' do
24
- it 'returns a String when token is set' do
25
- geo_results = Twitter::GeoResults.new(:result => {}, :token => 'abc123')
26
- expect(geo_results.token).to be_a String
27
- expect(geo_results.token).to eq('abc123')
28
- end
29
- it 'returns nil when token is not set' do
30
- geo_results = Twitter::GeoResults.new(:result => {})
31
- expect(geo_results.token).to be_nil
32
- end
33
- end
34
-
35
- end
@@ -1,29 +0,0 @@
1
- require 'helper'
2
-
3
- describe Twitter::Geo do
4
-
5
- before do
6
- @geo = Twitter::Geo.new(:coordinates => [[[-122.40348192, 37.77752898], [-122.387436, 37.77752898], [-122.387436, 37.79448597], [-122.40348192, 37.79448597]]])
7
- end
8
-
9
- describe '#==' do
10
- it 'returns true for empty objects' do
11
- geo = Twitter::Geo.new
12
- other = Twitter::Geo.new
13
- expect(geo == other).to be true
14
- end
15
- it 'returns true when objects coordinates are the same' do
16
- other = Twitter::Geo.new(:coordinates => [[[-122.40348192, 37.77752898], [-122.387436, 37.77752898], [-122.387436, 37.79448597], [-122.40348192, 37.79448597]]])
17
- expect(@geo == other).to be true
18
- end
19
- it 'returns false when objects coordinates are different' do
20
- other = Twitter::Geo.new(:coordinates => [[[37.77752898, -122.40348192], [37.77752898, -122.387436], [37.79448597, -122.387436], [37.79448597, -122.40348192]]])
21
- expect(@geo == other).to be false
22
- end
23
- it 'returns true when classes are different' do
24
- other = Twitter::Geo::Polygon.new(:coordinates => [[[-122.40348192, 37.77752898], [-122.387436, 37.77752898], [-122.387436, 37.79448597], [-122.40348192, 37.79448597]]])
25
- expect(@geo == other).to be true
26
- end
27
- end
28
-
29
- end
@@ -1,29 +0,0 @@
1
- require 'helper'
2
-
3
- describe Twitter::Identity do
4
-
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
- end
9
- end
10
-
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
- expect(one == two).to be true
16
- end
17
- it 'returns false when objects IDs are different' do
18
- one = Twitter::Identity.new(:id => 1)
19
- two = Twitter::Identity.new(:id => 2)
20
- expect(one == two).to be false
21
- end
22
- it 'returns false when classes are different' do
23
- one = Twitter::Identity.new(:id => 1)
24
- two = Twitter::Base.new(:id => 1)
25
- expect(one == two).to be false
26
- end
27
- end
28
-
29
- end
@@ -1,88 +0,0 @@
1
- require 'helper'
2
-
3
- describe Twitter::List do
4
-
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
- expect(list == other).to be true
10
- end
11
- it 'returns false when objects IDs are different' do
12
- list = Twitter::List.new(:id => 1)
13
- other = Twitter::List.new(:id => 2)
14
- expect(list == other).to be false
15
- end
16
- it 'returns false when classes are different' do
17
- list = Twitter::List.new(:id => 1)
18
- other = Twitter::Identity.new(:id => 1)
19
- expect(list == other).to be false
20
- end
21
- end
22
-
23
- describe '#created_at' do
24
- it 'returns a Time when created_at is set' do
25
- list = Twitter::List.new(:id => 8_863_586, :created_at => 'Mon Jul 16 12:59:01 +0000 2007')
26
- expect(list.created_at).to be_a Time
27
- end
28
- it 'returns nil when created_at is not set' do
29
- list = Twitter::List.new(:id => 8_863_586)
30
- expect(list.created_at).to be_nil
31
- end
32
- end
33
-
34
- describe '#created?' do
35
- it 'returns true when created_at is set' do
36
- list = Twitter::List.new(:id => 8_863_586, :created_at => 'Mon Jul 16 12:59:01 +0000 2007')
37
- expect(list.created?).to be true
38
- end
39
- it 'returns false when created_at is not set' do
40
- list = Twitter::List.new(:id => 8_863_586)
41
- expect(list.created?).to be false
42
- end
43
- end
44
-
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
- end
50
- end
51
-
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
- end
57
- end
58
-
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
- end
64
- end
65
-
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
- expect(list.user).to be_a Twitter::User
70
- end
71
- it 'returns nil when status is not set' do
72
- list = Twitter::List.new(:id => 8_863_586)
73
- expect(list.user).to be_nil
74
- end
75
- end
76
-
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
- expect(list.user?).to be true
81
- end
82
- it 'returns false when user is not set' do
83
- list = Twitter::List.new(:id => 8_863_586)
84
- expect(list.user?).to be false
85
- end
86
- end
87
-
88
- end
@@ -1,151 +0,0 @@
1
- # coding: utf-8
2
- require 'helper'
3
-
4
- describe Twitter::Media::Photo do
5
-
6
- describe '#==' do
7
- it 'returns true when objects IDs are the same' do
8
- photo = Twitter::Media::Photo.new(:id => 1)
9
- other = Twitter::Media::Photo.new(:id => 1)
10
- expect(photo == other).to be true
11
- end
12
- it 'returns false when objects IDs are different' do
13
- photo = Twitter::Media::Photo.new(:id => 1)
14
- other = Twitter::Media::Photo.new(:id => 2)
15
- expect(photo == other).to be false
16
- end
17
- it 'returns false when classes are different' do
18
- photo = Twitter::Media::Photo.new(:id => 1)
19
- other = Twitter::Identity.new(:id => 1)
20
- expect(photo == other).to be false
21
- end
22
- end
23
-
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
- expect(sizes).to be_a Hash
28
- expect(sizes[:small]).to be_a Twitter::Size
29
- end
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
- expect(sizes).to be_empty
33
- end
34
- end
35
-
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
- expect(photo.display_uri).to be_a String
40
- expect(photo.display_uri).to eq('example.com/expanded…')
41
- end
42
- it 'returns nil when the display_url is not set' do
43
- photo = Twitter::Media::Photo.new(:id => 1)
44
- expect(photo.display_uri).to be_nil
45
- end
46
- end
47
-
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
- expect(photo.display_uri?).to be true
52
- end
53
- it 'returns false when the display_url is not set' do
54
- photo = Twitter::Media::Photo.new(:id => 1)
55
- expect(photo.display_uri?).to be false
56
- end
57
- end
58
-
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
- expect(photo.expanded_uri).to be_an Addressable::URI
63
- expect(photo.expanded_uri.to_s).to eq('http://pbs.twimg.com/media/BQD6MPOCEAAbCH0.png')
64
- end
65
- it 'returns nil when the expanded_url is not set' do
66
- photo = Twitter::Media::Photo.new(:id => 1)
67
- expect(photo.expanded_uri).to be_nil
68
- end
69
- end
70
-
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
- expect(photo.expanded_uri?).to be true
75
- end
76
- it 'returns false when the expanded_url is not set' do
77
- photo = Twitter::Media::Photo.new(:id => 1)
78
- expect(photo.expanded_uri?).to be false
79
- end
80
- end
81
-
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
- expect(photo.media_uri).to be_an Addressable::URI
86
- expect(photo.media_uri.to_s).to eq('http://pbs.twimg.com/media/BQD6MPOCEAAbCH0.png')
87
- end
88
- it 'returns nil when the media_url is not set' do
89
- photo = Twitter::Media::Photo.new(:id => 1)
90
- expect(photo.media_uri).to be_nil
91
- end
92
- end
93
-
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
- expect(photo.media_uri?).to be true
98
- end
99
- it 'returns false when the media_url is not set' do
100
- photo = Twitter::Media::Photo.new(:id => 1)
101
- expect(photo.media_uri?).to be false
102
- end
103
- end
104
-
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
- expect(photo.media_uri_https).to be_an Addressable::URI
109
- expect(photo.media_uri_https.to_s).to eq('http://pbs.twimg.com/media/BQD6MPOCEAAbCH0.png')
110
- end
111
- it 'returns nil when the media_url_https is not set' do
112
- photo = Twitter::Media::Photo.new(:id => 1)
113
- expect(photo.media_uri_https).to be_nil
114
- end
115
- end
116
-
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
- expect(photo.media_uri_https?).to be true
121
- end
122
- it 'returns false when the media_url_https is not set' do
123
- photo = Twitter::Media::Photo.new(:id => 1)
124
- expect(photo.media_uri_https?).to be false
125
- end
126
- end
127
-
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
- expect(photo.uri).to be_an Addressable::URI
132
- expect(photo.uri.to_s).to eq('http://pbs.twimg.com/media/BQD6MPOCEAAbCH0.png')
133
- end
134
- it 'returns nil when the url is not set' do
135
- photo = Twitter::Media::Photo.new(:id => 1)
136
- expect(photo.uri).to be_nil
137
- end
138
- end
139
-
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
- expect(photo.uri?).to be true
144
- end
145
- it 'returns false when the url is not set' do
146
- photo = Twitter::Media::Photo.new(:id => 1)
147
- expect(photo.uri?).to be false
148
- end
149
- end
150
-
151
- end