t 1.3.0 → 1.3.1
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/README.md +27 -27
- data/lib/t/cli.rb +1 -1
- data/lib/t/version.rb +1 -1
- data/spec/cli_spec.rb +443 -981
- data/spec/delete_spec.rb +43 -99
- data/spec/helper.rb +6 -0
- data/spec/list_spec.rb +69 -151
- data/spec/rcfile_spec.rb +66 -66
- data/spec/search_spec.rb +126 -280
- data/spec/set_spec.rb +28 -52
- data/spec/stream_spec.rb +33 -33
- data/spec/utils_spec.rb +21 -21
- metadata +2 -2
data/spec/list_spec.rb
CHANGED
@@ -31,51 +31,36 @@ describe T::List do
|
|
31
31
|
describe "#add" do
|
32
32
|
before do
|
33
33
|
@list.options = @list.options.merge("profile" => fixture_path + "/.trc")
|
34
|
-
stub_get("/1.1/account/verify_credentials.json").
|
35
|
-
|
36
|
-
stub_post("/1.1/lists/members/create_all.json").
|
37
|
-
with(:body => {:screen_name => "BarackObama", :slug => "presidents", :owner_screen_name => "sferik"}).
|
38
|
-
to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
34
|
+
stub_get("/1.1/account/verify_credentials.json").to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
35
|
+
stub_post("/1.1/lists/members/create_all.json").with(:body => {:screen_name => "BarackObama", :slug => "presidents", :owner_screen_name => "sferik"}).to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
39
36
|
end
|
40
37
|
it "should request the correct resource" do
|
41
38
|
@list.add("presidents", "BarackObama")
|
42
|
-
a_get("/1.1/account/verify_credentials.json").
|
43
|
-
|
44
|
-
a_post("/1.1/lists/members/create_all.json").
|
45
|
-
with(:body => {:screen_name => "BarackObama", :slug => "presidents", :owner_screen_name => "sferik"}).
|
46
|
-
should have_been_made
|
39
|
+
expect(a_get("/1.1/account/verify_credentials.json")).to have_been_made
|
40
|
+
expect(a_post("/1.1/lists/members/create_all.json").with(:body => {:screen_name => "BarackObama", :slug => "presidents", :owner_screen_name => "sferik"})).to have_been_made
|
47
41
|
end
|
48
42
|
it "should have the correct output" do
|
49
43
|
@list.add("presidents", "BarackObama")
|
50
|
-
$stdout.string.split("\n").first.
|
44
|
+
expect($stdout.string.split("\n").first).to eq "@testcli added 1 member to the list \"presidents\"."
|
51
45
|
end
|
52
46
|
context "--id" do
|
53
47
|
before do
|
54
48
|
@list.options = @list.options.merge("id" => true)
|
55
|
-
stub_post("/1.1/lists/members/create_all.json").
|
56
|
-
with(:body => {:user_id => "7505382", :slug => "presidents", :owner_screen_name => "sferik"}).
|
57
|
-
to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
49
|
+
stub_post("/1.1/lists/members/create_all.json").with(:body => {:user_id => "7505382", :slug => "presidents", :owner_screen_name => "sferik"}).to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
58
50
|
end
|
59
51
|
it "should request the correct resource" do
|
60
52
|
@list.add("presidents", "7505382")
|
61
|
-
a_get("/1.1/account/verify_credentials.json").
|
62
|
-
|
63
|
-
a_post("/1.1/lists/members/create_all.json").
|
64
|
-
with(:body => {:user_id => "7505382", :slug => "presidents", :owner_screen_name => "sferik"}).
|
65
|
-
should have_been_made
|
53
|
+
expect(a_get("/1.1/account/verify_credentials.json")).to have_been_made
|
54
|
+
expect(a_post("/1.1/lists/members/create_all.json").with(:body => {:user_id => "7505382", :slug => "presidents", :owner_screen_name => "sferik"})).to have_been_made
|
66
55
|
end
|
67
56
|
end
|
68
57
|
context "Twitter is down" do
|
69
58
|
it "should retry 3 times and then raise an error" do
|
70
|
-
stub_post("/1.1/lists/members/create_all.json").
|
71
|
-
|
72
|
-
to_return(:status => 502)
|
73
|
-
lambda do
|
59
|
+
stub_post("/1.1/lists/members/create_all.json").with(:body => {:screen_name => "BarackObama", :slug => "presidents", :owner_screen_name => "sferik"}).to_return(:status => 502)
|
60
|
+
expect do
|
74
61
|
@list.add("presidents", "BarackObama")
|
75
|
-
end.
|
76
|
-
a_post("/1.1/lists/members/create_all.json").
|
77
|
-
with(:body => {:screen_name => "BarackObama", :slug => "presidents", :owner_screen_name => "sferik"}).
|
78
|
-
should have_been_made.times(3)
|
62
|
+
end.to raise_error("Twitter is down or being upgraded.")
|
63
|
+
expect(a_post("/1.1/lists/members/create_all.json").with(:body => {:screen_name => "BarackObama", :slug => "presidents", :owner_screen_name => "sferik"})).to have_been_made.times(3)
|
79
64
|
end
|
80
65
|
end
|
81
66
|
end
|
@@ -83,38 +68,30 @@ describe T::List do
|
|
83
68
|
describe "#create" do
|
84
69
|
before do
|
85
70
|
@list.options = @list.options.merge("profile" => fixture_path + "/.trc")
|
86
|
-
stub_post("/1.1/lists/create.json").
|
87
|
-
with(:body => {:name => "presidents"}).
|
88
|
-
to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
71
|
+
stub_post("/1.1/lists/create.json").with(:body => {:name => "presidents"}).to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
89
72
|
end
|
90
73
|
it "should request the correct resource" do
|
91
74
|
@list.create("presidents")
|
92
|
-
a_post("/1.1/lists/create.json").
|
93
|
-
with(:body => {:name => "presidents"}).
|
94
|
-
should have_been_made
|
75
|
+
expect(a_post("/1.1/lists/create.json").with(:body => {:name => "presidents"})).to have_been_made
|
95
76
|
end
|
96
77
|
it "should have the correct output" do
|
97
78
|
@list.create("presidents")
|
98
|
-
$stdout.string.chomp.
|
79
|
+
expect($stdout.string.chomp).to eq "@testcli created the list \"presidents\"."
|
99
80
|
end
|
100
81
|
end
|
101
82
|
|
102
83
|
describe "#information" do
|
103
84
|
before do
|
104
85
|
@list.options = @list.options.merge("profile" => fixture_path + "/.trc")
|
105
|
-
stub_get("/1.1/lists/show.json").
|
106
|
-
with(:query => {:owner_screen_name => "testcli", :slug => "presidents"}).
|
107
|
-
to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
86
|
+
stub_get("/1.1/lists/show.json").with(:query => {:owner_screen_name => "testcli", :slug => "presidents"}).to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
108
87
|
end
|
109
88
|
it "should request the correct resource" do
|
110
89
|
@list.information("presidents")
|
111
|
-
a_get("/1.1/lists/show.json").
|
112
|
-
with(:query => {:owner_screen_name => "testcli", :slug => "presidents"}).
|
113
|
-
should have_been_made
|
90
|
+
expect(a_get("/1.1/lists/show.json").with(:query => {:owner_screen_name => "testcli", :slug => "presidents"})).to have_been_made
|
114
91
|
end
|
115
92
|
it "should have the correct output" do
|
116
93
|
@list.information("presidents")
|
117
|
-
$stdout.string.
|
94
|
+
expect($stdout.string).to eq <<-eos
|
118
95
|
ID 8863586
|
119
96
|
Description Presidents of the United States of America
|
120
97
|
Slug presidents
|
@@ -130,22 +107,16 @@ URL https://twitter.com/sferik/presidents
|
|
130
107
|
context "with a user passed" do
|
131
108
|
it "should request the correct resource" do
|
132
109
|
@list.information("testcli/presidents")
|
133
|
-
a_get("/1.1/lists/show.json").
|
134
|
-
with(:query => {:owner_screen_name => "testcli", :slug => "presidents"}).
|
135
|
-
should have_been_made
|
110
|
+
expect(a_get("/1.1/lists/show.json").with(:query => {:owner_screen_name => "testcli", :slug => "presidents"})).to have_been_made
|
136
111
|
end
|
137
112
|
context "--id" do
|
138
113
|
before do
|
139
114
|
@list.options = @list.options.merge("id" => true)
|
140
|
-
stub_get("/1.1/lists/show.json").
|
141
|
-
with(:query => {:owner_id => "7505382", :slug => "presidents"}).
|
142
|
-
to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
115
|
+
stub_get("/1.1/lists/show.json").with(:query => {:owner_id => "7505382", :slug => "presidents"}).to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
143
116
|
end
|
144
117
|
it "should request the correct resource" do
|
145
118
|
@list.information("7505382/presidents")
|
146
|
-
a_get("/1.1/lists/show.json").
|
147
|
-
with(:query => {:owner_id => "7505382", :slug => "presidents"}).
|
148
|
-
should have_been_made
|
119
|
+
expect(a_get("/1.1/lists/show.json").with(:query => {:owner_id => "7505382", :slug => "presidents"})).to have_been_made
|
149
120
|
end
|
150
121
|
end
|
151
122
|
end
|
@@ -155,7 +126,7 @@ URL https://twitter.com/sferik/presidents
|
|
155
126
|
end
|
156
127
|
it "should have the correct output" do
|
157
128
|
@list.information("presidents")
|
158
|
-
$stdout.string.
|
129
|
+
expect($stdout.string).to eq <<-eos
|
159
130
|
ID,Description,Slug,Screen name,Created at,Members,Subscribers,Following,Mode,URL
|
160
131
|
8863586,Presidents of the United States of America,presidents,sferik,2010-03-15 12:10:13 +0000,2,1,false,public,https://twitter.com/sferik/presidents
|
161
132
|
eos
|
@@ -165,19 +136,15 @@ ID,Description,Slug,Screen name,Created at,Members,Subscribers,Following,Mode,UR
|
|
165
136
|
|
166
137
|
describe "#members" do
|
167
138
|
before do
|
168
|
-
stub_get("/1.1/lists/members.json").
|
169
|
-
with(:query => {:cursor => "-1", :owner_screen_name => "testcli", :skip_status => "true", :slug => "presidents"}).
|
170
|
-
to_return(:body => fixture("users_list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
139
|
+
stub_get("/1.1/lists/members.json").with(:query => {:cursor => "-1", :owner_screen_name => "testcli", :skip_status => "true", :slug => "presidents"}).to_return(:body => fixture("users_list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
171
140
|
end
|
172
141
|
it "should request the correct resource" do
|
173
142
|
@list.members("presidents")
|
174
|
-
a_get("/1.1/lists/members.json").
|
175
|
-
with(:query => {:cursor => "-1", :owner_screen_name => "testcli", :skip_status => "true", :slug => "presidents"}).
|
176
|
-
should have_been_made
|
143
|
+
expect(a_get("/1.1/lists/members.json").with(:query => {:cursor => "-1", :owner_screen_name => "testcli", :skip_status => "true", :slug => "presidents"})).to have_been_made
|
177
144
|
end
|
178
145
|
it "should have the correct output" do
|
179
146
|
@list.members("presidents")
|
180
|
-
$stdout.string.chomp.
|
147
|
+
expect($stdout.string.chomp).to eq "pengwynn sferik"
|
181
148
|
end
|
182
149
|
context "--csv" do
|
183
150
|
before do
|
@@ -185,7 +152,7 @@ ID,Description,Slug,Screen name,Created at,Members,Subscribers,Following,Mode,UR
|
|
185
152
|
end
|
186
153
|
it "should output in CSV format" do
|
187
154
|
@list.members("presidents")
|
188
|
-
$stdout.string.
|
155
|
+
expect($stdout.string).to eq <<-eos
|
189
156
|
ID,Since,Last tweeted at,Tweets,Favorites,Listed,Following,Followers,Screen name,Name
|
190
157
|
14100886,2008-03-08 16:34:22 +0000,2012-07-07 20:33:19 +0000,6940,192,358,3427,5457,pengwynn,Wynn Netherland ⚡
|
191
158
|
7505382,2007-07-16 12:59:01 +0000,2012-07-08 18:29:20 +0000,7890,3755,118,212,2262,sferik,Erik Michaels-Ober
|
@@ -198,7 +165,7 @@ ID,Since,Last tweeted at,Tweets,Favorites,Listed,Following,Followers,Screen name
|
|
198
165
|
end
|
199
166
|
it "should output in long format" do
|
200
167
|
@list.members("presidents")
|
201
|
-
$stdout.string.
|
168
|
+
expect($stdout.string).to eq <<-eos
|
202
169
|
ID Since Last tweeted at Tweets Favorites Listed Following...
|
203
170
|
14100886 Mar 8 2008 Jul 7 12:33 6940 192 358 3427...
|
204
171
|
7505382 Jul 16 2007 Jul 8 10:29 7890 3755 118 212...
|
@@ -211,7 +178,7 @@ ID Since Last tweeted at Tweets Favorites Listed Following...
|
|
211
178
|
end
|
212
179
|
it "should reverse the order of the sort" do
|
213
180
|
@list.members("presidents")
|
214
|
-
$stdout.string.chomp.
|
181
|
+
expect($stdout.string.chomp).to eq "sferik pengwynn"
|
215
182
|
end
|
216
183
|
end
|
217
184
|
context "--sort=favorites" do
|
@@ -220,7 +187,7 @@ ID Since Last tweeted at Tweets Favorites Listed Following...
|
|
220
187
|
end
|
221
188
|
it "should sort by number of favorites" do
|
222
189
|
@list.members("presidents")
|
223
|
-
$stdout.string.chomp.
|
190
|
+
expect($stdout.string.chomp).to eq "pengwynn sferik"
|
224
191
|
end
|
225
192
|
end
|
226
193
|
context "--sort=followers" do
|
@@ -229,7 +196,7 @@ ID Since Last tweeted at Tweets Favorites Listed Following...
|
|
229
196
|
end
|
230
197
|
it "should sort by number of followers" do
|
231
198
|
@list.members("presidents")
|
232
|
-
$stdout.string.chomp.
|
199
|
+
expect($stdout.string.chomp).to eq "sferik pengwynn"
|
233
200
|
end
|
234
201
|
end
|
235
202
|
context "--sort=friends" do
|
@@ -238,7 +205,7 @@ ID Since Last tweeted at Tweets Favorites Listed Following...
|
|
238
205
|
end
|
239
206
|
it "should sort by number of friends" do
|
240
207
|
@list.members("presidents")
|
241
|
-
$stdout.string.chomp.
|
208
|
+
expect($stdout.string.chomp).to eq "sferik pengwynn"
|
242
209
|
end
|
243
210
|
end
|
244
211
|
context "--sort=listed" do
|
@@ -247,7 +214,7 @@ ID Since Last tweeted at Tweets Favorites Listed Following...
|
|
247
214
|
end
|
248
215
|
it "should sort by number of list memberships" do
|
249
216
|
@list.members("presidents")
|
250
|
-
$stdout.string.chomp.
|
217
|
+
expect($stdout.string.chomp).to eq "sferik pengwynn"
|
251
218
|
end
|
252
219
|
end
|
253
220
|
context "--sort=since" do
|
@@ -256,7 +223,7 @@ ID Since Last tweeted at Tweets Favorites Listed Following...
|
|
256
223
|
end
|
257
224
|
it "should sort by the time wshen Twitter account was created" do
|
258
225
|
@list.members("presidents")
|
259
|
-
$stdout.string.chomp.
|
226
|
+
expect($stdout.string.chomp).to eq "sferik pengwynn"
|
260
227
|
end
|
261
228
|
end
|
262
229
|
context "--sort=tweets" do
|
@@ -265,7 +232,7 @@ ID Since Last tweeted at Tweets Favorites Listed Following...
|
|
265
232
|
end
|
266
233
|
it "should sort by number of Tweets" do
|
267
234
|
@list.members("presidents")
|
268
|
-
$stdout.string.chomp.
|
235
|
+
expect($stdout.string.chomp).to eq "pengwynn sferik"
|
269
236
|
end
|
270
237
|
end
|
271
238
|
context "--sort=tweeted" do
|
@@ -274,7 +241,7 @@ ID Since Last tweeted at Tweets Favorites Listed Following...
|
|
274
241
|
end
|
275
242
|
it "should sort by the time of the last Tweet" do
|
276
243
|
@list.members("presidents")
|
277
|
-
$stdout.string.chomp.
|
244
|
+
expect($stdout.string.chomp).to eq "pengwynn sferik"
|
278
245
|
end
|
279
246
|
end
|
280
247
|
context "--unsorted" do
|
@@ -283,28 +250,22 @@ ID Since Last tweeted at Tweets Favorites Listed Following...
|
|
283
250
|
end
|
284
251
|
it "should not be sorted" do
|
285
252
|
@list.members("presidents")
|
286
|
-
$stdout.string.chomp.
|
253
|
+
expect($stdout.string.chomp).to eq "sferik pengwynn"
|
287
254
|
end
|
288
255
|
end
|
289
256
|
context "with a user passed" do
|
290
257
|
it "should request the correct resource" do
|
291
258
|
@list.members("testcli/presidents")
|
292
|
-
a_get("/1.1/lists/members.json").
|
293
|
-
with(:query => {:cursor => "-1", :owner_screen_name => "testcli", :skip_status => "true", :slug => "presidents"}).
|
294
|
-
should have_been_made
|
259
|
+
expect(a_get("/1.1/lists/members.json").with(:query => {:cursor => "-1", :owner_screen_name => "testcli", :skip_status => "true", :slug => "presidents"})).to have_been_made
|
295
260
|
end
|
296
261
|
context "--id" do
|
297
262
|
before do
|
298
263
|
@list.options = @list.options.merge("id" => true)
|
299
|
-
stub_get("/1.1/lists/members.json").
|
300
|
-
with(:query => {:cursor => "-1", :owner_id => "7505382", :skip_status => "true", :slug => "presidents"}).
|
301
|
-
to_return(:body => fixture("users_list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
264
|
+
stub_get("/1.1/lists/members.json").with(:query => {:cursor => "-1", :owner_id => "7505382", :skip_status => "true", :slug => "presidents"}).to_return(:body => fixture("users_list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
302
265
|
end
|
303
266
|
it "should request the correct resource" do
|
304
267
|
@list.members("7505382/presidents")
|
305
|
-
a_get("/1.1/lists/members.json").
|
306
|
-
with(:query => {:cursor => "-1", :owner_id => "7505382", :skip_status => "true", :slug => "presidents"}).
|
307
|
-
should have_been_made
|
268
|
+
expect(a_get("/1.1/lists/members.json").with(:query => {:cursor => "-1", :owner_id => "7505382", :skip_status => "true", :slug => "presidents"})).to have_been_made
|
308
269
|
end
|
309
270
|
end
|
310
271
|
end
|
@@ -313,73 +274,52 @@ ID Since Last tweeted at Tweets Favorites Listed Following...
|
|
313
274
|
describe "#remove" do
|
314
275
|
before do
|
315
276
|
@list.options = @list.options.merge("profile" => fixture_path + "/.trc")
|
316
|
-
stub_get("/1.1/account/verify_credentials.json").
|
317
|
-
to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
277
|
+
stub_get("/1.1/account/verify_credentials.json").to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
318
278
|
end
|
319
279
|
it "should request the correct resource" do
|
320
|
-
stub_post("/1.1/lists/members/destroy_all.json").
|
321
|
-
with(:body => {:screen_name => "BarackObama", :slug => "presidents", :owner_screen_name => "sferik"}).
|
322
|
-
to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
280
|
+
stub_post("/1.1/lists/members/destroy_all.json").with(:body => {:screen_name => "BarackObama", :slug => "presidents", :owner_screen_name => "sferik"}).to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
323
281
|
@list.remove("presidents", "BarackObama")
|
324
|
-
a_get("/1.1/account/verify_credentials.json").
|
325
|
-
|
326
|
-
a_post("/1.1/lists/members/destroy_all.json").
|
327
|
-
with(:body => {:screen_name => "BarackObama", :slug => "presidents", :owner_screen_name => "sferik"}).
|
328
|
-
should have_been_made
|
282
|
+
expect(a_get("/1.1/account/verify_credentials.json")).to have_been_made
|
283
|
+
expect(a_post("/1.1/lists/members/destroy_all.json").with(:body => {:screen_name => "BarackObama", :slug => "presidents", :owner_screen_name => "sferik"})).to have_been_made
|
329
284
|
end
|
330
285
|
it "should have the correct output" do
|
331
|
-
stub_post("/1.1/lists/members/destroy_all.json").
|
332
|
-
with(:body => {:screen_name => "BarackObama", :slug => "presidents", :owner_screen_name => "sferik"}).
|
333
|
-
to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
286
|
+
stub_post("/1.1/lists/members/destroy_all.json").with(:body => {:screen_name => "BarackObama", :slug => "presidents", :owner_screen_name => "sferik"}).to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
334
287
|
@list.remove("presidents", "BarackObama")
|
335
|
-
$stdout.string.split("\n").first.
|
288
|
+
expect($stdout.string.split("\n").first).to eq "@testcli removed 1 member from the list \"presidents\"."
|
336
289
|
end
|
337
290
|
context "--id" do
|
338
291
|
before do
|
339
292
|
@list.options = @list.options.merge("id" => true)
|
340
|
-
stub_post("/1.1/lists/members/destroy_all.json").
|
341
|
-
with(:body => {:user_id => "7505382", :slug => "presidents", :owner_screen_name => "sferik"}).
|
342
|
-
to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
293
|
+
stub_post("/1.1/lists/members/destroy_all.json").with(:body => {:user_id => "7505382", :slug => "presidents", :owner_screen_name => "sferik"}).to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
343
294
|
end
|
344
295
|
it "should request the correct resource" do
|
345
296
|
@list.remove("presidents", "7505382")
|
346
|
-
a_get("/1.1/account/verify_credentials.json").
|
347
|
-
|
348
|
-
a_post("/1.1/lists/members/destroy_all.json").
|
349
|
-
with(:body => {:user_id => "7505382", :slug => "presidents", :owner_screen_name => "sferik"}).
|
350
|
-
should have_been_made
|
297
|
+
expect(a_get("/1.1/account/verify_credentials.json")).to have_been_made
|
298
|
+
expect(a_post("/1.1/lists/members/destroy_all.json").with(:body => {:user_id => "7505382", :slug => "presidents", :owner_screen_name => "sferik"})).to have_been_made
|
351
299
|
end
|
352
300
|
end
|
353
301
|
context "Twitter is down" do
|
354
302
|
it "should retry 3 times and then raise an error" do
|
355
|
-
stub_post("/1.1/lists/members/destroy_all.json").
|
356
|
-
|
357
|
-
to_return(:status => 502)
|
358
|
-
lambda do
|
303
|
+
stub_post("/1.1/lists/members/destroy_all.json").with(:body => {:screen_name => "BarackObama", :slug => "presidents", :owner_screen_name => "sferik"}).to_return(:status => 502)
|
304
|
+
expect do
|
359
305
|
@list.remove("presidents", "BarackObama")
|
360
|
-
end.
|
361
|
-
a_post("/1.1/lists/members/destroy_all.json").
|
362
|
-
with(:body => {:screen_name => "BarackObama", :slug => "presidents", :owner_screen_name => "sferik"}).
|
363
|
-
should have_been_made.times(3)
|
306
|
+
end.to raise_error("Twitter is down or being upgraded.")
|
307
|
+
expect(a_post("/1.1/lists/members/destroy_all.json").with(:body => {:screen_name => "BarackObama", :slug => "presidents", :owner_screen_name => "sferik"})).to have_been_made.times(3)
|
364
308
|
end
|
365
309
|
end
|
366
310
|
end
|
367
311
|
|
368
312
|
describe "#timeline" do
|
369
313
|
before do
|
370
|
-
stub_get("/1.1/lists/statuses.json").
|
371
|
-
with(:query => {:owner_screen_name => "testcli", :per_page => "20", :slug => "presidents"}).
|
372
|
-
to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
314
|
+
stub_get("/1.1/lists/statuses.json").with(:query => {:owner_screen_name => "testcli", :per_page => "20", :slug => "presidents"}).to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
373
315
|
end
|
374
316
|
it "should request the correct resource" do
|
375
317
|
@list.timeline("presidents")
|
376
|
-
a_get("/1.1/lists/statuses.json").
|
377
|
-
with(:query => {:owner_screen_name => "testcli", :per_page => "20", :slug => "presidents"}).
|
378
|
-
should have_been_made
|
318
|
+
expect(a_get("/1.1/lists/statuses.json").with(:query => {:owner_screen_name => "testcli", :per_page => "20", :slug => "presidents"})).to have_been_made
|
379
319
|
end
|
380
320
|
it "should have the correct output" do
|
381
321
|
@list.timeline("presidents")
|
382
|
-
$stdout.string.
|
322
|
+
expect($stdout.string).to eq <<-eos
|
383
323
|
\e[1m\e[33m @mutgoff\e[0m
|
384
324
|
Happy Birthday @imdane. Watch out for those @rally pranksters!
|
385
325
|
|
@@ -463,7 +403,7 @@ ID Since Last tweeted at Tweets Favorites Listed Following...
|
|
463
403
|
end
|
464
404
|
it "should output in long format" do
|
465
405
|
@list.timeline("presidents")
|
466
|
-
$stdout.string.
|
406
|
+
expect($stdout.string).to eq <<-eos
|
467
407
|
ID,Posted at,Screen name,Text
|
468
408
|
244111636544225280,2012-09-07 16:35:24 +0000,mutgoff,Happy Birthday @imdane. Watch out for those @rally pranksters!
|
469
409
|
244111183165157376,2012-09-07 16:33:36 +0000,ironicsans,"If you like good real-life stories, check out @NarrativelyNY's just-launched site http://t.co/wiUL07jE (and also visit http://t.co/ZoyQxqWA)"
|
@@ -494,7 +434,7 @@ ID,Posted at,Screen name,Text
|
|
494
434
|
end
|
495
435
|
it "should output in long format" do
|
496
436
|
@list.timeline("presidents")
|
497
|
-
$stdout.string.
|
437
|
+
expect($stdout.string).to eq <<-eos
|
498
438
|
ID Posted at Screen name Text
|
499
439
|
244111636544225280 Sep 7 08:35 @mutgoff Happy Birthday @imdane. W...
|
500
440
|
244111183165157376 Sep 7 08:33 @ironicsans If you like good real-lif...
|
@@ -524,7 +464,7 @@ ID Posted at Screen name Text
|
|
524
464
|
end
|
525
465
|
it "should reverse the order of the sort" do
|
526
466
|
@list.timeline("presidents")
|
527
|
-
$stdout.string.
|
467
|
+
expect($stdout.string).to eq <<-eos
|
528
468
|
ID Posted at Screen name Text
|
529
469
|
244099460672679938 Sep 7 07:47 @dwiskus Gentlemen, you can't figh...
|
530
470
|
244100411563339777 Sep 7 07:50 @sferik @episod @twitterapi Did y...
|
@@ -552,63 +492,41 @@ ID Posted at Screen name Text
|
|
552
492
|
end
|
553
493
|
context "--number" do
|
554
494
|
before do
|
555
|
-
stub_get("/1.1/lists/statuses.json").
|
556
|
-
|
557
|
-
|
558
|
-
stub_get("/1.1/lists/statuses.json").
|
559
|
-
with(:query => {:owner_screen_name => "testcli", :per_page => "200", :slug => "presidents"}).
|
560
|
-
to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
561
|
-
stub_get("/1.1/lists/statuses.json").
|
562
|
-
with(:query => {:owner_screen_name => "testcli", :per_page => "200", :max_id => "244099460672679937", :slug => "presidents"}).
|
563
|
-
to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
495
|
+
stub_get("/1.1/lists/statuses.json").with(:query => {:owner_screen_name => "testcli", :per_page => "1", :slug => "presidents"}).to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
496
|
+
stub_get("/1.1/lists/statuses.json").with(:query => {:owner_screen_name => "testcli", :per_page => "200", :slug => "presidents"}).to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
497
|
+
stub_get("/1.1/lists/statuses.json").with(:query => {:owner_screen_name => "testcli", :per_page => "200", :max_id => "244099460672679937", :slug => "presidents"}).to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
564
498
|
(5..185).step(20).to_a.reverse.each do |count|
|
565
|
-
stub_get("/1.1/lists/statuses.json").
|
566
|
-
with(:query => {:owner_screen_name => "testcli", :per_page => count, :max_id => "244099460672679937", :slug => "presidents"}).
|
567
|
-
to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
499
|
+
stub_get("/1.1/lists/statuses.json").with(:query => {:owner_screen_name => "testcli", :per_page => count, :max_id => "244099460672679937", :slug => "presidents"}).to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
568
500
|
end
|
569
501
|
end
|
570
502
|
it "should limit the number of results to 1" do
|
571
503
|
@list.options = @list.options.merge("number" => 1)
|
572
504
|
@list.timeline("presidents")
|
573
|
-
a_get("/1.1/lists/statuses.json").
|
574
|
-
with(:query => {:owner_screen_name => "testcli", :per_page => "1", :slug => "presidents"}).
|
575
|
-
should have_been_made
|
505
|
+
expect(a_get("/1.1/lists/statuses.json").with(:query => {:owner_screen_name => "testcli", :per_page => "1", :slug => "presidents"})).to have_been_made
|
576
506
|
end
|
577
507
|
it "should limit the number of results to 345" do
|
578
508
|
@list.options = @list.options.merge("number" => 345)
|
579
509
|
@list.timeline("presidents")
|
580
|
-
a_get("/1.1/lists/statuses.json").
|
581
|
-
|
582
|
-
should have_been_made
|
583
|
-
a_get("/1.1/lists/statuses.json").
|
584
|
-
with(:query => {:owner_screen_name => "testcli", :per_page => "200", :max_id => "244099460672679937", :slug => "presidents"}).
|
585
|
-
should have_been_made.times(7)
|
510
|
+
expect(a_get("/1.1/lists/statuses.json").with(:query => {:owner_screen_name => "testcli", :per_page => "200", :slug => "presidents"})).to have_been_made
|
511
|
+
expect(a_get("/1.1/lists/statuses.json").with(:query => {:owner_screen_name => "testcli", :per_page => "200", :max_id => "244099460672679937", :slug => "presidents"})).to have_been_made.times(7)
|
586
512
|
(5..185).step(20).to_a.reverse.each do |count|
|
587
|
-
a_get("/1.1/lists/statuses.json").
|
588
|
-
with(:query => {:owner_screen_name => "testcli", :per_page => count, :max_id => "244099460672679937", :slug => "presidents"}).
|
589
|
-
should have_been_made
|
513
|
+
expect(a_get("/1.1/lists/statuses.json").with(:query => {:owner_screen_name => "testcli", :per_page => count, :max_id => "244099460672679937", :slug => "presidents"})).to have_been_made
|
590
514
|
end
|
591
515
|
end
|
592
516
|
end
|
593
517
|
context "with a user passed" do
|
594
518
|
it "should request the correct resource" do
|
595
519
|
@list.timeline("testcli/presidents")
|
596
|
-
a_get("/1.1/lists/statuses.json").
|
597
|
-
with(:query => {:owner_screen_name => "testcli", :per_page => "20", :slug => "presidents"}).
|
598
|
-
should have_been_made
|
520
|
+
expect(a_get("/1.1/lists/statuses.json").with(:query => {:owner_screen_name => "testcli", :per_page => "20", :slug => "presidents"})).to have_been_made
|
599
521
|
end
|
600
522
|
context "--id" do
|
601
523
|
before do
|
602
524
|
@list.options = @list.options.merge("id" => true)
|
603
|
-
stub_get("/1.1/lists/statuses.json").
|
604
|
-
with(:query => {:owner_id => "7505382", :per_page => "20", :slug => "presidents"}).
|
605
|
-
to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
525
|
+
stub_get("/1.1/lists/statuses.json").with(:query => {:owner_id => "7505382", :per_page => "20", :slug => "presidents"}).to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
606
526
|
end
|
607
527
|
it "should request the correct resource" do
|
608
528
|
@list.timeline("7505382/presidents")
|
609
|
-
a_get("/1.1/lists/statuses.json").
|
610
|
-
with(:query => {:owner_id => "7505382", :per_page => "20", :slug => "presidents"}).
|
611
|
-
should have_been_made
|
529
|
+
expect(a_get("/1.1/lists/statuses.json").with(:query => {:owner_id => "7505382", :per_page => "20", :slug => "presidents"})).to have_been_made
|
612
530
|
end
|
613
531
|
end
|
614
532
|
end
|