twitter 4.1.0 → 4.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +5 -0
- data/README.md +11 -9
- data/lib/twitter/api.rb +3 -5
- data/lib/twitter/base.rb +1 -4
- data/lib/twitter/geo/point.rb +2 -2
- data/lib/twitter/request/multipart_with_file.rb +1 -1
- data/lib/twitter/tweet.rb +9 -1
- data/lib/twitter/user.rb +2 -0
- data/lib/twitter/version.rb +1 -1
- data/spec/fixtures/status.json +1 -1
- data/spec/helper.rb +6 -0
- data/spec/twitter/action/favorite_spec.rb +6 -6
- data/spec/twitter/action/follow_spec.rb +6 -6
- data/spec/twitter/action/list_member_added_spec.rb +9 -9
- data/spec/twitter/action/mention_spec.rb +11 -11
- data/spec/twitter/action/reply_spec.rb +9 -9
- data/spec/twitter/action/retweet_spec.rb +9 -9
- data/spec/twitter/action_factory_spec.rb +7 -9
- data/spec/twitter/action_spec.rb +2 -2
- data/spec/twitter/api/account_spec.rb +38 -66
- data/spec/twitter/api/activity_spec.rb +6 -10
- data/spec/twitter/api/blocks_spec.rb +38 -83
- data/spec/twitter/api/direct_messages_spec.rb +33 -55
- data/spec/twitter/api/friendships_spec.rb +124 -266
- data/spec/twitter/api/geo_spec.rb +18 -36
- data/spec/twitter/api/help_spec.rb +15 -23
- data/spec/twitter/api/lists_spec.rb +172 -402
- data/spec/twitter/api/report_spam_spec.rb +5 -9
- data/spec/twitter/api/saved_searches_spec.rb +23 -35
- data/spec/twitter/api/search_spec.rb +15 -25
- data/spec/twitter/api/statuses_spec.rb +137 -235
- data/spec/twitter/api/trends_spec.rb +17 -29
- data/spec/twitter/api/users_spec.rb +90 -181
- data/spec/twitter/base_spec.rb +38 -40
- data/spec/twitter/basic_user_spec.rb +3 -3
- data/spec/twitter/client_spec.rb +28 -46
- data/spec/twitter/configuration_spec.rb +3 -3
- data/spec/twitter/cursor_spec.rb +16 -32
- data/spec/twitter/direct_message_spec.rb +9 -9
- data/spec/twitter/error/client_error_spec.rb +4 -12
- data/spec/twitter/error/server_error_spec.rb +2 -6
- data/spec/twitter/error_spec.rb +2 -2
- data/spec/twitter/geo/point_spec.rb +6 -6
- data/spec/twitter/geo/polygon_spec.rb +4 -4
- data/spec/twitter/geo_factory_spec.rb +3 -5
- data/spec/twitter/geo_spec.rb +4 -4
- data/spec/twitter/identifiable_spec.rb +9 -13
- data/spec/twitter/list_spec.rb +7 -7
- data/spec/twitter/media/photo_spec.rb +6 -6
- data/spec/twitter/media_factory_spec.rb +2 -4
- data/spec/twitter/oembed_spec.rb +24 -24
- data/spec/twitter/place_spec.rb +13 -13
- data/spec/twitter/rate_limit_spec.rb +16 -16
- data/spec/twitter/relationship_spec.rb +5 -5
- data/spec/twitter/saved_search_spec.rb +5 -5
- data/spec/twitter/search_results_spec.rb +21 -21
- data/spec/twitter/settings_spec.rb +2 -2
- data/spec/twitter/size_spec.rb +6 -6
- data/spec/twitter/source_user_spec.rb +3 -3
- data/spec/twitter/suggestion_spec.rb +9 -9
- data/spec/twitter/target_user_spec.rb +3 -3
- data/spec/twitter/trend_spec.rb +6 -6
- data/spec/twitter/tweet_spec.rb +69 -69
- data/spec/twitter/user_spec.rb +43 -43
- data/spec/twitter_spec.rb +12 -16
- metadata +2 -2
@@ -5,36 +5,36 @@ describe Twitter::Action::Retweet do
|
|
5
5
|
describe "#sources" do
|
6
6
|
it "returns a collection of users who retweeted a user" do
|
7
7
|
sources = Twitter::Action::Retweet.new(:sources => [{:id => 7505382}]).sources
|
8
|
-
sources.
|
9
|
-
sources.first.
|
8
|
+
expect(sources).to be_an Array
|
9
|
+
expect(sources.first).to be_a Twitter::User
|
10
10
|
end
|
11
11
|
it "is empty when not set" do
|
12
12
|
sources = Twitter::Action::Retweet.new.sources
|
13
|
-
sources.
|
13
|
+
expect(sources).to be_empty
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
17
|
describe "#target_objects" do
|
18
18
|
it "returns a collection of retweets" do
|
19
19
|
targets = Twitter::Action::Retweet.new(:target_objects => [{:id => 25938088801}]).target_objects
|
20
|
-
targets.
|
21
|
-
targets.first.
|
20
|
+
expect(targets).to be_an Array
|
21
|
+
expect(targets.first).to be_a Twitter::Tweet
|
22
22
|
end
|
23
23
|
it "is empty when not set" do
|
24
24
|
targets = Twitter::Action::Retweet.new.target_objects
|
25
|
-
targets.
|
25
|
+
expect(targets).to be_empty
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
29
|
describe "#targets" do
|
30
30
|
it "returns a collection containing the retweeted user" do
|
31
31
|
targets = Twitter::Action::Retweet.new(:targets => [{:id => 7505382}]).targets
|
32
|
-
targets.
|
33
|
-
targets.first.
|
32
|
+
expect(targets).to be_an Array
|
33
|
+
expect(targets.first).to be_a Twitter::User
|
34
34
|
end
|
35
35
|
it "is empty when not set" do
|
36
36
|
targets = Twitter::Action::Retweet.new.targets
|
37
|
-
targets.
|
37
|
+
expect(targets).to be_empty
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
@@ -5,32 +5,30 @@ describe Twitter::ActionFactory do
|
|
5
5
|
describe ".new" do
|
6
6
|
it "generates a Favorite" do
|
7
7
|
action = Twitter::ActionFactory.fetch_or_new(:action => 'favorite')
|
8
|
-
action.
|
8
|
+
expect(action).to be_a Twitter::Action::Favorite
|
9
9
|
end
|
10
10
|
it "generates a Follow" do
|
11
11
|
action = Twitter::ActionFactory.fetch_or_new(:action => 'follow')
|
12
|
-
action.
|
12
|
+
expect(action).to be_a Twitter::Action::Follow
|
13
13
|
end
|
14
14
|
it "generates a ListMemberAdded" do
|
15
15
|
action = Twitter::ActionFactory.fetch_or_new(:action => 'list_member_added')
|
16
|
-
action.
|
16
|
+
expect(action).to be_a Twitter::Action::ListMemberAdded
|
17
17
|
end
|
18
18
|
it "generates a Mention" do
|
19
19
|
action = Twitter::ActionFactory.fetch_or_new(:action => 'mention')
|
20
|
-
action.
|
20
|
+
expect(action).to be_a Twitter::Action::Mention
|
21
21
|
end
|
22
22
|
it "generates a Reply" do
|
23
23
|
action = Twitter::ActionFactory.fetch_or_new(:action => 'reply')
|
24
|
-
action.
|
24
|
+
expect(action).to be_a Twitter::Action::Reply
|
25
25
|
end
|
26
26
|
it "generates a Retweet" do
|
27
27
|
action = Twitter::ActionFactory.fetch_or_new(:action => 'retweet')
|
28
|
-
action.
|
28
|
+
expect(action).to be_a Twitter::Action::Retweet
|
29
29
|
end
|
30
30
|
it "raises an ArgumentError when action is not specified" do
|
31
|
-
|
32
|
-
Twitter::ActionFactory.fetch_or_new
|
33
|
-
end.should raise_error(ArgumentError, "argument must have :action key")
|
31
|
+
expect{Twitter::ActionFactory.fetch_or_new}.to raise_error(ArgumentError, "argument must have :action key")
|
34
32
|
end
|
35
33
|
end
|
36
34
|
|
data/spec/twitter/action_spec.rb
CHANGED
@@ -5,11 +5,11 @@ describe Twitter::Action do
|
|
5
5
|
describe "#created_at" do
|
6
6
|
it "returns a Time when created_at is set" do
|
7
7
|
user = Twitter::User.new(:id => 7505382, :created_at => "Mon Jul 16 12:59:01 +0000 2007")
|
8
|
-
user.created_at.
|
8
|
+
expect(user.created_at).to be_a Time
|
9
9
|
end
|
10
10
|
it "returns nil when created_at is not set" do
|
11
11
|
user = Twitter::User.new(:id => 7505382)
|
12
|
-
user.created_at.
|
12
|
+
expect(user.created_at).to be_nil
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
@@ -8,172 +8,144 @@ describe Twitter::API do
|
|
8
8
|
|
9
9
|
describe "#verify_credentials" do
|
10
10
|
before do
|
11
|
-
stub_get("/1.1/account/verify_credentials.json").
|
12
|
-
to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
11
|
+
stub_get("/1.1/account/verify_credentials.json").to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
13
12
|
end
|
14
13
|
it "requests the correct resource" do
|
15
14
|
@client.verify_credentials
|
16
|
-
a_get("/1.1/account/verify_credentials.json").
|
17
|
-
should have_been_made
|
15
|
+
expect(a_get("/1.1/account/verify_credentials.json")).to have_been_made
|
18
16
|
end
|
19
17
|
it "returns the requesting user" do
|
20
18
|
user = @client.verify_credentials
|
21
|
-
user.
|
22
|
-
user.id.
|
19
|
+
expect(user).to be_a Twitter::User
|
20
|
+
expect(user.id).to eq 7505382
|
23
21
|
end
|
24
22
|
end
|
25
23
|
|
26
24
|
describe "#update_delivery_device" do
|
27
25
|
before do
|
28
|
-
stub_post("/1.1/account/update_delivery_device.json").
|
29
|
-
with(:body => {:device => "sms"}).
|
30
|
-
to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
26
|
+
stub_post("/1.1/account/update_delivery_device.json").with(:body => {:device => "sms"}).to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
31
27
|
end
|
32
28
|
it "requests the correct resource" do
|
33
29
|
@client.update_delivery_device("sms")
|
34
|
-
a_post("/1.1/account/update_delivery_device.json").
|
35
|
-
with(:body => {:device => "sms"}).
|
36
|
-
should have_been_made
|
30
|
+
expect(a_post("/1.1/account/update_delivery_device.json").with(:body => {:device => "sms"})).to have_been_made
|
37
31
|
end
|
38
32
|
it "returns a user" do
|
39
33
|
user = @client.update_delivery_device("sms")
|
40
|
-
user.
|
41
|
-
user.id.
|
34
|
+
expect(user).to be_a Twitter::User
|
35
|
+
expect(user.id).to eq 7505382
|
42
36
|
end
|
43
37
|
end
|
44
38
|
|
45
39
|
describe "#update_profile" do
|
46
40
|
before do
|
47
|
-
stub_post("/1.1/account/update_profile.json").
|
48
|
-
with(:body => {:url => "http://github.com/sferik/"}).
|
49
|
-
to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
41
|
+
stub_post("/1.1/account/update_profile.json").with(:body => {:url => "http://github.com/sferik/"}).to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
50
42
|
end
|
51
43
|
it "requests the correct resource" do
|
52
44
|
@client.update_profile(:url => "http://github.com/sferik/")
|
53
|
-
a_post("/1.1/account/update_profile.json").
|
54
|
-
with(:body => {:url => "http://github.com/sferik/"}).
|
55
|
-
should have_been_made
|
45
|
+
expect(a_post("/1.1/account/update_profile.json").with(:body => {:url => "http://github.com/sferik/"})).to have_been_made
|
56
46
|
end
|
57
47
|
it "returns a user" do
|
58
48
|
user = @client.update_profile(:url => "http://github.com/sferik/")
|
59
|
-
user.
|
60
|
-
user.id.
|
49
|
+
expect(user).to be_a Twitter::User
|
50
|
+
expect(user.id).to eq 7505382
|
61
51
|
end
|
62
52
|
end
|
63
53
|
|
64
54
|
describe "#update_profile_background_image" do
|
65
55
|
before do
|
66
|
-
stub_post("/1.1/account/update_profile_background_image.json").
|
67
|
-
to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
56
|
+
stub_post("/1.1/account/update_profile_background_image.json").to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
68
57
|
end
|
69
58
|
it "requests the correct resource" do
|
70
59
|
@client.update_profile_background_image(fixture("we_concept_bg2.png"))
|
71
|
-
a_post("/1.1/account/update_profile_background_image.json").
|
72
|
-
should have_been_made
|
60
|
+
expect(a_post("/1.1/account/update_profile_background_image.json")).to have_been_made
|
73
61
|
end
|
74
62
|
it "returns a user" do
|
75
63
|
user = @client.update_profile_background_image(fixture("we_concept_bg2.png"))
|
76
|
-
user.
|
77
|
-
user.id.
|
64
|
+
expect(user).to be_a Twitter::User
|
65
|
+
expect(user.id).to eq 7505382
|
78
66
|
end
|
79
67
|
end
|
80
68
|
|
81
69
|
describe "#update_profile_colors" do
|
82
70
|
before do
|
83
|
-
stub_post("/1.1/account/update_profile_colors.json").
|
84
|
-
with(:body => {:profile_background_color => "000000"}).
|
85
|
-
to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
71
|
+
stub_post("/1.1/account/update_profile_colors.json").with(:body => {:profile_background_color => "000000"}).to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
86
72
|
end
|
87
73
|
it "requests the correct resource" do
|
88
74
|
@client.update_profile_colors(:profile_background_color => "000000")
|
89
|
-
a_post("/1.1/account/update_profile_colors.json").
|
90
|
-
with(:body => {:profile_background_color => "000000"}).
|
91
|
-
should have_been_made
|
75
|
+
expect(a_post("/1.1/account/update_profile_colors.json").with(:body => {:profile_background_color => "000000"})).to have_been_made
|
92
76
|
end
|
93
77
|
it "returns a user" do
|
94
78
|
user = @client.update_profile_colors(:profile_background_color => "000000")
|
95
|
-
user.
|
96
|
-
user.id.
|
79
|
+
expect(user).to be_a Twitter::User
|
80
|
+
expect(user.id).to eq 7505382
|
97
81
|
end
|
98
82
|
end
|
99
83
|
|
100
84
|
describe "#update_profile_image" do
|
101
85
|
before do
|
102
|
-
stub_post("/1.1/account/update_profile_image.json").
|
103
|
-
to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
86
|
+
stub_post("/1.1/account/update_profile_image.json").to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
104
87
|
end
|
105
88
|
it "requests the correct resource" do
|
106
89
|
@client.update_profile_image(fixture("me.jpeg"))
|
107
|
-
a_post("/1.1/account/update_profile_image.json").
|
108
|
-
should have_been_made
|
90
|
+
expect(a_post("/1.1/account/update_profile_image.json")).to have_been_made
|
109
91
|
end
|
110
92
|
it "returns a user" do
|
111
93
|
user = @client.update_profile_image(fixture("me.jpeg"))
|
112
|
-
user.
|
113
|
-
user.id.
|
94
|
+
expect(user).to be_a Twitter::User
|
95
|
+
expect(user.id).to eq 7505382
|
114
96
|
end
|
115
97
|
end
|
116
98
|
|
117
99
|
describe "#update_profile_banner" do
|
118
100
|
before do
|
119
|
-
stub_post("/1.1/account/update_profile_banner.json").
|
120
|
-
to_return(:body => fixture("empty.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
101
|
+
stub_post("/1.1/account/update_profile_banner.json").to_return(:body => fixture("empty.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
121
102
|
end
|
122
103
|
it "requests the correct resource" do
|
123
104
|
@client.update_profile_banner(fixture("me.jpeg"))
|
124
|
-
a_post("/1.1/account/update_profile_banner.json").
|
125
|
-
should have_been_made
|
105
|
+
expect(a_post("/1.1/account/update_profile_banner.json")).to have_been_made
|
126
106
|
end
|
127
107
|
it "returns a user" do
|
128
108
|
user = @client.update_profile_banner(fixture("me.jpeg"))
|
129
|
-
user.
|
109
|
+
expect(user).to be_nil
|
130
110
|
end
|
131
111
|
end
|
132
112
|
|
133
113
|
describe "#remove_profile_banner" do
|
134
114
|
before do
|
135
|
-
stub_post("/1.1/account/remove_profile_banner.json").
|
136
|
-
to_return(:body => fixture("empty.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
115
|
+
stub_post("/1.1/account/remove_profile_banner.json").to_return(:body => fixture("empty.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
137
116
|
end
|
138
117
|
it "requests the correct resource" do
|
139
118
|
@client.remove_profile_banner
|
140
|
-
a_post("/1.1/account/remove_profile_banner.json").
|
141
|
-
should have_been_made
|
119
|
+
expect(a_post("/1.1/account/remove_profile_banner.json")).to have_been_made
|
142
120
|
end
|
143
121
|
it "returns a user" do
|
144
122
|
user = @client.remove_profile_banner
|
145
|
-
user.
|
123
|
+
expect(user).to be_nil
|
146
124
|
end
|
147
125
|
end
|
148
126
|
|
149
127
|
describe "#settings" do
|
150
128
|
before do
|
151
|
-
stub_get("/1.1/account/settings.json").
|
152
|
-
|
153
|
-
stub_post("/1.1/account/settings.json").
|
154
|
-
with(:body => {:trend_location_woeid => "23424803"}).
|
155
|
-
to_return(:body => fixture("settings.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
129
|
+
stub_get("/1.1/account/settings.json").to_return(:body => fixture("settings.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
130
|
+
stub_post("/1.1/account/settings.json").with(:body => {:trend_location_woeid => "23424803"}).to_return(:body => fixture("settings.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
156
131
|
end
|
157
132
|
it "requests the correct resource on GET" do
|
158
133
|
@client.settings
|
159
|
-
a_get("/1.1/account/settings.json").
|
160
|
-
should have_been_made
|
134
|
+
expect(a_get("/1.1/account/settings.json")).to have_been_made
|
161
135
|
end
|
162
136
|
it "returns settings" do
|
163
137
|
settings = @client.settings
|
164
|
-
settings.
|
165
|
-
settings.language.
|
138
|
+
expect(settings).to be_a Twitter::Settings
|
139
|
+
expect(settings.language).to eq 'en'
|
166
140
|
end
|
167
141
|
it "requests the correct resource on POST" do
|
168
142
|
@client.settings(:trend_location_woeid => "23424803")
|
169
|
-
a_post("/1.1/account/settings.json").
|
170
|
-
with(:body => {:trend_location_woeid => "23424803"}).
|
171
|
-
should have_been_made
|
143
|
+
expect(a_post("/1.1/account/settings.json").with(:body => {:trend_location_woeid => "23424803"})).to have_been_made
|
172
144
|
end
|
173
145
|
it "returns settings" do
|
174
146
|
settings = @client.settings(:trend_location_woeid => "23424803")
|
175
|
-
settings.
|
176
|
-
settings.language.
|
147
|
+
expect(settings).to be_a Twitter::Settings
|
148
|
+
expect(settings.language).to eq 'en'
|
177
149
|
end
|
178
150
|
end
|
179
151
|
|
@@ -8,33 +8,29 @@ describe Twitter::API do
|
|
8
8
|
|
9
9
|
describe "#activity_about_me" do
|
10
10
|
before do
|
11
|
-
stub_get("/i/activity/about_me.json").
|
12
|
-
to_return(:body => fixture("about_me.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
11
|
+
stub_get("/i/activity/about_me.json").to_return(:body => fixture("about_me.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
13
12
|
end
|
14
13
|
it "requests the correct resource" do
|
15
14
|
@client.activity_about_me
|
16
|
-
a_get("/i/activity/about_me.json").
|
17
|
-
should have_been_made
|
15
|
+
expect(a_get("/i/activity/about_me.json")).to have_been_made
|
18
16
|
end
|
19
17
|
it "returns activity about me" do
|
20
18
|
activity_about_me = @client.activity_about_me
|
21
|
-
activity_about_me.first.
|
19
|
+
expect(activity_about_me.first).to be_a Twitter::Action::Mention
|
22
20
|
end
|
23
21
|
end
|
24
22
|
|
25
23
|
describe "#activity_by_friends" do
|
26
24
|
before do
|
27
|
-
stub_get("/i/activity/by_friends.json").
|
28
|
-
to_return(:body => fixture("by_friends.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
25
|
+
stub_get("/i/activity/by_friends.json").to_return(:body => fixture("by_friends.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
29
26
|
end
|
30
27
|
it "requests the correct resource" do
|
31
28
|
@client.activity_by_friends
|
32
|
-
a_get("/i/activity/by_friends.json").
|
33
|
-
should have_been_made
|
29
|
+
expect(a_get("/i/activity/by_friends.json")).to have_been_made
|
34
30
|
end
|
35
31
|
it "returns activity by friends" do
|
36
32
|
activity_by_friends = @client.activity_by_friends
|
37
|
-
activity_by_friends.first.
|
33
|
+
expect(activity_by_friends.first).to be_a Twitter::Action::Favorite
|
38
34
|
end
|
39
35
|
end
|
40
36
|
|
@@ -8,159 +8,114 @@ describe Twitter::API do
|
|
8
8
|
|
9
9
|
describe "#blocking" do
|
10
10
|
before do
|
11
|
-
stub_get("/1.1/blocks/list.json").
|
12
|
-
with(:query => {:cursor => "-1"}).
|
13
|
-
to_return(:body => fixture("users_list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
11
|
+
stub_get("/1.1/blocks/list.json").with(:query => {:cursor => "-1"}).to_return(:body => fixture("users_list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
14
12
|
end
|
15
13
|
it "requests the correct resource" do
|
16
14
|
@client.blocking
|
17
|
-
a_get("/1.1/blocks/list.json").
|
18
|
-
with(:query => {:cursor => "-1"}).
|
19
|
-
should have_been_made
|
15
|
+
expect(a_get("/1.1/blocks/list.json").with(:query => {:cursor => "-1"})).to have_been_made
|
20
16
|
end
|
21
17
|
it "returns an array of user objects that the authenticating user is blocking" do
|
22
18
|
blocking = @client.blocking
|
23
|
-
blocking.
|
24
|
-
blocking.users.
|
25
|
-
blocking.users.first.
|
26
|
-
blocking.users.first.id.
|
19
|
+
expect(blocking).to be_a Twitter::Cursor
|
20
|
+
expect(blocking.users).to be_an Array
|
21
|
+
expect(blocking.users.first).to be_a Twitter::User
|
22
|
+
expect(blocking.users.first.id).to eq 7505382
|
27
23
|
end
|
28
24
|
end
|
29
25
|
|
30
26
|
describe "#blocked_ids" do
|
31
27
|
before do
|
32
|
-
stub_get("/1.1/blocks/ids.json").
|
33
|
-
with(:query => {:cursor => "-1"}).
|
34
|
-
to_return(:body => fixture("ids_list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
28
|
+
stub_get("/1.1/blocks/ids.json").with(:query => {:cursor => "-1"}).to_return(:body => fixture("ids_list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
35
29
|
end
|
36
30
|
it "requests the correct resource" do
|
37
31
|
@client.blocked_ids
|
38
|
-
a_get("/1.1/blocks/ids.json").
|
39
|
-
with(:query => {:cursor => "-1"}).
|
40
|
-
should have_been_made
|
32
|
+
expect(a_get("/1.1/blocks/ids.json").with(:query => {:cursor => "-1"})).to have_been_made
|
41
33
|
end
|
42
34
|
it "returns an array of numeric user IDs the authenticating user is blocking" do
|
43
35
|
blocked_ids = @client.blocked_ids
|
44
|
-
blocked_ids.
|
45
|
-
blocked_ids.ids.
|
46
|
-
blocked_ids.ids.first.
|
36
|
+
expect(blocked_ids).to be_a Twitter::Cursor
|
37
|
+
expect(blocked_ids.ids).to be_an Array
|
38
|
+
expect(blocked_ids.ids.first).to eq 14100886
|
47
39
|
end
|
48
40
|
end
|
49
41
|
|
50
42
|
describe "#block?" do
|
51
43
|
context "with a screen name passed" do
|
52
44
|
before do
|
53
|
-
stub_get("/1.1/blocks/ids.json").
|
54
|
-
|
55
|
-
|
56
|
-
stub_get("/1.1/
|
57
|
-
with(:query => {:cursor => "1305102810874389703"}).
|
58
|
-
to_return(:body => fixture("ids_list2.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
59
|
-
stub_get("/1.1/users/show.json").
|
60
|
-
with(:query => {:screen_name => "pengwynn"}).
|
61
|
-
to_return(:body => fixture("pengwynn.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
62
|
-
stub_get("/1.1/users/show.json").
|
63
|
-
with(:query => {:screen_name => "sferik"}).
|
64
|
-
to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
45
|
+
stub_get("/1.1/blocks/ids.json").with(:query => {:cursor => "-1"}).to_return(:body => fixture("ids_list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
46
|
+
stub_get("/1.1/blocks/ids.json").with(:query => {:cursor => "1305102810874389703"}).to_return(:body => fixture("ids_list2.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
47
|
+
stub_get("/1.1/users/show.json").with(:query => {:screen_name => "pengwynn"}).to_return(:body => fixture("pengwynn.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
48
|
+
stub_get("/1.1/users/show.json").with(:query => {:screen_name => "sferik"}).to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
65
49
|
end
|
66
50
|
it "requests the correct resource" do
|
67
51
|
@client.block?("sferik")
|
68
|
-
a_get("/1.1/blocks/ids.json").
|
69
|
-
|
70
|
-
|
71
|
-
a_get("/1.1/blocks/ids.json").
|
72
|
-
with(:query => {:cursor => "1305102810874389703"}).
|
73
|
-
should have_been_made
|
74
|
-
a_get("/1.1/users/show.json").
|
75
|
-
with(:query => {:screen_name => "sferik"}).
|
76
|
-
should have_been_made
|
52
|
+
expect(a_get("/1.1/blocks/ids.json").with(:query => {:cursor => "-1"})).to have_been_made
|
53
|
+
expect(a_get("/1.1/blocks/ids.json").with(:query => {:cursor => "1305102810874389703"})).to have_been_made
|
54
|
+
expect(a_get("/1.1/users/show.json").with(:query => {:screen_name => "sferik"})).to have_been_made
|
77
55
|
end
|
78
56
|
it "returns true if block exists" do
|
79
57
|
block = @client.block?("pengwynn")
|
80
|
-
block.
|
58
|
+
expect(block).to be_true
|
81
59
|
end
|
82
60
|
it "returns false if block does not exist" do
|
83
61
|
block = @client.block?("sferik")
|
84
|
-
block.
|
62
|
+
expect(block).to be_false
|
85
63
|
end
|
86
64
|
end
|
87
65
|
context "with a user ID passed" do
|
88
66
|
before do
|
89
|
-
stub_get("/1.1/blocks/ids.json").
|
90
|
-
|
91
|
-
to_return(:body => fixture("ids_list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
92
|
-
stub_get("/1.1/blocks/ids.json").
|
93
|
-
with(:query => {:cursor => "1305102810874389703"}).
|
94
|
-
to_return(:body => fixture("ids_list2.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
67
|
+
stub_get("/1.1/blocks/ids.json").with(:query => {:cursor => "-1"}).to_return(:body => fixture("ids_list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
68
|
+
stub_get("/1.1/blocks/ids.json").with(:query => {:cursor => "1305102810874389703"}).to_return(:body => fixture("ids_list2.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
95
69
|
end
|
96
70
|
it "requests the correct resources" do
|
97
71
|
@client.block?(7505382)
|
98
|
-
a_get("/1.1/blocks/ids.json").
|
99
|
-
|
100
|
-
should have_been_made
|
101
|
-
a_get("/1.1/blocks/ids.json").
|
102
|
-
with(:query => {:cursor => "1305102810874389703"}).
|
103
|
-
should have_been_made
|
72
|
+
expect(a_get("/1.1/blocks/ids.json").with(:query => {:cursor => "-1"})).to have_been_made
|
73
|
+
expect(a_get("/1.1/blocks/ids.json").with(:query => {:cursor => "1305102810874389703"})).to have_been_made
|
104
74
|
end
|
105
75
|
end
|
106
76
|
context "with a user object passed" do
|
107
77
|
before do
|
108
|
-
stub_get("/1.1/blocks/ids.json").
|
109
|
-
|
110
|
-
to_return(:body => fixture("ids_list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
111
|
-
stub_get("/1.1/blocks/ids.json").
|
112
|
-
with(:query => {:cursor => "1305102810874389703"}).
|
113
|
-
to_return(:body => fixture("ids_list2.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
78
|
+
stub_get("/1.1/blocks/ids.json").with(:query => {:cursor => "-1"}).to_return(:body => fixture("ids_list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
79
|
+
stub_get("/1.1/blocks/ids.json").with(:query => {:cursor => "1305102810874389703"}).to_return(:body => fixture("ids_list2.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
114
80
|
end
|
115
81
|
it "requests the correct resources" do
|
116
82
|
user = Twitter::User.new(:id => '7505382')
|
117
83
|
@client.block?(user)
|
118
|
-
a_get("/1.1/blocks/ids.json").
|
119
|
-
|
120
|
-
should have_been_made
|
121
|
-
a_get("/1.1/blocks/ids.json").
|
122
|
-
with(:query => {:cursor => "1305102810874389703"}).
|
123
|
-
should have_been_made
|
84
|
+
expect(a_get("/1.1/blocks/ids.json").with(:query => {:cursor => "-1"})).to have_been_made
|
85
|
+
expect(a_get("/1.1/blocks/ids.json").with(:query => {:cursor => "1305102810874389703"})).to have_been_made
|
124
86
|
end
|
125
87
|
end
|
126
88
|
end
|
127
89
|
|
128
90
|
describe "#block" do
|
129
91
|
before do
|
130
|
-
stub_post("/1.1/blocks/create.json").
|
131
|
-
with(:body => {:screen_name => "sferik"}).
|
132
|
-
to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
92
|
+
stub_post("/1.1/blocks/create.json").with(:body => {:screen_name => "sferik"}).to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
133
93
|
end
|
134
94
|
it "requests the correct resource" do
|
135
95
|
@client.block("sferik")
|
136
|
-
a_post("/1.1/blocks/create.json").
|
137
|
-
should have_been_made
|
96
|
+
expect(a_post("/1.1/blocks/create.json")).to have_been_made
|
138
97
|
end
|
139
98
|
it "returns an array of blocked users" do
|
140
99
|
users = @client.block("sferik")
|
141
|
-
users.
|
142
|
-
users.first.
|
143
|
-
users.first.id.
|
100
|
+
expect(users).to be_an Array
|
101
|
+
expect(users.first).to be_a Twitter::User
|
102
|
+
expect(users.first.id).to eq 7505382
|
144
103
|
end
|
145
104
|
end
|
146
105
|
|
147
106
|
describe "#unblock" do
|
148
107
|
before do
|
149
|
-
stub_post("/1.1/blocks/destroy.json").
|
150
|
-
with(:body => {:screen_name => "sferik"}).
|
151
|
-
to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
108
|
+
stub_post("/1.1/blocks/destroy.json").with(:body => {:screen_name => "sferik"}).to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
152
109
|
end
|
153
110
|
it "requests the correct resource" do
|
154
111
|
@client.unblock("sferik")
|
155
|
-
a_post("/1.1/blocks/destroy.json").
|
156
|
-
with(:body => {:screen_name => "sferik"}).
|
157
|
-
should have_been_made
|
112
|
+
expect(a_post("/1.1/blocks/destroy.json").with(:body => {:screen_name => "sferik"})).to have_been_made
|
158
113
|
end
|
159
114
|
it "returns an array of un-blocked users" do
|
160
115
|
users = @client.unblock("sferik")
|
161
|
-
users.
|
162
|
-
users.first.
|
163
|
-
users.first.id.
|
116
|
+
expect(users).to be_an Array
|
117
|
+
expect(users.first).to be_a Twitter::User
|
118
|
+
expect(users.first.id).to eq 7505382
|
164
119
|
end
|
165
120
|
end
|
166
121
|
|