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,158 +0,0 @@
1
- # encoding: utf-8
2
- require 'helper'
3
-
4
- describe T::CLI::Follow::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 "#followers" do
20
- before do
21
- @t.options = @t.options.merge(:profile => fixture_path + "/.trc")
22
- end
23
- context "no users" do
24
- before do
25
- stub_get("/1/followers/ids.json").
26
- with(:query => {:cursor => "-1"}).
27
- to_return(:body => fixture("friends_ids.json"), :headers => {:content_type => "application/json; charset=utf-8"})
28
- stub_get("/1/friends/ids.json").
29
- with(:query => {:cursor => "-1"}).
30
- to_return(:body => fixture("friends_ids.json"), :headers => {:content_type => "application/json; charset=utf-8"})
31
- end
32
- it "should request the correct resource" do
33
- @t.follow("all", "followers")
34
- a_get("/1/followers/ids.json").
35
- with(:query => {:cursor => "-1"}).
36
- should have_been_made
37
- a_get("/1/friends/ids.json").
38
- with(:query => {:cursor => "-1"}).
39
- should have_been_made
40
- end
41
- it "should have the correct output" do
42
- @t.follow("all", "followers")
43
- $stdout.string.chomp.should == "@testcli is already following all followers."
44
- end
45
- end
46
- context "one user" do
47
- before do
48
- stub_get("/1/followers/ids.json").
49
- with(:query => {:cursor => "-1"}).
50
- to_return(:body => fixture("friends_ids.json"), :headers => {:content_type => "application/json; charset=utf-8"})
51
- stub_get("/1/friends/ids.json").
52
- with(:query => {:cursor => "-1"}).
53
- to_return(:body => fixture("followers_ids.json"), :headers => {:content_type => "application/json; charset=utf-8"})
54
- stub_post("/1/friendships/create.json").
55
- with(:body => {:user_id => "7505382", :include_entities => "false"}).
56
- to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
57
- end
58
- it "should request the correct resource" do
59
- $stdout.should_receive(:print).with("Are you sure you want to follow 1 user? ")
60
- $stdin.should_receive(:gets).and_return("yes")
61
- @t.follow("all", "followers")
62
- a_get("/1/followers/ids.json").
63
- with(:query => {:cursor => "-1"}).
64
- should have_been_made
65
- a_get("/1/friends/ids.json").
66
- with(:query => {:cursor => "-1"}).
67
- should have_been_made
68
- a_post("/1/friendships/create.json").
69
- with(:body => {:user_id => "7505382", :include_entities => "false"}).
70
- should have_been_made
71
- end
72
- context "yes" do
73
- it "should have the correct output" do
74
- $stdout.should_receive(:print).with("Are you sure you want to follow 1 user? ")
75
- $stdin.should_receive(:gets).and_return("yes")
76
- @t.follow("all", "followers")
77
- $stdout.string.should =~ /^@testcli is now following 1 more user\.$/
78
- end
79
- end
80
- context "no" do
81
- it "should have the correct output" do
82
- $stdout.should_receive(:print).with("Are you sure you want to follow 1 user? ")
83
- $stdin.should_receive(:gets).and_return("no")
84
- @t.follow("all", "followers")
85
- $stdout.string.chomp.should == ""
86
- end
87
- end
88
- end
89
- end
90
-
91
- describe "#listed" do
92
- before do
93
- @t.options = @t.options.merge(:profile => fixture_path + "/.trc")
94
- stub_get("/1/account/verify_credentials.json").
95
- to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
96
- end
97
- context "no users" do
98
- before do
99
- stub_get("/1/lists/members.json").
100
- with(:query => {:cursor => "-1", :include_entities => "false", :owner_screen_name => "sferik", :skip_status => "true", :slug => "presidents"}).
101
- to_return(:body => fixture("empty_cursor.json"), :headers => {:content_type => "application/json; charset=utf-8"})
102
- end
103
- it "should request the correct resource" do
104
- @t.follow("all", "listed", "presidents")
105
- a_get("/1/account/verify_credentials.json").
106
- should have_been_made
107
- a_get("/1/lists/members.json").
108
- with(:query => {:cursor => "-1", :include_entities => "false", :owner_screen_name => "sferik", :skip_status => "true", :slug => "presidents"}).
109
- should have_been_made
110
- end
111
- it "should have the correct output" do
112
- @t.follow("all", "listed", "presidents")
113
- $stdout.string.chomp.should == "@testcli is already following all list members."
114
- end
115
- end
116
- context "one user" do
117
- before do
118
- @t.options = @t.options.merge(:profile => fixture_path + "/.trc")
119
- stub_get("/1/lists/members.json").
120
- with(:query => {:cursor => "-1", :include_entities => "false", :owner_screen_name => "sferik", :skip_status => "true", :slug => "presidents"}).
121
- to_return(:body => fixture("users_list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
122
- stub_post("/1/friendships/create.json").
123
- with(:body => {:user_id => "7505382", :include_entities => "false"}).
124
- to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
125
- end
126
- it "should request the correct resource" do
127
- $stdout.should_receive(:print).with("Are you sure you want to follow 1 user? ")
128
- $stdin.should_receive(:gets).and_return("yes")
129
- @t.follow("all", "listed", "presidents")
130
- a_get("/1/account/verify_credentials.json").
131
- should have_been_made
132
- a_get("/1/lists/members.json").
133
- with(:query => {:cursor => "-1", :include_entities => "false", :owner_screen_name => "sferik", :skip_status => "true", :slug => "presidents"}).
134
- should have_been_made
135
- a_post("/1/friendships/create.json").
136
- with(:body => {: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 follow 1 user? ")
142
- $stdin.should_receive(:gets).and_return("yes")
143
- @t.follow("all", "listed", "presidents")
144
- $stdout.string.should =~ /^@testcli is now following 1 more 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 follow 1 user? ")
150
- $stdin.should_receive(:gets).and_return("no")
151
- @t.follow("all", "listed", "presidents")
152
- $stdout.string.chomp.should == ""
153
- end
154
- end
155
- end
156
- end
157
-
158
- end
@@ -1,435 +0,0 @@
1
- # encoding: utf-8
2
- require 'helper'
3
-
4
- describe T::CLI::List::Add::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("add", "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("add", "all", "friends", "presidents")
42
- $stdout.string.chomp.should == "All of @testcli's friends are already 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/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", "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/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", "all", "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", "all", "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", "all", "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", "all", "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", "all", "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", "all", "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", "all", "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 users" 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", "all", "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", "all", "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 "one user" 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", "all", "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", "all", "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", "all", "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", "all", "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", "all", "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", "all", "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", "all", "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", "all", "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", "all", "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", "all", "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", "all", "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", "all", "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", "all", "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", "all", "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", "all", "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", "all", "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", "all", "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", "all", "listed", "democrats", "presidents")
430
- $stdout.string.chomp.should == "The list \"presidents\" are already contains the maximum of 500 members."
431
- end
432
- end
433
- end
434
-
435
- end