t 0.2.1 → 0.3.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/README.md +29 -13
- data/lib/t/cli.rb +51 -59
- data/lib/t/cli/follow.rb +47 -6
- data/lib/t/cli/list.rb +10 -8
- data/lib/t/cli/list/add.rb +98 -4
- data/lib/t/cli/list/remove.rb +99 -6
- data/lib/t/cli/search.rb +128 -0
- data/lib/t/cli/set.rb +1 -1
- data/lib/t/cli/unfollow.rb +90 -6
- data/lib/t/collectable.rb +12 -0
- data/lib/t/version.rb +2 -2
- data/spec/cli/follow_spec.rb +192 -3
- data/spec/cli/list/add_spec.rb +407 -14
- data/spec/cli/list/remove_spec.rb +392 -2
- data/spec/cli/search_spec.rb +205 -0
- data/spec/cli/unfollow_spec.rb +362 -3
- data/spec/cli_spec.rb +72 -99
- data/spec/rcfile_spec.rb +15 -17
- data/t.gemspec +1 -0
- metadata +45 -42
- data/lib/t/cli/follow/all.rb +0 -97
- data/lib/t/cli/list/add/all.rb +0 -169
- data/lib/t/cli/list/remove/all.rb +0 -163
- data/lib/t/cli/unfollow/all.rb +0 -148
- data/spec/cli/follow/all_spec.rb +0 -158
- data/spec/cli/list/add/all_spec.rb +0 -435
- data/spec/cli/list/remove/all_spec.rb +0 -315
- data/spec/cli/unfollow/all_spec.rb +0 -292
data/spec/cli/list/add_spec.rb
CHANGED
@@ -16,26 +16,419 @@ describe T::CLI::List::Add do
|
|
16
16
|
$stdout = @old_stdout
|
17
17
|
end
|
18
18
|
|
19
|
-
describe "#
|
19
|
+
describe "#friends" do
|
20
20
|
before do
|
21
21
|
@t.options = @t.options.merge(:profile => fixture_path + "/.trc")
|
22
22
|
stub_get("/1/account/verify_credentials.json").
|
23
23
|
to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
24
|
-
stub_post("/1/lists/members/create_all.json").
|
25
|
-
with(:body => {:screen_name => "sferik", :slug => "presidents", :owner_screen_name => "sferik"}).
|
26
|
-
to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
27
24
|
end
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
25
|
+
context "no friends" do
|
26
|
+
before do
|
27
|
+
stub_get("/1/lists/members.json").
|
28
|
+
with(:query => {:cursor => "-1", :include_entities => "false", :owner_screen_name => "sferik", :skip_status => "true", :slug => "presidents"}).
|
29
|
+
to_return(:body => fixture("empty_cursor.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
30
|
+
stub_get("/1/friends/ids.json").
|
31
|
+
with(:query => {:cursor => "-1"}).
|
32
|
+
to_return(:body => fixture("empty_cursor.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
33
|
+
end
|
34
|
+
it "should request the correct resource" do
|
35
|
+
@t.list("add", "friends", "presidents")
|
36
|
+
a_get("/1/friends/ids.json").
|
37
|
+
with(:query => {:cursor => "-1"}).
|
38
|
+
should have_been_made
|
39
|
+
end
|
40
|
+
it "should have the correct output" do
|
41
|
+
@t.list("add", "friends", "presidents")
|
42
|
+
$stdout.string.chomp.should == "All of @testcli's friends are already members of the list \"presidents\"."
|
43
|
+
end
|
35
44
|
end
|
36
|
-
|
37
|
-
|
38
|
-
|
45
|
+
context "one friend" do
|
46
|
+
before do
|
47
|
+
stub_get("/1/lists/members.json").
|
48
|
+
with(:query => {:cursor => "-1", :include_entities => "false", :owner_screen_name => "sferik", :skip_status => "true", :slug => "presidents"}).
|
49
|
+
to_return(:body => fixture("empty_cursor.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
50
|
+
stub_get("/1/friends/ids.json").
|
51
|
+
with(:query => {:cursor => "-1"}).
|
52
|
+
to_return(:body => fixture("friends_ids.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
53
|
+
stub_post("/1/lists/members/create_all.json").
|
54
|
+
with(:body => {:user_id => "7505382", :slug => "presidents", :owner_screen_name => "sferik"}).
|
55
|
+
to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
56
|
+
end
|
57
|
+
it "should request the correct resource" do
|
58
|
+
$stdout.should_receive(:print).with("Are you sure you want to add 1 friend to the list \"presidents\"? ")
|
59
|
+
$stdin.should_receive(:gets).and_return("yes")
|
60
|
+
@t.list("add", "friends", "presidents")
|
61
|
+
a_get("/1/account/verify_credentials.json").
|
62
|
+
should have_been_made
|
63
|
+
a_get("/1/lists/members.json").
|
64
|
+
with(:query => {:cursor => "-1", :include_entities => "false", :owner_screen_name => "sferik", :skip_status => "true", :slug => "presidents"}).
|
65
|
+
should have_been_made
|
66
|
+
a_get("/1/friends/ids.json").
|
67
|
+
with(:query => {:cursor => "-1"}).
|
68
|
+
should have_been_made
|
69
|
+
a_post("/1/lists/members/create_all.json").
|
70
|
+
with(:body => {:user_id => "7505382", :slug => "presidents", :owner_screen_name => "sferik"}).
|
71
|
+
should have_been_made
|
72
|
+
end
|
73
|
+
context "yes" do
|
74
|
+
it "should have the correct output" do
|
75
|
+
$stdout.should_receive(:print).with("Are you sure you want to add 1 friend to the list \"presidents\"? ")
|
76
|
+
$stdin.should_receive(:gets).and_return("yes")
|
77
|
+
@t.list("add", "friends", "presidents")
|
78
|
+
$stdout.string.should =~ /@testcli added 1 friend to the list "presidents"\./
|
79
|
+
end
|
80
|
+
end
|
81
|
+
context "no" do
|
82
|
+
it "should have the correct output" do
|
83
|
+
$stdout.should_receive(:print).with("Are you sure you want to add 1 friend to the list \"presidents\"? ")
|
84
|
+
$stdin.should_receive(:gets).and_return("no")
|
85
|
+
@t.list("add", "friends", "presidents")
|
86
|
+
$stdout.string.chomp.should == ""
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
context "501 users" do
|
91
|
+
before do
|
92
|
+
stub_get("/1/lists/members.json").
|
93
|
+
with(:query => {:cursor => "-1", :include_entities => "false", :owner_screen_name => "sferik", :skip_status => "true", :slug => "presidents"}).
|
94
|
+
to_return(:body => fixture("empty_cursor.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
95
|
+
stub_get("/1/friends/ids.json").
|
96
|
+
with(:query => {:cursor => "-1"}).
|
97
|
+
to_return(:body => fixture("501_ids.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
98
|
+
stub_post("/1/lists/members/create_all.json").
|
99
|
+
with(:body => {:user_id => "7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382", :slug => "presidents", :owner_screen_name => "sferik"}).
|
100
|
+
to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
101
|
+
end
|
102
|
+
it "should request the correct resource" do
|
103
|
+
$stdout.should_receive(:print).with("Lists can't have more than 500 members. Do you want to add up to 500 friends to the list \"presidents\"? ")
|
104
|
+
$stdin.should_receive(:gets).and_return("yes")
|
105
|
+
@t.list("add", "friends", "presidents")
|
106
|
+
a_get("/1/account/verify_credentials.json").
|
107
|
+
should have_been_made
|
108
|
+
a_get("/1/lists/members.json").
|
109
|
+
with(:query => {:cursor => "-1", :include_entities => "false", :owner_screen_name => "sferik", :skip_status => "true", :slug => "presidents"}).
|
110
|
+
should have_been_made
|
111
|
+
a_get("/1/friends/ids.json").
|
112
|
+
with(:query => {:cursor => "-1"}).
|
113
|
+
should have_been_made
|
114
|
+
a_post("/1/lists/members/create_all.json").
|
115
|
+
with(:body => {:user_id => "7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382", :slug => "presidents", :owner_screen_name => "sferik"}).
|
116
|
+
should have_been_made.times(5)
|
117
|
+
end
|
118
|
+
context "yes" do
|
119
|
+
it "should have the correct output" do
|
120
|
+
$stdout.should_receive(:print).with("Lists can't have more than 500 members. Do you want to add up to 500 friends to the list \"presidents\"? ")
|
121
|
+
$stdin.should_receive(:gets).and_return("yes")
|
122
|
+
@t.list("add", "friends", "presidents")
|
123
|
+
$stdout.string.should =~ /@testcli added 500 friends to the list "presidents"\./
|
124
|
+
end
|
125
|
+
end
|
126
|
+
context "no" do
|
127
|
+
it "should have the correct output" do
|
128
|
+
$stdout.should_receive(:print).with("Lists can't have more than 500 members. Do you want to add up to 500 friends to the list \"presidents\"? ")
|
129
|
+
$stdin.should_receive(:gets).and_return("no")
|
130
|
+
@t.list("add", "friends", "presidents")
|
131
|
+
$stdout.string.chomp.should == ""
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
context "500 list members" do
|
136
|
+
before do
|
137
|
+
stub_get("/1/lists/members.json").
|
138
|
+
with(:query => {:cursor => "-1", :include_entities => "false", :owner_screen_name => "sferik", :skip_status => "true", :slug => "presidents"}).
|
139
|
+
to_return(:body => fixture("501_users_list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
140
|
+
end
|
141
|
+
it "should request the correct resource" do
|
142
|
+
@t.list("add", "friends", "presidents")
|
143
|
+
a_get("/1/account/verify_credentials.json").
|
144
|
+
should have_been_made
|
145
|
+
a_get("/1/lists/members.json").
|
146
|
+
with(:query => {:cursor => "-1", :include_entities => "false", :owner_screen_name => "sferik", :skip_status => "true", :slug => "presidents"}).
|
147
|
+
should have_been_made
|
148
|
+
end
|
149
|
+
it "should have the correct output" do
|
150
|
+
@t.list("add", "friends", "presidents")
|
151
|
+
$stdout.string.chomp.should == "The list \"presidents\" are already contains the maximum of 500 members."
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
describe "#followers" do
|
157
|
+
before do
|
158
|
+
@t.options = @t.options.merge(:profile => fixture_path + "/.trc")
|
159
|
+
stub_get("/1/account/verify_credentials.json").
|
160
|
+
to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
161
|
+
end
|
162
|
+
context "no followers" do
|
163
|
+
before do
|
164
|
+
stub_get("/1/lists/members.json").
|
165
|
+
with(:query => {:cursor => "-1", :include_entities => "false", :owner_screen_name => "sferik", :skip_status => "true", :slug => "presidents"}).
|
166
|
+
to_return(:body => fixture("empty_cursor.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
167
|
+
stub_get("/1/followers/ids.json").
|
168
|
+
with(:query => {:cursor => "-1"}).
|
169
|
+
to_return(:body => fixture("empty_cursor.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
170
|
+
end
|
171
|
+
it "should request the correct resource" do
|
172
|
+
@t.list("add", "followers", "presidents")
|
173
|
+
a_get("/1/followers/ids.json").
|
174
|
+
with(:query => {:cursor => "-1"}).
|
175
|
+
should have_been_made
|
176
|
+
end
|
177
|
+
it "should have the correct output" do
|
178
|
+
@t.list("add", "followers", "presidents")
|
179
|
+
$stdout.string.chomp.should == "All of @testcli's followers are already members of the list \"presidents\"."
|
180
|
+
end
|
181
|
+
end
|
182
|
+
context "two followers" do
|
183
|
+
before do
|
184
|
+
stub_get("/1/lists/members.json").
|
185
|
+
with(:query => {:cursor => "-1", :include_entities => "false", :owner_screen_name => "sferik", :skip_status => "true", :slug => "presidents"}).
|
186
|
+
to_return(:body => fixture("empty_cursor.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
187
|
+
stub_get("/1/followers/ids.json").
|
188
|
+
with(:query => {:cursor => "-1"}).
|
189
|
+
to_return(:body => fixture("followers_ids.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
190
|
+
stub_post("/1/lists/members/create_all.json").
|
191
|
+
with(:body => {:user_id => "213747670,428004849", :slug => "presidents", :owner_screen_name => "sferik"}).
|
192
|
+
to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
193
|
+
end
|
194
|
+
it "should request the correct resource" do
|
195
|
+
$stdout.should_receive(:print).with("Are you sure you want to add 2 followers to the list \"presidents\"? ")
|
196
|
+
$stdin.should_receive(:gets).and_return("yes")
|
197
|
+
@t.list("add", "followers", "presidents")
|
198
|
+
a_get("/1/account/verify_credentials.json").
|
199
|
+
should have_been_made
|
200
|
+
a_get("/1/lists/members.json").
|
201
|
+
with(:query => {:cursor => "-1", :include_entities => "false", :owner_screen_name => "sferik", :skip_status => "true", :slug => "presidents"}).
|
202
|
+
should have_been_made
|
203
|
+
a_get("/1/followers/ids.json").
|
204
|
+
with(:query => {:cursor => "-1"}).
|
205
|
+
should have_been_made
|
206
|
+
a_post("/1/lists/members/create_all.json").
|
207
|
+
with(:body => {:user_id => "213747670,428004849", :slug => "presidents", :owner_screen_name => "sferik"}).
|
208
|
+
should have_been_made
|
209
|
+
end
|
210
|
+
context "yes" do
|
211
|
+
it "should have the correct output" do
|
212
|
+
$stdout.should_receive(:print).with("Are you sure you want to add 2 followers to the list \"presidents\"? ")
|
213
|
+
$stdin.should_receive(:gets).and_return("yes")
|
214
|
+
@t.list("add", "followers", "presidents")
|
215
|
+
$stdout.string.should =~ /@testcli added 2 followers to the list "presidents"\./
|
216
|
+
end
|
217
|
+
end
|
218
|
+
context "no" do
|
219
|
+
it "should have the correct output" do
|
220
|
+
$stdout.should_receive(:print).with("Are you sure you want to add 2 followers to the list \"presidents\"? ")
|
221
|
+
$stdin.should_receive(:gets).and_return("no")
|
222
|
+
@t.list("add", "followers", "presidents")
|
223
|
+
$stdout.string.chomp.should == ""
|
224
|
+
end
|
225
|
+
end
|
226
|
+
end
|
227
|
+
context "501 users" do
|
228
|
+
before do
|
229
|
+
stub_get("/1/lists/members.json").
|
230
|
+
with(:query => {:cursor => "-1", :include_entities => "false", :owner_screen_name => "sferik", :skip_status => "true", :slug => "presidents"}).
|
231
|
+
to_return(:body => fixture("empty_cursor.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
232
|
+
stub_get("/1/followers/ids.json").
|
233
|
+
with(:query => {:cursor => "-1"}).
|
234
|
+
to_return(:body => fixture("501_ids.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
235
|
+
stub_post("/1/lists/members/create_all.json").
|
236
|
+
with(:body => {:user_id => "7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382", :slug => "presidents", :owner_screen_name => "sferik"}).
|
237
|
+
to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
238
|
+
end
|
239
|
+
it "should request the correct resource" do
|
240
|
+
$stdout.should_receive(:print).with("Lists can't have more than 500 members. Do you want to add up to 500 followers to the list \"presidents\"? ")
|
241
|
+
$stdin.should_receive(:gets).and_return("yes")
|
242
|
+
@t.list("add", "followers", "presidents")
|
243
|
+
a_get("/1/account/verify_credentials.json").
|
244
|
+
should have_been_made
|
245
|
+
a_get("/1/lists/members.json").
|
246
|
+
with(:query => {:cursor => "-1", :include_entities => "false", :owner_screen_name => "sferik", :skip_status => "true", :slug => "presidents"}).
|
247
|
+
should have_been_made
|
248
|
+
a_get("/1/followers/ids.json").
|
249
|
+
with(:query => {:cursor => "-1"}).
|
250
|
+
should have_been_made
|
251
|
+
a_post("/1/lists/members/create_all.json").
|
252
|
+
with(:body => {:user_id => "7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382", :slug => "presidents", :owner_screen_name => "sferik"}).
|
253
|
+
should have_been_made.times(5)
|
254
|
+
end
|
255
|
+
context "yes" do
|
256
|
+
it "should have the correct output" do
|
257
|
+
$stdout.should_receive(:print).with("Lists can't have more than 500 members. Do you want to add up to 500 followers to the list \"presidents\"? ")
|
258
|
+
$stdin.should_receive(:gets).and_return("yes")
|
259
|
+
@t.list("add", "followers", "presidents")
|
260
|
+
$stdout.string.should =~ /@testcli added 500 followers to the list "presidents"\./
|
261
|
+
end
|
262
|
+
end
|
263
|
+
context "no" do
|
264
|
+
it "should have the correct output" do
|
265
|
+
$stdout.should_receive(:print).with("Lists can't have more than 500 members. Do you want to add up to 500 followers to the list \"presidents\"? ")
|
266
|
+
$stdin.should_receive(:gets).and_return("no")
|
267
|
+
@t.list("add", "followers", "presidents")
|
268
|
+
$stdout.string.chomp.should == ""
|
269
|
+
end
|
270
|
+
end
|
271
|
+
end
|
272
|
+
context "500 list members" do
|
273
|
+
before do
|
274
|
+
stub_get("/1/lists/members.json").
|
275
|
+
with(:query => {:cursor => "-1", :include_entities => "false", :owner_screen_name => "sferik", :skip_status => "true", :slug => "presidents"}).
|
276
|
+
to_return(:body => fixture("501_users_list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
277
|
+
end
|
278
|
+
it "should request the correct resource" do
|
279
|
+
@t.list("add", "followers", "presidents")
|
280
|
+
a_get("/1/account/verify_credentials.json").
|
281
|
+
should have_been_made
|
282
|
+
a_get("/1/lists/members.json").
|
283
|
+
with(:query => {:cursor => "-1", :include_entities => "false", :owner_screen_name => "sferik", :skip_status => "true", :slug => "presidents"}).
|
284
|
+
should have_been_made
|
285
|
+
end
|
286
|
+
it "should have the correct output" do
|
287
|
+
@t.list("add", "followers", "presidents")
|
288
|
+
$stdout.string.chomp.should == "The list \"presidents\" are already contains the maximum of 500 members."
|
289
|
+
end
|
290
|
+
end
|
291
|
+
end
|
292
|
+
|
293
|
+
describe "#listed" do
|
294
|
+
before do
|
295
|
+
@t.options = @t.options.merge(:profile => fixture_path + "/.trc")
|
296
|
+
stub_get("/1/account/verify_credentials.json").
|
297
|
+
to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
298
|
+
end
|
299
|
+
context "no users" do
|
300
|
+
before do
|
301
|
+
stub_get("/1/lists/members.json").
|
302
|
+
with(:query => {:cursor => "-1", :include_entities => "false", :owner_screen_name => "sferik", :skip_status => "true", :slug => "presidents"}).
|
303
|
+
to_return(:body => fixture("empty_cursor.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
304
|
+
stub_get("/1/lists/members.json").
|
305
|
+
with(:query => {:cursor => "-1", :include_entities => "false", :owner_screen_name => "sferik", :skip_status => "true", :slug => "democrats"}).
|
306
|
+
to_return(:body => fixture("empty_cursor.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
307
|
+
end
|
308
|
+
it "should request the correct resource" do
|
309
|
+
@t.list("add", "listed", "democrats", "presidents")
|
310
|
+
a_get("/1/account/verify_credentials.json").
|
311
|
+
should have_been_made
|
312
|
+
a_get("/1/lists/members.json").
|
313
|
+
with(:query => {:cursor => "-1", :include_entities => "false", :owner_screen_name => "sferik", :skip_status => "true", :slug => "presidents"}).
|
314
|
+
should have_been_made
|
315
|
+
a_get("/1/lists/members.json").
|
316
|
+
with(:query => {:cursor => "-1", :include_entities => "false", :owner_screen_name => "sferik", :skip_status => "true", :slug => "democrats"}).
|
317
|
+
should have_been_made
|
318
|
+
end
|
319
|
+
it "should have the correct output" do
|
320
|
+
@t.list("add", "listed", "democrats", "presidents")
|
321
|
+
$stdout.string.chomp.should == "All of the members of the list \"democrats\" are already members of the list \"presidents\"."
|
322
|
+
end
|
323
|
+
end
|
324
|
+
context "one user" do
|
325
|
+
before do
|
326
|
+
stub_get("/1/lists/members.json").
|
327
|
+
with(:query => {:cursor => "-1", :include_entities => "false", :owner_screen_name => "sferik", :skip_status => "true", :slug => "presidents"}).
|
328
|
+
to_return(:body => fixture("empty_cursor.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
329
|
+
stub_get("/1/lists/members.json").
|
330
|
+
with(:query => {:cursor => "-1", :include_entities => "false", :owner_screen_name => "sferik", :skip_status => "true", :slug => "democrats"}).
|
331
|
+
to_return(:body => fixture("users_list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
332
|
+
stub_post("/1/lists/members/create_all.json").
|
333
|
+
with(:body => {:user_id => "7505382", :slug => "presidents", :owner_screen_name => "sferik"}).
|
334
|
+
to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
335
|
+
end
|
336
|
+
it "should request the correct resource" do
|
337
|
+
$stdout.should_receive(:print).with("Are you sure you want to add 1 member to the list \"presidents\"? ")
|
338
|
+
$stdin.should_receive(:gets).and_return("yes")
|
339
|
+
@t.list("add", "listed", "democrats", "presidents")
|
340
|
+
a_get("/1/account/verify_credentials.json").
|
341
|
+
should have_been_made
|
342
|
+
a_get("/1/lists/members.json").
|
343
|
+
with(:query => {:cursor => "-1", :include_entities => "false", :owner_screen_name => "sferik", :skip_status => "true", :slug => "presidents"}).
|
344
|
+
should have_been_made
|
345
|
+
a_get("/1/lists/members.json").
|
346
|
+
with(:query => {:cursor => "-1", :include_entities => "false", :owner_screen_name => "sferik", :skip_status => "true", :slug => "democrats"}).
|
347
|
+
should have_been_made
|
348
|
+
a_post("/1/lists/members/create_all.json").
|
349
|
+
with(:body => {:user_id => "7505382", :slug => "presidents", :owner_screen_name => "sferik"}).
|
350
|
+
should have_been_made
|
351
|
+
end
|
352
|
+
context "yes" do
|
353
|
+
it "should have the correct output" do
|
354
|
+
$stdout.should_receive(:print).with("Are you sure you want to add 1 member to the list \"presidents\"? ")
|
355
|
+
$stdin.should_receive(:gets).and_return("yes")
|
356
|
+
@t.list("add", "listed", "democrats", "presidents")
|
357
|
+
$stdout.string.should =~ /@testcli added 1 member to the list "presidents"\./
|
358
|
+
end
|
359
|
+
end
|
360
|
+
context "no" do
|
361
|
+
it "should have the correct output" do
|
362
|
+
$stdout.should_receive(:print).with("Are you sure you want to add 1 member to the list \"presidents\"? ")
|
363
|
+
$stdin.should_receive(:gets).and_return("no")
|
364
|
+
@t.list("add", "listed", "democrats", "presidents")
|
365
|
+
$stdout.string.chomp.should == ""
|
366
|
+
end
|
367
|
+
end
|
368
|
+
end
|
369
|
+
context "501 users" do
|
370
|
+
before do
|
371
|
+
stub_get("/1/lists/members.json").
|
372
|
+
with(:query => {:cursor => "-1", :include_entities => "false", :owner_screen_name => "sferik", :skip_status => "true", :slug => "presidents"}).
|
373
|
+
to_return(:body => fixture("empty_cursor.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
374
|
+
stub_get("/1/lists/members.json").
|
375
|
+
with(:query => {:cursor => "-1", :include_entities => "false", :owner_screen_name => "sferik", :skip_status => "true", :slug => "democrats"}).
|
376
|
+
to_return(:body => fixture("501_users_list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
377
|
+
stub_post("/1/lists/members/create_all.json").
|
378
|
+
with(:body => {:user_id => "7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382", :slug => "presidents", :owner_screen_name => "sferik"}).
|
379
|
+
to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
380
|
+
end
|
381
|
+
it "should request the correct resource" do
|
382
|
+
$stdout.should_receive(:print).with("Lists can't have more than 500 members. Do you want to add up to 500 members to the list \"presidents\"? ")
|
383
|
+
$stdin.should_receive(:gets).and_return("yes")
|
384
|
+
@t.list("add", "listed", "democrats", "presidents")
|
385
|
+
a_get("/1/account/verify_credentials.json").
|
386
|
+
should have_been_made
|
387
|
+
a_get("/1/lists/members.json").
|
388
|
+
with(:query => {:cursor => "-1", :include_entities => "false", :owner_screen_name => "sferik", :skip_status => "true", :slug => "presidents"}).
|
389
|
+
should have_been_made
|
390
|
+
a_get("/1/lists/members.json").
|
391
|
+
with(:query => {:cursor => "-1", :include_entities => "false", :owner_screen_name => "sferik", :skip_status => "true", :slug => "democrats"}).
|
392
|
+
should have_been_made
|
393
|
+
a_post("/1/lists/members/create_all.json").
|
394
|
+
with(:body => {:user_id => "7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382,7505382", :slug => "presidents", :owner_screen_name => "sferik"}).
|
395
|
+
should have_been_made.times(5)
|
396
|
+
end
|
397
|
+
context "yes" do
|
398
|
+
it "should have the correct output" do
|
399
|
+
$stdout.should_receive(:print).with("Lists can't have more than 500 members. Do you want to add up to 500 members to the list \"presidents\"? ")
|
400
|
+
$stdin.should_receive(:gets).and_return("yes")
|
401
|
+
@t.list("add", "listed", "democrats", "presidents")
|
402
|
+
$stdout.string.should =~ /@testcli added 500 members to the list "presidents"\./
|
403
|
+
end
|
404
|
+
end
|
405
|
+
context "no" do
|
406
|
+
it "should have the correct output" do
|
407
|
+
$stdout.should_receive(:print).with("Lists can't have more than 500 members. Do you want to add up to 500 members to the list \"presidents\"? ")
|
408
|
+
$stdin.should_receive(:gets).and_return("no")
|
409
|
+
@t.list("add", "listed", "democrats", "presidents")
|
410
|
+
$stdout.string.chomp.should == ""
|
411
|
+
end
|
412
|
+
end
|
413
|
+
end
|
414
|
+
context "500 list members" do
|
415
|
+
before do
|
416
|
+
stub_get("/1/lists/members.json").
|
417
|
+
with(:query => {:cursor => "-1", :include_entities => "false", :owner_screen_name => "sferik", :skip_status => "true", :slug => "presidents"}).
|
418
|
+
to_return(:body => fixture("501_users_list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
419
|
+
end
|
420
|
+
it "should request the correct resource" do
|
421
|
+
@t.list("add", "listed", "democrats", "presidents")
|
422
|
+
a_get("/1/account/verify_credentials.json").
|
423
|
+
should have_been_made
|
424
|
+
a_get("/1/lists/members.json").
|
425
|
+
with(:query => {:cursor => "-1", :include_entities => "false", :owner_screen_name => "sferik", :skip_status => "true", :slug => "presidents"}).
|
426
|
+
should have_been_made
|
427
|
+
end
|
428
|
+
it "should have the correct output" do
|
429
|
+
@t.list("add", "listed", "democrats", "presidents")
|
430
|
+
$stdout.string.chomp.should == "The list \"presidents\" are already contains the maximum of 500 members."
|
431
|
+
end
|
39
432
|
end
|
40
433
|
end
|
41
434
|
|
@@ -16,16 +16,390 @@ describe T::CLI::List::Remove do
|
|
16
16
|
$stdout = @old_stdout
|
17
17
|
end
|
18
18
|
|
19
|
+
describe "#friends" do
|
20
|
+
before do
|
21
|
+
@t.options = @t.options.merge(:profile => fixture_path + "/.trc")
|
22
|
+
stub_get("/1/account/verify_credentials.json").
|
23
|
+
to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
24
|
+
end
|
25
|
+
context "no friends" do
|
26
|
+
before do
|
27
|
+
stub_get("/1/lists/members.json").
|
28
|
+
with(:query => {:cursor => "-1", :include_entities => "false", :owner_screen_name => "sferik", :skip_status => "true", :slug => "presidents"}).
|
29
|
+
to_return(:body => fixture("empty_cursor.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
30
|
+
stub_get("/1/friends/ids.json").
|
31
|
+
with(:query => {:cursor => "-1"}).
|
32
|
+
to_return(:body => fixture("empty_cursor.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
33
|
+
end
|
34
|
+
it "should request the correct resource" do
|
35
|
+
@t.list("remove", "friends", "presidents")
|
36
|
+
a_get("/1/friends/ids.json").
|
37
|
+
with(:query => {:cursor => "-1"}).
|
38
|
+
should have_been_made
|
39
|
+
end
|
40
|
+
it "should have the correct output" do
|
41
|
+
@t.list("remove", "friends", "presidents")
|
42
|
+
$stdout.string.chomp.should == "None of @testcli's friends are members of the list \"presidents\"."
|
43
|
+
end
|
44
|
+
end
|
45
|
+
context "one friend" do
|
46
|
+
before do
|
47
|
+
stub_get("/1/lists/members.json").
|
48
|
+
with(:query => {:cursor => "-1", :include_entities => "false", :owner_screen_name => "sferik", :skip_status => "true", :slug => "presidents"}).
|
49
|
+
to_return(:body => fixture("empty_cursor.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
50
|
+
stub_get("/1/friends/ids.json").
|
51
|
+
with(:query => {:cursor => "-1"}).
|
52
|
+
to_return(:body => fixture("friends_ids.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
53
|
+
end
|
54
|
+
it "should request the correct resource" do
|
55
|
+
stub_post("/1/lists/members/destroy.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"})
|
58
|
+
$stdout.should_receive(:print).with("Are you sure you want to remove 1 friend from the list \"presidents\"? ")
|
59
|
+
$stdin.should_receive(:gets).and_return("yes")
|
60
|
+
@t.list("remove", "friends", "presidents")
|
61
|
+
a_get("/1/account/verify_credentials.json").
|
62
|
+
should have_been_made
|
63
|
+
a_get("/1/lists/members.json").
|
64
|
+
with(:query => {:cursor => "-1", :include_entities => "false", :owner_screen_name => "sferik", :skip_status => "true", :slug => "presidents"}).
|
65
|
+
should have_been_made
|
66
|
+
a_get("/1/friends/ids.json").
|
67
|
+
with(:query => {:cursor => "-1"}).
|
68
|
+
should have_been_made
|
69
|
+
a_post("/1/lists/members/destroy.json").
|
70
|
+
with(:body => {:user_id => "7505382", :slug => "presidents", :owner_screen_name => "sferik"}).
|
71
|
+
should have_been_made
|
72
|
+
end
|
73
|
+
context "yes" do
|
74
|
+
it "should have the correct output" do
|
75
|
+
stub_post("/1/lists/members/destroy.json").
|
76
|
+
with(:body => {:user_id => "7505382", :slug => "presidents", :owner_screen_name => "sferik"}).
|
77
|
+
to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
78
|
+
$stdout.should_receive(:print).with("Are you sure you want to remove 1 friend from the list \"presidents\"? ")
|
79
|
+
$stdin.should_receive(:gets).and_return("yes")
|
80
|
+
@t.list("remove", "friends", "presidents")
|
81
|
+
$stdout.string.should =~ /@testcli removed 1 friend from the list "presidents"\./
|
82
|
+
end
|
83
|
+
end
|
84
|
+
context "no" do
|
85
|
+
it "should have the correct output" do
|
86
|
+
$stdout.should_receive(:print).with("Are you sure you want to remove 1 friend from the list \"presidents\"? ")
|
87
|
+
$stdin.should_receive(:gets).and_return("no")
|
88
|
+
@t.list("remove", "friends", "presidents")
|
89
|
+
$stdout.string.chomp.should == ""
|
90
|
+
end
|
91
|
+
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
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
describe "#followers" do
|
111
|
+
before do
|
112
|
+
@t.options = @t.options.merge(:profile => fixture_path + "/.trc")
|
113
|
+
stub_get("/1/account/verify_credentials.json").
|
114
|
+
to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
115
|
+
end
|
116
|
+
context "no followers" do
|
117
|
+
before do
|
118
|
+
stub_get("/1/lists/members.json").
|
119
|
+
with(:query => {:cursor => "-1", :include_entities => "false", :owner_screen_name => "sferik", :skip_status => "true", :slug => "presidents"}).
|
120
|
+
to_return(:body => fixture("empty_cursor.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
121
|
+
stub_get("/1/followers/ids.json").
|
122
|
+
with(:query => {:cursor => "-1"}).
|
123
|
+
to_return(:body => fixture("empty_cursor.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
124
|
+
end
|
125
|
+
it "should request the correct resource" do
|
126
|
+
@t.list("remove", "followers", "presidents")
|
127
|
+
a_get("/1/followers/ids.json").
|
128
|
+
with(:query => {:cursor => "-1"}).
|
129
|
+
should have_been_made
|
130
|
+
end
|
131
|
+
it "should have the correct output" do
|
132
|
+
@t.list("remove", "followers", "presidents")
|
133
|
+
$stdout.string.chomp.should == "None of @testcli's followers are members of the list \"presidents\"."
|
134
|
+
end
|
135
|
+
end
|
136
|
+
context "two followers" do
|
137
|
+
before do
|
138
|
+
stub_get("/1/lists/members.json").
|
139
|
+
with(:query => {:cursor => "-1", :include_entities => "false", :owner_screen_name => "sferik", :skip_status => "true", :slug => "presidents"}).
|
140
|
+
to_return(:body => fixture("empty_cursor.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
141
|
+
stub_get("/1/followers/ids.json").
|
142
|
+
with(:query => {:cursor => "-1"}).
|
143
|
+
to_return(:body => fixture("followers_ids.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
144
|
+
end
|
145
|
+
it "should request the correct resource" do
|
146
|
+
stub_post("/1/lists/members/destroy.json").
|
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"}).
|
151
|
+
to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
152
|
+
$stdout.should_receive(:print).with("Are you sure you want to remove 2 followers from the list \"presidents\"? ")
|
153
|
+
$stdin.should_receive(:gets).and_return("yes")
|
154
|
+
@t.list("remove", "followers", "presidents")
|
155
|
+
a_get("/1/account/verify_credentials.json").
|
156
|
+
should have_been_made
|
157
|
+
a_get("/1/lists/members.json").
|
158
|
+
with(:query => {:cursor => "-1", :include_entities => "false", :owner_screen_name => "sferik", :skip_status => "true", :slug => "presidents"}).
|
159
|
+
should have_been_made
|
160
|
+
a_get("/1/followers/ids.json").
|
161
|
+
with(:query => {:cursor => "-1"}).
|
162
|
+
should have_been_made
|
163
|
+
a_post("/1/lists/members/destroy.json").
|
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"}).
|
168
|
+
should have_been_made
|
169
|
+
end
|
170
|
+
context "yes" do
|
171
|
+
it "should have the correct output" do
|
172
|
+
stub_post("/1/lists/members/destroy.json").
|
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"}).
|
177
|
+
to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
178
|
+
$stdout.should_receive(:print).with("Are you sure you want to remove 2 followers from the list \"presidents\"? ")
|
179
|
+
$stdin.should_receive(:gets).and_return("yes")
|
180
|
+
@t.list("remove", "followers", "presidents")
|
181
|
+
$stdout.string.should =~ /@testcli removed 2 followers from the list "presidents"\./
|
182
|
+
end
|
183
|
+
end
|
184
|
+
context "no" do
|
185
|
+
it "should have the correct output" do
|
186
|
+
$stdout.should_receive(:print).with("Are you sure you want to remove 2 followers from the list \"presidents\"? ")
|
187
|
+
$stdin.should_receive(:gets).and_return("no")
|
188
|
+
@t.list("remove", "followers", "presidents")
|
189
|
+
$stdout.string.chomp.should == ""
|
190
|
+
end
|
191
|
+
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
|
+
end
|
211
|
+
end
|
212
|
+
|
213
|
+
describe "#listed" do
|
214
|
+
before do
|
215
|
+
@t.options = @t.options.merge(:profile => fixture_path + "/.trc")
|
216
|
+
stub_get("/1/account/verify_credentials.json").
|
217
|
+
to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
218
|
+
end
|
219
|
+
context "no users" do
|
220
|
+
before do
|
221
|
+
stub_get("/1/lists/members.json").
|
222
|
+
with(:query => {:cursor => "-1", :include_entities => "false", :owner_screen_name => "sferik", :skip_status => "true", :slug => "presidents"}).
|
223
|
+
to_return(:body => fixture("empty_cursor.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
224
|
+
stub_get("/1/lists/members.json").
|
225
|
+
with(:query => {:cursor => "-1", :include_entities => "false", :owner_screen_name => "sferik", :skip_status => "true", :slug => "democrats"}).
|
226
|
+
to_return(:body => fixture("empty_cursor.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
227
|
+
end
|
228
|
+
it "should request the correct resource" do
|
229
|
+
@t.list("remove", "listed", "democrats", "presidents")
|
230
|
+
a_get("/1/account/verify_credentials.json").
|
231
|
+
should have_been_made
|
232
|
+
a_get("/1/lists/members.json").
|
233
|
+
with(:query => {:cursor => "-1", :include_entities => "false", :owner_screen_name => "sferik", :skip_status => "true", :slug => "presidents"}).
|
234
|
+
should have_been_made
|
235
|
+
a_get("/1/lists/members.json").
|
236
|
+
with(:query => {:cursor => "-1", :include_entities => "false", :owner_screen_name => "sferik", :skip_status => "true", :slug => "democrats"}).
|
237
|
+
should have_been_made
|
238
|
+
end
|
239
|
+
it "should have the correct output" do
|
240
|
+
@t.list("remove", "listed", "democrats", "presidents")
|
241
|
+
$stdout.string.chomp.should == "None of the members of the list \"democrats\" are members of the list \"presidents\"."
|
242
|
+
end
|
243
|
+
end
|
244
|
+
context "one user" do
|
245
|
+
before do
|
246
|
+
stub_get("/1/lists/members.json").
|
247
|
+
with(:query => {:cursor => "-1", :include_entities => "false", :owner_screen_name => "sferik", :skip_status => "true", :slug => "presidents"}).
|
248
|
+
to_return(:body => fixture("empty_cursor.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
249
|
+
stub_get("/1/lists/members.json").
|
250
|
+
with(:query => {:cursor => "-1", :include_entities => "false", :owner_screen_name => "sferik", :skip_status => "true", :slug => "democrats"}).
|
251
|
+
to_return(:body => fixture("users_list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
252
|
+
end
|
253
|
+
it "should request the correct resource" do
|
254
|
+
stub_post("/1/lists/members/destroy.json").
|
255
|
+
with(:body => {:user_id => "7505382", :slug => "presidents", :owner_screen_name => "sferik"}).
|
256
|
+
to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
257
|
+
$stdout.should_receive(:print).with("Are you sure you want to remove 1 member from the list \"presidents\"? ")
|
258
|
+
$stdin.should_receive(:gets).and_return("yes")
|
259
|
+
@t.list("remove", "listed", "democrats", "presidents")
|
260
|
+
a_get("/1/account/verify_credentials.json").
|
261
|
+
should have_been_made
|
262
|
+
a_get("/1/lists/members.json").
|
263
|
+
with(:query => {:cursor => "-1", :include_entities => "false", :owner_screen_name => "sferik", :skip_status => "true", :slug => "presidents"}).
|
264
|
+
should have_been_made
|
265
|
+
a_get("/1/lists/members.json").
|
266
|
+
with(:query => {:cursor => "-1", :include_entities => "false", :owner_screen_name => "sferik", :skip_status => "true", :slug => "democrats"}).
|
267
|
+
should have_been_made
|
268
|
+
a_post("/1/lists/members/destroy.json").
|
269
|
+
with(:body => {:user_id => "7505382", :slug => "presidents", :owner_screen_name => "sferik"}).
|
270
|
+
should have_been_made
|
271
|
+
end
|
272
|
+
context "yes" do
|
273
|
+
it "should have the correct output" do
|
274
|
+
stub_post("/1/lists/members/destroy.json").
|
275
|
+
with(:body => {:user_id => "7505382", :slug => "presidents", :owner_screen_name => "sferik"}).
|
276
|
+
to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
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
|
+
@t.list("remove", "listed", "democrats", "presidents")
|
280
|
+
$stdout.string.should =~ /@testcli removed 1 member from the list "presidents"\./
|
281
|
+
end
|
282
|
+
end
|
283
|
+
context "no" do
|
284
|
+
it "should have the correct output" do
|
285
|
+
$stdout.should_receive(:print).with("Are you sure you want to remove 1 member from the list \"presidents\"? ")
|
286
|
+
$stdin.should_receive(:gets).and_return("no")
|
287
|
+
@t.list("remove", "listed", "democrats", "presidents")
|
288
|
+
$stdout.string.chomp.should == ""
|
289
|
+
end
|
290
|
+
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
|
+
end
|
307
|
+
end
|
308
|
+
|
309
|
+
describe "#members" do
|
310
|
+
before do
|
311
|
+
@t.options = @t.options.merge(:profile => fixture_path + "/.trc")
|
312
|
+
stub_get("/1/account/verify_credentials.json").
|
313
|
+
to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
314
|
+
end
|
315
|
+
context "no users" do
|
316
|
+
before do
|
317
|
+
stub_get("/1/lists/members.json").
|
318
|
+
with(:query => {:cursor => "-1", :include_entities => "false", :owner_screen_name => "sferik", :skip_status => "true", :slug => "presidents"}).
|
319
|
+
to_return(:body => fixture("empty_cursor.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
320
|
+
end
|
321
|
+
it "should request the correct resource" do
|
322
|
+
@t.list("remove", "members", "presidents")
|
323
|
+
a_get("/1/account/verify_credentials.json").
|
324
|
+
should have_been_made
|
325
|
+
a_get("/1/lists/members.json").
|
326
|
+
with(:query => {:cursor => "-1", :include_entities => "false", :owner_screen_name => "sferik", :skip_status => "true", :slug => "presidents"}).
|
327
|
+
should have_been_made
|
328
|
+
end
|
329
|
+
it "should have the correct output" do
|
330
|
+
@t.list("remove", "members", "presidents")
|
331
|
+
$stdout.string.chomp.should == "The list \"presidents\" doesn't have any members."
|
332
|
+
end
|
333
|
+
end
|
334
|
+
context "one user" do
|
335
|
+
before do
|
336
|
+
stub_get("/1/lists/members.json").
|
337
|
+
with(:query => {:cursor => "-1", :include_entities => "false", :owner_screen_name => "sferik", :skip_status => "true", :slug => "presidents"}).
|
338
|
+
to_return(:body => fixture("users_list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
339
|
+
end
|
340
|
+
it "should request the correct resource" do
|
341
|
+
stub_post("/1/lists/members/destroy.json").
|
342
|
+
with(:body => {:user_id => "7505382", :slug => "presidents", :owner_screen_name => "sferik"}).
|
343
|
+
to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
344
|
+
$stdout.should_receive(:print).with("Are you sure you want to remove 1 member from the list \"presidents\"? ")
|
345
|
+
$stdin.should_receive(:gets).and_return("yes")
|
346
|
+
@t.list("remove", "members", "presidents")
|
347
|
+
a_get("/1/account/verify_credentials.json").
|
348
|
+
should have_been_made
|
349
|
+
a_get("/1/lists/members.json").
|
350
|
+
with(:query => {:cursor => "-1", :include_entities => "false", :owner_screen_name => "sferik", :skip_status => "true", :slug => "presidents"}).
|
351
|
+
should have_been_made
|
352
|
+
a_post("/1/lists/members/destroy.json").
|
353
|
+
with(:body => {:user_id => "7505382", :slug => "presidents", :owner_screen_name => "sferik"}).
|
354
|
+
should have_been_made
|
355
|
+
end
|
356
|
+
context "yes" do
|
357
|
+
it "should have the correct output" do
|
358
|
+
stub_post("/1/lists/members/destroy.json").
|
359
|
+
with(:body => {:user_id => "7505382", :slug => "presidents", :owner_screen_name => "sferik"}).
|
360
|
+
to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
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
|
+
@t.list("remove", "members", "presidents")
|
364
|
+
$stdout.string.should =~ /@testcli removed 1 member from the list "presidents"\./
|
365
|
+
end
|
366
|
+
end
|
367
|
+
context "no" do
|
368
|
+
it "should have the correct output" do
|
369
|
+
$stdout.should_receive(:print).with("Are you sure you want to remove 1 member from the list \"presidents\"? ")
|
370
|
+
$stdin.should_receive(:gets).and_return("no")
|
371
|
+
@t.list("remove", "members", "presidents")
|
372
|
+
$stdout.string.chomp.should == ""
|
373
|
+
end
|
374
|
+
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
|
+
end
|
391
|
+
end
|
392
|
+
|
19
393
|
describe "#users" do
|
20
394
|
before do
|
21
395
|
@t.options = @t.options.merge(:profile => fixture_path + "/.trc")
|
22
396
|
stub_get("/1/account/verify_credentials.json").
|
23
397
|
to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
398
|
+
end
|
399
|
+
it "should request the correct resource" do
|
24
400
|
stub_post("/1/lists/members/destroy.json").
|
25
401
|
with(:body => {:screen_name => "sferik", :slug => "presidents", :owner_screen_name => "sferik"}).
|
26
402
|
to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
27
|
-
end
|
28
|
-
it "should request the correct resource" do
|
29
403
|
@t.list("remove", "users", "presidents", "sferik")
|
30
404
|
a_get("/1/account/verify_credentials.json").
|
31
405
|
should have_been_made
|
@@ -34,9 +408,25 @@ describe T::CLI::List::Remove do
|
|
34
408
|
should have_been_made
|
35
409
|
end
|
36
410
|
it "should have the correct output" do
|
411
|
+
stub_post("/1/lists/members/destroy.json").
|
412
|
+
with(:body => {:screen_name => "sferik", :slug => "presidents", :owner_screen_name => "sferik"}).
|
413
|
+
to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
37
414
|
@t.list("remove", "users", "presidents", "sferik")
|
38
415
|
$stdout.string.should =~ /@testcli removed 1 user from the list "presidents"\./
|
39
416
|
end
|
417
|
+
context "Twitter is down" do
|
418
|
+
it "should retry 3 times and then raise an error" do
|
419
|
+
stub_post("/1/lists/members/destroy.json").
|
420
|
+
with(:body => {:screen_name => "sferik", :slug => "presidents", :owner_screen_name => "sferik"}).
|
421
|
+
to_return(:status => 502)
|
422
|
+
lambda do
|
423
|
+
@t.list("remove", "users", "presidents", "sferik")
|
424
|
+
end.should raise_error("Twitter is down or being upgraded.")
|
425
|
+
a_post("/1/lists/members/destroy.json").
|
426
|
+
with(:body => {:screen_name => "sferik", :slug => "presidents", :owner_screen_name => "sferik"}).
|
427
|
+
should have_been_made.times(3)
|
428
|
+
end
|
429
|
+
end
|
40
430
|
end
|
41
431
|
|
42
432
|
end
|