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.
@@ -1,315 +0,0 @@
1
- # encoding: utf-8
2
- require 'helper'
3
-
4
- describe T::CLI::List::Remove::All do
5
-
6
- before do
7
- @t = T::CLI.new
8
- @old_stderr = $stderr
9
- $stderr = StringIO.new
10
- @old_stdout = $stdout
11
- $stdout = StringIO.new
12
- end
13
-
14
- after do
15
- $stderr = @old_stderr
16
- $stdout = @old_stdout
17
- end
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 users" 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", "all", "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", "all", "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 user" 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/destroy.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 remove 1 friend from the list \"presidents\"? ")
59
- $stdin.should_receive(:gets).and_return("yes")
60
- @t.list("remove", "all", "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
- $stdout.should_receive(:print).with("Are you sure you want to remove 1 friend from the list \"presidents\"? ")
76
- $stdin.should_receive(:gets).and_return("yes")
77
- @t.list("remove", "all", "friends", "presidents")
78
- $stdout.string.should =~ /@testcli removed 1 friend from 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 remove 1 friend from the list \"presidents\"? ")
84
- $stdin.should_receive(:gets).and_return("no")
85
- @t.list("remove", "all", "friends", "presidents")
86
- $stdout.string.chomp.should == ""
87
- end
88
- end
89
- end
90
- end
91
-
92
- describe "#followers" do
93
- before do
94
- @t.options = @t.options.merge(:profile => fixture_path + "/.trc")
95
- stub_get("/1/account/verify_credentials.json").
96
- to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
97
- end
98
- context "no users" do
99
- before do
100
- stub_get("/1/lists/members.json").
101
- with(:query => {:cursor => "-1", :include_entities => "false", :owner_screen_name => "sferik", :skip_status => "true", :slug => "presidents"}).
102
- to_return(:body => fixture("empty_cursor.json"), :headers => {:content_type => "application/json; charset=utf-8"})
103
- stub_get("/1/followers/ids.json").
104
- with(:query => {:cursor => "-1"}).
105
- to_return(:body => fixture("empty_cursor.json"), :headers => {:content_type => "application/json; charset=utf-8"})
106
- end
107
- it "should request the correct resource" do
108
- @t.list("remove", "all", "followers", "presidents")
109
- a_get("/1/followers/ids.json").
110
- with(:query => {:cursor => "-1"}).
111
- should have_been_made
112
- end
113
- it "should have the correct output" do
114
- @t.list("remove", "all", "followers", "presidents")
115
- $stdout.string.chomp.should == "None of @testcli's followers are members of the list \"presidents\"."
116
- end
117
- end
118
- context "one user" do
119
- before do
120
- stub_get("/1/lists/members.json").
121
- with(:query => {:cursor => "-1", :include_entities => "false", :owner_screen_name => "sferik", :skip_status => "true", :slug => "presidents"}).
122
- to_return(:body => fixture("empty_cursor.json"), :headers => {:content_type => "application/json; charset=utf-8"})
123
- stub_get("/1/followers/ids.json").
124
- with(:query => {:cursor => "-1"}).
125
- to_return(:body => fixture("followers_ids.json"), :headers => {:content_type => "application/json; charset=utf-8"})
126
- stub_post("/1/lists/members/destroy.json").
127
- with(:body => {:user_id => "213747670", :slug => "presidents", :owner_screen_name => "sferik"}).
128
- to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
129
- stub_post("/1/lists/members/destroy.json").
130
- with(:body => {:user_id => "428004849", :slug => "presidents", :owner_screen_name => "sferik"}).
131
- to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
132
- end
133
- it "should request the correct resource" do
134
- $stdout.should_receive(:print).with("Are you sure you want to remove 2 followers from the list \"presidents\"? ")
135
- $stdin.should_receive(:gets).and_return("yes")
136
- @t.list("remove", "all", "followers", "presidents")
137
- a_get("/1/account/verify_credentials.json").
138
- should have_been_made
139
- a_get("/1/lists/members.json").
140
- with(:query => {:cursor => "-1", :include_entities => "false", :owner_screen_name => "sferik", :skip_status => "true", :slug => "presidents"}).
141
- should have_been_made
142
- a_get("/1/followers/ids.json").
143
- with(:query => {:cursor => "-1"}).
144
- should have_been_made
145
- a_post("/1/lists/members/destroy.json").
146
- with(:body => {:user_id => "213747670", :slug => "presidents", :owner_screen_name => "sferik"}).
147
- should have_been_made
148
- a_post("/1/lists/members/destroy.json").
149
- with(:body => {:user_id => "428004849", :slug => "presidents", :owner_screen_name => "sferik"}).
150
- should have_been_made
151
- end
152
- context "yes" do
153
- it "should have the correct output" do
154
- $stdout.should_receive(:print).with("Are you sure you want to remove 2 followers from the list \"presidents\"? ")
155
- $stdin.should_receive(:gets).and_return("yes")
156
- @t.list("remove", "all", "followers", "presidents")
157
- $stdout.string.should =~ /@testcli removed 2 followers from the list "presidents"\./
158
- end
159
- end
160
- context "no" do
161
- it "should have the correct output" do
162
- $stdout.should_receive(:print).with("Are you sure you want to remove 2 followers from the list \"presidents\"? ")
163
- $stdin.should_receive(:gets).and_return("no")
164
- @t.list("remove", "all", "followers", "presidents")
165
- $stdout.string.chomp.should == ""
166
- end
167
- end
168
- end
169
- end
170
-
171
- describe "#listed" do
172
- before do
173
- @t.options = @t.options.merge(:profile => fixture_path + "/.trc")
174
- stub_get("/1/account/verify_credentials.json").
175
- to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
176
- end
177
- context "no users" do
178
- before do
179
- stub_get("/1/lists/members.json").
180
- with(:query => {:cursor => "-1", :include_entities => "false", :owner_screen_name => "sferik", :skip_status => "true", :slug => "presidents"}).
181
- to_return(:body => fixture("empty_cursor.json"), :headers => {:content_type => "application/json; charset=utf-8"})
182
- stub_get("/1/lists/members.json").
183
- with(:query => {:cursor => "-1", :include_entities => "false", :owner_screen_name => "sferik", :skip_status => "true", :slug => "democrats"}).
184
- to_return(:body => fixture("empty_cursor.json"), :headers => {:content_type => "application/json; charset=utf-8"})
185
- end
186
- it "should request the correct resource" do
187
- @t.list("remove", "all", "listed", "democrats", "presidents")
188
- a_get("/1/account/verify_credentials.json").
189
- should have_been_made
190
- a_get("/1/lists/members.json").
191
- with(:query => {:cursor => "-1", :include_entities => "false", :owner_screen_name => "sferik", :skip_status => "true", :slug => "presidents"}).
192
- should have_been_made
193
- a_get("/1/lists/members.json").
194
- with(:query => {:cursor => "-1", :include_entities => "false", :owner_screen_name => "sferik", :skip_status => "true", :slug => "democrats"}).
195
- should have_been_made
196
- end
197
- it "should have the correct output" do
198
- @t.list("remove", "all", "listed", "democrats", "presidents")
199
- $stdout.string.chomp.should == "None of the members of the list \"democrats\" are members of the list \"presidents\"."
200
- end
201
- end
202
- context "one user" do
203
- before do
204
- stub_get("/1/lists/members.json").
205
- with(:query => {:cursor => "-1", :include_entities => "false", :owner_screen_name => "sferik", :skip_status => "true", :slug => "presidents"}).
206
- to_return(:body => fixture("empty_cursor.json"), :headers => {:content_type => "application/json; charset=utf-8"})
207
- stub_get("/1/lists/members.json").
208
- with(:query => {:cursor => "-1", :include_entities => "false", :owner_screen_name => "sferik", :skip_status => "true", :slug => "democrats"}).
209
- to_return(:body => fixture("users_list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
210
- stub_post("/1/lists/members/destroy.json").
211
- with(:body => {:user_id => "7505382", :slug => "presidents", :owner_screen_name => "sferik"}).
212
- to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
213
- end
214
- it "should request the correct resource" do
215
- $stdout.should_receive(:print).with("Are you sure you want to remove 1 member from the list \"presidents\"? ")
216
- $stdin.should_receive(:gets).and_return("yes")
217
- @t.list("remove", "all", "listed", "democrats", "presidents")
218
- a_get("/1/account/verify_credentials.json").
219
- should have_been_made
220
- a_get("/1/lists/members.json").
221
- with(:query => {:cursor => "-1", :include_entities => "false", :owner_screen_name => "sferik", :skip_status => "true", :slug => "presidents"}).
222
- should have_been_made
223
- a_get("/1/lists/members.json").
224
- with(:query => {:cursor => "-1", :include_entities => "false", :owner_screen_name => "sferik", :skip_status => "true", :slug => "democrats"}).
225
- should have_been_made
226
- a_post("/1/lists/members/destroy.json").
227
- with(:body => {:user_id => "7505382", :slug => "presidents", :owner_screen_name => "sferik"}).
228
- should have_been_made
229
- end
230
- context "yes" do
231
- it "should have the correct output" do
232
- $stdout.should_receive(:print).with("Are you sure you want to remove 1 member from the list \"presidents\"? ")
233
- $stdin.should_receive(:gets).and_return("yes")
234
- @t.list("remove", "all", "listed", "democrats", "presidents")
235
- $stdout.string.should =~ /@testcli removed 1 member from the list "presidents"\./
236
- end
237
- end
238
- context "no" do
239
- it "should have the correct output" do
240
- $stdout.should_receive(:print).with("Are you sure you want to remove 1 member from the list \"presidents\"? ")
241
- $stdin.should_receive(:gets).and_return("no")
242
- @t.list("remove", "all", "listed", "democrats", "presidents")
243
- $stdout.string.chomp.should == ""
244
- end
245
- end
246
- end
247
- end
248
-
249
- describe "#members" do
250
- before do
251
- @t.options = @t.options.merge(:profile => fixture_path + "/.trc")
252
- stub_get("/1/account/verify_credentials.json").
253
- to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
254
- end
255
- context "no users" do
256
- before do
257
- stub_get("/1/lists/members.json").
258
- with(:query => {:cursor => "-1", :include_entities => "false", :owner_screen_name => "sferik", :skip_status => "true", :slug => "presidents"}).
259
- to_return(:body => fixture("empty_cursor.json"), :headers => {:content_type => "application/json; charset=utf-8"})
260
- end
261
- it "should request the correct resource" do
262
- @t.list("remove", "all", "members", "presidents")
263
- a_get("/1/account/verify_credentials.json").
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 => "presidents"}).
267
- should have_been_made
268
- end
269
- it "should have the correct output" do
270
- @t.list("remove", "all", "members", "presidents")
271
- $stdout.string.chomp.should == "The list \"presidents\" doesn't have any members."
272
- end
273
- end
274
- context "one user" do
275
- before do
276
- stub_get("/1/lists/members.json").
277
- with(:query => {:cursor => "-1", :include_entities => "false", :owner_screen_name => "sferik", :skip_status => "true", :slug => "presidents"}).
278
- to_return(:body => fixture("users_list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
279
- stub_post("/1/lists/members/destroy.json").
280
- with(:body => {:user_id => "7505382", :slug => "presidents", :owner_screen_name => "sferik"}).
281
- to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
282
- end
283
- it "should request the correct resource" do
284
- $stdout.should_receive(:print).with("Are you sure you want to remove 1 member from the list \"presidents\"? ")
285
- $stdin.should_receive(:gets).and_return("yes")
286
- @t.list("remove", "all", "members", "presidents")
287
- a_get("/1/account/verify_credentials.json").
288
- should have_been_made
289
- a_get("/1/lists/members.json").
290
- with(:query => {:cursor => "-1", :include_entities => "false", :owner_screen_name => "sferik", :skip_status => "true", :slug => "presidents"}).
291
- should have_been_made
292
- a_post("/1/lists/members/destroy.json").
293
- with(:body => {:user_id => "7505382", :slug => "presidents", :owner_screen_name => "sferik"}).
294
- should have_been_made
295
- end
296
- context "yes" do
297
- it "should have the correct output" do
298
- $stdout.should_receive(:print).with("Are you sure you want to remove 1 member from the list \"presidents\"? ")
299
- $stdin.should_receive(:gets).and_return("yes")
300
- @t.list("remove", "all", "members", "presidents")
301
- $stdout.string.should =~ /@testcli removed 1 member from the list "presidents"\./
302
- end
303
- end
304
- context "no" do
305
- it "should have the correct output" do
306
- $stdout.should_receive(:print).with("Are you sure you want to remove 1 member from the list \"presidents\"? ")
307
- $stdin.should_receive(:gets).and_return("no")
308
- @t.list("remove", "all", "members", "presidents")
309
- $stdout.string.chomp.should == ""
310
- end
311
- end
312
- end
313
- end
314
-
315
- end
@@ -1,292 +0,0 @@
1
- # encoding: utf-8
2
- require 'helper'
3
-
4
- describe T::CLI::Unfollow::All do
5
-
6
- before do
7
- @t = T::CLI.new
8
- @old_stderr = $stderr
9
- $stderr = StringIO.new
10
- @old_stdout = $stdout
11
- $stdout = StringIO.new
12
- end
13
-
14
- after do
15
- $stderr = @old_stderr
16
- $stdout = @old_stdout
17
- end
18
-
19
- describe "#listed" 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 users" 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
- end
31
- it "should request the correct resource" do
32
- @t.unfollow("all", "listed", "presidents")
33
- a_get("/1/account/verify_credentials.json").
34
- should have_been_made
35
- a_get("/1/lists/members.json").
36
- with(:query => {:cursor => "-1", :include_entities => "false", :owner_screen_name => "sferik", :skip_status => "true", :slug => "presidents"}).
37
- should have_been_made
38
- end
39
- it "should have the correct output" do
40
- @t.unfollow("all", "listed", "presidents")
41
- $stdout.string.chomp.should == "@testcli is already not following any list members."
42
- end
43
- end
44
- context "one user" do
45
- before do
46
- @t.options = @t.options.merge(:profile => fixture_path + "/.trc")
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("users_list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
50
- stub_delete("/1/friendships/destroy.json").
51
- with(:query => {:user_id => "7505382", :include_entities => "false"}).
52
- to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
53
- end
54
- it "should request the correct resource" do
55
- $stdout.should_receive(:print).with("Are you sure you want to unfollow 1 user? ")
56
- $stdin.should_receive(:gets).and_return("yes")
57
- @t.unfollow("all", "listed", "presidents")
58
- a_get("/1/account/verify_credentials.json").
59
- should have_been_made
60
- a_get("/1/lists/members.json").
61
- with(:query => {:cursor => "-1", :include_entities => "false", :owner_screen_name => "sferik", :skip_status => "true", :slug => "presidents"}).
62
- should have_been_made
63
- a_delete("/1/friendships/destroy.json").
64
- with(:query => {:user_id => "7505382", :include_entities => "false"}).
65
- should have_been_made
66
- end
67
- context "yes" do
68
- it "should have the correct output" do
69
- $stdout.should_receive(:print).with("Are you sure you want to unfollow 1 user? ")
70
- $stdin.should_receive(:gets).and_return("yes")
71
- @t.unfollow("all", "listed", "presidents")
72
- $stdout.string.should =~ /^@testcli is no longer following 1 user\.$/
73
- end
74
- end
75
- context "no" do
76
- it "should have the correct output" do
77
- $stdout.should_receive(:print).with("Are you sure you want to unfollow 1 user? ")
78
- $stdin.should_receive(:gets).and_return("no")
79
- @t.unfollow("all", "listed", "presidents")
80
- $stdout.string.chomp.should == ""
81
- end
82
- end
83
- end
84
- end
85
-
86
- describe "#followers" do
87
- before do
88
- @t.options = @t.options.merge(:profile => fixture_path + "/.trc")
89
- end
90
- context "no users" do
91
- before do
92
- stub_get("/1/followers/ids.json").
93
- with(:query => {:cursor => "-1"}).
94
- to_return(:body => fixture("friends_ids.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("friends_ids.json"), :headers => {:content_type => "application/json; charset=utf-8"})
98
- end
99
- it "should request the correct resource" do
100
- @t.unfollow("all", "followers")
101
- a_get("/1/followers/ids.json").
102
- with(:query => {:cursor => "-1"}).
103
- should have_been_made
104
- a_get("/1/friends/ids.json").
105
- with(:query => {:cursor => "-1"}).
106
- should have_been_made
107
- end
108
- it "should have the correct output" do
109
- @t.unfollow("all", "followers")
110
- $stdout.string.chomp.should == "@testcli is already not following any followers."
111
- end
112
- end
113
- context "one user" do
114
- before do
115
- stub_get("/1/followers/ids.json").
116
- with(:query => {:cursor => "-1"}).
117
- to_return(:body => fixture("friends_ids.json"), :headers => {:content_type => "application/json; charset=utf-8"})
118
- stub_get("/1/friends/ids.json").
119
- with(:query => {:cursor => "-1"}).
120
- to_return(:body => fixture("followers_ids.json"), :headers => {:content_type => "application/json; charset=utf-8"})
121
- stub_delete("/1/friendships/destroy.json").
122
- with(:query => {:user_id => "7505382", :include_entities => "false"}).
123
- to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
124
- end
125
- it "should request the correct resource" do
126
- $stdout.should_receive(:print).with("Are you sure you want to unfollow 1 user? ")
127
- $stdin.should_receive(:gets).and_return("yes")
128
- @t.unfollow("all", "followers")
129
- a_get("/1/followers/ids.json").
130
- with(:query => {:cursor => "-1"}).
131
- should have_been_made
132
- a_get("/1/friends/ids.json").
133
- with(:query => {:cursor => "-1"}).
134
- should have_been_made
135
- a_delete("/1/friendships/destroy.json").
136
- with(:query => {:user_id => "7505382", :include_entities => "false"}).
137
- should have_been_made
138
- end
139
- context "yes" do
140
- it "should have the correct output" do
141
- $stdout.should_receive(:print).with("Are you sure you want to unfollow 1 user? ")
142
- $stdin.should_receive(:gets).and_return("yes")
143
- @t.unfollow("all", "followers")
144
- $stdout.string.should =~ /^@testcli is no longer following 1 user\.$/
145
- end
146
- end
147
- context "no" do
148
- it "should have the correct output" do
149
- $stdout.should_receive(:print).with("Are you sure you want to unfollow 1 user? ")
150
- $stdin.should_receive(:gets).and_return("no")
151
- @t.unfollow("all", "followers")
152
- $stdout.string.chomp.should == ""
153
- end
154
- end
155
- end
156
- end
157
-
158
- describe "#nonfollowers" do
159
- before do
160
- @t.options = @t.options.merge(:profile => fixture_path + "/.trc")
161
- end
162
- context "no users" do
163
- before do
164
- stub_get("/1/friends/ids.json").
165
- with(:query => {:cursor => "-1"}).
166
- to_return(:body => fixture("friends_ids.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("friends_ids.json"), :headers => {:content_type => "application/json; charset=utf-8"})
170
- end
171
- it "should request the correct resource" do
172
- @t.unfollow("all", "nonfollowers")
173
- a_get("/1/friends/ids.json").
174
- with(:query => {:cursor => "-1"}).
175
- should have_been_made
176
- a_get("/1/followers/ids.json").
177
- with(:query => {:cursor => "-1"}).
178
- should have_been_made
179
- end
180
- it "should have the correct output" do
181
- @t.unfollow("all", "nonfollowers")
182
- $stdout.string.chomp.should == "@testcli is already not following any non-followers."
183
- end
184
- end
185
- context "one user" do
186
- before do
187
- @t.options = @t.options.merge(:profile => fixture_path + "/.trc")
188
- stub_get("/1/friends/ids.json").
189
- with(:query => {:cursor => "-1"}).
190
- to_return(:body => fixture("friends_ids.json"), :headers => {:content_type => "application/json; charset=utf-8"})
191
- stub_get("/1/followers/ids.json").
192
- with(:query => {:cursor => "-1"}).
193
- to_return(:body => fixture("followers_ids.json"), :headers => {:content_type => "application/json; charset=utf-8"})
194
- stub_delete("/1/friendships/destroy.json").
195
- with(:query => {:user_id => "7505382", :include_entities => "false"}).
196
- to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
197
- end
198
- it "should request the correct resource" do
199
- $stdout.should_receive(:print).with("Are you sure you want to unfollow 1 user? ")
200
- $stdin.should_receive(:gets).and_return("yes")
201
- @t.unfollow("all", "nonfollowers")
202
- a_get("/1/friends/ids.json").
203
- with(:query => {:cursor => "-1"}).
204
- should have_been_made
205
- a_get("/1/followers/ids.json").
206
- with(:query => {:cursor => "-1"}).
207
- should have_been_made
208
- a_delete("/1/friendships/destroy.json").
209
- with(:query => {:user_id => "7505382", :include_entities => "false"}).
210
- should have_been_made
211
- end
212
- context "yes" do
213
- it "should have the correct output" do
214
- $stdout.should_receive(:print).with("Are you sure you want to unfollow 1 user? ")
215
- $stdin.should_receive(:gets).and_return("yes")
216
- @t.unfollow("all", "nonfollowers")
217
- $stdout.string.should =~ /^@testcli is no longer following 1 user\.$/
218
- end
219
- end
220
- context "no" do
221
- it "should have the correct output" do
222
- $stdout.should_receive(:print).with("Are you sure you want to unfollow 1 user? ")
223
- $stdin.should_receive(:gets).and_return("no")
224
- @t.unfollow("all", "nonfollowers")
225
- $stdout.string.chomp.should == ""
226
- end
227
- end
228
- end
229
- end
230
-
231
- describe "#users" do
232
- before do
233
- @t.options = @t.options.merge(:profile => fixture_path + "/.trc")
234
- end
235
- context "no users" do
236
- before do
237
- stub_get("/1/friends/ids.json").
238
- with(:query => {:cursor => "-1"}).
239
- to_return(:body => fixture("empty_cursor.json"), :headers => {:content_type => "application/json; charset=utf-8"})
240
- end
241
- it "should request the correct resource" do
242
- @t.unfollow("all", "users")
243
- a_get("/1/friends/ids.json").
244
- with(:query => {:cursor => "-1"}).
245
- should have_been_made
246
- end
247
- it "should have the correct output" do
248
- @t.unfollow("all", "users")
249
- $stdout.string.chomp.should == "@testcli is already not following anyone."
250
- end
251
- end
252
- context "four users" do
253
- before do
254
- @t.options = @t.options.merge(:profile => fixture_path + "/.trc")
255
- stub_get("/1/friends/ids.json").
256
- with(:query => {:cursor => "-1"}).
257
- to_return(:body => fixture("friends_ids.json"), :headers => {:content_type => "application/json; charset=utf-8"})
258
- stub_delete("/1/friendships/destroy.json").
259
- with(:query => {:user_id => "7505382", :include_entities => "false"}).
260
- to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
261
- end
262
- it "should request the correct resource" do
263
- $stdout.should_receive(:print).with("Are you sure you want to unfollow 1 user? ")
264
- $stdin.should_receive(:gets).and_return("yes")
265
- @t.unfollow("all", "users")
266
- a_get("/1/friends/ids.json").
267
- with(:query => {:cursor => "-1"}).
268
- should have_been_made
269
- a_delete("/1/friendships/destroy.json").
270
- with(:query => {:user_id => "7505382", :include_entities => "false"}).
271
- should have_been_made
272
- end
273
- context "yes" do
274
- it "should have the correct output" do
275
- $stdout.should_receive(:print).with("Are you sure you want to unfollow 1 user? ")
276
- $stdin.should_receive(:gets).and_return("yes")
277
- @t.unfollow("all", "users")
278
- $stdout.string.should =~ /^@testcli is no longer following 1 user\.$/
279
- end
280
- end
281
- context "no" do
282
- it "should have the correct output" do
283
- $stdout.should_receive(:print).with("Are you sure you want to unfollow 1 user? ")
284
- $stdin.should_receive(:gets).and_return("no")
285
- @t.unfollow("all", "users")
286
- $stdout.string.chomp.should == ""
287
- end
288
- end
289
- end
290
- end
291
-
292
- end