twitter 5.0.0.rc.1 → 5.0.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/CHANGELOG.md +7 -1
- data/CONTRIBUTING.md +13 -15
- data/README.md +53 -33
- data/Rakefile +6 -0
- data/lib/twitter/arguments.rb +3 -0
- data/lib/twitter/base.rb +88 -89
- data/lib/twitter/client.rb +5 -41
- data/lib/twitter/configuration.rb +4 -5
- data/lib/twitter/core_ext/kernel.rb +5 -1
- data/lib/twitter/creatable.rb +6 -1
- data/lib/twitter/cursor.rb +16 -12
- data/lib/twitter/entity/uri.rb +2 -1
- data/lib/twitter/enumerable.rb +1 -1
- data/lib/twitter/error.rb +42 -39
- data/lib/twitter/factory.rb +12 -5
- data/lib/twitter/geo.rb +2 -7
- data/lib/twitter/geo_factory.rb +11 -7
- data/lib/twitter/geo_results.rb +12 -8
- data/lib/twitter/identity.rb +4 -12
- data/lib/twitter/list.rb +6 -3
- data/lib/twitter/media/photo.rb +5 -3
- data/lib/twitter/media_factory.rb +11 -7
- data/lib/twitter/null_object.rb +4 -3
- data/lib/twitter/place.rb +10 -16
- data/lib/twitter/profile_banner.rb +4 -5
- data/lib/twitter/rate_limit.rb +3 -0
- data/lib/twitter/relationship.rb +0 -9
- data/lib/twitter/rest/api/direct_messages.rb +9 -6
- data/lib/twitter/rest/api/favorites.rb +6 -11
- data/lib/twitter/rest/api/friends_and_followers.rb +6 -9
- data/lib/twitter/rest/api/lists.rb +27 -20
- data/lib/twitter/rest/api/oauth.rb +17 -0
- data/lib/twitter/rest/api/places_and_geo.rb +0 -18
- data/lib/twitter/rest/api/saved_searches.rb +6 -4
- data/lib/twitter/rest/api/suggested_users.rb +2 -2
- data/lib/twitter/rest/api/tweets.rb +7 -9
- data/lib/twitter/rest/api/users.rb +6 -6
- data/lib/twitter/rest/api/utils.rb +44 -17
- data/lib/twitter/rest/client.rb +25 -43
- data/lib/twitter/rest/response/parse_error_json.rb +15 -0
- data/lib/twitter/rest/response/parse_json.rb +5 -1
- data/lib/twitter/search_results.rb +12 -8
- data/lib/twitter/size.rb +2 -15
- data/lib/twitter/streaming/client.rb +23 -11
- data/lib/twitter/streaming/event.rb +35 -0
- data/lib/twitter/streaming/friend_list.rb +13 -0
- data/lib/twitter/streaming/message_parser.rb +18 -0
- data/lib/twitter/streaming/response.rb +4 -0
- data/lib/twitter/suggestion.rb +5 -10
- data/lib/twitter/token.rb +3 -1
- data/lib/twitter/trend.rb +2 -7
- data/lib/twitter/trend_results.rb +20 -14
- data/lib/twitter/tweet.rb +18 -23
- data/lib/twitter/user.rb +34 -19
- data/lib/twitter/version.rb +1 -1
- data/spec/fixtures/request_token.txt +6 -0
- data/spec/fixtures/track_streaming_user.json +5 -0
- data/spec/twitter/base_spec.rb +0 -16
- data/spec/twitter/basic_user_spec.rb +3 -3
- data/spec/twitter/cursor_spec.rb +4 -4
- data/spec/twitter/direct_message_spec.rb +9 -9
- data/spec/twitter/entity/uri_spec.rb +12 -11
- data/spec/twitter/geo/point_spec.rb +5 -5
- data/spec/twitter/geo/polygon_spec.rb +5 -5
- data/spec/twitter/geo_factory_spec.rb +2 -2
- data/spec/twitter/geo_spec.rb +6 -6
- data/spec/twitter/identifiable_spec.rb +5 -5
- data/spec/twitter/list_spec.rb +7 -7
- data/spec/twitter/media/photo_spec.rb +19 -18
- data/spec/twitter/media_factory_spec.rb +2 -2
- data/spec/twitter/null_object_spec.rb +7 -6
- data/spec/twitter/oembed_spec.rb +6 -6
- data/spec/twitter/place_spec.rb +37 -37
- data/spec/twitter/rate_limit_spec.rb +0 -17
- data/spec/twitter/relationship_spec.rb +4 -12
- data/spec/twitter/rest/api/direct_messages_spec.rb +8 -8
- data/spec/twitter/rest/api/friends_and_followers_spec.rb +50 -120
- data/spec/twitter/rest/api/geo_spec.rb +0 -14
- data/spec/twitter/rest/api/lists_spec.rb +39 -39
- data/spec/twitter/rest/api/oauth_spec.rb +15 -4
- data/spec/twitter/rest/api/saved_searches_spec.rb +6 -6
- data/spec/twitter/rest/api/tweets_spec.rb +6 -6
- data/spec/twitter/rest/api/users_spec.rb +4 -4
- data/spec/twitter/rest/client_spec.rb +9 -9
- data/spec/twitter/saved_search_spec.rb +5 -5
- data/spec/twitter/search_results_spec.rb +3 -3
- data/spec/twitter/settings_spec.rb +2 -2
- data/spec/twitter/size_spec.rb +5 -15
- data/spec/twitter/source_user_spec.rb +3 -3
- data/spec/twitter/streaming/client_spec.rb +33 -16
- data/spec/twitter/streaming/event_spec.rb +45 -0
- data/spec/twitter/suggestion_spec.rb +5 -15
- data/spec/twitter/target_user_spec.rb +3 -3
- data/spec/twitter/token_spec.rb +2 -2
- data/spec/twitter/trend_results_spec.rb +6 -6
- data/spec/twitter/trend_spec.rb +7 -17
- data/spec/twitter/tweet_spec.rb +31 -25
- data/spec/twitter/user_spec.rb +16 -16
- data/twitter.gemspec +5 -2
- metadata +67 -15
- metadata.gz.sig +0 -0
data/lib/twitter/user.rb
CHANGED
@@ -4,6 +4,7 @@ require 'twitter/creatable'
|
|
4
4
|
module Twitter
|
5
5
|
class User < Twitter::BasicUser
|
6
6
|
PROFILE_IMAGE_SUFFIX_REGEX = /_normal(\.gif|\.jpe?g|\.png)$/i
|
7
|
+
PREDICATE_URI_METHOD_REGEX = /_uri\?$/
|
7
8
|
include Twitter::Creatable
|
8
9
|
attr_reader :connections, :contributors_enabled, :default_profile,
|
9
10
|
:default_profile_image, :description, :favourites_count,
|
@@ -16,6 +17,7 @@ module Twitter
|
|
16
17
|
:profile_use_background_image, :protected, :statuses_count, :time_zone,
|
17
18
|
:utc_offset, :verified
|
18
19
|
alias favorites_count favourites_count
|
20
|
+
remove_method :favourites_count
|
19
21
|
alias profile_background_image_uri profile_background_image_url
|
20
22
|
alias profile_background_image_uri_https profile_background_image_url_https
|
21
23
|
alias translator? is_translator
|
@@ -25,14 +27,29 @@ module Twitter
|
|
25
27
|
alias tweet? status?
|
26
28
|
alias tweeted? status?
|
27
29
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
30
|
+
class << self
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def alias_predicate_uri_methods(method)
|
35
|
+
for replacement in %w(_url? _uri_https? _url_https?)
|
36
|
+
alias_method_sub(method, PREDICATE_URI_METHOD_REGEX, replacement)
|
33
37
|
end
|
34
38
|
end
|
39
|
+
|
40
|
+
def alias_method_sub(method, pattern, replacement)
|
41
|
+
alias_method(method.to_s.sub(pattern, replacement).to_sym, method)
|
42
|
+
end
|
43
|
+
|
35
44
|
end
|
45
|
+
|
46
|
+
# @return [Array<Twitter::Entity::URI>]
|
47
|
+
def description_uris
|
48
|
+
Array(@attrs[:entities][:description][:urls]).map do |entity|
|
49
|
+
Entity::URI.new(entity)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
memoize :description_uris
|
36
53
|
alias description_urls description_uris
|
37
54
|
|
38
55
|
# Return the URL to the user's profile banner image
|
@@ -53,12 +70,12 @@ module Twitter
|
|
53
70
|
end
|
54
71
|
alias profile_banner_url_https profile_banner_uri_https
|
55
72
|
|
73
|
+
# @return [Boolean]
|
56
74
|
def profile_banner_uri?
|
57
75
|
!!@attrs[:profile_banner_url]
|
58
76
|
end
|
59
|
-
|
60
|
-
|
61
|
-
alias profile_banner_url_https? profile_banner_uri?
|
77
|
+
memoize :profile_banner_uri?
|
78
|
+
alias_predicate_uri_methods :profile_banner_uri?
|
62
79
|
|
63
80
|
# Return the URL to the user's profile image
|
64
81
|
#
|
@@ -87,29 +104,31 @@ module Twitter
|
|
87
104
|
def profile_image_uri?
|
88
105
|
!!@attrs[:profile_image_url_https]
|
89
106
|
end
|
90
|
-
|
91
|
-
|
92
|
-
alias profile_image_url_https? profile_image_uri?
|
107
|
+
memoize :profile_image_uri?
|
108
|
+
alias_predicate_uri_methods :profile_image_uri?
|
93
109
|
|
94
110
|
# @return [String] The URL to the user.
|
95
111
|
def uri
|
96
|
-
|
112
|
+
URI.parse("https://twitter.com/#{screen_name}")
|
97
113
|
end
|
114
|
+
memoize :uri
|
98
115
|
alias url uri
|
99
116
|
|
100
117
|
# @return [String] The URL to the user's website.
|
101
118
|
def website
|
102
|
-
|
119
|
+
URI.parse(@attrs[:url]) if @attrs[:url]
|
103
120
|
end
|
121
|
+
memoize :website
|
104
122
|
|
105
123
|
def website?
|
106
124
|
!!@attrs[:url]
|
107
125
|
end
|
126
|
+
memoize :website?
|
108
127
|
|
109
128
|
private
|
110
129
|
|
111
130
|
def parse_encoded_uri(uri)
|
112
|
-
|
131
|
+
URI.parse(URI.encode(uri))
|
113
132
|
end
|
114
133
|
|
115
134
|
def insecure_uri(uri)
|
@@ -117,11 +136,7 @@ module Twitter
|
|
117
136
|
end
|
118
137
|
|
119
138
|
def profile_image_suffix(size)
|
120
|
-
|
121
|
-
"\\1"
|
122
|
-
else
|
123
|
-
"_#{size}\\1"
|
124
|
-
end
|
139
|
+
:original == size.to_sym ? "\\1" : "_#{size}\\1"
|
125
140
|
end
|
126
141
|
|
127
142
|
end
|
data/lib/twitter/version.rb
CHANGED
@@ -0,0 +1,5 @@
|
|
1
|
+
{"friends":[488736931,311444249]}
|
2
|
+
{"created_at":"Wed Apr 06 19:13:37 +0000 2011","id":55709764298092545,"id_str":"55709764298092545","text":"The problem with your code is that it's doing exactly what you told it to do.","source":"\u003ca href=\"http:\/\/twitter.com\/download\/iphone\" rel=\"nofollow\"\u003eTwitter for iPhone\u003c\/a\u003e","truncated":false,"in_reply_to_status_id":null,"in_reply_to_status_id_str":null,"in_reply_to_user_id":null,"in_reply_to_user_id_str":null,"in_reply_to_screen_name":null,"user":{"id":7505382,"id_str":"7505382","name":"Erik Michaels-Ober","screen_name":"sferik","location":"San Francisco","description":"Write code. Not too much. Mostly Ruby.","url":"https:\/\/github.com\/sferik","entities":{"url":{"urls":[{"url":"https:\/\/github.com\/sferik","expanded_url":null,"indices":[0,25]}]},"description":{"urls":[]}},"protected":false,"followers_count":2479,"friends_count":200,"listed_count":132,"created_at":"Mon Jul 16 12:59:01 +0000 2007","favourites_count":4421,"utc_offset":-28800,"time_zone":"Pacific Time (US & Canada)","geo_enabled":true,"verified":false,"statuses_count":8730,"lang":"en","contributors_enabled":false,"is_translator":false,"profile_background_color":"000000","profile_background_image_url":"http:\/\/a0.twimg.com\/profile_background_images\/677717672\/bb0b3653dcf0644e344823e0a2eb3382.png","profile_background_image_url_https":"https:\/\/si0.twimg.com\/profile_background_images\/677717672\/bb0b3653dcf0644e344823e0a2eb3382.png","profile_background_tile":false,"profile_image_url":"http:\/\/a0.twimg.com\/profile_images\/1759857427\/image1326743606_normal.png","profile_image_url_https":"https:\/\/si0.twimg.com\/profile_images\/1759857427\/image1326743606_normal.png","profile_banner_url":"https:\/\/si0.twimg.com\/profile_banners\/7505382\/1349499693","profile_link_color":"0084B4","profile_sidebar_border_color":"000000","profile_sidebar_fill_color":"DDEEF6","profile_text_color":"333333","profile_use_background_image":true,"default_profile":false,"default_profile_image":false,"following":false,"follow_request_sent":false,"notifications":false},"geo":{"type":"Point","coordinates":[37.78349999,-122.39362884]},"coordinates":{"type":"Point","coordinates":[-122.39362884,37.78349999]},"place":{"id":"5c92ab5379de3839","url":"https:\/\/api.twitter.com\/1.1\/geo\/id\/5c92ab5379de3839.json","place_type":"neighborhood","name":"South Beach","full_name":"South Beach, San Francisco","country_code":"US","country":"United States","bounding_box":{"type":"Polygon","coordinates":[[[-122.403482,37.777529],[-122.387436,37.777529],[-122.387436,37.794486],[-122.403482,37.794486]]]},"attributes":{}},"contributors":null,"retweet_count":316,"entities":{"hashtags":[],"urls":[],"user_mentions":[]},"favorited":false,"retweeted":false}
|
3
|
+
{"created_at":"Wed Apr 06 19:13:37 +0000 2011","id":55709764298092545,"id_str":"55709764298092545","text":"The problem with your code is that it's doing exactly what you told it to do.","source":"\u003ca href=\"http:\/\/twitter.com\/download\/iphone\" rel=\"nofollow\"\u003eTwitter for iPhone\u003c\/a\u003e","truncated":false,"in_reply_to_status_id":null,"in_reply_to_status_id_str":null,"in_reply_to_user_id":null,"in_reply_to_user_id_str":null,"in_reply_to_screen_name":null,"user":{"id":7505382,"id_str":"7505382","name":"Erik Michaels-Ober","screen_name":"sferik","location":"San Francisco","description":"Write code. Not too much. Mostly Ruby.","url":"https:\/\/github.com\/sferik","entities":{"url":{"urls":[{"url":"https:\/\/github.com\/sferik","expanded_url":null,"indices":[0,25]}]},"description":{"urls":[]}},"protected":false,"followers_count":2479,"friends_count":200,"listed_count":132,"created_at":"Mon Jul 16 12:59:01 +0000 2007","favourites_count":4421,"utc_offset":-28800,"time_zone":"Pacific Time (US & Canada)","geo_enabled":true,"verified":false,"statuses_count":8730,"lang":"en","contributors_enabled":false,"is_translator":false,"profile_background_color":"000000","profile_background_image_url":"http:\/\/a0.twimg.com\/profile_background_images\/677717672\/bb0b3653dcf0644e344823e0a2eb3382.png","profile_background_image_url_https":"https:\/\/si0.twimg.com\/profile_background_images\/677717672\/bb0b3653dcf0644e344823e0a2eb3382.png","profile_background_tile":false,"profile_image_url":"http:\/\/a0.twimg.com\/profile_images\/1759857427\/image1326743606_normal.png","profile_image_url_https":"https:\/\/si0.twimg.com\/profile_images\/1759857427\/image1326743606_normal.png","profile_banner_url":"https:\/\/si0.twimg.com\/profile_banners\/7505382\/1349499693","profile_link_color":"0084B4","profile_sidebar_border_color":"000000","profile_sidebar_fill_color":"DDEEF6","profile_text_color":"333333","profile_use_background_image":true,"default_profile":false,"default_profile_image":false,"following":false,"follow_request_sent":false,"notifications":false},"geo":{"type":"Point","coordinates":[37.78349999,-122.39362884]},"coordinates":{"type":"Point","coordinates":[-122.39362884,37.78349999]},"place":{"id":"5c92ab5379de3839","url":"https:\/\/api.twitter.com\/1.1\/geo\/id\/5c92ab5379de3839.json","place_type":"neighborhood","name":"South Beach","full_name":"South Beach, San Francisco","country_code":"US","country":"United States","bounding_box":{"type":"Polygon","coordinates":[[[-122.403482,37.777529],[-122.387436,37.777529],[-122.387436,37.794486],[-122.403482,37.794486]]]},"attributes":{}},"contributors":null,"retweet_count":316,"entities":{"hashtags":[],"urls":[],"user_mentions":[]},"favorited":false,"retweeted":false}
|
4
|
+
{"direct_message":{"id":389327745617891328,"id_str":"389327745617891328","text":"hello bot","sender":{"id":10083602,"id_str":"10083602","name":"Adam Bird","screen_name":"adambird","location":"Nottingham, UK","url":"http:\/\/about.me\/adambird", "description":"CEO @onediaryapp, ex @esendex CTO and co-founder, still cycling","protected":false,"followers_count":1286,"friends_count":850,"listed_count":51,"created_at":"Fri Nov 09 00:35:12 +0000 2007","favourites_count":93,"utc_offset":3600,"time_zone":"London","geo_enabled":true,"verified":false,"statuses_count":13480,"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:\/\/a0.twimg.com\/profile_images\/378800000477232297\/23d85bb78f71534eea1e1133fb771f86_normal.jpeg","profile_image_url_https":"https:\/\/si0.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},"sender_id":10083602,"sender_id_str":"10083602","sender_screen_name":"adambird","recipient":{"id":1292911088,"id_str":"1292911088","name":"One Diary Bot","screen_name":"onediarybot","location":"","url":"http:\/\/www.onediary.com","description":"I'm the One Diary bot, here to help you with your life including personal cycling weather forecasts.","protected":false,"followers_count":113,"friends_count":148,"listed_count":1,"created_at":"Sat Mar 23 23:52:18 +0000 2013","favourites_count":0,"utc_offset":"","time_zone":"","geo_enabled":false,"verified":false,"statuses_count":7919,"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:\/\/a0.twimg.com\/profile_images\/3651575369\/090551d8dd92080198f707769239ff43_normal.jpeg","profile_image_url_https":"https:\/\/si0.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},"recipient_id":1292911088,"recipient_id_str":"1292911088","recipient_screen_name":"onediarybot","created_at":"Sun Oct 13 09:52:22 +0000 2013","entities":{"hashtags":[],"symbols":[],"urls":[],"user_mentions":[]}}}
|
5
|
+
{"event":"follow","source":{"id":10083602,"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":13507,"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/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":1292911088,"id_str":"1292911088","name":"One Diary Bot","screen_name":"onediarybot","location":null,"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":null,"time_zone":null,"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:35:25 +0000 2013"}
|
data/spec/twitter/base_spec.rb
CHANGED
@@ -24,20 +24,4 @@ describe Twitter::Base do
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
-
describe "#delete" do
|
28
|
-
it "deletes an attribute and returns its value" do
|
29
|
-
base = Twitter::Base.new(:id => 1)
|
30
|
-
expect(base.delete(:id)).to eq(1)
|
31
|
-
expect(base.attrs[:id]).to be_nil
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
describe "#update" do
|
36
|
-
it "returns a hash of attributes" do
|
37
|
-
base = Twitter::Base.new(:id => 1)
|
38
|
-
base.update(:id => 2)
|
39
|
-
expect(base.attrs[:id]).to eq(2)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
27
|
end
|
@@ -6,17 +6,17 @@ describe Twitter::BasicUser do
|
|
6
6
|
it "returns true when objects IDs are the same" do
|
7
7
|
saved_search = Twitter::BasicUser.new(:id => 1, :name => "foo")
|
8
8
|
other = Twitter::BasicUser.new(:id => 1, :name => "bar")
|
9
|
-
expect(saved_search == other).to
|
9
|
+
expect(saved_search == other).to be true
|
10
10
|
end
|
11
11
|
it "returns false when objects IDs are different" do
|
12
12
|
saved_search = Twitter::BasicUser.new(:id => 1)
|
13
13
|
other = Twitter::BasicUser.new(:id => 2)
|
14
|
-
expect(saved_search == other).to
|
14
|
+
expect(saved_search == other).to be false
|
15
15
|
end
|
16
16
|
it "returns false when classes are different" do
|
17
17
|
saved_search = Twitter::BasicUser.new(:id => 1)
|
18
18
|
other = Twitter::Identity.new(:id => 1)
|
19
|
-
expect(saved_search == other).to
|
19
|
+
expect(saved_search == other).to be false
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
data/spec/twitter/cursor_spec.rb
CHANGED
@@ -33,7 +33,7 @@ describe Twitter::Cursor do
|
|
33
33
|
@cursor = Twitter::Cursor.new({:previous_cursor => 0}, :ids, nil, Twitter::REST::Client.new, :get, "/1.1/followers/ids.json", {})
|
34
34
|
end
|
35
35
|
it "returns true" do
|
36
|
-
expect(@cursor.first?).to
|
36
|
+
expect(@cursor.first?).to be true
|
37
37
|
end
|
38
38
|
end
|
39
39
|
context "when previous cursor does not equal zero" do
|
@@ -41,7 +41,7 @@ describe Twitter::Cursor do
|
|
41
41
|
@cursor = Twitter::Cursor.new({:previous_cursor => 1}, :ids, nil, Twitter::REST::Client.new, :get, "/1.1/followers/ids.json", {})
|
42
42
|
end
|
43
43
|
it "returns true" do
|
44
|
-
expect(@cursor.first?).to
|
44
|
+
expect(@cursor.first?).to be false
|
45
45
|
end
|
46
46
|
end
|
47
47
|
end
|
@@ -52,7 +52,7 @@ describe Twitter::Cursor do
|
|
52
52
|
@cursor = Twitter::Cursor.new({:next_cursor => 0}, :ids, nil, Twitter::REST::Client.new, :get, "/1.1/followers/ids.json", {})
|
53
53
|
end
|
54
54
|
it "returns true" do
|
55
|
-
expect(@cursor.last?).to
|
55
|
+
expect(@cursor.last?).to be true
|
56
56
|
end
|
57
57
|
end
|
58
58
|
context "when next cursor does not equal zero" do
|
@@ -60,7 +60,7 @@ describe Twitter::Cursor do
|
|
60
60
|
@cursor = Twitter::Cursor.new({:next_cursor => 1}, :ids, nil, Twitter::REST::Client.new, :get, "/1.1/followers/ids.json", {})
|
61
61
|
end
|
62
62
|
it "returns false" do
|
63
|
-
expect(@cursor.last?).to
|
63
|
+
expect(@cursor.last?).to be false
|
64
64
|
end
|
65
65
|
end
|
66
66
|
end
|
@@ -6,17 +6,17 @@ describe Twitter::DirectMessage do
|
|
6
6
|
it "returns true when objects IDs are the same" do
|
7
7
|
direct_message = Twitter::DirectMessage.new(:id => 1, :text => "foo")
|
8
8
|
other = Twitter::DirectMessage.new(:id => 1, :text => "bar")
|
9
|
-
expect(direct_message == other).to
|
9
|
+
expect(direct_message == other).to be true
|
10
10
|
end
|
11
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
|
-
expect(direct_message == other).to
|
14
|
+
expect(direct_message == other).to be false
|
15
15
|
end
|
16
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
|
-
expect(direct_message == other).to
|
19
|
+
expect(direct_message == other).to be false
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
@@ -34,11 +34,11 @@ describe Twitter::DirectMessage do
|
|
34
34
|
describe "#created?" do
|
35
35
|
it "returns true when created_at is set" do
|
36
36
|
direct_message = Twitter::DirectMessage.new(:id => 1825786345, :created_at => "Mon Jul 16 12:59:01 +0000 2007")
|
37
|
-
expect(direct_message.created?).to
|
37
|
+
expect(direct_message.created?).to be true
|
38
38
|
end
|
39
39
|
it "returns false when created_at is not set" do
|
40
40
|
direct_message = Twitter::DirectMessage.new(:id => 1825786345)
|
41
|
-
expect(direct_message.created?).to
|
41
|
+
expect(direct_message.created?).to be false
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
@@ -56,11 +56,11 @@ describe Twitter::DirectMessage do
|
|
56
56
|
describe "#recipient?" do
|
57
57
|
it "returns true when recipient is set" do
|
58
58
|
direct_message = Twitter::DirectMessage.new(:id => 1825786345, :recipient => {:id => 7505382})
|
59
|
-
expect(direct_message.recipient?).to
|
59
|
+
expect(direct_message.recipient?).to be true
|
60
60
|
end
|
61
61
|
it "returns false when recipient is not set" do
|
62
62
|
direct_message = Twitter::DirectMessage.new(:id => 1825786345)
|
63
|
-
expect(direct_message.recipient?).to
|
63
|
+
expect(direct_message.recipient?).to be false
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
@@ -78,11 +78,11 @@ describe Twitter::DirectMessage do
|
|
78
78
|
describe "#sender?" do
|
79
79
|
it "returns true when sender is set" do
|
80
80
|
direct_message = Twitter::DirectMessage.new(:id => 1825786345, :sender => {:id => 7505382})
|
81
|
-
expect(direct_message.sender?).to
|
81
|
+
expect(direct_message.sender?).to be true
|
82
82
|
end
|
83
83
|
it "returns false when sender is not set" do
|
84
84
|
direct_message = Twitter::DirectMessage.new(:id => 1825786345)
|
85
|
-
expect(direct_message.sender?).to
|
85
|
+
expect(direct_message.sender?).to be false
|
86
86
|
end
|
87
87
|
end
|
88
88
|
|
@@ -1,12 +1,13 @@
|
|
1
|
+
# coding: utf-8
|
1
2
|
require 'helper'
|
2
3
|
|
3
4
|
describe Twitter::Entity::URI do
|
4
5
|
|
5
6
|
describe "#display_uri" do
|
6
|
-
it "returns a
|
7
|
-
uri = Twitter::Entity::URI.new(:display_url => "
|
8
|
-
expect(uri.display_uri).to be_a
|
9
|
-
expect(uri.display_uri
|
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…")
|
10
11
|
end
|
11
12
|
it "returns nil when the display_url is not set" do
|
12
13
|
uri = Twitter::Entity::URI.new
|
@@ -16,12 +17,12 @@ describe Twitter::Entity::URI do
|
|
16
17
|
|
17
18
|
describe "#display_uri?" do
|
18
19
|
it "returns true when the display_url is set" do
|
19
|
-
uri = Twitter::Entity::URI.new(:display_url => "
|
20
|
-
expect(uri.display_uri).to
|
20
|
+
uri = Twitter::Entity::URI.new(:display_url => "example.com/expanded…")
|
21
|
+
expect(uri.display_uri?).to be true
|
21
22
|
end
|
22
23
|
it "returns false when the display_url is not set" do
|
23
24
|
uri = Twitter::Entity::URI.new
|
24
|
-
expect(uri.display_uri).to
|
25
|
+
expect(uri.display_uri?).to be false
|
25
26
|
end
|
26
27
|
end
|
27
28
|
|
@@ -40,11 +41,11 @@ describe Twitter::Entity::URI do
|
|
40
41
|
describe "#expanded_uri?" do
|
41
42
|
it "returns true when the expanded_url is set" do
|
42
43
|
uri = Twitter::Entity::URI.new(:expanded_url => "https://github.com/sferik")
|
43
|
-
expect(uri.expanded_uri).to
|
44
|
+
expect(uri.expanded_uri?).to be true
|
44
45
|
end
|
45
46
|
it "returns false when the expanded_url is not set" do
|
46
47
|
uri = Twitter::Entity::URI.new
|
47
|
-
expect(uri.expanded_uri).to
|
48
|
+
expect(uri.expanded_uri?).to be false
|
48
49
|
end
|
49
50
|
end
|
50
51
|
|
@@ -63,11 +64,11 @@ describe Twitter::Entity::URI do
|
|
63
64
|
describe "#uri?" do
|
64
65
|
it "returns true when the url is set" do
|
65
66
|
uri = Twitter::Entity::URI.new(:url => "https://github.com/sferik")
|
66
|
-
expect(uri.uri).to
|
67
|
+
expect(uri.uri?).to be true
|
67
68
|
end
|
68
69
|
it "returns false when the url is not set" do
|
69
70
|
uri = Twitter::Entity::URI.new
|
70
|
-
expect(uri.uri).to
|
71
|
+
expect(uri.uri?).to be false
|
71
72
|
end
|
72
73
|
end
|
73
74
|
|
@@ -7,22 +7,22 @@ describe Twitter::Geo::Point do
|
|
7
7
|
end
|
8
8
|
|
9
9
|
describe "#==" do
|
10
|
-
it "returns
|
10
|
+
it "returns true for empty objects" do
|
11
11
|
point = Twitter::Geo::Point.new
|
12
12
|
other = Twitter::Geo::Point.new
|
13
|
-
expect(point == other).to
|
13
|
+
expect(point == other).to be true
|
14
14
|
end
|
15
15
|
it "returns true when objects coordinates are the same" do
|
16
16
|
other = Twitter::Geo::Point.new(:coordinates => [-122.399983, 37.788299])
|
17
|
-
expect(@point == other).to
|
17
|
+
expect(@point == other).to be true
|
18
18
|
end
|
19
19
|
it "returns false when objects coordinates are different" do
|
20
20
|
other = Twitter::Geo::Point.new(:coordinates => [37.788299, -122.399983])
|
21
|
-
expect(@point == other).to
|
21
|
+
expect(@point == other).to be false
|
22
22
|
end
|
23
23
|
it "returns false when classes are different" do
|
24
24
|
other = Twitter::Geo.new(:coordinates => [-122.399983, 37.788299])
|
25
|
-
expect(@point == other).to
|
25
|
+
expect(@point == other).to be false
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
@@ -7,22 +7,22 @@ describe Twitter::Geo::Polygon do
|
|
7
7
|
end
|
8
8
|
|
9
9
|
describe "#==" do
|
10
|
-
it "returns
|
10
|
+
it "returns true for empty objects" do
|
11
11
|
polygon = Twitter::Geo::Polygon.new
|
12
12
|
other = Twitter::Geo::Polygon.new
|
13
|
-
expect(polygon == other).to
|
13
|
+
expect(polygon == other).to be true
|
14
14
|
end
|
15
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
|
-
expect(@polygon == other).to
|
17
|
+
expect(@polygon == other).to be true
|
18
18
|
end
|
19
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
|
-
expect(@polygon == other).to
|
21
|
+
expect(@polygon == other).to be false
|
22
22
|
end
|
23
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
|
-
expect(@polygon == other).to
|
25
|
+
expect(@polygon == other).to be false
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
@@ -11,8 +11,8 @@ describe Twitter::GeoFactory do
|
|
11
11
|
geo = Twitter::GeoFactory.new(:type => "Polygon")
|
12
12
|
expect(geo).to be_a Twitter::Geo::Polygon
|
13
13
|
end
|
14
|
-
it "raises an
|
15
|
-
expect{Twitter::GeoFactory.new}.to raise_error
|
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
|
|
data/spec/twitter/geo_spec.rb
CHANGED
@@ -7,22 +7,22 @@ describe Twitter::Geo do
|
|
7
7
|
end
|
8
8
|
|
9
9
|
describe "#==" do
|
10
|
-
it "returns
|
10
|
+
it "returns true for empty objects" do
|
11
11
|
geo = Twitter::Geo.new
|
12
12
|
other = Twitter::Geo.new
|
13
|
-
expect(geo == other).to
|
13
|
+
expect(geo == other).to be true
|
14
14
|
end
|
15
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
|
-
expect(@geo == other).to
|
17
|
+
expect(@geo == other).to be true
|
18
18
|
end
|
19
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
|
-
expect(@geo == other).to
|
21
|
+
expect(@geo == other).to be false
|
22
22
|
end
|
23
|
-
it "returns
|
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
|
-
expect(@geo == other).to
|
25
|
+
expect(@geo == other).to be true
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
@@ -3,8 +3,8 @@ require 'helper'
|
|
3
3
|
describe Twitter::Identity do
|
4
4
|
|
5
5
|
describe "#initialize" do
|
6
|
-
it "raises an
|
7
|
-
expect{Twitter::Identity.new}.to raise_error
|
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
|
|
@@ -12,17 +12,17 @@ describe Twitter::Identity do
|
|
12
12
|
it "returns true when objects IDs are the same" do
|
13
13
|
one = Twitter::Identity.new(:id => 1, :screen_name => "sferik")
|
14
14
|
two = Twitter::Identity.new(:id => 1, :screen_name => "garybernhardt")
|
15
|
-
expect(one == two).to
|
15
|
+
expect(one == two).to be true
|
16
16
|
end
|
17
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
|
-
expect(one == two).to
|
20
|
+
expect(one == two).to be false
|
21
21
|
end
|
22
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
|
-
expect(one == two).to
|
25
|
+
expect(one == two).to be false
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|