t 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -1
- data/README.md +81 -48
- data/lib/t/cli.rb +181 -153
- data/lib/t/cli/delete.rb +112 -0
- data/lib/t/cli/follow.rb +66 -0
- data/lib/t/cli/follow/all.rb +99 -0
- data/lib/t/cli/list.rb +108 -0
- data/lib/t/cli/list/add.rb +64 -0
- data/lib/t/cli/list/add/all.rb +169 -0
- data/lib/t/cli/list/remove.rb +67 -0
- data/lib/t/cli/list/remove/all.rb +162 -0
- data/lib/t/cli/set.rb +86 -0
- data/lib/t/cli/unfollow.rb +66 -0
- data/lib/t/cli/unfollow/all.rb +122 -0
- data/lib/t/version.rb +1 -1
- data/spec/cli/delete_spec.rb +332 -0
- data/spec/cli/follow/all_spec.rb +159 -0
- data/spec/cli/follow_spec.rb +74 -0
- data/spec/cli/list/add/all_spec.rb +435 -0
- data/spec/cli/list/add_spec.rb +65 -0
- data/spec/cli/list/remove/all_spec.rb +315 -0
- data/spec/cli/list/remove_spec.rb +42 -0
- data/spec/cli/list_spec.rb +80 -0
- data/spec/{set_spec.rb → cli/set_spec.rb} +16 -16
- data/spec/cli/unfollow/all_spec.rb +223 -0
- data/spec/cli/unfollow_spec.rb +74 -0
- data/spec/cli_spec.rb +115 -70
- data/spec/fixtures/501_ids.json +1 -0
- data/spec/fixtures/501_users_list.json +1 -0
- data/spec/fixtures/empty_cursor.json +1 -0
- data/spec/fixtures/followers_ids.json +1 -0
- data/spec/fixtures/friends_ids.json +1 -0
- data/spec/fixtures/gem.json +1 -0
- data/spec/fixtures/list.json +1 -0
- data/spec/fixtures/search.json +1 -0
- data/spec/fixtures/users_list.json +1 -0
- data/t.gemspec +1 -0
- metadata +93 -34
- data/lib/t/delete.rb +0 -101
- data/lib/t/set.rb +0 -83
- data/spec/delete_spec.rb +0 -251
@@ -0,0 +1,65 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'helper'
|
3
|
+
|
4
|
+
describe T::CLI::List::Add 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 "#users" 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
|
+
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
|
+
end
|
28
|
+
it "should request the correct resource" do
|
29
|
+
@t.list("add", "users", "presidents", "sferik")
|
30
|
+
a_get("/1/account/verify_credentials.json").
|
31
|
+
should have_been_made
|
32
|
+
a_post("/1/lists/members/create_all.json").
|
33
|
+
with(:body => {:screen_name => "sferik", :slug => "presidents", :owner_screen_name => "sferik"}).
|
34
|
+
should have_been_made
|
35
|
+
end
|
36
|
+
it "should have the correct output" do
|
37
|
+
@t.list("add", "users", "presidents", "sferik")
|
38
|
+
$stdout.string.should =~ /@testcli added 1 user to the list "presidents"\./
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe "#users" do
|
43
|
+
before do
|
44
|
+
@t.options = @t.options.merge(:profile => fixture_path + "/.trc")
|
45
|
+
stub_get("/1/account/verify_credentials.json").
|
46
|
+
to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
47
|
+
stub_post("/1/lists/members/create_all.json").
|
48
|
+
with(:body => {:screen_name => "sferik", :slug => "presidents", :owner_screen_name => "sferik"}).
|
49
|
+
to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
50
|
+
end
|
51
|
+
it "should request the correct resource" do
|
52
|
+
@t.list("add", "users", "presidents", "sferik")
|
53
|
+
a_get("/1/account/verify_credentials.json").
|
54
|
+
should have_been_made
|
55
|
+
a_post("/1/lists/members/create_all.json").
|
56
|
+
with(:body => {:screen_name => "sferik", :slug => "presidents", :owner_screen_name => "sferik"}).
|
57
|
+
should have_been_made
|
58
|
+
end
|
59
|
+
it "should have the correct output" do
|
60
|
+
@t.list("add", "users", "presidents", "sferik")
|
61
|
+
$stdout.string.should =~ /@testcli added 1 user to the list "presidents"\./
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
@@ -0,0 +1,315 @@
|
|
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
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'helper'
|
3
|
+
|
4
|
+
describe T::CLI::List::Remove 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 "#users" 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
|
+
stub_post("/1/lists/members/destroy.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
|
+
end
|
28
|
+
it "should request the correct resource" do
|
29
|
+
@t.list("remove", "users", "presidents", "sferik")
|
30
|
+
a_get("/1/account/verify_credentials.json").
|
31
|
+
should have_been_made
|
32
|
+
a_post("/1/lists/members/destroy.json").
|
33
|
+
with(:body => {:screen_name => "sferik", :slug => "presidents", :owner_screen_name => "sferik"}).
|
34
|
+
should have_been_made
|
35
|
+
end
|
36
|
+
it "should have the correct output" do
|
37
|
+
@t.list("remove", "users", "presidents", "sferik")
|
38
|
+
$stdout.string.should =~ /@testcli removed 1 user from the list "presidents"\./
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'helper'
|
3
|
+
|
4
|
+
describe T::CLI::List 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 "#create" do
|
20
|
+
before do
|
21
|
+
@t.options = @t.options.merge(:profile => fixture_path + "/.trc")
|
22
|
+
stub_post("/1/lists/create.json").
|
23
|
+
with(:body => {:name => "presidents"}).
|
24
|
+
to_return(:body => fixture("list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
25
|
+
end
|
26
|
+
it "should request the correct resource" do
|
27
|
+
@t.list("create", "presidents")
|
28
|
+
a_post("/1/lists/create.json").
|
29
|
+
with(:body => {:name => "presidents"}).
|
30
|
+
should have_been_made
|
31
|
+
end
|
32
|
+
it "should have the correct output" do
|
33
|
+
@t.list("create", "presidents")
|
34
|
+
$stdout.string.chomp.should == "@testcli created the list \"presidents\"."
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe "#timeline" do
|
39
|
+
before do
|
40
|
+
stub_get("/1/account/verify_credentials.json").
|
41
|
+
to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
42
|
+
stub_get("/1/lists/statuses.json").
|
43
|
+
with(:query => {:owner_screen_name => "sferik", :per_page => "20", :slug => "presidents", :include_entities => "false"}).
|
44
|
+
to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
45
|
+
end
|
46
|
+
it "should request the correct resource" do
|
47
|
+
@t.list("timeline", "presidents")
|
48
|
+
a_get("/1/account/verify_credentials.json").
|
49
|
+
should have_been_made
|
50
|
+
a_get("/1/lists/statuses.json").
|
51
|
+
with(:query => {:owner_screen_name => "sferik", :per_page => "20", :slug => "presidents", :include_entities => "false"}).
|
52
|
+
should have_been_made
|
53
|
+
end
|
54
|
+
it "should have the correct output" do
|
55
|
+
@t.list("timeline", "presidents")
|
56
|
+
$stdout.string.should == <<-eos.gsub(/^/, ' ' * 6)
|
57
|
+
sferik: Ruby is the best programming language for hiding the ugly bits. (about 1 year ago)
|
58
|
+
sferik: There are 1.3 billion people in China; when people say there are 1 billion they are rounding off the entire population of the United States. (about 1 year ago)
|
59
|
+
sferik: The new Windows Phone campaign is the best advertising from Microsoft since "Start Me Up" (1995). Great work by CP+B. http://t.co/tIzxopI (about 1 year ago)
|
60
|
+
sferik: Fear not to sow seeds because of the birds. http://twitpic.com/2wg621 (about 1 year ago)
|
61
|
+
sferik: Speaking of things that are maddening: the interview with the Wall Street guys on the most recent This American Life http://bit.ly/af9pSD (about 1 year ago)
|
62
|
+
sferik: Holy cow! RailsAdmin is up to 200 watchers (from 100 yesterday). http://github.com/sferik/rails_admin (about 1 year ago)
|
63
|
+
sferik: Kind of cool that Facebook acts as a mirror for open-source projects that they use or like http://mirror.facebook.net/ (about 1 year ago)
|
64
|
+
sferik: RailsAdmin already has 100 watchers, 12 forks, and 6 contributors in less than 2 months. Let's keep the momentum going! http://bit.ly/cCMMqD (about 1 year ago)
|
65
|
+
sferik: This week's This American Life is amazing. @JoeLipari is an American hero. http://bit.ly/d9RbnB (about 1 year ago)
|
66
|
+
sferik: RT @polyseme: OH: shofars should be called jewvuzelas. (about 1 year ago)
|
67
|
+
sferik: Spent this morning fixing broken windows in RailsAdmin http://github.com/sferik/rails_admin/compare/ab6c598...0e3770f (about 1 year ago)
|
68
|
+
sferik: I'm a big believer that the broken windows theory applies to software development http://en.wikipedia.org/wiki/Broken_windows_theory (about 1 year ago)
|
69
|
+
sferik: I hope you idiots are happy with your piece of shit Android phones. http://www.apple.com/pr/library/2010/09/09statement.html (about 1 year ago)
|
70
|
+
sferik: Ping: kills MySpace dead. (about 1 year ago)
|
71
|
+
sferik: Crazy that iTunes Ping didn't leak a drop. (about 1 year ago)
|
72
|
+
sferik: The plot thickens http://twitpic.com/2k5lt2 (about 1 year ago)
|
73
|
+
sferik: 140 Proof Provides A Piece Of The Twitter Advertising Puzzle http://t.co/R2cUSDe via @techcrunch (about 1 year ago)
|
74
|
+
sferik: Try as you may http://www.thedoghousediaries.com/?p=1940 (about 1 year ago)
|
75
|
+
sferik: I know @SarahPalinUSA has a right to use Twitter, but should she? (over 1 year ago)
|
76
|
+
eos
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|