t 0.3.1 → 0.4.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/.rspec +1 -1
- data/.travis.yml +4 -4
- data/README.md +19 -8
- data/lib/t/cli.rb +33 -17
- data/lib/t/cli/delete.rb +4 -31
- data/lib/t/cli/follow.rb +5 -33
- data/lib/t/cli/list.rb +2 -29
- data/lib/t/cli/list/add.rb +27 -41
- data/lib/t/cli/list/remove.rb +19 -43
- data/lib/t/cli/search.rb +54 -33
- data/lib/t/cli/set.rb +2 -29
- data/lib/t/cli/unfollow.rb +7 -35
- data/lib/t/core_ext/enumerable.rb +9 -0
- data/lib/t/rcfile.rb +0 -4
- data/lib/t/requestable.rb +37 -0
- data/lib/t/version.rb +2 -2
- data/spec/cli/delete_spec.rb +2 -1
- data/spec/cli/follow_spec.rb +2 -0
- data/spec/cli/list/add_spec.rb +60 -0
- data/spec/cli/list/remove_spec.rb +82 -92
- data/spec/cli/list_spec.rb +4 -0
- data/spec/cli/search_spec.rb +232 -0
- data/spec/cli/set_spec.rb +2 -1
- data/spec/cli/unfollow_spec.rb +2 -0
- data/spec/cli_spec.rb +81 -1
- data/spec/helper.rb +5 -2
- data/t.gemspec +3 -3
- metadata +129 -42
data/lib/t/version.rb
CHANGED
data/spec/cli/delete_spec.rb
CHANGED
@@ -4,8 +4,9 @@ require 'helper'
|
|
4
4
|
describe T::CLI::Delete do
|
5
5
|
|
6
6
|
before do
|
7
|
+
rcfile = RCFile.instance
|
8
|
+
rcfile.path = fixture_path + "/.trc"
|
7
9
|
@t = T::CLI.new
|
8
|
-
Timecop.freeze(Time.local(2011, 11, 24, 16, 20, 0))
|
9
10
|
@old_stderr = $stderr
|
10
11
|
$stderr = StringIO.new
|
11
12
|
@old_stdout = $stdout
|
data/spec/cli/follow_spec.rb
CHANGED
data/spec/cli/list/add_spec.rb
CHANGED
@@ -4,6 +4,8 @@ require 'helper'
|
|
4
4
|
describe T::CLI::List::Add do
|
5
5
|
|
6
6
|
before do
|
7
|
+
rcfile = RCFile.instance
|
8
|
+
rcfile.path = fixture_path + "/.trc"
|
7
9
|
@t = T::CLI.new
|
8
10
|
@old_stderr = $stderr
|
9
11
|
$stderr = StringIO.new
|
@@ -77,6 +79,21 @@ describe T::CLI::List::Add do
|
|
77
79
|
@t.list("add", "friends", "presidents")
|
78
80
|
$stdout.string.should =~ /@testcli added 1 friend to the list "presidents"\./
|
79
81
|
end
|
82
|
+
context "Twitter is down" do
|
83
|
+
it "should retry 3 times and then raise an error" do
|
84
|
+
stub_post("/1/lists/members/create_all.json").
|
85
|
+
with(:body => {:user_id => "7505382", :slug => "presidents", :owner_screen_name => "sferik"}).
|
86
|
+
to_return(:status => 502)
|
87
|
+
$stdout.should_receive(:print).with("Are you sure you want to add 1 friend to the list \"presidents\"? ")
|
88
|
+
$stdin.should_receive(:gets).and_return("yes")
|
89
|
+
lambda do
|
90
|
+
@t.list("add", "friends", "presidents")
|
91
|
+
end.should raise_error("Twitter is down or being upgraded.")
|
92
|
+
a_post("/1/lists/members/create_all.json").
|
93
|
+
with(:body => {:user_id => "7505382", :slug => "presidents", :owner_screen_name => "sferik"}).
|
94
|
+
should have_been_made.times(3)
|
95
|
+
end
|
96
|
+
end
|
80
97
|
end
|
81
98
|
context "no" do
|
82
99
|
it "should have the correct output" do
|
@@ -214,6 +231,21 @@ describe T::CLI::List::Add do
|
|
214
231
|
@t.list("add", "followers", "presidents")
|
215
232
|
$stdout.string.should =~ /@testcli added 2 followers to the list "presidents"\./
|
216
233
|
end
|
234
|
+
context "Twitter is down" do
|
235
|
+
it "should retry 3 times and then raise an error" do
|
236
|
+
stub_post("/1/lists/members/create_all.json").
|
237
|
+
with(:body => {:user_id => "213747670,428004849", :slug => "presidents", :owner_screen_name => "sferik"}).
|
238
|
+
to_return(:status => 502)
|
239
|
+
$stdout.should_receive(:print).with("Are you sure you want to add 2 followers to the list \"presidents\"? ")
|
240
|
+
$stdin.should_receive(:gets).and_return("yes")
|
241
|
+
lambda do
|
242
|
+
@t.list("add", "followers", "presidents")
|
243
|
+
end.should raise_error("Twitter is down or being upgraded.")
|
244
|
+
a_post("/1/lists/members/create_all.json").
|
245
|
+
with(:body => {:user_id => "213747670,428004849", :slug => "presidents", :owner_screen_name => "sferik"}).
|
246
|
+
should have_been_made.times(3)
|
247
|
+
end
|
248
|
+
end
|
217
249
|
end
|
218
250
|
context "no" do
|
219
251
|
it "should have the correct output" do
|
@@ -356,6 +388,21 @@ describe T::CLI::List::Add do
|
|
356
388
|
@t.list("add", "listed", "democrats", "presidents")
|
357
389
|
$stdout.string.should =~ /@testcli added 1 member to the list "presidents"\./
|
358
390
|
end
|
391
|
+
context "Twitter is down" do
|
392
|
+
it "should retry 3 times and then raise an error" do
|
393
|
+
stub_post("/1/lists/members/create_all.json").
|
394
|
+
with(:body => {:user_id => "7505382", :slug => "presidents", :owner_screen_name => "sferik"}).
|
395
|
+
to_return(:status => 502)
|
396
|
+
$stdout.should_receive(:print).with("Are you sure you want to add 1 member to the list \"presidents\"? ")
|
397
|
+
$stdin.should_receive(:gets).and_return("yes")
|
398
|
+
lambda do
|
399
|
+
@t.list("add", "listed", "democrats", "presidents")
|
400
|
+
end.should raise_error("Twitter is down or being upgraded.")
|
401
|
+
a_post("/1/lists/members/create_all.json").
|
402
|
+
with(:body => {:user_id => "7505382", :slug => "presidents", :owner_screen_name => "sferik"}).
|
403
|
+
should have_been_made.times(3)
|
404
|
+
end
|
405
|
+
end
|
359
406
|
end
|
360
407
|
context "no" do
|
361
408
|
it "should have the correct output" do
|
@@ -453,6 +500,19 @@ describe T::CLI::List::Add do
|
|
453
500
|
@t.list("add", "users", "presidents", "sferik")
|
454
501
|
$stdout.string.should =~ /@testcli added 1 user to the list "presidents"\./
|
455
502
|
end
|
503
|
+
context "Twitter is down" do
|
504
|
+
it "should retry 3 times and then raise an error" do
|
505
|
+
stub_post("/1/lists/members/create_all.json").
|
506
|
+
with(:body => {:screen_name => "sferik", :slug => "presidents", :owner_screen_name => "sferik"}).
|
507
|
+
to_return(:status => 502)
|
508
|
+
lambda do
|
509
|
+
@t.list("add", "users", "presidents", "sferik")
|
510
|
+
end.should raise_error("Twitter is down or being upgraded.")
|
511
|
+
a_post("/1/lists/members/create_all.json").
|
512
|
+
with(:body => {:screen_name => "sferik", :slug => "presidents", :owner_screen_name => "sferik"}).
|
513
|
+
should have_been_made.times(3)
|
514
|
+
end
|
515
|
+
end
|
456
516
|
end
|
457
517
|
|
458
518
|
end
|
@@ -4,6 +4,8 @@ require 'helper'
|
|
4
4
|
describe T::CLI::List::Remove do
|
5
5
|
|
6
6
|
before do
|
7
|
+
rcfile = RCFile.instance
|
8
|
+
rcfile.path = fixture_path + "/.trc"
|
7
9
|
@t = T::CLI.new
|
8
10
|
@old_stderr = $stderr
|
9
11
|
$stderr = StringIO.new
|
@@ -52,7 +54,7 @@ describe T::CLI::List::Remove do
|
|
52
54
|
to_return(:body => fixture("friends_ids.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
53
55
|
end
|
54
56
|
it "should request the correct resource" do
|
55
|
-
stub_post("/1/lists/members/
|
57
|
+
stub_post("/1/lists/members/destroy_all.json").
|
56
58
|
with(:body => {:user_id => "7505382", :slug => "presidents", :owner_screen_name => "sferik"}).
|
57
59
|
to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
58
60
|
$stdout.should_receive(:print).with("Are you sure you want to remove 1 friend from the list \"presidents\"? ")
|
@@ -66,13 +68,13 @@ describe T::CLI::List::Remove do
|
|
66
68
|
a_get("/1/friends/ids.json").
|
67
69
|
with(:query => {:cursor => "-1"}).
|
68
70
|
should have_been_made
|
69
|
-
a_post("/1/lists/members/
|
71
|
+
a_post("/1/lists/members/destroy_all.json").
|
70
72
|
with(:body => {:user_id => "7505382", :slug => "presidents", :owner_screen_name => "sferik"}).
|
71
73
|
should have_been_made
|
72
74
|
end
|
73
75
|
context "yes" do
|
74
76
|
it "should have the correct output" do
|
75
|
-
stub_post("/1/lists/members/
|
77
|
+
stub_post("/1/lists/members/destroy_all.json").
|
76
78
|
with(:body => {:user_id => "7505382", :slug => "presidents", :owner_screen_name => "sferik"}).
|
77
79
|
to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
78
80
|
$stdout.should_receive(:print).with("Are you sure you want to remove 1 friend from the list \"presidents\"? ")
|
@@ -80,6 +82,21 @@ describe T::CLI::List::Remove do
|
|
80
82
|
@t.list("remove", "friends", "presidents")
|
81
83
|
$stdout.string.should =~ /@testcli removed 1 friend from the list "presidents"\./
|
82
84
|
end
|
85
|
+
context "Twitter is down" do
|
86
|
+
it "should retry 3 times and then raise an error" do
|
87
|
+
stub_post("/1/lists/members/destroy_all.json").
|
88
|
+
with(:body => {:user_id => "7505382", :slug => "presidents", :owner_screen_name => "sferik"}).
|
89
|
+
to_return(:status => 502)
|
90
|
+
$stdout.should_receive(:print).with("Are you sure you want to remove 1 friend from the list \"presidents\"? ")
|
91
|
+
$stdin.should_receive(:gets).and_return("yes")
|
92
|
+
lambda do
|
93
|
+
@t.list("remove", "friends", "presidents")
|
94
|
+
end.should raise_error("Twitter is down or being upgraded.")
|
95
|
+
a_post("/1/lists/members/destroy_all.json").
|
96
|
+
with(:body => {:user_id => "7505382", :slug => "presidents", :owner_screen_name => "sferik"}).
|
97
|
+
should have_been_made.times(3)
|
98
|
+
end
|
99
|
+
end
|
83
100
|
end
|
84
101
|
context "no" do
|
85
102
|
it "should have the correct output" do
|
@@ -89,21 +106,6 @@ describe T::CLI::List::Remove do
|
|
89
106
|
$stdout.string.chomp.should == ""
|
90
107
|
end
|
91
108
|
end
|
92
|
-
context "Twitter is down" do
|
93
|
-
it "should retry 3 times and then raise an error" do
|
94
|
-
stub_post("/1/lists/members/destroy.json").
|
95
|
-
with(:body => {:user_id => "7505382", :slug => "presidents", :owner_screen_name => "sferik"}).
|
96
|
-
to_return(:status => 502)
|
97
|
-
$stdout.should_receive(:print).with("Are you sure you want to remove 1 friend from the list \"presidents\"? ")
|
98
|
-
$stdin.should_receive(:gets).and_return("yes")
|
99
|
-
lambda do
|
100
|
-
@t.list("remove", "friends", "presidents")
|
101
|
-
end.should raise_error("Twitter is down or being upgraded.")
|
102
|
-
a_post("/1/lists/members/destroy.json").
|
103
|
-
with(:body => {:user_id => "7505382", :slug => "presidents", :owner_screen_name => "sferik"}).
|
104
|
-
should have_been_made.times(3)
|
105
|
-
end
|
106
|
-
end
|
107
109
|
end
|
108
110
|
end
|
109
111
|
|
@@ -143,11 +145,8 @@ describe T::CLI::List::Remove do
|
|
143
145
|
to_return(:body => fixture("followers_ids.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
144
146
|
end
|
145
147
|
it "should request the correct resource" do
|
146
|
-
stub_post("/1/lists/members/
|
147
|
-
with(:body => {:user_id => "213747670", :slug => "presidents", :owner_screen_name => "sferik"}).
|
148
|
-
to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
149
|
-
stub_post("/1/lists/members/destroy.json").
|
150
|
-
with(:body => {:user_id => "428004849", :slug => "presidents", :owner_screen_name => "sferik"}).
|
148
|
+
stub_post("/1/lists/members/destroy_all.json").
|
149
|
+
with(:body => {:user_id => "213747670,428004849", :slug => "presidents", :owner_screen_name => "sferik"}).
|
151
150
|
to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
152
151
|
$stdout.should_receive(:print).with("Are you sure you want to remove 2 followers from the list \"presidents\"? ")
|
153
152
|
$stdin.should_receive(:gets).and_return("yes")
|
@@ -160,26 +159,35 @@ describe T::CLI::List::Remove do
|
|
160
159
|
a_get("/1/followers/ids.json").
|
161
160
|
with(:query => {:cursor => "-1"}).
|
162
161
|
should have_been_made
|
163
|
-
a_post("/1/lists/members/
|
164
|
-
with(:body => {:user_id => "213747670", :slug => "presidents", :owner_screen_name => "sferik"}).
|
165
|
-
should have_been_made
|
166
|
-
a_post("/1/lists/members/destroy.json").
|
167
|
-
with(:body => {:user_id => "428004849", :slug => "presidents", :owner_screen_name => "sferik"}).
|
162
|
+
a_post("/1/lists/members/destroy_all.json").
|
163
|
+
with(:body => {:user_id => "213747670,428004849", :slug => "presidents", :owner_screen_name => "sferik"}).
|
168
164
|
should have_been_made
|
169
165
|
end
|
170
166
|
context "yes" do
|
171
167
|
it "should have the correct output" do
|
172
|
-
stub_post("/1/lists/members/
|
173
|
-
with(:body => {:user_id => "213747670", :slug => "presidents", :owner_screen_name => "sferik"}).
|
174
|
-
to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
175
|
-
stub_post("/1/lists/members/destroy.json").
|
176
|
-
with(:body => {:user_id => "428004849", :slug => "presidents", :owner_screen_name => "sferik"}).
|
168
|
+
stub_post("/1/lists/members/destroy_all.json").
|
169
|
+
with(:body => {:user_id => "213747670,428004849", :slug => "presidents", :owner_screen_name => "sferik"}).
|
177
170
|
to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
178
171
|
$stdout.should_receive(:print).with("Are you sure you want to remove 2 followers from the list \"presidents\"? ")
|
179
172
|
$stdin.should_receive(:gets).and_return("yes")
|
180
173
|
@t.list("remove", "followers", "presidents")
|
181
174
|
$stdout.string.should =~ /@testcli removed 2 followers from the list "presidents"\./
|
182
175
|
end
|
176
|
+
context "Twitter is down" do
|
177
|
+
it "should retry 3 times and then raise an error" do
|
178
|
+
stub_post("/1/lists/members/destroy_all.json").
|
179
|
+
with(:body => {:user_id => "213747670,428004849", :slug => "presidents", :owner_screen_name => "sferik"}).
|
180
|
+
to_return(:status => 502)
|
181
|
+
$stdout.should_receive(:print).with("Are you sure you want to remove 2 followers from the list \"presidents\"? ")
|
182
|
+
$stdin.should_receive(:gets).and_return("yes")
|
183
|
+
lambda do
|
184
|
+
@t.list("remove", "followers", "presidents")
|
185
|
+
end.should raise_error("Twitter is down or being upgraded.")
|
186
|
+
a_post("/1/lists/members/destroy_all.json").
|
187
|
+
with(:body => {:user_id => "213747670,428004849", :slug => "presidents", :owner_screen_name => "sferik"}).
|
188
|
+
should have_been_made.times(3)
|
189
|
+
end
|
190
|
+
end
|
183
191
|
end
|
184
192
|
context "no" do
|
185
193
|
it "should have the correct output" do
|
@@ -189,24 +197,6 @@ describe T::CLI::List::Remove do
|
|
189
197
|
$stdout.string.chomp.should == ""
|
190
198
|
end
|
191
199
|
end
|
192
|
-
context "Twitter is down" do
|
193
|
-
it "should retry 3 times and then raise an error" do
|
194
|
-
stub_post("/1/lists/members/destroy.json").
|
195
|
-
with(:body => {:user_id => "213747670", :slug => "presidents", :owner_screen_name => "sferik"}).
|
196
|
-
to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
197
|
-
stub_post("/1/lists/members/destroy.json").
|
198
|
-
with(:body => {:user_id => "428004849", :slug => "presidents", :owner_screen_name => "sferik"}).
|
199
|
-
to_return(:status => 502)
|
200
|
-
$stdout.should_receive(:print).with("Are you sure you want to remove 2 followers from the list \"presidents\"? ")
|
201
|
-
$stdin.should_receive(:gets).and_return("yes")
|
202
|
-
lambda do
|
203
|
-
@t.list("remove", "followers", "presidents")
|
204
|
-
end.should raise_error("Twitter is down or being upgraded.")
|
205
|
-
a_post("/1/lists/members/destroy.json").
|
206
|
-
with(:body => {:user_id => "428004849", :slug => "presidents", :owner_screen_name => "sferik"}).
|
207
|
-
should have_been_made.times(3)
|
208
|
-
end
|
209
|
-
end
|
210
200
|
end
|
211
201
|
end
|
212
202
|
|
@@ -251,7 +241,7 @@ describe T::CLI::List::Remove do
|
|
251
241
|
to_return(:body => fixture("users_list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
252
242
|
end
|
253
243
|
it "should request the correct resource" do
|
254
|
-
stub_post("/1/lists/members/
|
244
|
+
stub_post("/1/lists/members/destroy_all.json").
|
255
245
|
with(:body => {:user_id => "7505382", :slug => "presidents", :owner_screen_name => "sferik"}).
|
256
246
|
to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
257
247
|
$stdout.should_receive(:print).with("Are you sure you want to remove 1 member from the list \"presidents\"? ")
|
@@ -265,13 +255,13 @@ describe T::CLI::List::Remove do
|
|
265
255
|
a_get("/1/lists/members.json").
|
266
256
|
with(:query => {:cursor => "-1", :include_entities => "false", :owner_screen_name => "sferik", :skip_status => "true", :slug => "democrats"}).
|
267
257
|
should have_been_made
|
268
|
-
a_post("/1/lists/members/
|
258
|
+
a_post("/1/lists/members/destroy_all.json").
|
269
259
|
with(:body => {:user_id => "7505382", :slug => "presidents", :owner_screen_name => "sferik"}).
|
270
260
|
should have_been_made
|
271
261
|
end
|
272
262
|
context "yes" do
|
273
263
|
it "should have the correct output" do
|
274
|
-
stub_post("/1/lists/members/
|
264
|
+
stub_post("/1/lists/members/destroy_all.json").
|
275
265
|
with(:body => {:user_id => "7505382", :slug => "presidents", :owner_screen_name => "sferik"}).
|
276
266
|
to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
277
267
|
$stdout.should_receive(:print).with("Are you sure you want to remove 1 member from the list \"presidents\"? ")
|
@@ -279,6 +269,21 @@ describe T::CLI::List::Remove do
|
|
279
269
|
@t.list("remove", "listed", "democrats", "presidents")
|
280
270
|
$stdout.string.should =~ /@testcli removed 1 member from the list "presidents"\./
|
281
271
|
end
|
272
|
+
context "Twitter is down" do
|
273
|
+
it "should retry 3 times and then raise an error" do
|
274
|
+
stub_post("/1/lists/members/destroy_all.json").
|
275
|
+
with(:body => {:user_id => "7505382", :slug => "presidents", :owner_screen_name => "sferik"}).
|
276
|
+
to_return(:status => 502)
|
277
|
+
$stdout.should_receive(:print).with("Are you sure you want to remove 1 member from the list \"presidents\"? ")
|
278
|
+
$stdin.should_receive(:gets).and_return("yes")
|
279
|
+
lambda do
|
280
|
+
@t.list("remove", "listed", "democrats", "presidents")
|
281
|
+
end.should raise_error("Twitter is down or being upgraded.")
|
282
|
+
a_post("/1/lists/members/destroy_all.json").
|
283
|
+
with(:body => {:user_id => "7505382", :slug => "presidents", :owner_screen_name => "sferik"}).
|
284
|
+
should have_been_made.times(3)
|
285
|
+
end
|
286
|
+
end
|
282
287
|
end
|
283
288
|
context "no" do
|
284
289
|
it "should have the correct output" do
|
@@ -288,21 +293,6 @@ describe T::CLI::List::Remove do
|
|
288
293
|
$stdout.string.chomp.should == ""
|
289
294
|
end
|
290
295
|
end
|
291
|
-
context "Twitter is down" do
|
292
|
-
it "should retry 3 times and then raise an error" do
|
293
|
-
stub_post("/1/lists/members/destroy.json").
|
294
|
-
with(:body => {:user_id => "7505382", :slug => "presidents", :owner_screen_name => "sferik"}).
|
295
|
-
to_return(:status => 502)
|
296
|
-
$stdout.should_receive(:print).with("Are you sure you want to remove 1 member from the list \"presidents\"? ")
|
297
|
-
$stdin.should_receive(:gets).and_return("yes")
|
298
|
-
lambda do
|
299
|
-
@t.list("remove", "listed", "democrats", "presidents")
|
300
|
-
end.should raise_error("Twitter is down or being upgraded.")
|
301
|
-
a_post("/1/lists/members/destroy.json").
|
302
|
-
with(:body => {:user_id => "7505382", :slug => "presidents", :owner_screen_name => "sferik"}).
|
303
|
-
should have_been_made.times(3)
|
304
|
-
end
|
305
|
-
end
|
306
296
|
end
|
307
297
|
end
|
308
298
|
|
@@ -338,7 +328,7 @@ describe T::CLI::List::Remove do
|
|
338
328
|
to_return(:body => fixture("users_list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
339
329
|
end
|
340
330
|
it "should request the correct resource" do
|
341
|
-
stub_post("/1/lists/members/
|
331
|
+
stub_post("/1/lists/members/destroy_all.json").
|
342
332
|
with(:body => {:user_id => "7505382", :slug => "presidents", :owner_screen_name => "sferik"}).
|
343
333
|
to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
344
334
|
$stdout.should_receive(:print).with("Are you sure you want to remove 1 member from the list \"presidents\"? ")
|
@@ -349,13 +339,13 @@ describe T::CLI::List::Remove do
|
|
349
339
|
a_get("/1/lists/members.json").
|
350
340
|
with(:query => {:cursor => "-1", :include_entities => "false", :owner_screen_name => "sferik", :skip_status => "true", :slug => "presidents"}).
|
351
341
|
should have_been_made
|
352
|
-
a_post("/1/lists/members/
|
342
|
+
a_post("/1/lists/members/destroy_all.json").
|
353
343
|
with(:body => {:user_id => "7505382", :slug => "presidents", :owner_screen_name => "sferik"}).
|
354
344
|
should have_been_made
|
355
345
|
end
|
356
346
|
context "yes" do
|
357
347
|
it "should have the correct output" do
|
358
|
-
stub_post("/1/lists/members/
|
348
|
+
stub_post("/1/lists/members/destroy_all.json").
|
359
349
|
with(:body => {:user_id => "7505382", :slug => "presidents", :owner_screen_name => "sferik"}).
|
360
350
|
to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
361
351
|
$stdout.should_receive(:print).with("Are you sure you want to remove 1 member from the list \"presidents\"? ")
|
@@ -363,6 +353,21 @@ describe T::CLI::List::Remove do
|
|
363
353
|
@t.list("remove", "members", "presidents")
|
364
354
|
$stdout.string.should =~ /@testcli removed 1 member from the list "presidents"\./
|
365
355
|
end
|
356
|
+
context "Twitter is down" do
|
357
|
+
it "should retry 3 times and then raise an error" do
|
358
|
+
stub_post("/1/lists/members/destroy_all.json").
|
359
|
+
with(:body => {:user_id => "7505382", :slug => "presidents", :owner_screen_name => "sferik"}).
|
360
|
+
to_return(:status => 502)
|
361
|
+
$stdout.should_receive(:print).with("Are you sure you want to remove 1 member from the list \"presidents\"? ")
|
362
|
+
$stdin.should_receive(:gets).and_return("yes")
|
363
|
+
lambda do
|
364
|
+
@t.list("remove", "members", "presidents")
|
365
|
+
end.should raise_error("Twitter is down or being upgraded.")
|
366
|
+
a_post("/1/lists/members/destroy_all.json").
|
367
|
+
with(:body => {:user_id => "7505382", :slug => "presidents", :owner_screen_name => "sferik"}).
|
368
|
+
should have_been_made.times(3)
|
369
|
+
end
|
370
|
+
end
|
366
371
|
end
|
367
372
|
context "no" do
|
368
373
|
it "should have the correct output" do
|
@@ -372,21 +377,6 @@ describe T::CLI::List::Remove do
|
|
372
377
|
$stdout.string.chomp.should == ""
|
373
378
|
end
|
374
379
|
end
|
375
|
-
context "Twitter is down" do
|
376
|
-
it "should retry 3 times and then raise an error" do
|
377
|
-
stub_post("/1/lists/members/destroy.json").
|
378
|
-
with(:body => {:user_id => "7505382", :slug => "presidents", :owner_screen_name => "sferik"}).
|
379
|
-
to_return(:status => 502)
|
380
|
-
$stdout.should_receive(:print).with("Are you sure you want to remove 1 member from the list \"presidents\"? ")
|
381
|
-
$stdin.should_receive(:gets).and_return("yes")
|
382
|
-
lambda do
|
383
|
-
@t.list("remove", "members", "presidents")
|
384
|
-
end.should raise_error("Twitter is down or being upgraded.")
|
385
|
-
a_post("/1/lists/members/destroy.json").
|
386
|
-
with(:body => {:user_id => "7505382", :slug => "presidents", :owner_screen_name => "sferik"}).
|
387
|
-
should have_been_made.times(3)
|
388
|
-
end
|
389
|
-
end
|
390
380
|
end
|
391
381
|
end
|
392
382
|
|
@@ -397,18 +387,18 @@ describe T::CLI::List::Remove do
|
|
397
387
|
to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
398
388
|
end
|
399
389
|
it "should request the correct resource" do
|
400
|
-
stub_post("/1/lists/members/
|
390
|
+
stub_post("/1/lists/members/destroy_all.json").
|
401
391
|
with(:body => {:screen_name => "sferik", :slug => "presidents", :owner_screen_name => "sferik"}).
|
402
392
|
to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
403
393
|
@t.list("remove", "users", "presidents", "sferik")
|
404
394
|
a_get("/1/account/verify_credentials.json").
|
405
395
|
should have_been_made
|
406
|
-
a_post("/1/lists/members/
|
396
|
+
a_post("/1/lists/members/destroy_all.json").
|
407
397
|
with(:body => {:screen_name => "sferik", :slug => "presidents", :owner_screen_name => "sferik"}).
|
408
398
|
should have_been_made
|
409
399
|
end
|
410
400
|
it "should have the correct output" do
|
411
|
-
stub_post("/1/lists/members/
|
401
|
+
stub_post("/1/lists/members/destroy_all.json").
|
412
402
|
with(:body => {:screen_name => "sferik", :slug => "presidents", :owner_screen_name => "sferik"}).
|
413
403
|
to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
414
404
|
@t.list("remove", "users", "presidents", "sferik")
|
@@ -416,13 +406,13 @@ describe T::CLI::List::Remove do
|
|
416
406
|
end
|
417
407
|
context "Twitter is down" do
|
418
408
|
it "should retry 3 times and then raise an error" do
|
419
|
-
stub_post("/1/lists/members/
|
409
|
+
stub_post("/1/lists/members/destroy_all.json").
|
420
410
|
with(:body => {:screen_name => "sferik", :slug => "presidents", :owner_screen_name => "sferik"}).
|
421
411
|
to_return(:status => 502)
|
422
412
|
lambda do
|
423
413
|
@t.list("remove", "users", "presidents", "sferik")
|
424
414
|
end.should raise_error("Twitter is down or being upgraded.")
|
425
|
-
a_post("/1/lists/members/
|
415
|
+
a_post("/1/lists/members/destroy_all.json").
|
426
416
|
with(:body => {:screen_name => "sferik", :slug => "presidents", :owner_screen_name => "sferik"}).
|
427
417
|
should have_been_made.times(3)
|
428
418
|
end
|