twitter 5.0.0.rc.1 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data.tar.gz.sig +0 -0
- data/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/spec/twitter/list_spec.rb
CHANGED
@@ -6,17 +6,17 @@ describe Twitter::List do
|
|
6
6
|
it "returns true when objects IDs are the same" do
|
7
7
|
list = Twitter::List.new(:id => 1, :slug => "foo")
|
8
8
|
other = Twitter::List.new(:id => 1, :slug => "bar")
|
9
|
-
expect(list == other).to
|
9
|
+
expect(list == other).to be true
|
10
10
|
end
|
11
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
|
-
expect(list == other).to
|
14
|
+
expect(list == other).to be false
|
15
15
|
end
|
16
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
|
-
expect(list == other).to
|
19
|
+
expect(list == other).to be false
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
@@ -34,11 +34,11 @@ describe Twitter::List do
|
|
34
34
|
describe "#created?" do
|
35
35
|
it "returns true when created_at is set" do
|
36
36
|
list = Twitter::List.new(:id => 8863586, :created_at => "Mon Jul 16 12:59:01 +0000 2007")
|
37
|
-
expect(list.created?).to
|
37
|
+
expect(list.created?).to be true
|
38
38
|
end
|
39
39
|
it "returns false when created_at is not set" do
|
40
40
|
list = Twitter::List.new(:id => 8863586)
|
41
|
-
expect(list.created?).to
|
41
|
+
expect(list.created?).to be false
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
@@ -77,11 +77,11 @@ describe Twitter::List do
|
|
77
77
|
describe "#user?" do
|
78
78
|
it "returns true when user is set" do
|
79
79
|
list = Twitter::List.new(:id => 8863586, :user => {:id => 7505382})
|
80
|
-
expect(list.user?).to
|
80
|
+
expect(list.user?).to be true
|
81
81
|
end
|
82
82
|
it "returns false when user is not set" do
|
83
83
|
list = Twitter::List.new(:id => 8863586)
|
84
|
-
expect(list.user?).to
|
84
|
+
expect(list.user?).to be false
|
85
85
|
end
|
86
86
|
end
|
87
87
|
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# coding: utf-8
|
1
2
|
require 'helper'
|
2
3
|
|
3
4
|
describe Twitter::Media::Photo do
|
@@ -6,17 +7,17 @@ describe Twitter::Media::Photo do
|
|
6
7
|
it "returns true when objects IDs are the same" do
|
7
8
|
photo = Twitter::Media::Photo.new(:id => 1)
|
8
9
|
other = Twitter::Media::Photo.new(:id => 1)
|
9
|
-
expect(photo == other).to
|
10
|
+
expect(photo == other).to be true
|
10
11
|
end
|
11
12
|
it "returns false when objects IDs are different" do
|
12
13
|
photo = Twitter::Media::Photo.new(:id => 1)
|
13
14
|
other = Twitter::Media::Photo.new(:id => 2)
|
14
|
-
expect(photo == other).to
|
15
|
+
expect(photo == other).to be false
|
15
16
|
end
|
16
17
|
it "returns false when classes are different" do
|
17
18
|
photo = Twitter::Media::Photo.new(:id => 1)
|
18
19
|
other = Twitter::Identity.new(:id => 1)
|
19
|
-
expect(photo == other).to
|
20
|
+
expect(photo == other).to be false
|
20
21
|
end
|
21
22
|
end
|
22
23
|
|
@@ -33,10 +34,10 @@ describe Twitter::Media::Photo do
|
|
33
34
|
end
|
34
35
|
|
35
36
|
describe "#display_uri" do
|
36
|
-
it "returns a
|
37
|
-
photo = Twitter::Media::Photo.new(:id => 1, :display_url => "
|
38
|
-
expect(photo.display_uri).to be_a
|
39
|
-
expect(photo.display_uri
|
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…")
|
40
41
|
end
|
41
42
|
it "returns nil when the display_url is not set" do
|
42
43
|
photo = Twitter::Media::Photo.new(:id => 1)
|
@@ -46,12 +47,12 @@ describe Twitter::Media::Photo do
|
|
46
47
|
|
47
48
|
describe "#display_uri?" do
|
48
49
|
it "returns true when the display_url is set" do
|
49
|
-
photo = Twitter::Media::Photo.new(:id => 1, :display_url => "
|
50
|
-
expect(photo.display_uri).to
|
50
|
+
photo = Twitter::Media::Photo.new(:id => 1, :display_url => "example.com/expanded…")
|
51
|
+
expect(photo.display_uri?).to be true
|
51
52
|
end
|
52
53
|
it "returns false when the display_url is not set" do
|
53
54
|
photo = Twitter::Media::Photo.new(:id => 1)
|
54
|
-
expect(photo.display_uri).to
|
55
|
+
expect(photo.display_uri?).to be false
|
55
56
|
end
|
56
57
|
end
|
57
58
|
|
@@ -70,11 +71,11 @@ describe Twitter::Media::Photo do
|
|
70
71
|
describe "#expanded_uri?" do
|
71
72
|
it "returns true when the expanded_url is set" do
|
72
73
|
photo = Twitter::Media::Photo.new(:id => 1, :expanded_url => "http://pbs.twimg.com/media/BQD6MPOCEAAbCH0.png")
|
73
|
-
expect(photo.expanded_uri).to
|
74
|
+
expect(photo.expanded_uri?).to be true
|
74
75
|
end
|
75
76
|
it "returns false when the expanded_url is not set" do
|
76
77
|
photo = Twitter::Media::Photo.new(:id => 1)
|
77
|
-
expect(photo.expanded_uri).to
|
78
|
+
expect(photo.expanded_uri?).to be false
|
78
79
|
end
|
79
80
|
end
|
80
81
|
|
@@ -93,11 +94,11 @@ describe Twitter::Media::Photo do
|
|
93
94
|
describe "#media_uri?" do
|
94
95
|
it "returns true when the media_url is set" do
|
95
96
|
photo = Twitter::Media::Photo.new(:id => 1, :media_url => "http://pbs.twimg.com/media/BQD6MPOCEAAbCH0.png")
|
96
|
-
expect(photo.media_uri).to
|
97
|
+
expect(photo.media_uri?).to be true
|
97
98
|
end
|
98
99
|
it "returns false when the media_url is not set" do
|
99
100
|
photo = Twitter::Media::Photo.new(:id => 1)
|
100
|
-
expect(photo.media_uri).to
|
101
|
+
expect(photo.media_uri?).to be false
|
101
102
|
end
|
102
103
|
end
|
103
104
|
|
@@ -116,11 +117,11 @@ describe Twitter::Media::Photo do
|
|
116
117
|
describe "#media_uri_https?" do
|
117
118
|
it "returns true when the media_url_https is set" do
|
118
119
|
photo = Twitter::Media::Photo.new(:id => 1, :media_url_https => "http://pbs.twimg.com/media/BQD6MPOCEAAbCH0.png")
|
119
|
-
expect(photo.media_uri_https).to
|
120
|
+
expect(photo.media_uri_https?).to be true
|
120
121
|
end
|
121
122
|
it "returns false when the media_url_https is not set" do
|
122
123
|
photo = Twitter::Media::Photo.new(:id => 1)
|
123
|
-
expect(photo.media_uri_https).to
|
124
|
+
expect(photo.media_uri_https?).to be false
|
124
125
|
end
|
125
126
|
end
|
126
127
|
|
@@ -139,11 +140,11 @@ describe Twitter::Media::Photo do
|
|
139
140
|
describe "#uri?" do
|
140
141
|
it "returns true when the url is set" do
|
141
142
|
photo = Twitter::Media::Photo.new(:id => 1, :url => "http://pbs.twimg.com/media/BQD6MPOCEAAbCH0.png")
|
142
|
-
expect(photo.uri).to
|
143
|
+
expect(photo.uri?).to be true
|
143
144
|
end
|
144
145
|
it "returns false when the url is not set" do
|
145
146
|
photo = Twitter::Media::Photo.new(:id => 1)
|
146
|
-
expect(photo.uri).to
|
147
|
+
expect(photo.uri?).to be false
|
147
148
|
end
|
148
149
|
end
|
149
150
|
|
@@ -7,8 +7,8 @@ describe Twitter::MediaFactory do
|
|
7
7
|
media = Twitter::MediaFactory.new(:id => 1, :type => "photo")
|
8
8
|
expect(media).to be_a Twitter::Media::Photo
|
9
9
|
end
|
10
|
-
it "raises an
|
11
|
-
expect{Twitter::MediaFactory.new}.to raise_error
|
10
|
+
it "raises an IndexError when type is not specified" do
|
11
|
+
expect{Twitter::MediaFactory.new}.to raise_error IndexError
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
@@ -2,24 +2,25 @@ require 'helper'
|
|
2
2
|
|
3
3
|
describe Twitter::NullObject do
|
4
4
|
|
5
|
+
before do
|
6
|
+
@null_object = Twitter::NullObject.new
|
7
|
+
end
|
8
|
+
|
5
9
|
describe "#nil?" do
|
6
10
|
it "returns true" do
|
7
|
-
null_object
|
8
|
-
expect(null_object.null?).to be_true
|
11
|
+
expect(@null_object.nil?).to be true
|
9
12
|
end
|
10
13
|
end
|
11
14
|
|
12
15
|
describe "calling any method" do
|
13
16
|
it "returns self" do
|
14
|
-
null_object
|
15
|
-
expect(null_object.any).to equal null_object
|
17
|
+
expect(@null_object.any).to equal @null_object
|
16
18
|
end
|
17
19
|
end
|
18
20
|
|
19
21
|
describe "#respond_to?" do
|
20
22
|
it "returns true" do
|
21
|
-
null_object
|
22
|
-
expect(null_object.respond_to?(:any)).to be_true
|
23
|
+
expect(@null_object.respond_to?(:any)).to be true
|
23
24
|
end
|
24
25
|
end
|
25
26
|
|
data/spec/twitter/oembed_spec.rb
CHANGED
@@ -17,11 +17,11 @@ describe Twitter::OEmbed do
|
|
17
17
|
describe "#author_uri?" do
|
18
18
|
it "returns true when the author_url is set" do
|
19
19
|
oembed = Twitter::OEmbed.new(:author_url => "https://twitter.com/sferik")
|
20
|
-
expect(oembed.author_uri?).to
|
20
|
+
expect(oembed.author_uri?).to be true
|
21
21
|
end
|
22
22
|
it "returns false when the author_uri is not set" do
|
23
23
|
oembed = Twitter::OEmbed.new
|
24
|
-
expect(oembed.author_uri?).to
|
24
|
+
expect(oembed.author_uri?).to be false
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
@@ -99,11 +99,11 @@ describe Twitter::OEmbed do
|
|
99
99
|
describe "#provider_uri?" do
|
100
100
|
it "returns true when the provider_url is set" do
|
101
101
|
oembed = Twitter::OEmbed.new(:provider_url => "https://twitter.com/sferik")
|
102
|
-
expect(oembed.provider_uri?).to
|
102
|
+
expect(oembed.provider_uri?).to be true
|
103
103
|
end
|
104
104
|
it "returns false when the provider_uri is not set" do
|
105
105
|
oembed = Twitter::OEmbed.new
|
106
|
-
expect(oembed.provider_uri?).to
|
106
|
+
expect(oembed.provider_uri?).to be false
|
107
107
|
end
|
108
108
|
end
|
109
109
|
|
@@ -148,11 +148,11 @@ describe Twitter::OEmbed do
|
|
148
148
|
describe "#uri?" do
|
149
149
|
it "returns true when the url is set" do
|
150
150
|
oembed = Twitter::OEmbed.new(:url => "https://twitter.com/twitterapi/status/133640144317198338")
|
151
|
-
expect(oembed.uri?).to
|
151
|
+
expect(oembed.uri?).to be true
|
152
152
|
end
|
153
153
|
it "returns false when the url is not set" do
|
154
154
|
oembed = Twitter::OEmbed.new
|
155
|
-
expect(oembed.uri?).to
|
155
|
+
expect(oembed.uri?).to be false
|
156
156
|
end
|
157
157
|
end
|
158
158
|
|
data/spec/twitter/place_spec.rb
CHANGED
@@ -3,128 +3,128 @@ require 'helper'
|
|
3
3
|
describe Twitter::Place do
|
4
4
|
|
5
5
|
describe "#==" do
|
6
|
-
it "returns true when objects IDs are the same" do
|
7
|
-
place = Twitter::Place.new(:
|
8
|
-
other = Twitter::Place.new(:
|
9
|
-
expect(place == other).to
|
6
|
+
it "returns true when objects WOE IDs are the same" do
|
7
|
+
place = Twitter::Place.new(:woeid => 1, :name => "foo")
|
8
|
+
other = Twitter::Place.new(:woeid => 1, :name => "bar")
|
9
|
+
expect(place == other).to be true
|
10
10
|
end
|
11
|
-
it "returns false when objects IDs are different" do
|
12
|
-
place = Twitter::Place.new(:
|
13
|
-
other = Twitter::Place.new(:
|
14
|
-
expect(place == other).to
|
11
|
+
it "returns false when objects WOE IDs are different" do
|
12
|
+
place = Twitter::Place.new(:woeid => 1)
|
13
|
+
other = Twitter::Place.new(:woeid => 2)
|
14
|
+
expect(place == other).to be false
|
15
15
|
end
|
16
16
|
it "returns false when classes are different" do
|
17
|
-
place = Twitter::Place.new(:
|
18
|
-
other = Twitter::
|
19
|
-
expect(place == other).to
|
17
|
+
place = Twitter::Place.new(:woeid => 1)
|
18
|
+
other = Twitter::Base.new(:woeid => 1)
|
19
|
+
expect(place == other).to be false
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
23
|
describe "#bounding_box" do
|
24
24
|
it "returns a Twitter::Geo when bounding_box is set" do
|
25
|
-
place = Twitter::Place.new(:
|
25
|
+
place = Twitter::Place.new(:woeid => "247f43d441defc03", :bounding_box => {:type => "Polygon", :coordinates => [[[-122.40348192, 37.77752898], [-122.387436, 37.77752898], [-122.387436, 37.79448597], [-122.40348192, 37.79448597]]]})
|
26
26
|
expect(place.bounding_box).to be_a Twitter::Geo::Polygon
|
27
27
|
end
|
28
28
|
it "returns nil when not bounding_box is not set" do
|
29
|
-
place = Twitter::Place.new(:
|
29
|
+
place = Twitter::Place.new(:woeid => "247f43d441defc03")
|
30
30
|
expect(place.bounding_box).to be_nil
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
34
|
describe "#bounding_box?" do
|
35
35
|
it "returns true when bounding_box is set" do
|
36
|
-
place = Twitter::Place.new(:
|
37
|
-
expect(place.bounding_box?).to
|
36
|
+
place = Twitter::Place.new(:woeid => "247f43d441defc03", :bounding_box => {:type => "Polygon", :coordinates => [[[-122.40348192, 37.77752898], [-122.387436, 37.77752898], [-122.387436, 37.79448597], [-122.40348192, 37.79448597]]]})
|
37
|
+
expect(place.bounding_box?).to be true
|
38
38
|
end
|
39
39
|
it "returns false when bounding_box is not set" do
|
40
|
-
place = Twitter::Place.new(:
|
41
|
-
expect(place.bounding_box?).to
|
40
|
+
place = Twitter::Place.new(:woeid => "247f43d441defc03")
|
41
|
+
expect(place.bounding_box?).to be false
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
45
|
describe "#contained_within" do
|
46
46
|
it "returns a Twitter::Place when contained_within is set" do
|
47
|
-
place = Twitter::Place.new(:
|
47
|
+
place = Twitter::Place.new(:woeid => "247f43d441defc03", :contained_within => {:woeid => "247f43d441defc04"})
|
48
48
|
expect(place.contained_within).to be_a Twitter::Place
|
49
49
|
end
|
50
50
|
it "returns nil when not contained_within is not set" do
|
51
|
-
place = Twitter::Place.new(:
|
51
|
+
place = Twitter::Place.new(:woeid => "247f43d441defc03")
|
52
52
|
expect(place.contained_within).to be_nil
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
56
|
describe "#contained_within?" do
|
57
57
|
it "returns true when contained_within is set" do
|
58
|
-
place = Twitter::Place.new(:
|
59
|
-
expect(place.contained?).to
|
58
|
+
place = Twitter::Place.new(:woeid => "247f43d441defc03", :contained_within => {:woeid => "247f43d441defc04"})
|
59
|
+
expect(place.contained?).to be true
|
60
60
|
end
|
61
61
|
it "returns false when contained_within is not set" do
|
62
|
-
place = Twitter::Place.new(:
|
63
|
-
expect(place.contained?).to
|
62
|
+
place = Twitter::Place.new(:woeid => "247f43d441defc03")
|
63
|
+
expect(place.contained?).to be false
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
67
|
describe "#country_code" do
|
68
68
|
it "returns a country code when set with country_code" do
|
69
|
-
place = Twitter::Place.new(:
|
69
|
+
place = Twitter::Place.new(:woeid => "247f43d441defc03", :country_code => "US")
|
70
70
|
expect(place.country_code).to eq("US")
|
71
71
|
end
|
72
72
|
it "returns a country code when set with countryCode" do
|
73
|
-
place = Twitter::Place.new(:
|
73
|
+
place = Twitter::Place.new(:woeid => "247f43d441defc03", :countryCode => "US")
|
74
74
|
expect(place.country_code).to eq("US")
|
75
75
|
end
|
76
76
|
it "returns nil when not set" do
|
77
|
-
place = Twitter::Place.new(:
|
77
|
+
place = Twitter::Place.new(:woeid => "247f43d441defc03")
|
78
78
|
expect(place.country_code).to be_nil
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
82
82
|
describe "#parent_id" do
|
83
83
|
it "returns a parent ID when set with parentid" do
|
84
|
-
place = Twitter::Place.new(:
|
84
|
+
place = Twitter::Place.new(:woeid => "247f43d441defc03", :parentid => 1)
|
85
85
|
expect(place.parent_id).to eq(1)
|
86
86
|
end
|
87
87
|
it "returns nil when not set" do
|
88
|
-
place = Twitter::Place.new(:
|
88
|
+
place = Twitter::Place.new(:woeid => "247f43d441defc03")
|
89
89
|
expect(place.parent_id).to be_nil
|
90
90
|
end
|
91
91
|
end
|
92
92
|
|
93
93
|
describe "#place_type" do
|
94
94
|
it "returns a place type when set with place_type" do
|
95
|
-
place = Twitter::Place.new(:
|
95
|
+
place = Twitter::Place.new(:woeid => "247f43d441defc03", :place_type => "city")
|
96
96
|
expect(place.place_type).to eq("city")
|
97
97
|
end
|
98
98
|
it "returns a place type when set with placeType[name]" do
|
99
|
-
place = Twitter::Place.new(:
|
99
|
+
place = Twitter::Place.new(:woeid => "247f43d441defc03", :placeType => {:name => "Town"})
|
100
100
|
expect(place.place_type).to eq("Town")
|
101
101
|
end
|
102
102
|
it "returns nil when not set" do
|
103
|
-
place = Twitter::Place.new(:
|
103
|
+
place = Twitter::Place.new(:woeid => "247f43d441defc03")
|
104
104
|
expect(place.place_type).to be_nil
|
105
105
|
end
|
106
106
|
end
|
107
107
|
|
108
108
|
describe "#uri" do
|
109
109
|
it "returns a URI when the url is set" do
|
110
|
-
place = Twitter::Place.new(:
|
110
|
+
place = Twitter::Place.new(:woeid => "247f43d441defc03", :url => "https://api.twitter.com/1.1/geo/id/247f43d441defc03.json")
|
111
111
|
expect(place.uri).to be_a URI
|
112
112
|
expect(place.uri.to_s).to eq("https://api.twitter.com/1.1/geo/id/247f43d441defc03.json")
|
113
113
|
end
|
114
114
|
it "returns nil when the url is not set" do
|
115
|
-
place = Twitter::Place.new(:
|
115
|
+
place = Twitter::Place.new(:woeid => "247f43d441defc03")
|
116
116
|
expect(place.uri).to be_nil
|
117
117
|
end
|
118
118
|
end
|
119
119
|
|
120
120
|
describe "#uri?" do
|
121
121
|
it "returns true when the url is set" do
|
122
|
-
place = Twitter::Place.new(:
|
123
|
-
expect(place.uri).to
|
122
|
+
place = Twitter::Place.new(:woeid => "247f43d441defc03", :url => "https://api.twitter.com/1.1/geo/id/247f43d441defc03.json")
|
123
|
+
expect(place.uri?).to be true
|
124
124
|
end
|
125
125
|
it "returns false when the url is not set" do
|
126
|
-
place = Twitter::Place.new(:
|
127
|
-
expect(place.uri).to
|
126
|
+
place = Twitter::Place.new(:woeid => "247f43d441defc03")
|
127
|
+
expect(place.uri?).to be false
|
128
128
|
end
|
129
129
|
end
|
130
130
|
|
@@ -56,21 +56,4 @@ describe Twitter::RateLimit do
|
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
|
-
describe "#update" do
|
60
|
-
before do
|
61
|
-
Timecop.freeze(Time.utc(2012, 6, 6, 17, 22, 0))
|
62
|
-
end
|
63
|
-
after do
|
64
|
-
Timecop.return
|
65
|
-
end
|
66
|
-
it "updates a rate limit" do
|
67
|
-
rate_limit = Twitter::RateLimit.new("x-rate-limit-reset" => "1339019097")
|
68
|
-
expect(rate_limit.reset_in).to be_an Integer
|
69
|
-
expect(rate_limit.reset_in).to eq(15777)
|
70
|
-
rate_limit.update({"x-rate-limit-reset" => "1339019098"})
|
71
|
-
expect(rate_limit.reset_in).to be_an Integer
|
72
|
-
expect(rate_limit.reset_in).to eq(15778)
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
59
|
end
|
@@ -16,11 +16,11 @@ describe Twitter::Relationship do
|
|
16
16
|
describe "#source?" do
|
17
17
|
it "returns true when source is set" do
|
18
18
|
relationship = Twitter::Relationship.new(:relationship => {:source => {:id => 7505382}})
|
19
|
-
expect(relationship.source?).to
|
19
|
+
expect(relationship.source?).to be true
|
20
20
|
end
|
21
21
|
it "returns false when source is not set" do
|
22
22
|
relationship = Twitter::Relationship.new(:relationship => {})
|
23
|
-
expect(relationship.source?).to
|
23
|
+
expect(relationship.source?).to be false
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
@@ -38,19 +38,11 @@ describe Twitter::Relationship do
|
|
38
38
|
describe "#target?" do
|
39
39
|
it "returns true when target is set" do
|
40
40
|
relationship = Twitter::Relationship.new(:relationship => {:target => {:id => 7505382}})
|
41
|
-
expect(relationship.target?).to
|
41
|
+
expect(relationship.target?).to be true
|
42
42
|
end
|
43
43
|
it "returns false when target is not set" do
|
44
44
|
relationship = Twitter::Relationship.new(:relationship => {})
|
45
|
-
expect(relationship.target?).to
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
describe "#update" do
|
50
|
-
it "updates a relationship" do
|
51
|
-
relationship = Twitter::Relationship.new(:relationship => {:target => {:id => 7505382}})
|
52
|
-
relationship.update(:relationship => {:target => {:id => 14100886}})
|
53
|
-
expect(relationship.target.id).to eq(14100886)
|
45
|
+
expect(relationship.target?).to be false
|
54
46
|
end
|
55
47
|
end
|
56
48
|
|