t 2.0.1 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data.tar.gz.sig +0 -0
- data/CONTRIBUTING.md +1 -1
- data/README.md +12 -12
- data/Rakefile +11 -1
- data/bin/t +11 -11
- data/lib/t.rb +7 -9
- data/lib/t/cli.rb +299 -360
- data/lib/t/collectable.rb +2 -4
- data/lib/t/core_ext/kernel.rb +3 -5
- data/lib/t/core_ext/string.rb +4 -6
- data/lib/t/delete.rb +27 -29
- data/lib/t/editor.rb +1 -3
- data/lib/t/list.rb +44 -45
- data/lib/t/printable.rb +43 -44
- data/lib/t/rcfile.rb +4 -5
- data/lib/t/requestable.rb +1 -3
- data/lib/t/search.rb +42 -55
- data/lib/t/set.rb +11 -12
- data/lib/t/stream.rb +24 -20
- data/lib/t/utils.rb +20 -28
- data/lib/t/version.rb +1 -3
- data/spec/cli_spec.rb +1241 -1242
- data/spec/delete_spec.rb +122 -122
- data/spec/editor_spec.rb +42 -42
- data/spec/fixtures/lists.json +1 -1
- data/spec/fixtures/locations.json +1 -1
- data/spec/helper.rb +17 -13
- data/spec/list_spec.rb +202 -202
- data/spec/rcfile_spec.rb +73 -73
- data/spec/search_spec.rb +398 -398
- data/spec/set_spec.rb +72 -72
- data/spec/stream_spec.rb +56 -56
- data/spec/utils_spec.rb +29 -29
- data/t.gemspec +1 -1
- metadata +56 -32
- metadata.gz.sig +0 -0
- checksums.yaml +0 -7
- checksums.yaml.gz.sig +0 -0
data/lib/t/version.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
module T
|
2
2
|
class Version
|
3
3
|
class << self
|
4
|
-
|
5
4
|
# @return [Integer]
|
6
5
|
def major
|
7
6
|
2
|
@@ -14,7 +13,7 @@ module T
|
|
14
13
|
|
15
14
|
# @return [Integer]
|
16
15
|
def patch
|
17
|
-
|
16
|
+
2
|
18
17
|
end
|
19
18
|
|
20
19
|
# @return [String, NilClass]
|
@@ -26,7 +25,6 @@ module T
|
|
26
25
|
def to_s
|
27
26
|
[major, minor, patch, pre].compact.join('.')
|
28
27
|
end
|
29
|
-
|
30
28
|
end
|
31
29
|
end
|
32
30
|
end
|
data/spec/cli_spec.rb
CHANGED
@@ -14,9 +14,9 @@ describe T::CLI do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
before :each do
|
17
|
-
T::RCFile.instance.path = fixture_path +
|
17
|
+
T::RCFile.instance.path = fixture_path + '/.trc'
|
18
18
|
@cli = T::CLI.new
|
19
|
-
@cli.options = @cli.options.merge(
|
19
|
+
@cli.options = @cli.options.merge('color' => 'always')
|
20
20
|
@old_stderr = $stderr
|
21
21
|
$stderr = StringIO.new
|
22
22
|
@old_stdout = $stdout
|
@@ -29,11 +29,11 @@ describe T::CLI do
|
|
29
29
|
$stdout = @old_stdout
|
30
30
|
end
|
31
31
|
|
32
|
-
describe
|
32
|
+
describe '#account' do
|
33
33
|
before do
|
34
|
-
@cli.options = @cli.options.merge(
|
34
|
+
@cli.options = @cli.options.merge('profile' => fixture_path + '/.trc')
|
35
35
|
end
|
36
|
-
it
|
36
|
+
it 'has the correct output' do
|
37
37
|
@cli.accounts
|
38
38
|
expect($stdout.string).to eq <<-eos
|
39
39
|
testcli
|
@@ -42,120 +42,120 @@ testcli
|
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
-
describe
|
45
|
+
describe '#authorize' do
|
46
46
|
before do
|
47
|
-
@cli.options = @cli.options.merge(
|
48
|
-
stub_post(
|
49
|
-
stub_post(
|
50
|
-
stub_get(
|
47
|
+
@cli.options = @cli.options.merge('profile' => project_path + '/tmp/authorize', 'display-uri' => true)
|
48
|
+
stub_post('/oauth/request_token').to_return(:body => fixture('request_token'))
|
49
|
+
stub_post('/oauth/access_token').to_return(:body => fixture('access_token'))
|
50
|
+
stub_get('/1.1/account/verify_credentials.json').with(:query => {:include_entities => 'false', :skip_status => 'true'}).to_return(:body => fixture('sferik.json'))
|
51
51
|
end
|
52
|
-
it
|
52
|
+
it 'requests the correct resource' do
|
53
53
|
expect($stdout).to receive(:print)
|
54
54
|
expect($stdin).to receive(:gets).and_return("\n")
|
55
|
-
expect($stdout).to receive(:print).with(
|
56
|
-
expect($stdin).to receive(:gets).and_return(
|
57
|
-
expect($stdout).to receive(:print).with(
|
58
|
-
expect($stdin).to receive(:gets).and_return(
|
59
|
-
expect($stdout).to receive(:print).with(
|
55
|
+
expect($stdout).to receive(:print).with('Enter your consumer key: ')
|
56
|
+
expect($stdin).to receive(:gets).and_return('abc123')
|
57
|
+
expect($stdout).to receive(:print).with('Enter your consumer secret: ')
|
58
|
+
expect($stdin).to receive(:gets).and_return('asdfasd223sd2')
|
59
|
+
expect($stdout).to receive(:print).with('Press [Enter] to open the Twitter app authorization page. ')
|
60
60
|
expect($stdin).to receive(:gets).and_return("\n")
|
61
|
-
expect($stdout).to receive(:print).with(
|
62
|
-
expect($stdin).to receive(:gets).and_return(
|
61
|
+
expect($stdout).to receive(:print).with('Enter the supplied PIN: ')
|
62
|
+
expect($stdin).to receive(:gets).and_return('1234567890')
|
63
63
|
@cli.authorize
|
64
|
-
expect(a_post(
|
65
|
-
expect(a_post(
|
66
|
-
expect(a_get(
|
64
|
+
expect(a_post('/oauth/request_token')).to have_been_made
|
65
|
+
expect(a_post('/oauth/access_token')).to have_been_made
|
66
|
+
expect(a_get('/1.1/account/verify_credentials.json').with(:query => {:include_entities => 'false', :skip_status => 'true'})).to have_been_made
|
67
67
|
end
|
68
|
-
it
|
68
|
+
it 'does not raise error' do
|
69
69
|
expect do
|
70
70
|
expect($stdout).to receive(:print)
|
71
71
|
expect($stdin).to receive(:gets).and_return("\n")
|
72
|
-
expect($stdout).to receive(:print).with(
|
73
|
-
expect($stdin).to receive(:gets).and_return(
|
74
|
-
expect($stdout).to receive(:print).with(
|
75
|
-
expect($stdin).to receive(:gets).and_return(
|
76
|
-
expect($stdout).to receive(:print).with(
|
72
|
+
expect($stdout).to receive(:print).with('Enter your consumer key: ')
|
73
|
+
expect($stdin).to receive(:gets).and_return('abc123')
|
74
|
+
expect($stdout).to receive(:print).with('Enter your consumer secret: ')
|
75
|
+
expect($stdin).to receive(:gets).and_return('asdfasd223sd2')
|
76
|
+
expect($stdout).to receive(:print).with('Press [Enter] to open the Twitter app authorization page. ')
|
77
77
|
expect($stdin).to receive(:gets).and_return("\n")
|
78
|
-
expect($stdout).to receive(:print).with(
|
79
|
-
expect($stdin).to receive(:gets).and_return(
|
78
|
+
expect($stdout).to receive(:print).with('Enter the supplied PIN: ')
|
79
|
+
expect($stdin).to receive(:gets).and_return('1234567890')
|
80
80
|
@cli.authorize
|
81
81
|
end.not_to raise_error
|
82
82
|
end
|
83
|
-
context
|
83
|
+
context 'empty RC file' do
|
84
84
|
before do
|
85
|
-
@cli.options = @cli.options.merge(
|
85
|
+
@cli.options = @cli.options.merge('profile' => project_path + '/tmp/empty', 'display-uri' => true)
|
86
86
|
end
|
87
87
|
after do
|
88
|
-
File.delete(project_path +
|
88
|
+
File.delete(project_path + '/tmp/empty')
|
89
89
|
end
|
90
|
-
it
|
90
|
+
it 'requests the correct resource' do
|
91
91
|
expect($stdout).to receive(:print)
|
92
92
|
expect($stdin).to receive(:gets).and_return("\n")
|
93
|
-
expect($stdout).to receive(:print).with(
|
94
|
-
expect($stdin).to receive(:gets).and_return(
|
95
|
-
expect($stdout).to receive(:print).with(
|
96
|
-
expect($stdin).to receive(:gets).and_return(
|
97
|
-
expect($stdout).to receive(:print).with(
|
93
|
+
expect($stdout).to receive(:print).with('Enter your consumer key: ')
|
94
|
+
expect($stdin).to receive(:gets).and_return('abc123')
|
95
|
+
expect($stdout).to receive(:print).with('Enter your consumer secret: ')
|
96
|
+
expect($stdin).to receive(:gets).and_return('asdfasd223sd2')
|
97
|
+
expect($stdout).to receive(:print).with('Press [Enter] to open the Twitter app authorization page. ')
|
98
98
|
expect($stdin).to receive(:gets).and_return("\n")
|
99
|
-
expect($stdout).to receive(:print).with(
|
100
|
-
expect($stdin).to receive(:gets).and_return(
|
99
|
+
expect($stdout).to receive(:print).with('Enter the supplied PIN: ')
|
100
|
+
expect($stdin).to receive(:gets).and_return('1234567890')
|
101
101
|
@cli.authorize
|
102
|
-
expect(a_post(
|
103
|
-
expect(a_post(
|
104
|
-
expect(a_get(
|
102
|
+
expect(a_post('/oauth/request_token')).to have_been_made
|
103
|
+
expect(a_post('/oauth/access_token')).to have_been_made
|
104
|
+
expect(a_get('/1.1/account/verify_credentials.json').with(:query => {:include_entities => 'false', :skip_status => 'true'})).to have_been_made
|
105
105
|
end
|
106
|
-
it
|
106
|
+
it 'does not raise error' do
|
107
107
|
expect do
|
108
108
|
expect($stdout).to receive(:print)
|
109
109
|
expect($stdin).to receive(:gets).and_return("\n")
|
110
|
-
expect($stdout).to receive(:print).with(
|
111
|
-
expect($stdin).to receive(:gets).and_return(
|
112
|
-
expect($stdout).to receive(:print).with(
|
113
|
-
expect($stdin).to receive(:gets).and_return(
|
114
|
-
expect($stdout).to receive(:print).with(
|
110
|
+
expect($stdout).to receive(:print).with('Enter your consumer key: ')
|
111
|
+
expect($stdin).to receive(:gets).and_return('abc123')
|
112
|
+
expect($stdout).to receive(:print).with('Enter your consumer secret: ')
|
113
|
+
expect($stdin).to receive(:gets).and_return('asdfasd223sd2')
|
114
|
+
expect($stdout).to receive(:print).with('Press [Enter] to open the Twitter app authorization page. ')
|
115
115
|
expect($stdin).to receive(:gets).and_return("\n")
|
116
|
-
expect($stdout).to receive(:print).with(
|
117
|
-
expect($stdin).to receive(:gets).and_return(
|
116
|
+
expect($stdout).to receive(:print).with('Enter the supplied PIN: ')
|
117
|
+
expect($stdin).to receive(:gets).and_return('1234567890')
|
118
118
|
@cli.authorize
|
119
119
|
end.not_to raise_error
|
120
120
|
end
|
121
121
|
end
|
122
122
|
end
|
123
123
|
|
124
|
-
describe
|
124
|
+
describe '#block' do
|
125
125
|
before do
|
126
|
-
@cli.options = @cli.options.merge(
|
127
|
-
stub_post(
|
126
|
+
@cli.options = @cli.options.merge('profile' => fixture_path + '/.trc')
|
127
|
+
stub_post('/1.1/blocks/create.json').with(:body => {:screen_name => 'sferik'}).to_return(:body => fixture('sferik.json'))
|
128
128
|
end
|
129
|
-
it
|
130
|
-
@cli.block(
|
131
|
-
expect(a_post(
|
129
|
+
it 'requests the correct resource' do
|
130
|
+
@cli.block('sferik')
|
131
|
+
expect(a_post('/1.1/blocks/create.json').with(:body => {:screen_name => 'sferik'})).to have_been_made
|
132
132
|
end
|
133
|
-
it
|
134
|
-
@cli.block(
|
133
|
+
it 'has the correct output' do
|
134
|
+
@cli.block('sferik')
|
135
135
|
expect($stdout.string).to match /^@testcli blocked 1 user/
|
136
136
|
end
|
137
|
-
context
|
137
|
+
context '--id' do
|
138
138
|
before do
|
139
|
-
@cli.options = @cli.options.merge(
|
140
|
-
stub_post(
|
139
|
+
@cli.options = @cli.options.merge('id' => true)
|
140
|
+
stub_post('/1.1/blocks/create.json').with(:body => {:user_id => '7505382'}).to_return(:body => fixture('sferik.json'))
|
141
141
|
end
|
142
|
-
it
|
143
|
-
@cli.block(
|
144
|
-
expect(a_post(
|
142
|
+
it 'requests the correct resource' do
|
143
|
+
@cli.block('7505382')
|
144
|
+
expect(a_post('/1.1/blocks/create.json').with(:body => {:user_id => '7505382'})).to have_been_made
|
145
145
|
end
|
146
146
|
end
|
147
147
|
end
|
148
148
|
|
149
|
-
describe
|
149
|
+
describe '#direct_messages' do
|
150
150
|
before do
|
151
|
-
stub_get(
|
152
|
-
stub_get(
|
151
|
+
stub_get('/1.1/direct_messages.json').with(:query => {:count => '20'}).to_return(:body => fixture('direct_messages.json'))
|
152
|
+
stub_get('/1.1/direct_messages.json').with(:query => {:count => '10', 'max_id' => '1624782205'}).to_return(:body => fixture('empty_array.json'))
|
153
153
|
end
|
154
|
-
it
|
154
|
+
it 'requests the correct resource' do
|
155
155
|
@cli.direct_messages
|
156
|
-
expect(a_get(
|
156
|
+
expect(a_get('/1.1/direct_messages.json').with(:query => {:count => '20'})).to have_been_made
|
157
157
|
end
|
158
|
-
it
|
158
|
+
it 'has the correct output' do
|
159
159
|
@cli.direct_messages
|
160
160
|
expect($stdout.string).to eq <<-eos
|
161
161
|
@sferik
|
@@ -196,11 +196,11 @@ testcli
|
|
196
196
|
|
197
197
|
eos
|
198
198
|
end
|
199
|
-
context
|
199
|
+
context '--csv' do
|
200
200
|
before do
|
201
|
-
@cli.options = @cli.options.merge(
|
201
|
+
@cli.options = @cli.options.merge('csv' => true)
|
202
202
|
end
|
203
|
-
it
|
203
|
+
it 'outputs in CSV format' do
|
204
204
|
@cli.direct_messages
|
205
205
|
expect($stdout.string).to eq <<-eos
|
206
206
|
ID,Posted at,Screen name,Text
|
@@ -217,11 +217,11 @@ ID,Posted at,Screen name,Text
|
|
217
217
|
eos
|
218
218
|
end
|
219
219
|
end
|
220
|
-
context
|
220
|
+
context '--long' do
|
221
221
|
before do
|
222
|
-
@cli.options = @cli.options.merge(
|
222
|
+
@cli.options = @cli.options.merge('long' => true)
|
223
223
|
end
|
224
|
-
it
|
224
|
+
it 'outputs in long format' do
|
225
225
|
@cli.direct_messages
|
226
226
|
expect($stdout.string).to eq <<-eos
|
227
227
|
ID Posted at Screen name Text
|
@@ -238,29 +238,29 @@ ID Posted at Screen name Text
|
|
238
238
|
eos
|
239
239
|
end
|
240
240
|
end
|
241
|
-
context
|
241
|
+
context '--number' do
|
242
242
|
before do
|
243
|
-
stub_get(
|
244
|
-
stub_get(
|
245
|
-
stub_get(
|
243
|
+
stub_get('/1.1/direct_messages.json').with(:query => {:count => '1'}).to_return(:body => fixture('direct_messages.json'))
|
244
|
+
stub_get('/1.1/direct_messages.json').with(:query => {:count => '200'}).to_return(:body => fixture('200_direct_messages.json'))
|
245
|
+
stub_get('/1.1/direct_messages.json').with(:query => {:count => '1', :max_id => '235851563443306495'}).to_return(:body => fixture('direct_messages.json'))
|
246
246
|
end
|
247
|
-
it
|
248
|
-
@cli.options = @cli.options.merge(
|
247
|
+
it 'limits the number of results to 1' do
|
248
|
+
@cli.options = @cli.options.merge('number' => 1)
|
249
249
|
@cli.direct_messages
|
250
|
-
expect(a_get(
|
250
|
+
expect(a_get('/1.1/direct_messages.json').with(:query => {:count => '1'})).to have_been_made
|
251
251
|
end
|
252
|
-
it
|
253
|
-
@cli.options = @cli.options.merge(
|
252
|
+
it 'limits the number of results to 201' do
|
253
|
+
@cli.options = @cli.options.merge('number' => 201)
|
254
254
|
@cli.direct_messages
|
255
|
-
expect(a_get(
|
256
|
-
expect(a_get(
|
255
|
+
expect(a_get('/1.1/direct_messages.json').with(:query => {:count => '200'})).to have_been_made
|
256
|
+
expect(a_get('/1.1/direct_messages.json').with(:query => {:count => '1', :max_id => '235851563443306495'})).to have_been_made
|
257
257
|
end
|
258
258
|
end
|
259
|
-
context
|
259
|
+
context '--reverse' do
|
260
260
|
before do
|
261
|
-
@cli.options = @cli.options.merge(
|
261
|
+
@cli.options = @cli.options.merge('reverse' => true)
|
262
262
|
end
|
263
|
-
it
|
263
|
+
it 'reverses the order of the sort' do
|
264
264
|
@cli.direct_messages
|
265
265
|
expect($stdout.string).to eq <<-eos
|
266
266
|
@sferik
|
@@ -304,16 +304,16 @@ ID Posted at Screen name Text
|
|
304
304
|
end
|
305
305
|
end
|
306
306
|
|
307
|
-
describe
|
307
|
+
describe '#direct_messages_sent' do
|
308
308
|
before do
|
309
|
-
stub_get(
|
310
|
-
stub_get(
|
309
|
+
stub_get('/1.1/direct_messages/sent.json').with(:query => {:count => '20'}).to_return(:body => fixture('direct_messages.json'))
|
310
|
+
stub_get('/1.1/direct_messages/sent.json').with(:query => {:count => '10', 'max_id' => '1624782205'}).to_return(:body => fixture('empty_array.json'))
|
311
311
|
end
|
312
|
-
it
|
312
|
+
it 'requests the correct resource' do
|
313
313
|
@cli.direct_messages_sent
|
314
|
-
expect(a_get(
|
314
|
+
expect(a_get('/1.1/direct_messages/sent.json').with(:query => {:count => '20'})).to have_been_made
|
315
315
|
end
|
316
|
-
it
|
316
|
+
it 'has the correct output' do
|
317
317
|
@cli.direct_messages_sent
|
318
318
|
expect($stdout.string).to eq <<-eos
|
319
319
|
@hurrycane
|
@@ -354,11 +354,11 @@ ID Posted at Screen name Text
|
|
354
354
|
|
355
355
|
eos
|
356
356
|
end
|
357
|
-
context
|
357
|
+
context '--csv' do
|
358
358
|
before do
|
359
|
-
@cli.options = @cli.options.merge(
|
359
|
+
@cli.options = @cli.options.merge('csv' => true)
|
360
360
|
end
|
361
|
-
it
|
361
|
+
it 'outputs in CSV format' do
|
362
362
|
@cli.direct_messages_sent
|
363
363
|
expect($stdout.string).to eq <<-eos
|
364
364
|
ID,Posted at,Screen name,Text
|
@@ -375,11 +375,11 @@ ID,Posted at,Screen name,Text
|
|
375
375
|
eos
|
376
376
|
end
|
377
377
|
end
|
378
|
-
context
|
378
|
+
context '--long' do
|
379
379
|
before do
|
380
|
-
@cli.options = @cli.options.merge(
|
380
|
+
@cli.options = @cli.options.merge('long' => true)
|
381
381
|
end
|
382
|
-
it
|
382
|
+
it 'outputs in long format' do
|
383
383
|
@cli.direct_messages_sent
|
384
384
|
expect($stdout.string).to eq <<-eos
|
385
385
|
ID Posted at Screen name Text
|
@@ -396,29 +396,29 @@ ID Posted at Screen name Text
|
|
396
396
|
eos
|
397
397
|
end
|
398
398
|
end
|
399
|
-
context
|
399
|
+
context '--number' do
|
400
400
|
before do
|
401
|
-
stub_get(
|
402
|
-
stub_get(
|
403
|
-
stub_get(
|
401
|
+
stub_get('/1.1/direct_messages/sent.json').with(:query => {:count => '1'}).to_return(:body => fixture('direct_messages.json'))
|
402
|
+
stub_get('/1.1/direct_messages/sent.json').with(:query => {:count => '200'}).to_return(:body => fixture('200_direct_messages.json'))
|
403
|
+
stub_get('/1.1/direct_messages/sent.json').with(:query => {:count => '1', :max_id => '235851563443306495'}).to_return(:body => fixture('direct_messages.json'))
|
404
404
|
end
|
405
|
-
it
|
406
|
-
@cli.options = @cli.options.merge(
|
405
|
+
it 'limits the number of results 1' do
|
406
|
+
@cli.options = @cli.options.merge('number' => 1)
|
407
407
|
@cli.direct_messages_sent
|
408
|
-
expect(a_get(
|
408
|
+
expect(a_get('/1.1/direct_messages/sent.json').with(:query => {:count => '1'})).to have_been_made
|
409
409
|
end
|
410
|
-
it
|
411
|
-
@cli.options = @cli.options.merge(
|
410
|
+
it 'limits the number of results to 201' do
|
411
|
+
@cli.options = @cli.options.merge('number' => 201)
|
412
412
|
@cli.direct_messages_sent
|
413
|
-
expect(a_get(
|
414
|
-
expect(a_get(
|
413
|
+
expect(a_get('/1.1/direct_messages/sent.json').with(:query => {:count => '200'})).to have_been_made
|
414
|
+
expect(a_get('/1.1/direct_messages/sent.json').with(:query => {:count => '1', :max_id => '235851563443306495'})).to have_been_made
|
415
415
|
end
|
416
416
|
end
|
417
|
-
context
|
417
|
+
context '--reverse' do
|
418
418
|
before do
|
419
|
-
@cli.options = @cli.options.merge(
|
419
|
+
@cli.options = @cli.options.merge('reverse' => true)
|
420
420
|
end
|
421
|
-
it
|
421
|
+
it 'reverses the order of the sort' do
|
422
422
|
@cli.direct_messages_sent
|
423
423
|
expect($stdout.string).to eq <<-eos
|
424
424
|
@hurrycane
|
@@ -462,29 +462,29 @@ ID Posted at Screen name Text
|
|
462
462
|
end
|
463
463
|
end
|
464
464
|
|
465
|
-
describe
|
465
|
+
describe '#groupies' do
|
466
466
|
before do
|
467
|
-
stub_get(
|
468
|
-
stub_get(
|
469
|
-
stub_get(
|
470
|
-
stub_post(
|
467
|
+
stub_get('/1.1/account/verify_credentials.json').to_return(:body => fixture('sferik.json'))
|
468
|
+
stub_get('/1.1/followers/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'}).to_return(:body => fixture('followers_ids.json'))
|
469
|
+
stub_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'}).to_return(:body => fixture('friends_ids.json'))
|
470
|
+
stub_post('/1.1/users/lookup.json').with(:body => {:user_id => '213747670,428004849'}).to_return(:body => fixture('users.json'))
|
471
471
|
end
|
472
|
-
it
|
472
|
+
it 'requests the correct resource' do
|
473
473
|
@cli.groupies
|
474
|
-
expect(a_get(
|
475
|
-
expect(a_get(
|
476
|
-
expect(a_get(
|
477
|
-
expect(a_post(
|
474
|
+
expect(a_get('/1.1/account/verify_credentials.json')).to have_been_made
|
475
|
+
expect(a_get('/1.1/followers/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'})).to have_been_made
|
476
|
+
expect(a_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'})).to have_been_made
|
477
|
+
expect(a_post('/1.1/users/lookup.json').with(:body => {:user_id => '213747670,428004849'})).to have_been_made
|
478
478
|
end
|
479
|
-
it
|
479
|
+
it 'has the correct output' do
|
480
480
|
@cli.groupies
|
481
|
-
expect($stdout.string.chomp).to eq
|
481
|
+
expect($stdout.string.chomp).to eq 'pengwynn sferik'
|
482
482
|
end
|
483
|
-
context
|
483
|
+
context '--csv' do
|
484
484
|
before do
|
485
|
-
@cli.options = @cli.options.merge(
|
485
|
+
@cli.options = @cli.options.merge('csv' => true)
|
486
486
|
end
|
487
|
-
it
|
487
|
+
it 'outputs in CSV format' do
|
488
488
|
@cli.groupies
|
489
489
|
expect($stdout.string).to eq <<-eos
|
490
490
|
ID,Since,Last tweeted at,Tweets,Favorites,Listed,Following,Followers,Screen name,Name,Verified,Protected,Bio,Status,Location,URL
|
@@ -493,11 +493,11 @@ ID,Since,Last tweeted at,Tweets,Favorites,Listed,Following,Followers,Screen name
|
|
493
493
|
eos
|
494
494
|
end
|
495
495
|
end
|
496
|
-
context
|
496
|
+
context '--long' do
|
497
497
|
before do
|
498
|
-
@cli.options = @cli.options.merge(
|
498
|
+
@cli.options = @cli.options.merge('long' => true)
|
499
499
|
end
|
500
|
-
it
|
500
|
+
it 'outputs in long format' do
|
501
501
|
@cli.groupies
|
502
502
|
expect($stdout.string).to eq <<-eos
|
503
503
|
ID Since Last tweeted at Tweets Favorites Listed Following...
|
@@ -506,298 +506,298 @@ ID Since Last tweeted at Tweets Favorites Listed Following...
|
|
506
506
|
eos
|
507
507
|
end
|
508
508
|
end
|
509
|
-
context
|
509
|
+
context '--reverse' do
|
510
510
|
before do
|
511
|
-
@cli.options = @cli.options.merge(
|
511
|
+
@cli.options = @cli.options.merge('reverse' => true)
|
512
512
|
end
|
513
|
-
it
|
513
|
+
it 'reverses the order of the sort' do
|
514
514
|
@cli.groupies
|
515
|
-
expect($stdout.string.chomp).to eq
|
515
|
+
expect($stdout.string.chomp).to eq 'sferik pengwynn'
|
516
516
|
end
|
517
517
|
end
|
518
|
-
context
|
518
|
+
context '--sort=favorites' do
|
519
519
|
before do
|
520
|
-
@cli.options = @cli.options.merge(
|
520
|
+
@cli.options = @cli.options.merge('sort' => 'favorites')
|
521
521
|
end
|
522
|
-
it
|
522
|
+
it 'sorts by the number of favorites' do
|
523
523
|
@cli.groupies
|
524
|
-
expect($stdout.string.chomp).to eq
|
524
|
+
expect($stdout.string.chomp).to eq 'pengwynn sferik'
|
525
525
|
end
|
526
526
|
end
|
527
|
-
context
|
527
|
+
context '--sort=followers' do
|
528
528
|
before do
|
529
|
-
@cli.options = @cli.options.merge(
|
529
|
+
@cli.options = @cli.options.merge('sort' => 'followers')
|
530
530
|
end
|
531
|
-
it
|
531
|
+
it 'sorts by the number of followers' do
|
532
532
|
@cli.groupies
|
533
|
-
expect($stdout.string.chomp).to eq
|
533
|
+
expect($stdout.string.chomp).to eq 'sferik pengwynn'
|
534
534
|
end
|
535
535
|
end
|
536
|
-
context
|
536
|
+
context '--sort=friends' do
|
537
537
|
before do
|
538
|
-
@cli.options = @cli.options.merge(
|
538
|
+
@cli.options = @cli.options.merge('sort' => 'friends')
|
539
539
|
end
|
540
|
-
it
|
540
|
+
it 'sorts by the number of friends' do
|
541
541
|
@cli.groupies
|
542
|
-
expect($stdout.string.chomp).to eq
|
542
|
+
expect($stdout.string.chomp).to eq 'sferik pengwynn'
|
543
543
|
end
|
544
544
|
end
|
545
|
-
context
|
545
|
+
context '--sort=listed' do
|
546
546
|
before do
|
547
|
-
@cli.options = @cli.options.merge(
|
547
|
+
@cli.options = @cli.options.merge('sort' => 'listed')
|
548
548
|
end
|
549
|
-
it
|
549
|
+
it 'sorts by the number of list memberships' do
|
550
550
|
@cli.groupies
|
551
|
-
expect($stdout.string.chomp).to eq
|
551
|
+
expect($stdout.string.chomp).to eq 'sferik pengwynn'
|
552
552
|
end
|
553
553
|
end
|
554
|
-
context
|
554
|
+
context '--sort=since' do
|
555
555
|
before do
|
556
|
-
@cli.options = @cli.options.merge(
|
556
|
+
@cli.options = @cli.options.merge('sort' => 'since')
|
557
557
|
end
|
558
|
-
it
|
558
|
+
it 'sorts by the time when Twitter acount was created' do
|
559
559
|
@cli.groupies
|
560
|
-
expect($stdout.string.chomp).to eq
|
560
|
+
expect($stdout.string.chomp).to eq 'sferik pengwynn'
|
561
561
|
end
|
562
562
|
end
|
563
|
-
context
|
563
|
+
context '--sort=tweets' do
|
564
564
|
before do
|
565
|
-
@cli.options = @cli.options.merge(
|
565
|
+
@cli.options = @cli.options.merge('sort' => 'tweets')
|
566
566
|
end
|
567
|
-
it
|
567
|
+
it 'sorts by the number of Tweets' do
|
568
568
|
@cli.groupies
|
569
|
-
expect($stdout.string.chomp).to eq
|
569
|
+
expect($stdout.string.chomp).to eq 'pengwynn sferik'
|
570
570
|
end
|
571
571
|
end
|
572
|
-
context
|
572
|
+
context '--sort=tweeted' do
|
573
573
|
before do
|
574
|
-
@cli.options = @cli.options.merge(
|
574
|
+
@cli.options = @cli.options.merge('sort' => 'tweeted')
|
575
575
|
end
|
576
|
-
it
|
576
|
+
it 'sorts by the time of the last Tweet' do
|
577
577
|
@cli.groupies
|
578
|
-
expect($stdout.string.chomp).to eq
|
578
|
+
expect($stdout.string.chomp).to eq 'pengwynn sferik'
|
579
579
|
end
|
580
580
|
end
|
581
|
-
context
|
581
|
+
context '--unsorted' do
|
582
582
|
before do
|
583
|
-
@cli.options = @cli.options.merge(
|
583
|
+
@cli.options = @cli.options.merge('unsorted' => true)
|
584
584
|
end
|
585
|
-
it
|
585
|
+
it 'is not sorted' do
|
586
586
|
@cli.groupies
|
587
|
-
expect($stdout.string.chomp).to eq
|
587
|
+
expect($stdout.string.chomp).to eq 'pengwynn sferik'
|
588
588
|
end
|
589
589
|
end
|
590
|
-
context
|
590
|
+
context 'with a user passed' do
|
591
591
|
before do
|
592
|
-
stub_get(
|
593
|
-
stub_get(
|
592
|
+
stub_get('/1.1/followers/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'}).to_return(:body => fixture('followers_ids.json'))
|
593
|
+
stub_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'}).to_return(:body => fixture('friends_ids.json'))
|
594
594
|
end
|
595
|
-
it
|
596
|
-
@cli.groupies(
|
597
|
-
expect(a_get(
|
598
|
-
expect(a_get(
|
599
|
-
expect(a_post(
|
595
|
+
it 'requests the correct resource' do
|
596
|
+
@cli.groupies('sferik')
|
597
|
+
expect(a_get('/1.1/followers/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'})).to have_been_made
|
598
|
+
expect(a_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'})).to have_been_made
|
599
|
+
expect(a_post('/1.1/users/lookup.json').with(:body => {:user_id => '213747670,428004849'})).to have_been_made
|
600
600
|
end
|
601
|
-
context
|
601
|
+
context '--id' do
|
602
602
|
before do
|
603
|
-
@cli.options = @cli.options.merge(
|
604
|
-
stub_get(
|
605
|
-
stub_get(
|
603
|
+
@cli.options = @cli.options.merge('id' => true)
|
604
|
+
stub_get('/1.1/followers/ids.json').with(:query => {:cursor => '-1', :user_id => '7505382'}).to_return(:body => fixture('followers_ids.json'))
|
605
|
+
stub_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :user_id => '7505382'}).to_return(:body => fixture('friends_ids.json'))
|
606
606
|
end
|
607
|
-
it
|
608
|
-
@cli.groupies(
|
609
|
-
expect(a_get(
|
610
|
-
expect(a_get(
|
611
|
-
expect(a_post(
|
607
|
+
it 'requests the correct resource' do
|
608
|
+
@cli.groupies('7505382')
|
609
|
+
expect(a_get('/1.1/followers/ids.json').with(:query => {:cursor => '-1', :user_id => '7505382'})).to have_been_made
|
610
|
+
expect(a_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :user_id => '7505382'})).to have_been_made
|
611
|
+
expect(a_post('/1.1/users/lookup.json').with(:body => {:user_id => '213747670,428004849'})).to have_been_made
|
612
612
|
end
|
613
613
|
end
|
614
614
|
end
|
615
615
|
end
|
616
616
|
|
617
|
-
describe
|
617
|
+
describe '#dm' do
|
618
618
|
before do
|
619
|
-
@cli.options = @cli.options.merge(
|
620
|
-
stub_post(
|
619
|
+
@cli.options = @cli.options.merge('profile' => fixture_path + '/.trc')
|
620
|
+
stub_post('/1.1/direct_messages/new.json').with(:body => {:screen_name => 'pengwynn', :text => 'Creating a fixture for the Twitter gem'}).to_return(:body => fixture('direct_message.json'))
|
621
621
|
end
|
622
|
-
it
|
623
|
-
@cli.dm(
|
624
|
-
expect(a_post(
|
622
|
+
it 'requests the correct resource' do
|
623
|
+
@cli.dm('pengwynn', 'Creating a fixture for the Twitter gem')
|
624
|
+
expect(a_post('/1.1/direct_messages/new.json').with(:body => {:screen_name => 'pengwynn', :text => 'Creating a fixture for the Twitter gem'})).to have_been_made
|
625
625
|
end
|
626
|
-
it
|
627
|
-
@cli.dm(
|
628
|
-
expect($stdout.string.chomp).to eq
|
626
|
+
it 'has the correct output' do
|
627
|
+
@cli.dm('pengwynn', 'Creating a fixture for the Twitter gem')
|
628
|
+
expect($stdout.string.chomp).to eq 'Direct Message sent from @testcli to @pengwynn.'
|
629
629
|
end
|
630
|
-
context
|
630
|
+
context '--id' do
|
631
631
|
before do
|
632
|
-
@cli.options = @cli.options.merge(
|
633
|
-
stub_post(
|
632
|
+
@cli.options = @cli.options.merge('id' => true)
|
633
|
+
stub_post('/1.1/direct_messages/new.json').with(:body => {:user_id => '14100886', :text => 'Creating a fixture for the Twitter gem'}).to_return(:body => fixture('direct_message.json'))
|
634
634
|
end
|
635
|
-
it
|
636
|
-
@cli.dm(
|
637
|
-
expect(a_post(
|
635
|
+
it 'requests the correct resource' do
|
636
|
+
@cli.dm('14100886', 'Creating a fixture for the Twitter gem')
|
637
|
+
expect(a_post('/1.1/direct_messages/new.json').with(:body => {:user_id => '14100886', :text => 'Creating a fixture for the Twitter gem'})).to have_been_made
|
638
638
|
end
|
639
639
|
end
|
640
640
|
end
|
641
641
|
|
642
|
-
describe
|
642
|
+
describe '#does_contain' do
|
643
643
|
before do
|
644
|
-
@cli.options = @cli.options.merge(
|
645
|
-
stub_get(
|
644
|
+
@cli.options = @cli.options.merge('profile' => fixture_path + '/.trc')
|
645
|
+
stub_get('/1.1/lists/members/show.json').with(:query => {:owner_screen_name => 'testcli', :screen_name => 'testcli', :slug => 'presidents'}).to_return(:body => fixture('list.json'))
|
646
646
|
end
|
647
|
-
it
|
648
|
-
@cli.does_contain(
|
649
|
-
expect(a_get(
|
647
|
+
it 'requests the correct resource' do
|
648
|
+
@cli.does_contain('presidents')
|
649
|
+
expect(a_get('/1.1/lists/members/show.json').with(:query => {:owner_screen_name => 'testcli', :screen_name => 'testcli', :slug => 'presidents'})).to have_been_made
|
650
650
|
end
|
651
|
-
it
|
652
|
-
@cli.does_contain(
|
653
|
-
expect($stdout.string.chomp).to eq
|
651
|
+
it 'has the correct output' do
|
652
|
+
@cli.does_contain('presidents')
|
653
|
+
expect($stdout.string.chomp).to eq 'Yes, presidents contains @testcli.'
|
654
654
|
end
|
655
|
-
context
|
655
|
+
context '--id' do
|
656
656
|
before do
|
657
|
-
@cli.options = @cli.options.merge(
|
658
|
-
stub_get(
|
659
|
-
stub_get(
|
657
|
+
@cli.options = @cli.options.merge('id' => true)
|
658
|
+
stub_get('/1.1/users/show.json').with(:query => {:user_id => '7505382'}).to_return(:body => fixture('sferik.json'))
|
659
|
+
stub_get('/1.1/lists/members/show.json').with(:query => {:owner_screen_name => 'testcli', :screen_name => 'sferik', :slug => 'presidents'}).to_return(:body => fixture('list.json'))
|
660
660
|
end
|
661
|
-
it
|
662
|
-
@cli.does_contain(
|
663
|
-
expect(a_get(
|
664
|
-
expect(a_get(
|
661
|
+
it 'requests the correct resource' do
|
662
|
+
@cli.does_contain('presidents', '7505382')
|
663
|
+
expect(a_get('/1.1/users/show.json').with(:query => {:user_id => '7505382'})).to have_been_made
|
664
|
+
expect(a_get('/1.1/lists/members/show.json').with(:query => {:owner_screen_name => 'testcli', :screen_name => 'sferik', :slug => 'presidents'})).to have_been_made
|
665
665
|
end
|
666
666
|
end
|
667
|
-
context
|
668
|
-
it
|
669
|
-
@cli.does_contain(
|
670
|
-
expect($stdout.string.chomp).to eq
|
667
|
+
context 'with an owner passed' do
|
668
|
+
it 'has the correct output' do
|
669
|
+
@cli.does_contain('testcli/presidents', 'testcli')
|
670
|
+
expect($stdout.string.chomp).to eq 'Yes, presidents contains @testcli.'
|
671
671
|
end
|
672
|
-
context
|
672
|
+
context '--id' do
|
673
673
|
before do
|
674
|
-
@cli.options = @cli.options.merge(
|
675
|
-
stub_get(
|
676
|
-
stub_get(
|
674
|
+
@cli.options = @cli.options.merge('id' => true)
|
675
|
+
stub_get('/1.1/users/show.json').with(:query => {:user_id => '7505382'}).to_return(:body => fixture('sferik.json'))
|
676
|
+
stub_get('/1.1/lists/members/show.json').with(:query => {:owner_id => '7505382', :screen_name => 'sferik', :slug => 'presidents'}).to_return(:body => fixture('list.json'))
|
677
677
|
end
|
678
|
-
it
|
679
|
-
@cli.does_contain(
|
680
|
-
expect(a_get(
|
681
|
-
expect(a_get(
|
678
|
+
it 'requests the correct resource' do
|
679
|
+
@cli.does_contain('7505382/presidents', '7505382')
|
680
|
+
expect(a_get('/1.1/users/show.json').with(:query => {:user_id => '7505382'})).to have_been_made
|
681
|
+
expect(a_get('/1.1/lists/members/show.json').with(:query => {:owner_id => '7505382', :screen_name => 'sferik', :slug => 'presidents'})).to have_been_made
|
682
682
|
end
|
683
683
|
end
|
684
684
|
end
|
685
|
-
context
|
686
|
-
it
|
687
|
-
@cli.does_contain(
|
688
|
-
expect($stdout.string.chomp).to eq
|
685
|
+
context 'with a user passed' do
|
686
|
+
it 'has the correct output' do
|
687
|
+
@cli.does_contain('presidents', 'testcli')
|
688
|
+
expect($stdout.string.chomp).to eq 'Yes, presidents contains @testcli.'
|
689
689
|
end
|
690
690
|
end
|
691
|
-
context
|
691
|
+
context 'false' do
|
692
692
|
before do
|
693
|
-
stub_get(
|
693
|
+
stub_get('/1.1/lists/members/show.json').with(:query => {:owner_screen_name => 'testcli', :screen_name => 'testcli', :slug => 'presidents'}).to_return(:body => fixture('not_found.json'), :status => 404)
|
694
694
|
end
|
695
|
-
it
|
695
|
+
it 'exits' do
|
696
696
|
expect do
|
697
|
-
@cli.does_contain(
|
697
|
+
@cli.does_contain('presidents')
|
698
698
|
end.to raise_error(SystemExit)
|
699
|
-
expect(a_get(
|
699
|
+
expect(a_get('/1.1/lists/members/show.json').with(:query => {:owner_screen_name => 'testcli', :screen_name => 'testcli', :slug => 'presidents'})).to have_been_made
|
700
700
|
end
|
701
701
|
end
|
702
702
|
end
|
703
703
|
|
704
|
-
describe
|
704
|
+
describe '#does_follow' do
|
705
705
|
before do
|
706
|
-
@cli.options = @cli.options.merge(
|
707
|
-
stub_get(
|
706
|
+
@cli.options = @cli.options.merge('profile' => fixture_path + '/.trc')
|
707
|
+
stub_get('/1.1/friendships/show.json').with(:query => {:source_screen_name => 'ev', :target_screen_name => 'testcli'}).to_return(:body => fixture('following.json'))
|
708
708
|
end
|
709
|
-
it
|
710
|
-
@cli.does_follow(
|
711
|
-
expect(a_get(
|
709
|
+
it 'requests the correct resource' do
|
710
|
+
@cli.does_follow('ev')
|
711
|
+
expect(a_get('/1.1/friendships/show.json').with(:query => {:source_screen_name => 'ev', :target_screen_name => 'testcli'})).to have_been_made
|
712
712
|
end
|
713
|
-
it
|
714
|
-
@cli.does_follow(
|
715
|
-
expect($stdout.string.chomp).to eq
|
713
|
+
it 'has the correct output' do
|
714
|
+
@cli.does_follow('ev')
|
715
|
+
expect($stdout.string.chomp).to eq 'Yes, @ev follows @testcli.'
|
716
716
|
end
|
717
|
-
context
|
717
|
+
context '--id' do
|
718
718
|
before do
|
719
|
-
@cli.options = @cli.options.merge(
|
720
|
-
stub_get(
|
721
|
-
stub_get(
|
719
|
+
@cli.options = @cli.options.merge('id' => true)
|
720
|
+
stub_get('/1.1/users/show.json').with(:query => {:user_id => '20'}).to_return(:body => fixture('sferik.json'))
|
721
|
+
stub_get('/1.1/friendships/show.json').with(:query => {:source_screen_name => 'sferik', :target_screen_name => 'testcli'}).to_return(:body => fixture('following.json'))
|
722
722
|
end
|
723
|
-
it
|
724
|
-
@cli.does_follow(
|
725
|
-
expect(a_get(
|
726
|
-
expect(a_get(
|
723
|
+
it 'requests the correct resource' do
|
724
|
+
@cli.does_follow('20')
|
725
|
+
expect(a_get('/1.1/users/show.json').with(:query => {:user_id => '20'})).to have_been_made
|
726
|
+
expect(a_get('/1.1/friendships/show.json').with(:query => {:source_screen_name => 'sferik', :target_screen_name => 'testcli'})).to have_been_made
|
727
727
|
end
|
728
|
-
it
|
729
|
-
@cli.does_follow(
|
730
|
-
expect($stdout.string.chomp).to eq
|
728
|
+
it 'has the correct output' do
|
729
|
+
@cli.does_follow('20')
|
730
|
+
expect($stdout.string.chomp).to eq 'Yes, @sferik follows @testcli.'
|
731
731
|
end
|
732
732
|
end
|
733
|
-
context
|
733
|
+
context 'with a user passed' do
|
734
734
|
before do
|
735
|
-
stub_get(
|
735
|
+
stub_get('/1.1/friendships/show.json').with(:query => {:source_screen_name => 'ev', :target_screen_name => 'sferik'}).to_return(:body => fixture('following.json'))
|
736
736
|
end
|
737
|
-
it
|
738
|
-
@cli.does_follow(
|
739
|
-
expect(a_get(
|
737
|
+
it 'requests the correct resource' do
|
738
|
+
@cli.does_follow('ev', 'sferik')
|
739
|
+
expect(a_get('/1.1/friendships/show.json').with(:query => {:source_screen_name => 'ev', :target_screen_name => 'sferik'})).to have_been_made
|
740
740
|
end
|
741
|
-
it
|
742
|
-
@cli.does_follow(
|
743
|
-
expect($stdout.string.chomp).to eq
|
741
|
+
it 'has the correct output' do
|
742
|
+
@cli.does_follow('ev', 'sferik')
|
743
|
+
expect($stdout.string.chomp).to eq 'Yes, @ev follows @sferik.'
|
744
744
|
end
|
745
|
-
context
|
745
|
+
context '--id' do
|
746
746
|
before do
|
747
|
-
@cli.options = @cli.options.merge(
|
748
|
-
stub_get(
|
749
|
-
stub_get(
|
750
|
-
stub_get(
|
747
|
+
@cli.options = @cli.options.merge('id' => true)
|
748
|
+
stub_get('/1.1/users/show.json').with(:query => {:user_id => '20'}).to_return(:body => fixture('sferik.json'))
|
749
|
+
stub_get('/1.1/users/show.json').with(:query => {:user_id => '428004849'}).to_return(:body => fixture('sferik.json'))
|
750
|
+
stub_get('/1.1/friendships/show.json').with(:query => {:source_screen_name => 'sferik', :target_screen_name => 'sferik'}).to_return(:body => fixture('following.json'))
|
751
751
|
end
|
752
|
-
it
|
753
|
-
@cli.does_follow(
|
754
|
-
expect(a_get(
|
755
|
-
expect(a_get(
|
756
|
-
expect(a_get(
|
752
|
+
it 'requests the correct resource' do
|
753
|
+
@cli.does_follow('20', '428004849')
|
754
|
+
expect(a_get('/1.1/users/show.json').with(:query => {:user_id => '20'})).to have_been_made
|
755
|
+
expect(a_get('/1.1/users/show.json').with(:query => {:user_id => '428004849'})).to have_been_made
|
756
|
+
expect(a_get('/1.1/friendships/show.json').with(:query => {:source_screen_name => 'sferik', :target_screen_name => 'sferik'})).to have_been_made
|
757
757
|
end
|
758
|
-
it
|
759
|
-
@cli.does_follow(
|
760
|
-
expect($stdout.string.chomp).to eq
|
758
|
+
it 'has the correct output' do
|
759
|
+
@cli.does_follow('20', '428004849')
|
760
|
+
expect($stdout.string.chomp).to eq 'Yes, @sferik follows @sferik.'
|
761
761
|
end
|
762
762
|
end
|
763
763
|
end
|
764
|
-
context
|
764
|
+
context 'false' do
|
765
765
|
before do
|
766
|
-
stub_get(
|
766
|
+
stub_get('/1.1/friendships/show.json').with(:query => {:source_screen_name => 'ev', :target_screen_name => 'testcli'}).to_return(:body => fixture('not_following.json'))
|
767
767
|
end
|
768
|
-
it
|
768
|
+
it 'exits' do
|
769
769
|
expect do
|
770
|
-
@cli.does_follow(
|
770
|
+
@cli.does_follow('ev')
|
771
771
|
end.to raise_error(SystemExit)
|
772
|
-
expect(a_get(
|
772
|
+
expect(a_get('/1.1/friendships/show.json').with(:query => {:source_screen_name => 'ev', :target_screen_name => 'testcli'})).to have_been_made
|
773
773
|
end
|
774
774
|
end
|
775
775
|
end
|
776
776
|
|
777
|
-
describe
|
777
|
+
describe '#favorite' do
|
778
778
|
before do
|
779
|
-
@cli.options = @cli.options.merge(
|
780
|
-
stub_post(
|
779
|
+
@cli.options = @cli.options.merge('profile' => fixture_path + '/.trc')
|
780
|
+
stub_post('/1.1/favorites/create.json').with(:body => {:id => '26755176471724032'}).to_return(:body => fixture('status.json'))
|
781
781
|
end
|
782
|
-
it
|
783
|
-
@cli.favorite(
|
784
|
-
expect(a_post(
|
782
|
+
it 'requests the correct resource' do
|
783
|
+
@cli.favorite('26755176471724032')
|
784
|
+
expect(a_post('/1.1/favorites/create.json').with(:body => {:id => '26755176471724032'})).to have_been_made
|
785
785
|
end
|
786
|
-
it
|
787
|
-
@cli.favorite(
|
786
|
+
it 'has the correct output' do
|
787
|
+
@cli.favorite('26755176471724032')
|
788
788
|
expect($stdout.string).to match /^@testcli favorited 1 tweet.$/
|
789
789
|
end
|
790
790
|
end
|
791
791
|
|
792
|
-
describe
|
792
|
+
describe '#favorites' do
|
793
793
|
before do
|
794
|
-
stub_get(
|
794
|
+
stub_get('/1.1/favorites/list.json').with(:query => {:count => '20'}).to_return(:body => fixture('statuses.json'))
|
795
795
|
end
|
796
|
-
it
|
796
|
+
it 'requests the correct resource' do
|
797
797
|
@cli.favorites
|
798
|
-
expect(a_get(
|
798
|
+
expect(a_get('/1.1/favorites/list.json').with(:query => {:count => '20'})).to have_been_made
|
799
799
|
end
|
800
|
-
it
|
800
|
+
it 'has the correct output' do
|
801
801
|
@cli.favorites
|
802
802
|
expect($stdout.string).to eq <<-eos
|
803
803
|
@mutgoff
|
@@ -877,11 +877,11 @@ ID Since Last tweeted at Tweets Favorites Listed Following...
|
|
877
877
|
|
878
878
|
eos
|
879
879
|
end
|
880
|
-
context
|
880
|
+
context '--csv' do
|
881
881
|
before do
|
882
|
-
@cli.options = @cli.options.merge(
|
882
|
+
@cli.options = @cli.options.merge('csv' => true)
|
883
883
|
end
|
884
|
-
it
|
884
|
+
it 'outputs in CSV format' do
|
885
885
|
@cli.favorites
|
886
886
|
expect($stdout.string).to eq <<-eos
|
887
887
|
ID,Posted at,Screen name,Text
|
@@ -908,11 +908,11 @@ ID,Posted at,Screen name,Text
|
|
908
908
|
eos
|
909
909
|
end
|
910
910
|
end
|
911
|
-
context
|
911
|
+
context '--long' do
|
912
912
|
before do
|
913
|
-
@cli.options = @cli.options.merge(
|
913
|
+
@cli.options = @cli.options.merge('long' => true)
|
914
914
|
end
|
915
|
-
it
|
915
|
+
it 'outputs in long format' do
|
916
916
|
@cli.favorites
|
917
917
|
expect($stdout.string).to eq <<-eos
|
918
918
|
ID Posted at Screen name Text
|
@@ -938,11 +938,11 @@ ID Posted at Screen name Text
|
|
938
938
|
244099460672679938 Sep 7 07:47 @dwiskus Gentlemen, you can't fig...
|
939
939
|
eos
|
940
940
|
end
|
941
|
-
context
|
941
|
+
context '--reverse' do
|
942
942
|
before do
|
943
|
-
@cli.options = @cli.options.merge(
|
943
|
+
@cli.options = @cli.options.merge('reverse' => true)
|
944
944
|
end
|
945
|
-
it
|
945
|
+
it 'reverses the order of the sort' do
|
946
946
|
@cli.favorites
|
947
947
|
expect($stdout.string).to eq <<-eos
|
948
948
|
ID Posted at Screen name Text
|
@@ -970,176 +970,176 @@ ID Posted at Screen name Text
|
|
970
970
|
end
|
971
971
|
end
|
972
972
|
end
|
973
|
-
context
|
973
|
+
context '--max-id' do
|
974
974
|
before do
|
975
|
-
@cli.options = @cli.options.merge(
|
976
|
-
stub_get(
|
975
|
+
@cli.options = @cli.options.merge('max_id' => 244_104_558_433_951_744)
|
976
|
+
stub_get('/1.1/favorites/list.json').with(:query => {:count => '20', :max_id => '244104558433951744'}).to_return(:body => fixture('statuses.json'))
|
977
977
|
end
|
978
|
-
it
|
978
|
+
it 'requests the correct resource' do
|
979
979
|
@cli.favorites
|
980
|
-
expect(a_get(
|
980
|
+
expect(a_get('/1.1/favorites/list.json').with(:query => {:count => '20', :max_id => '244104558433951744'})).to have_been_made
|
981
981
|
end
|
982
982
|
end
|
983
|
-
context
|
983
|
+
context '--number' do
|
984
984
|
before do
|
985
|
-
stub_get(
|
986
|
-
stub_get(
|
987
|
-
stub_get(
|
985
|
+
stub_get('/1.1/favorites/list.json').with(:query => {:count => '1'}).to_return(:body => fixture('statuses.json'))
|
986
|
+
stub_get('/1.1/favorites/list.json').with(:query => {:count => '200'}).to_return(:body => fixture('200_statuses.json'))
|
987
|
+
stub_get('/1.1/favorites/list.json').with(:query => {:count => '1', :max_id => '265500541700956160'}).to_return(:body => fixture('statuses.json'))
|
988
988
|
end
|
989
|
-
it
|
990
|
-
@cli.options = @cli.options.merge(
|
989
|
+
it 'limits the number of results to 1' do
|
990
|
+
@cli.options = @cli.options.merge('number' => 1)
|
991
991
|
@cli.favorites
|
992
|
-
expect(a_get(
|
992
|
+
expect(a_get('/1.1/favorites/list.json').with(:query => {:count => '1'})).to have_been_made
|
993
993
|
end
|
994
|
-
it
|
995
|
-
@cli.options = @cli.options.merge(
|
994
|
+
it 'limits the number of results to 201' do
|
995
|
+
@cli.options = @cli.options.merge('number' => 201)
|
996
996
|
@cli.favorites
|
997
|
-
expect(a_get(
|
998
|
-
expect(a_get(
|
997
|
+
expect(a_get('/1.1/favorites/list.json').with(:query => {:count => '200'})).to have_been_made
|
998
|
+
expect(a_get('/1.1/favorites/list.json').with(:query => {:count => '1', :max_id => '265500541700956160'})).to have_been_made
|
999
999
|
end
|
1000
1000
|
end
|
1001
|
-
context
|
1001
|
+
context '--since-id' do
|
1002
1002
|
before do
|
1003
|
-
@cli.options = @cli.options.merge(
|
1004
|
-
stub_get(
|
1003
|
+
@cli.options = @cli.options.merge('since_id' => 244_104_558_433_951_744)
|
1004
|
+
stub_get('/1.1/favorites/list.json').with(:query => {:count => '20', :since_id => '244104558433951744'}).to_return(:body => fixture('statuses.json'))
|
1005
1005
|
end
|
1006
|
-
it
|
1006
|
+
it 'requests the correct resource' do
|
1007
1007
|
@cli.favorites
|
1008
|
-
expect(a_get(
|
1008
|
+
expect(a_get('/1.1/favorites/list.json').with(:query => {:count => '20', :since_id => '244104558433951744'})).to have_been_made
|
1009
1009
|
end
|
1010
1010
|
end
|
1011
|
-
context
|
1011
|
+
context 'with a user passed' do
|
1012
1012
|
before do
|
1013
|
-
stub_get(
|
1013
|
+
stub_get('/1.1/favorites/list.json').with(:query => {:count => '20', :screen_name => 'sferik'}).to_return(:body => fixture('statuses.json'))
|
1014
1014
|
end
|
1015
|
-
it
|
1016
|
-
@cli.favorites(
|
1017
|
-
expect(a_get(
|
1015
|
+
it 'requests the correct resource' do
|
1016
|
+
@cli.favorites('sferik')
|
1017
|
+
expect(a_get('/1.1/favorites/list.json').with(:query => {:count => '20', :screen_name => 'sferik'})).to have_been_made
|
1018
1018
|
end
|
1019
|
-
context
|
1019
|
+
context '--id' do
|
1020
1020
|
before do
|
1021
|
-
@cli.options = @cli.options.merge(
|
1022
|
-
stub_get(
|
1021
|
+
@cli.options = @cli.options.merge('id' => true)
|
1022
|
+
stub_get('/1.1/favorites/list.json').with(:query => {:user_id => '7505382', :count => '20'}).to_return(:body => fixture('statuses.json'))
|
1023
1023
|
end
|
1024
|
-
it
|
1025
|
-
@cli.favorites(
|
1026
|
-
expect(a_get(
|
1024
|
+
it 'requests the correct resource' do
|
1025
|
+
@cli.favorites('7505382')
|
1026
|
+
expect(a_get('/1.1/favorites/list.json').with(:query => {:user_id => '7505382', :count => '20'})).to have_been_made
|
1027
1027
|
end
|
1028
1028
|
end
|
1029
|
-
context
|
1029
|
+
context '--max-id' do
|
1030
1030
|
before do
|
1031
|
-
@cli.options = @cli.options.merge(
|
1032
|
-
stub_get(
|
1031
|
+
@cli.options = @cli.options.merge('max_id' => 244_104_558_433_951_744)
|
1032
|
+
stub_get('/1.1/favorites/list.json').with(:query => {:count => '20', :screen_name => 'sferik', :max_id => '244104558433951744'}).to_return(:body => fixture('statuses.json'))
|
1033
1033
|
end
|
1034
|
-
it
|
1035
|
-
@cli.favorites(
|
1036
|
-
expect(a_get(
|
1034
|
+
it 'requests the correct resource' do
|
1035
|
+
@cli.favorites('sferik')
|
1036
|
+
expect(a_get('/1.1/favorites/list.json').with(:query => {:count => '20', :screen_name => 'sferik', :max_id => '244104558433951744'})).to have_been_made
|
1037
1037
|
end
|
1038
1038
|
end
|
1039
|
-
context
|
1039
|
+
context '--number' do
|
1040
1040
|
before do
|
1041
|
-
stub_get(
|
1042
|
-
stub_get(
|
1043
|
-
stub_get(
|
1041
|
+
stub_get('/1.1/favorites/list.json').with(:query => {:count => '1', :screen_name => 'sferik'}).to_return(:body => fixture('statuses.json'))
|
1042
|
+
stub_get('/1.1/favorites/list.json').with(:query => {:count => '200', :screen_name => 'sferik'}).to_return(:body => fixture('200_statuses.json'))
|
1043
|
+
stub_get('/1.1/favorites/list.json').with(:query => {:count => '1', :screen_name => 'sferik', :max_id => '265500541700956160'}).to_return(:body => fixture('statuses.json'))
|
1044
1044
|
end
|
1045
|
-
it
|
1046
|
-
@cli.options = @cli.options.merge(
|
1047
|
-
@cli.favorites(
|
1048
|
-
expect(a_get(
|
1045
|
+
it 'limits the number of results to 1' do
|
1046
|
+
@cli.options = @cli.options.merge('number' => 1)
|
1047
|
+
@cli.favorites('sferik')
|
1048
|
+
expect(a_get('/1.1/favorites/list.json').with(:query => {:count => '1', :screen_name => 'sferik'})).to have_been_made
|
1049
1049
|
end
|
1050
|
-
it
|
1051
|
-
@cli.options = @cli.options.merge(
|
1052
|
-
@cli.favorites(
|
1053
|
-
expect(a_get(
|
1054
|
-
expect(a_get(
|
1050
|
+
it 'limits the number of results to 201' do
|
1051
|
+
@cli.options = @cli.options.merge('number' => 201)
|
1052
|
+
@cli.favorites('sferik')
|
1053
|
+
expect(a_get('/1.1/favorites/list.json').with(:query => {:count => '200', :screen_name => 'sferik'})).to have_been_made
|
1054
|
+
expect(a_get('/1.1/favorites/list.json').with(:query => {:count => '1', :screen_name => 'sferik', :max_id => '265500541700956160'})).to have_been_made
|
1055
1055
|
end
|
1056
1056
|
end
|
1057
|
-
context
|
1057
|
+
context '--since-id' do
|
1058
1058
|
before do
|
1059
|
-
@cli.options = @cli.options.merge(
|
1060
|
-
stub_get(
|
1059
|
+
@cli.options = @cli.options.merge('since_id' => 244_104_558_433_951_744)
|
1060
|
+
stub_get('/1.1/favorites/list.json').with(:query => {:count => '20', :screen_name => 'sferik', :since_id => '244104558433951744'}).to_return(:body => fixture('statuses.json'))
|
1061
1061
|
end
|
1062
|
-
it
|
1063
|
-
@cli.favorites(
|
1064
|
-
expect(a_get(
|
1062
|
+
it 'requests the correct resource' do
|
1063
|
+
@cli.favorites('sferik')
|
1064
|
+
expect(a_get('/1.1/favorites/list.json').with(:query => {:count => '20', :screen_name => 'sferik', :since_id => '244104558433951744'})).to have_been_made
|
1065
1065
|
end
|
1066
1066
|
end
|
1067
1067
|
end
|
1068
1068
|
end
|
1069
1069
|
|
1070
|
-
describe
|
1070
|
+
describe '#follow' do
|
1071
1071
|
before do
|
1072
|
-
@cli.options = @cli.options.merge(
|
1072
|
+
@cli.options = @cli.options.merge('profile' => fixture_path + '/.trc')
|
1073
1073
|
end
|
1074
|
-
context
|
1074
|
+
context 'one user' do
|
1075
1075
|
before do
|
1076
|
-
stub_get(
|
1077
|
-
stub_get(
|
1078
|
-
stub_post(
|
1079
|
-
stub_post(
|
1076
|
+
stub_get('/1.1/account/verify_credentials.json').to_return(:body => fixture('sferik.json'))
|
1077
|
+
stub_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'}).to_return(:body => fixture('friends_ids.json'))
|
1078
|
+
stub_post('/1.1/users/lookup.json').with(:body => {:screen_name => 'sferik,pengwynn'}).to_return(:body => fixture('users.json'))
|
1079
|
+
stub_post('/1.1/friendships/create.json').with(:body => {:user_id => '14100886'}).to_return(:body => fixture('sferik.json'))
|
1080
1080
|
end
|
1081
|
-
it
|
1082
|
-
@cli.follow(
|
1083
|
-
expect(a_get(
|
1084
|
-
expect(a_get(
|
1085
|
-
expect(a_post(
|
1086
|
-
expect(a_post(
|
1081
|
+
it 'requests the correct resource' do
|
1082
|
+
@cli.follow('sferik', 'pengwynn')
|
1083
|
+
expect(a_get('/1.1/account/verify_credentials.json')).to have_been_made
|
1084
|
+
expect(a_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'})).to have_been_made
|
1085
|
+
expect(a_post('/1.1/users/lookup.json').with(:body => {:screen_name => 'sferik,pengwynn'})).to have_been_made
|
1086
|
+
expect(a_post('/1.1/friendships/create.json').with(:body => {:user_id => '14100886'})).to have_been_made
|
1087
1087
|
end
|
1088
|
-
it
|
1089
|
-
@cli.follow(
|
1088
|
+
it 'has the correct output' do
|
1089
|
+
@cli.follow('sferik', 'pengwynn')
|
1090
1090
|
expect($stdout.string).to match /^@testcli is now following 1 more user\.$/
|
1091
1091
|
end
|
1092
|
-
context
|
1092
|
+
context '--id' do
|
1093
1093
|
before do
|
1094
|
-
@cli.options = @cli.options.merge(
|
1095
|
-
stub_get(
|
1096
|
-
stub_post(
|
1097
|
-
stub_post(
|
1094
|
+
@cli.options = @cli.options.merge('id' => true)
|
1095
|
+
stub_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'}).to_return(:body => fixture('friends_ids.json'))
|
1096
|
+
stub_post('/1.1/users/lookup.json').with(:body => {:user_id => '7505382,14100886'}).to_return(:body => fixture('users.json'))
|
1097
|
+
stub_post('/1.1/friendships/create.json').with(:body => {:user_id => '14100886'}).to_return(:body => fixture('sferik.json'))
|
1098
1098
|
end
|
1099
|
-
it
|
1100
|
-
@cli.follow(
|
1101
|
-
expect(a_get(
|
1102
|
-
expect(a_post(
|
1103
|
-
expect(a_post(
|
1099
|
+
it 'requests the correct resource' do
|
1100
|
+
@cli.follow('7505382', '14100886')
|
1101
|
+
expect(a_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'})).to have_been_made
|
1102
|
+
expect(a_post('/1.1/users/lookup.json').with(:body => {:user_id => '7505382,14100886'})).to have_been_made
|
1103
|
+
expect(a_post('/1.1/friendships/create.json').with(:body => {:user_id => '14100886'})).to have_been_made
|
1104
1104
|
end
|
1105
1105
|
end
|
1106
|
-
context
|
1107
|
-
it
|
1108
|
-
stub_get(
|
1109
|
-
stub_post(
|
1110
|
-
stub_post(
|
1106
|
+
context 'Twitter is down' do
|
1107
|
+
it 'retries 3 times and then raise an error' do
|
1108
|
+
stub_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'}).to_return(:body => fixture('friends_ids.json'))
|
1109
|
+
stub_post('/1.1/users/lookup.json').with(:body => {:screen_name => 'sferik,pengwynn'}).to_return(:body => fixture('users.json'))
|
1110
|
+
stub_post('/1.1/friendships/create.json').with(:body => {:user_id => '14100886'}).to_return(:status => 502)
|
1111
1111
|
expect do
|
1112
|
-
@cli.follow(
|
1112
|
+
@cli.follow('sferik', 'pengwynn')
|
1113
1113
|
end.to raise_error(Twitter::Error::BadGateway)
|
1114
|
-
expect(a_get(
|
1115
|
-
expect(a_post(
|
1116
|
-
expect(a_post(
|
1114
|
+
expect(a_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'})).to have_been_made.times(3)
|
1115
|
+
expect(a_post('/1.1/users/lookup.json').with(:body => {:screen_name => 'sferik,pengwynn'})).to have_been_made.times(3)
|
1116
|
+
expect(a_post('/1.1/friendships/create.json').with(:body => {:user_id => '14100886'})).to have_been_made.times(3)
|
1117
1117
|
end
|
1118
1118
|
end
|
1119
1119
|
end
|
1120
1120
|
end
|
1121
1121
|
|
1122
|
-
describe
|
1122
|
+
describe '#followings' do
|
1123
1123
|
before do
|
1124
|
-
stub_get(
|
1125
|
-
stub_get(
|
1126
|
-
stub_post(
|
1124
|
+
stub_get('/1.1/account/verify_credentials.json').to_return(:body => fixture('sferik.json'))
|
1125
|
+
stub_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'}).to_return(:body => fixture('friends_ids.json'))
|
1126
|
+
stub_post('/1.1/users/lookup.json').with(:body => {:user_id => '7505382'}).to_return(:body => fixture('users.json'))
|
1127
1127
|
end
|
1128
|
-
it
|
1128
|
+
it 'requests the correct resource' do
|
1129
1129
|
@cli.followings
|
1130
|
-
expect(a_get(
|
1131
|
-
expect(a_get(
|
1132
|
-
expect(a_post(
|
1130
|
+
expect(a_get('/1.1/account/verify_credentials.json')).to have_been_made
|
1131
|
+
expect(a_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'})).to have_been_made
|
1132
|
+
expect(a_post('/1.1/users/lookup.json').with(:body => {:user_id => '7505382'})).to have_been_made
|
1133
1133
|
end
|
1134
|
-
it
|
1134
|
+
it 'has the correct output' do
|
1135
1135
|
@cli.followings
|
1136
|
-
expect($stdout.string.chomp).to eq
|
1136
|
+
expect($stdout.string.chomp).to eq 'pengwynn sferik'
|
1137
1137
|
end
|
1138
|
-
context
|
1138
|
+
context '--csv' do
|
1139
1139
|
before do
|
1140
|
-
@cli.options = @cli.options.merge(
|
1140
|
+
@cli.options = @cli.options.merge('csv' => true)
|
1141
1141
|
end
|
1142
|
-
it
|
1142
|
+
it 'outputs in CSV format' do
|
1143
1143
|
@cli.followings
|
1144
1144
|
expect($stdout.string).to eq <<-eos
|
1145
1145
|
ID,Since,Last tweeted at,Tweets,Favorites,Listed,Following,Followers,Screen name,Name,Verified,Protected,Bio,Status,Location,URL
|
@@ -1148,11 +1148,11 @@ ID,Since,Last tweeted at,Tweets,Favorites,Listed,Following,Followers,Screen name
|
|
1148
1148
|
eos
|
1149
1149
|
end
|
1150
1150
|
end
|
1151
|
-
context
|
1151
|
+
context '--long' do
|
1152
1152
|
before do
|
1153
|
-
@cli.options = @cli.options.merge(
|
1153
|
+
@cli.options = @cli.options.merge('long' => true)
|
1154
1154
|
end
|
1155
|
-
it
|
1155
|
+
it 'outputs in long format' do
|
1156
1156
|
@cli.followings
|
1157
1157
|
expect($stdout.string).to eq <<-eos
|
1158
1158
|
ID Since Last tweeted at Tweets Favorites Listed Following...
|
@@ -1161,131 +1161,131 @@ ID Since Last tweeted at Tweets Favorites Listed Following...
|
|
1161
1161
|
eos
|
1162
1162
|
end
|
1163
1163
|
end
|
1164
|
-
context
|
1164
|
+
context '--reverse' do
|
1165
1165
|
before do
|
1166
|
-
@cli.options = @cli.options.merge(
|
1166
|
+
@cli.options = @cli.options.merge('reverse' => true)
|
1167
1167
|
end
|
1168
|
-
it
|
1168
|
+
it 'reverses the order of the sort' do
|
1169
1169
|
@cli.followings
|
1170
|
-
expect($stdout.string.chomp).to eq
|
1170
|
+
expect($stdout.string.chomp).to eq 'sferik pengwynn'
|
1171
1171
|
end
|
1172
1172
|
end
|
1173
|
-
context
|
1173
|
+
context '--sort=favorites' do
|
1174
1174
|
before do
|
1175
|
-
@cli.options = @cli.options.merge(
|
1175
|
+
@cli.options = @cli.options.merge('sort' => 'favorites')
|
1176
1176
|
end
|
1177
|
-
it
|
1177
|
+
it 'sorts by the number of favorites' do
|
1178
1178
|
@cli.followings
|
1179
|
-
expect($stdout.string.chomp).to eq
|
1179
|
+
expect($stdout.string.chomp).to eq 'pengwynn sferik'
|
1180
1180
|
end
|
1181
1181
|
end
|
1182
|
-
context
|
1182
|
+
context '--sort=followers' do
|
1183
1183
|
before do
|
1184
|
-
@cli.options = @cli.options.merge(
|
1184
|
+
@cli.options = @cli.options.merge('sort' => 'followers')
|
1185
1185
|
end
|
1186
|
-
it
|
1186
|
+
it 'sorts by the number of followers' do
|
1187
1187
|
@cli.followings
|
1188
|
-
expect($stdout.string.chomp).to eq
|
1188
|
+
expect($stdout.string.chomp).to eq 'sferik pengwynn'
|
1189
1189
|
end
|
1190
1190
|
end
|
1191
|
-
context
|
1191
|
+
context '--sort=friends' do
|
1192
1192
|
before do
|
1193
|
-
@cli.options = @cli.options.merge(
|
1193
|
+
@cli.options = @cli.options.merge('sort' => 'friends')
|
1194
1194
|
end
|
1195
|
-
it
|
1195
|
+
it 'sorts by the number of friends' do
|
1196
1196
|
@cli.followings
|
1197
|
-
expect($stdout.string.chomp).to eq
|
1197
|
+
expect($stdout.string.chomp).to eq 'sferik pengwynn'
|
1198
1198
|
end
|
1199
1199
|
end
|
1200
|
-
context
|
1200
|
+
context '--sort=listed' do
|
1201
1201
|
before do
|
1202
|
-
@cli.options = @cli.options.merge(
|
1202
|
+
@cli.options = @cli.options.merge('sort' => 'listed')
|
1203
1203
|
end
|
1204
|
-
it
|
1204
|
+
it 'sorts by the number of list memberships' do
|
1205
1205
|
@cli.followings
|
1206
|
-
expect($stdout.string.chomp).to eq
|
1206
|
+
expect($stdout.string.chomp).to eq 'sferik pengwynn'
|
1207
1207
|
end
|
1208
1208
|
end
|
1209
|
-
context
|
1209
|
+
context '--sort=since' do
|
1210
1210
|
before do
|
1211
|
-
@cli.options = @cli.options.merge(
|
1211
|
+
@cli.options = @cli.options.merge('sort' => 'since')
|
1212
1212
|
end
|
1213
|
-
it
|
1213
|
+
it 'sorts by the time when Twitter acount was created' do
|
1214
1214
|
@cli.followings
|
1215
|
-
expect($stdout.string.chomp).to eq
|
1215
|
+
expect($stdout.string.chomp).to eq 'sferik pengwynn'
|
1216
1216
|
end
|
1217
1217
|
end
|
1218
|
-
context
|
1218
|
+
context '--sort=tweets' do
|
1219
1219
|
before do
|
1220
|
-
@cli.options = @cli.options.merge(
|
1220
|
+
@cli.options = @cli.options.merge('sort' => 'tweets')
|
1221
1221
|
end
|
1222
|
-
it
|
1222
|
+
it 'sorts by the number of Tweets' do
|
1223
1223
|
@cli.followings
|
1224
|
-
expect($stdout.string.chomp).to eq
|
1224
|
+
expect($stdout.string.chomp).to eq 'pengwynn sferik'
|
1225
1225
|
end
|
1226
1226
|
end
|
1227
|
-
context
|
1227
|
+
context '--sort=tweeted' do
|
1228
1228
|
before do
|
1229
|
-
@cli.options = @cli.options.merge(
|
1229
|
+
@cli.options = @cli.options.merge('sort' => 'tweeted')
|
1230
1230
|
end
|
1231
|
-
it
|
1231
|
+
it 'sorts by the time of the last Tweet' do
|
1232
1232
|
@cli.followings
|
1233
|
-
expect($stdout.string.chomp).to eq
|
1233
|
+
expect($stdout.string.chomp).to eq 'pengwynn sferik'
|
1234
1234
|
end
|
1235
1235
|
end
|
1236
|
-
context
|
1236
|
+
context '--unsorted' do
|
1237
1237
|
before do
|
1238
|
-
@cli.options = @cli.options.merge(
|
1238
|
+
@cli.options = @cli.options.merge('unsorted' => true)
|
1239
1239
|
end
|
1240
|
-
it
|
1240
|
+
it 'is not sorted' do
|
1241
1241
|
@cli.followings
|
1242
|
-
expect($stdout.string.chomp).to eq
|
1242
|
+
expect($stdout.string.chomp).to eq 'pengwynn sferik'
|
1243
1243
|
end
|
1244
1244
|
end
|
1245
|
-
context
|
1245
|
+
context 'with a user passed' do
|
1246
1246
|
before do
|
1247
|
-
stub_get(
|
1247
|
+
stub_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'}).to_return(:body => fixture('friends_ids.json'))
|
1248
1248
|
end
|
1249
|
-
it
|
1250
|
-
@cli.followings(
|
1251
|
-
expect(a_get(
|
1252
|
-
expect(a_post(
|
1249
|
+
it 'requests the correct resource' do
|
1250
|
+
@cli.followings('sferik')
|
1251
|
+
expect(a_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'})).to have_been_made
|
1252
|
+
expect(a_post('/1.1/users/lookup.json').with(:body => {:user_id => '7505382'})).to have_been_made
|
1253
1253
|
end
|
1254
1254
|
end
|
1255
|
-
context
|
1255
|
+
context '--id' do
|
1256
1256
|
before do
|
1257
|
-
@cli.options = @cli.options.merge(
|
1258
|
-
stub_get(
|
1257
|
+
@cli.options = @cli.options.merge('id' => true)
|
1258
|
+
stub_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :user_id => '7505382'}).to_return(:body => fixture('friends_ids.json'))
|
1259
1259
|
end
|
1260
|
-
it
|
1261
|
-
@cli.followings(
|
1262
|
-
expect(a_get(
|
1263
|
-
expect(a_post(
|
1260
|
+
it 'requests the correct resource' do
|
1261
|
+
@cli.followings('7505382')
|
1262
|
+
expect(a_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :user_id => '7505382'})).to have_been_made
|
1263
|
+
expect(a_post('/1.1/users/lookup.json').with(:body => {:user_id => '7505382'})).to have_been_made
|
1264
1264
|
end
|
1265
1265
|
end
|
1266
1266
|
end
|
1267
1267
|
|
1268
|
-
describe
|
1268
|
+
describe '#followers' do
|
1269
1269
|
before do
|
1270
|
-
stub_get(
|
1271
|
-
stub_get(
|
1272
|
-
stub_post(
|
1270
|
+
stub_get('/1.1/account/verify_credentials.json').to_return(:body => fixture('sferik.json'))
|
1271
|
+
stub_get('/1.1/followers/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'}).to_return(:body => fixture('friends_ids.json'))
|
1272
|
+
stub_post('/1.1/users/lookup.json').with(:body => {:user_id => '7505382'}).to_return(:body => fixture('users.json'))
|
1273
1273
|
end
|
1274
|
-
it
|
1274
|
+
it 'requests the correct resource' do
|
1275
1275
|
@cli.followers
|
1276
|
-
expect(a_get(
|
1277
|
-
expect(a_get(
|
1278
|
-
expect(a_post(
|
1276
|
+
expect(a_get('/1.1/account/verify_credentials.json')).to have_been_made
|
1277
|
+
expect(a_get('/1.1/followers/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'})).to have_been_made
|
1278
|
+
expect(a_post('/1.1/users/lookup.json').with(:body => {:user_id => '7505382'})).to have_been_made
|
1279
1279
|
end
|
1280
|
-
it
|
1280
|
+
it 'has the correct output' do
|
1281
1281
|
@cli.followers
|
1282
|
-
expect($stdout.string.chomp).to eq
|
1282
|
+
expect($stdout.string.chomp).to eq 'pengwynn sferik'
|
1283
1283
|
end
|
1284
|
-
context
|
1284
|
+
context '--csv' do
|
1285
1285
|
before do
|
1286
|
-
@cli.options = @cli.options.merge(
|
1286
|
+
@cli.options = @cli.options.merge('csv' => true)
|
1287
1287
|
end
|
1288
|
-
it
|
1288
|
+
it 'outputs in CSV format' do
|
1289
1289
|
@cli.followers
|
1290
1290
|
expect($stdout.string).to eq <<-eos
|
1291
1291
|
ID,Since,Last tweeted at,Tweets,Favorites,Listed,Following,Followers,Screen name,Name,Verified,Protected,Bio,Status,Location,URL
|
@@ -1294,11 +1294,11 @@ ID,Since,Last tweeted at,Tweets,Favorites,Listed,Following,Followers,Screen name
|
|
1294
1294
|
eos
|
1295
1295
|
end
|
1296
1296
|
end
|
1297
|
-
context
|
1297
|
+
context '--long' do
|
1298
1298
|
before do
|
1299
|
-
@cli.options = @cli.options.merge(
|
1299
|
+
@cli.options = @cli.options.merge('long' => true)
|
1300
1300
|
end
|
1301
|
-
it
|
1301
|
+
it 'outputs in long format' do
|
1302
1302
|
@cli.followers
|
1303
1303
|
expect($stdout.string).to eq <<-eos
|
1304
1304
|
ID Since Last tweeted at Tweets Favorites Listed Following...
|
@@ -1307,134 +1307,134 @@ ID Since Last tweeted at Tweets Favorites Listed Following...
|
|
1307
1307
|
eos
|
1308
1308
|
end
|
1309
1309
|
end
|
1310
|
-
context
|
1310
|
+
context '--reverse' do
|
1311
1311
|
before do
|
1312
|
-
@cli.options = @cli.options.merge(
|
1312
|
+
@cli.options = @cli.options.merge('reverse' => true)
|
1313
1313
|
end
|
1314
|
-
it
|
1314
|
+
it 'reverses the order of the sort' do
|
1315
1315
|
@cli.followers
|
1316
|
-
expect($stdout.string.chomp).to eq
|
1316
|
+
expect($stdout.string.chomp).to eq 'sferik pengwynn'
|
1317
1317
|
end
|
1318
1318
|
end
|
1319
|
-
context
|
1319
|
+
context '--sort=favorites' do
|
1320
1320
|
before do
|
1321
|
-
@cli.options = @cli.options.merge(
|
1321
|
+
@cli.options = @cli.options.merge('sort' => 'favorites')
|
1322
1322
|
end
|
1323
|
-
it
|
1323
|
+
it 'sorts by the number of favorites' do
|
1324
1324
|
@cli.followers
|
1325
|
-
expect($stdout.string.chomp).to eq
|
1325
|
+
expect($stdout.string.chomp).to eq 'pengwynn sferik'
|
1326
1326
|
end
|
1327
1327
|
end
|
1328
|
-
context
|
1328
|
+
context '--sort=followers' do
|
1329
1329
|
before do
|
1330
|
-
@cli.options = @cli.options.merge(
|
1330
|
+
@cli.options = @cli.options.merge('sort' => 'followers')
|
1331
1331
|
end
|
1332
|
-
it
|
1332
|
+
it 'sorts by the number of followers' do
|
1333
1333
|
@cli.followers
|
1334
|
-
expect($stdout.string.chomp).to eq
|
1334
|
+
expect($stdout.string.chomp).to eq 'sferik pengwynn'
|
1335
1335
|
end
|
1336
1336
|
end
|
1337
|
-
context
|
1337
|
+
context '--sort=friends' do
|
1338
1338
|
before do
|
1339
|
-
@cli.options = @cli.options.merge(
|
1339
|
+
@cli.options = @cli.options.merge('sort' => 'friends')
|
1340
1340
|
end
|
1341
|
-
it
|
1341
|
+
it 'sorts by the number of friends' do
|
1342
1342
|
@cli.followers
|
1343
|
-
expect($stdout.string.chomp).to eq
|
1343
|
+
expect($stdout.string.chomp).to eq 'sferik pengwynn'
|
1344
1344
|
end
|
1345
1345
|
end
|
1346
|
-
context
|
1346
|
+
context '--sort=listed' do
|
1347
1347
|
before do
|
1348
|
-
@cli.options = @cli.options.merge(
|
1348
|
+
@cli.options = @cli.options.merge('sort' => 'listed')
|
1349
1349
|
end
|
1350
|
-
it
|
1350
|
+
it 'sorts by the number of list memberships' do
|
1351
1351
|
@cli.followers
|
1352
|
-
expect($stdout.string.chomp).to eq
|
1352
|
+
expect($stdout.string.chomp).to eq 'sferik pengwynn'
|
1353
1353
|
end
|
1354
1354
|
end
|
1355
|
-
context
|
1355
|
+
context '--sort=since' do
|
1356
1356
|
before do
|
1357
|
-
@cli.options = @cli.options.merge(
|
1357
|
+
@cli.options = @cli.options.merge('sort' => 'since')
|
1358
1358
|
end
|
1359
|
-
it
|
1359
|
+
it 'sorts by the time when Twitter acount was created' do
|
1360
1360
|
@cli.followers
|
1361
|
-
expect($stdout.string.chomp).to eq
|
1361
|
+
expect($stdout.string.chomp).to eq 'sferik pengwynn'
|
1362
1362
|
end
|
1363
1363
|
end
|
1364
|
-
context
|
1364
|
+
context '--sort=tweets' do
|
1365
1365
|
before do
|
1366
|
-
@cli.options = @cli.options.merge(
|
1366
|
+
@cli.options = @cli.options.merge('sort' => 'tweets')
|
1367
1367
|
end
|
1368
|
-
it
|
1368
|
+
it 'sorts by the number of Tweets' do
|
1369
1369
|
@cli.followers
|
1370
|
-
expect($stdout.string.chomp).to eq
|
1370
|
+
expect($stdout.string.chomp).to eq 'pengwynn sferik'
|
1371
1371
|
end
|
1372
1372
|
end
|
1373
|
-
context
|
1373
|
+
context '--sort=tweeted' do
|
1374
1374
|
before do
|
1375
|
-
@cli.options = @cli.options.merge(
|
1375
|
+
@cli.options = @cli.options.merge('sort' => 'tweeted')
|
1376
1376
|
end
|
1377
|
-
it
|
1377
|
+
it 'sorts by the time of the last Tweet' do
|
1378
1378
|
@cli.followers
|
1379
|
-
expect($stdout.string.chomp).to eq
|
1379
|
+
expect($stdout.string.chomp).to eq 'pengwynn sferik'
|
1380
1380
|
end
|
1381
1381
|
end
|
1382
|
-
context
|
1382
|
+
context '--unsorted' do
|
1383
1383
|
before do
|
1384
|
-
@cli.options = @cli.options.merge(
|
1384
|
+
@cli.options = @cli.options.merge('unsorted' => true)
|
1385
1385
|
end
|
1386
|
-
it
|
1386
|
+
it 'is not sorted' do
|
1387
1387
|
@cli.followers
|
1388
|
-
expect($stdout.string.chomp).to eq
|
1388
|
+
expect($stdout.string.chomp).to eq 'pengwynn sferik'
|
1389
1389
|
end
|
1390
1390
|
end
|
1391
|
-
context
|
1391
|
+
context 'with a user passed' do
|
1392
1392
|
before do
|
1393
|
-
stub_get(
|
1394
|
-
stub_post(
|
1393
|
+
stub_get('/1.1/followers/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'}).to_return(:body => fixture('friends_ids.json'))
|
1394
|
+
stub_post('/1.1/users/lookup.json').with(:body => {:user_id => '213747670,428004849'}).to_return(:body => fixture('users.json'))
|
1395
1395
|
end
|
1396
|
-
it
|
1397
|
-
@cli.followers(
|
1398
|
-
expect(a_get(
|
1399
|
-
expect(a_post(
|
1396
|
+
it 'requests the correct resource' do
|
1397
|
+
@cli.followers('sferik')
|
1398
|
+
expect(a_get('/1.1/followers/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'})).to have_been_made
|
1399
|
+
expect(a_post('/1.1/users/lookup.json').with(:body => {:user_id => '7505382'})).to have_been_made
|
1400
1400
|
end
|
1401
|
-
context
|
1401
|
+
context '--id' do
|
1402
1402
|
before do
|
1403
|
-
@cli.options = @cli.options.merge(
|
1404
|
-
stub_get(
|
1403
|
+
@cli.options = @cli.options.merge('id' => true)
|
1404
|
+
stub_get('/1.1/followers/ids.json').with(:query => {:cursor => '-1', :user_id => '7505382'}).to_return(:body => fixture('friends_ids.json'))
|
1405
1405
|
end
|
1406
|
-
it
|
1407
|
-
@cli.followers(
|
1408
|
-
expect(a_get(
|
1409
|
-
expect(a_post(
|
1406
|
+
it 'requests the correct resource' do
|
1407
|
+
@cli.followers('7505382')
|
1408
|
+
expect(a_get('/1.1/followers/ids.json').with(:query => {:cursor => '-1', :user_id => '7505382'})).to have_been_made
|
1409
|
+
expect(a_post('/1.1/users/lookup.json').with(:body => {:user_id => '7505382'})).to have_been_made
|
1410
1410
|
end
|
1411
1411
|
end
|
1412
1412
|
end
|
1413
1413
|
end
|
1414
1414
|
|
1415
|
-
describe
|
1415
|
+
describe '#friends' do
|
1416
1416
|
before do
|
1417
|
-
stub_get(
|
1418
|
-
stub_get(
|
1419
|
-
stub_get(
|
1420
|
-
stub_post(
|
1417
|
+
stub_get('/1.1/account/verify_credentials.json').to_return(:body => fixture('sferik.json'))
|
1418
|
+
stub_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'}).to_return(:body => fixture('friends_ids.json'))
|
1419
|
+
stub_get('/1.1/followers/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'}).to_return(:body => fixture('friends_ids.json'))
|
1420
|
+
stub_post('/1.1/users/lookup.json').with(:body => {:user_id => '7505382'}).to_return(:body => fixture('users.json'))
|
1421
1421
|
end
|
1422
|
-
it
|
1422
|
+
it 'requests the correct resource' do
|
1423
1423
|
@cli.friends
|
1424
|
-
expect(a_get(
|
1425
|
-
expect(a_get(
|
1426
|
-
expect(a_get(
|
1427
|
-
expect(a_post(
|
1424
|
+
expect(a_get('/1.1/account/verify_credentials.json')).to have_been_made
|
1425
|
+
expect(a_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'})).to have_been_made
|
1426
|
+
expect(a_get('/1.1/followers/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'})).to have_been_made
|
1427
|
+
expect(a_post('/1.1/users/lookup.json').with(:body => {:user_id => '7505382'})).to have_been_made
|
1428
1428
|
end
|
1429
|
-
it
|
1429
|
+
it 'has the correct output' do
|
1430
1430
|
@cli.friends
|
1431
|
-
expect($stdout.string.chomp).to eq
|
1431
|
+
expect($stdout.string.chomp).to eq 'pengwynn sferik'
|
1432
1432
|
end
|
1433
|
-
context
|
1433
|
+
context '--csv' do
|
1434
1434
|
before do
|
1435
|
-
@cli.options = @cli.options.merge(
|
1435
|
+
@cli.options = @cli.options.merge('csv' => true)
|
1436
1436
|
end
|
1437
|
-
it
|
1437
|
+
it 'outputs in CSV format' do
|
1438
1438
|
@cli.friends
|
1439
1439
|
expect($stdout.string).to eq <<-eos
|
1440
1440
|
ID,Since,Last tweeted at,Tweets,Favorites,Listed,Following,Followers,Screen name,Name,Verified,Protected,Bio,Status,Location,URL
|
@@ -1443,11 +1443,11 @@ ID,Since,Last tweeted at,Tweets,Favorites,Listed,Following,Followers,Screen name
|
|
1443
1443
|
eos
|
1444
1444
|
end
|
1445
1445
|
end
|
1446
|
-
context
|
1446
|
+
context '--long' do
|
1447
1447
|
before do
|
1448
|
-
@cli.options = @cli.options.merge(
|
1448
|
+
@cli.options = @cli.options.merge('long' => true)
|
1449
1449
|
end
|
1450
|
-
it
|
1450
|
+
it 'outputs in long format' do
|
1451
1451
|
@cli.friends
|
1452
1452
|
expect($stdout.string).to eq <<-eos
|
1453
1453
|
ID Since Last tweeted at Tweets Favorites Listed Following...
|
@@ -1456,137 +1456,137 @@ ID Since Last tweeted at Tweets Favorites Listed Following...
|
|
1456
1456
|
eos
|
1457
1457
|
end
|
1458
1458
|
end
|
1459
|
-
context
|
1459
|
+
context '--reverse' do
|
1460
1460
|
before do
|
1461
|
-
@cli.options = @cli.options.merge(
|
1461
|
+
@cli.options = @cli.options.merge('reverse' => true)
|
1462
1462
|
end
|
1463
|
-
it
|
1463
|
+
it 'reverses the order of the sort' do
|
1464
1464
|
@cli.friends
|
1465
|
-
expect($stdout.string.chomp).to eq
|
1465
|
+
expect($stdout.string.chomp).to eq 'sferik pengwynn'
|
1466
1466
|
end
|
1467
1467
|
end
|
1468
|
-
context
|
1468
|
+
context '--sort=favorites' do
|
1469
1469
|
before do
|
1470
|
-
@cli.options = @cli.options.merge(
|
1470
|
+
@cli.options = @cli.options.merge('sort' => 'favorites')
|
1471
1471
|
end
|
1472
|
-
it
|
1472
|
+
it 'sorts by the number of favorites' do
|
1473
1473
|
@cli.friends
|
1474
|
-
expect($stdout.string.chomp).to eq
|
1474
|
+
expect($stdout.string.chomp).to eq 'pengwynn sferik'
|
1475
1475
|
end
|
1476
1476
|
end
|
1477
|
-
context
|
1477
|
+
context '--sort=followers' do
|
1478
1478
|
before do
|
1479
|
-
@cli.options = @cli.options.merge(
|
1479
|
+
@cli.options = @cli.options.merge('sort' => 'followers')
|
1480
1480
|
end
|
1481
|
-
it
|
1481
|
+
it 'sorts by the number of followers' do
|
1482
1482
|
@cli.friends
|
1483
|
-
expect($stdout.string.chomp).to eq
|
1483
|
+
expect($stdout.string.chomp).to eq 'sferik pengwynn'
|
1484
1484
|
end
|
1485
1485
|
end
|
1486
|
-
context
|
1486
|
+
context '--sort=friends' do
|
1487
1487
|
before do
|
1488
|
-
@cli.options = @cli.options.merge(
|
1488
|
+
@cli.options = @cli.options.merge('sort' => 'friends')
|
1489
1489
|
end
|
1490
|
-
it
|
1490
|
+
it 'sorts by the number of friends' do
|
1491
1491
|
@cli.friends
|
1492
|
-
expect($stdout.string.chomp).to eq
|
1492
|
+
expect($stdout.string.chomp).to eq 'sferik pengwynn'
|
1493
1493
|
end
|
1494
1494
|
end
|
1495
|
-
context
|
1495
|
+
context '--sort=listed' do
|
1496
1496
|
before do
|
1497
|
-
@cli.options = @cli.options.merge(
|
1497
|
+
@cli.options = @cli.options.merge('sort' => 'listed')
|
1498
1498
|
end
|
1499
|
-
it
|
1499
|
+
it 'sorts by the number of list memberships' do
|
1500
1500
|
@cli.friends
|
1501
|
-
expect($stdout.string.chomp).to eq
|
1501
|
+
expect($stdout.string.chomp).to eq 'sferik pengwynn'
|
1502
1502
|
end
|
1503
1503
|
end
|
1504
|
-
context
|
1504
|
+
context '--sort=since' do
|
1505
1505
|
before do
|
1506
|
-
@cli.options = @cli.options.merge(
|
1506
|
+
@cli.options = @cli.options.merge('sort' => 'since')
|
1507
1507
|
end
|
1508
|
-
it
|
1508
|
+
it 'sorts by the time when Twitter acount was created' do
|
1509
1509
|
@cli.friends
|
1510
|
-
expect($stdout.string.chomp).to eq
|
1510
|
+
expect($stdout.string.chomp).to eq 'sferik pengwynn'
|
1511
1511
|
end
|
1512
1512
|
end
|
1513
|
-
context
|
1513
|
+
context '--sort=tweets' do
|
1514
1514
|
before do
|
1515
|
-
@cli.options = @cli.options.merge(
|
1515
|
+
@cli.options = @cli.options.merge('sort' => 'tweets')
|
1516
1516
|
end
|
1517
|
-
it
|
1517
|
+
it 'sorts by the number of Tweets' do
|
1518
1518
|
@cli.friends
|
1519
|
-
expect($stdout.string.chomp).to eq
|
1519
|
+
expect($stdout.string.chomp).to eq 'pengwynn sferik'
|
1520
1520
|
end
|
1521
1521
|
end
|
1522
|
-
context
|
1522
|
+
context '--sort=tweeted' do
|
1523
1523
|
before do
|
1524
|
-
@cli.options = @cli.options.merge(
|
1524
|
+
@cli.options = @cli.options.merge('sort' => 'tweeted')
|
1525
1525
|
end
|
1526
|
-
it
|
1526
|
+
it 'sorts by the time of the last Tweet' do
|
1527
1527
|
@cli.friends
|
1528
|
-
expect($stdout.string.chomp).to eq
|
1528
|
+
expect($stdout.string.chomp).to eq 'pengwynn sferik'
|
1529
1529
|
end
|
1530
1530
|
end
|
1531
|
-
context
|
1531
|
+
context '--unsorted' do
|
1532
1532
|
before do
|
1533
|
-
@cli.options = @cli.options.merge(
|
1533
|
+
@cli.options = @cli.options.merge('unsorted' => true)
|
1534
1534
|
end
|
1535
|
-
it
|
1535
|
+
it 'is not sorted' do
|
1536
1536
|
@cli.friends
|
1537
|
-
expect($stdout.string.chomp).to eq
|
1537
|
+
expect($stdout.string.chomp).to eq 'pengwynn sferik'
|
1538
1538
|
end
|
1539
1539
|
end
|
1540
|
-
context
|
1540
|
+
context 'with a user passed' do
|
1541
1541
|
before do
|
1542
|
-
stub_get(
|
1543
|
-
stub_get(
|
1542
|
+
stub_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'}).to_return(:body => fixture('friends_ids.json'))
|
1543
|
+
stub_get('/1.1/followers/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'}).to_return(:body => fixture('friends_ids.json'))
|
1544
1544
|
end
|
1545
|
-
it
|
1546
|
-
@cli.friends(
|
1547
|
-
expect(a_get(
|
1548
|
-
expect(a_get(
|
1549
|
-
expect(a_post(
|
1545
|
+
it 'requests the correct resource' do
|
1546
|
+
@cli.friends('sferik')
|
1547
|
+
expect(a_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'})).to have_been_made
|
1548
|
+
expect(a_get('/1.1/followers/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'})).to have_been_made
|
1549
|
+
expect(a_post('/1.1/users/lookup.json').with(:body => {:user_id => '7505382'})).to have_been_made
|
1550
1550
|
end
|
1551
|
-
context
|
1551
|
+
context '--id' do
|
1552
1552
|
before do
|
1553
|
-
@cli.options = @cli.options.merge(
|
1554
|
-
stub_get(
|
1555
|
-
stub_get(
|
1553
|
+
@cli.options = @cli.options.merge('id' => true)
|
1554
|
+
stub_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :user_id => '7505382'}).to_return(:body => fixture('friends_ids.json'))
|
1555
|
+
stub_get('/1.1/followers/ids.json').with(:query => {:cursor => '-1', :user_id => '7505382'}).to_return(:body => fixture('friends_ids.json'))
|
1556
1556
|
end
|
1557
|
-
it
|
1558
|
-
@cli.friends(
|
1559
|
-
expect(a_get(
|
1560
|
-
expect(a_get(
|
1561
|
-
expect(a_post(
|
1557
|
+
it 'requests the correct resource' do
|
1558
|
+
@cli.friends('7505382')
|
1559
|
+
expect(a_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :user_id => '7505382'})).to have_been_made
|
1560
|
+
expect(a_get('/1.1/followers/ids.json').with(:query => {:cursor => '-1', :user_id => '7505382'})).to have_been_made
|
1561
|
+
expect(a_post('/1.1/users/lookup.json').with(:body => {:user_id => '7505382'})).to have_been_made
|
1562
1562
|
end
|
1563
1563
|
end
|
1564
1564
|
end
|
1565
1565
|
end
|
1566
1566
|
|
1567
|
-
describe
|
1567
|
+
describe '#leaders' do
|
1568
1568
|
before do
|
1569
|
-
stub_get(
|
1570
|
-
stub_get(
|
1571
|
-
stub_get(
|
1572
|
-
stub_post(
|
1569
|
+
stub_get('/1.1/account/verify_credentials.json').to_return(:body => fixture('sferik.json'))
|
1570
|
+
stub_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'}).to_return(:body => fixture('friends_ids.json'))
|
1571
|
+
stub_get('/1.1/followers/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'}).to_return(:body => fixture('followers_ids.json'))
|
1572
|
+
stub_post('/1.1/users/lookup.json').with(:body => {:user_id => '7505382'}).to_return(:body => fixture('users.json'))
|
1573
1573
|
end
|
1574
|
-
it
|
1574
|
+
it 'requests the correct resource' do
|
1575
1575
|
@cli.leaders
|
1576
|
-
expect(a_get(
|
1577
|
-
expect(a_get(
|
1578
|
-
expect(a_get(
|
1579
|
-
expect(a_post(
|
1576
|
+
expect(a_get('/1.1/account/verify_credentials.json')).to have_been_made
|
1577
|
+
expect(a_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'})).to have_been_made
|
1578
|
+
expect(a_get('/1.1/followers/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'})).to have_been_made
|
1579
|
+
expect(a_post('/1.1/users/lookup.json').with(:body => {:user_id => '7505382'})).to have_been_made
|
1580
1580
|
end
|
1581
|
-
it
|
1581
|
+
it 'has the correct output' do
|
1582
1582
|
@cli.leaders
|
1583
|
-
expect($stdout.string.chomp).to eq
|
1583
|
+
expect($stdout.string.chomp).to eq 'pengwynn sferik'
|
1584
1584
|
end
|
1585
|
-
context
|
1585
|
+
context '--csv' do
|
1586
1586
|
before do
|
1587
|
-
@cli.options = @cli.options.merge(
|
1587
|
+
@cli.options = @cli.options.merge('csv' => true)
|
1588
1588
|
end
|
1589
|
-
it
|
1589
|
+
it 'outputs in CSV format' do
|
1590
1590
|
@cli.leaders
|
1591
1591
|
expect($stdout.string).to eq <<-eos
|
1592
1592
|
ID,Since,Last tweeted at,Tweets,Favorites,Listed,Following,Followers,Screen name,Name,Verified,Protected,Bio,Status,Location,URL
|
@@ -1595,11 +1595,11 @@ ID,Since,Last tweeted at,Tweets,Favorites,Listed,Following,Followers,Screen name
|
|
1595
1595
|
eos
|
1596
1596
|
end
|
1597
1597
|
end
|
1598
|
-
context
|
1598
|
+
context '--long' do
|
1599
1599
|
before do
|
1600
|
-
@cli.options = @cli.options.merge(
|
1600
|
+
@cli.options = @cli.options.merge('long' => true)
|
1601
1601
|
end
|
1602
|
-
it
|
1602
|
+
it 'outputs in long format' do
|
1603
1603
|
@cli.leaders
|
1604
1604
|
expect($stdout.string).to eq <<-eos
|
1605
1605
|
ID Since Last tweeted at Tweets Favorites Listed Following...
|
@@ -1608,238 +1608,238 @@ ID Since Last tweeted at Tweets Favorites Listed Following...
|
|
1608
1608
|
eos
|
1609
1609
|
end
|
1610
1610
|
end
|
1611
|
-
context
|
1611
|
+
context '--reverse' do
|
1612
1612
|
before do
|
1613
|
-
@cli.options = @cli.options.merge(
|
1613
|
+
@cli.options = @cli.options.merge('reverse' => true)
|
1614
1614
|
end
|
1615
|
-
it
|
1615
|
+
it 'reverses the order of the sort' do
|
1616
1616
|
@cli.leaders
|
1617
|
-
expect($stdout.string.chomp).to eq
|
1617
|
+
expect($stdout.string.chomp).to eq 'sferik pengwynn'
|
1618
1618
|
end
|
1619
1619
|
end
|
1620
|
-
context
|
1620
|
+
context '--sort=favorites' do
|
1621
1621
|
before do
|
1622
|
-
@cli.options = @cli.options.merge(
|
1622
|
+
@cli.options = @cli.options.merge('sort' => 'favorites')
|
1623
1623
|
end
|
1624
|
-
it
|
1624
|
+
it 'sorts by the number of favorites' do
|
1625
1625
|
@cli.leaders
|
1626
|
-
expect($stdout.string.chomp).to eq
|
1626
|
+
expect($stdout.string.chomp).to eq 'pengwynn sferik'
|
1627
1627
|
end
|
1628
1628
|
end
|
1629
|
-
context
|
1629
|
+
context '--sort=followers' do
|
1630
1630
|
before do
|
1631
|
-
@cli.options = @cli.options.merge(
|
1631
|
+
@cli.options = @cli.options.merge('sort' => 'followers')
|
1632
1632
|
end
|
1633
|
-
it
|
1633
|
+
it 'sorts by the number of followers' do
|
1634
1634
|
@cli.leaders
|
1635
|
-
expect($stdout.string.chomp).to eq
|
1635
|
+
expect($stdout.string.chomp).to eq 'sferik pengwynn'
|
1636
1636
|
end
|
1637
1637
|
end
|
1638
|
-
context
|
1638
|
+
context '--sort=friends' do
|
1639
1639
|
before do
|
1640
|
-
@cli.options = @cli.options.merge(
|
1640
|
+
@cli.options = @cli.options.merge('sort' => 'friends')
|
1641
1641
|
end
|
1642
|
-
it
|
1642
|
+
it 'sorts by the number of friends' do
|
1643
1643
|
@cli.leaders
|
1644
|
-
expect($stdout.string.chomp).to eq
|
1644
|
+
expect($stdout.string.chomp).to eq 'sferik pengwynn'
|
1645
1645
|
end
|
1646
1646
|
end
|
1647
|
-
context
|
1647
|
+
context '--sort=listed' do
|
1648
1648
|
before do
|
1649
|
-
@cli.options = @cli.options.merge(
|
1649
|
+
@cli.options = @cli.options.merge('sort' => 'listed')
|
1650
1650
|
end
|
1651
|
-
it
|
1651
|
+
it 'sorts by the number of list memberships' do
|
1652
1652
|
@cli.leaders
|
1653
|
-
expect($stdout.string.chomp).to eq
|
1653
|
+
expect($stdout.string.chomp).to eq 'sferik pengwynn'
|
1654
1654
|
end
|
1655
1655
|
end
|
1656
|
-
context
|
1656
|
+
context '--sort=since' do
|
1657
1657
|
before do
|
1658
|
-
@cli.options = @cli.options.merge(
|
1658
|
+
@cli.options = @cli.options.merge('sort' => 'since')
|
1659
1659
|
end
|
1660
|
-
it
|
1660
|
+
it 'sorts by the time when Twitter acount was created' do
|
1661
1661
|
@cli.leaders
|
1662
|
-
expect($stdout.string.chomp).to eq
|
1662
|
+
expect($stdout.string.chomp).to eq 'sferik pengwynn'
|
1663
1663
|
end
|
1664
1664
|
end
|
1665
|
-
context
|
1665
|
+
context '--sort=tweets' do
|
1666
1666
|
before do
|
1667
|
-
@cli.options = @cli.options.merge(
|
1667
|
+
@cli.options = @cli.options.merge('sort' => 'tweets')
|
1668
1668
|
end
|
1669
|
-
it
|
1669
|
+
it 'sorts by the number of Tweets' do
|
1670
1670
|
@cli.leaders
|
1671
|
-
expect($stdout.string.chomp).to eq
|
1671
|
+
expect($stdout.string.chomp).to eq 'pengwynn sferik'
|
1672
1672
|
end
|
1673
1673
|
end
|
1674
|
-
context
|
1674
|
+
context '--sort=tweeted' do
|
1675
1675
|
before do
|
1676
|
-
@cli.options = @cli.options.merge(
|
1676
|
+
@cli.options = @cli.options.merge('sort' => 'tweeted')
|
1677
1677
|
end
|
1678
|
-
it
|
1678
|
+
it 'sorts by the time of the last Tweet' do
|
1679
1679
|
@cli.leaders
|
1680
|
-
expect($stdout.string.chomp).to eq
|
1680
|
+
expect($stdout.string.chomp).to eq 'pengwynn sferik'
|
1681
1681
|
end
|
1682
1682
|
end
|
1683
|
-
context
|
1683
|
+
context '--unsorted' do
|
1684
1684
|
before do
|
1685
|
-
@cli.options = @cli.options.merge(
|
1685
|
+
@cli.options = @cli.options.merge('unsorted' => true)
|
1686
1686
|
end
|
1687
|
-
it
|
1687
|
+
it 'is not sorted' do
|
1688
1688
|
@cli.leaders
|
1689
|
-
expect($stdout.string.chomp).to eq
|
1689
|
+
expect($stdout.string.chomp).to eq 'pengwynn sferik'
|
1690
1690
|
end
|
1691
1691
|
end
|
1692
|
-
context
|
1692
|
+
context 'with a user passed' do
|
1693
1693
|
before do
|
1694
|
-
stub_get(
|
1695
|
-
stub_get(
|
1694
|
+
stub_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'}).to_return(:body => fixture('friends_ids.json'))
|
1695
|
+
stub_get('/1.1/followers/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'}).to_return(:body => fixture('followers_ids.json'))
|
1696
1696
|
end
|
1697
|
-
it
|
1698
|
-
@cli.leaders(
|
1699
|
-
expect(a_get(
|
1700
|
-
expect(a_get(
|
1701
|
-
expect(a_post(
|
1697
|
+
it 'requests the correct resource' do
|
1698
|
+
@cli.leaders('sferik')
|
1699
|
+
expect(a_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'})).to have_been_made
|
1700
|
+
expect(a_get('/1.1/followers/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'})).to have_been_made
|
1701
|
+
expect(a_post('/1.1/users/lookup.json').with(:body => {:user_id => '7505382'})).to have_been_made
|
1702
1702
|
end
|
1703
|
-
context
|
1703
|
+
context '--id' do
|
1704
1704
|
before do
|
1705
|
-
@cli.options = @cli.options.merge(
|
1706
|
-
stub_get(
|
1707
|
-
stub_get(
|
1705
|
+
@cli.options = @cli.options.merge('id' => true)
|
1706
|
+
stub_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :user_id => '7505382'}).to_return(:body => fixture('friends_ids.json'))
|
1707
|
+
stub_get('/1.1/followers/ids.json').with(:query => {:cursor => '-1', :user_id => '7505382'}).to_return(:body => fixture('followers_ids.json'))
|
1708
1708
|
end
|
1709
|
-
it
|
1710
|
-
@cli.leaders(
|
1711
|
-
expect(a_get(
|
1712
|
-
expect(a_get(
|
1713
|
-
expect(a_post(
|
1709
|
+
it 'requests the correct resource' do
|
1710
|
+
@cli.leaders('7505382')
|
1711
|
+
expect(a_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :user_id => '7505382'})).to have_been_made
|
1712
|
+
expect(a_get('/1.1/followers/ids.json').with(:query => {:cursor => '-1', :user_id => '7505382'})).to have_been_made
|
1713
|
+
expect(a_post('/1.1/users/lookup.json').with(:body => {:user_id => '7505382'})).to have_been_made
|
1714
1714
|
end
|
1715
1715
|
end
|
1716
1716
|
end
|
1717
1717
|
end
|
1718
1718
|
|
1719
|
-
describe
|
1719
|
+
describe '#lists' do
|
1720
1720
|
before do
|
1721
|
-
stub_get(
|
1721
|
+
stub_get('/1.1/lists/list.json').to_return(:body => fixture('lists.json'))
|
1722
1722
|
end
|
1723
|
-
it
|
1723
|
+
it 'requests the correct resource' do
|
1724
1724
|
@cli.lists
|
1725
|
-
expect(a_get(
|
1725
|
+
expect(a_get('/1.1/lists/list.json')).to have_been_made
|
1726
1726
|
end
|
1727
|
-
it
|
1727
|
+
it 'has the correct output' do
|
1728
1728
|
@cli.lists
|
1729
|
-
expect($stdout.string.chomp).to eq
|
1729
|
+
expect($stdout.string.chomp).to eq '@pengwynn/rubyists @twitter/team @sferik/test'
|
1730
1730
|
end
|
1731
|
-
context
|
1731
|
+
context '--csv' do
|
1732
1732
|
before do
|
1733
|
-
@cli.options = @cli.options.merge(
|
1733
|
+
@cli.options = @cli.options.merge('csv' => true)
|
1734
1734
|
end
|
1735
|
-
it
|
1735
|
+
it 'outputs in CSV format' do
|
1736
1736
|
@cli.lists
|
1737
1737
|
expect($stdout.string).to eq <<-eos
|
1738
1738
|
ID,Created at,Screen name,Slug,Members,Subscribers,Mode,Description
|
1739
1739
|
1129440,2009-10-30 14:39:25 +0000,pengwynn,rubyists,499,39,public,""
|
1740
|
-
574,2009-09-23 01:18:01 +0000,twitter,team,1199,78078,
|
1740
|
+
574,2009-09-23 01:18:01 +0000,twitter,team,1199,78078,other,""
|
1741
1741
|
73546689,2012-07-08 22:19:05 +0000,sferik,test,2,0,private,""
|
1742
1742
|
eos
|
1743
1743
|
end
|
1744
1744
|
end
|
1745
|
-
context
|
1745
|
+
context '--long' do
|
1746
1746
|
before do
|
1747
|
-
@cli.options = @cli.options.merge(
|
1747
|
+
@cli.options = @cli.options.merge('long' => true)
|
1748
1748
|
end
|
1749
|
-
it
|
1749
|
+
it 'outputs in long format' do
|
1750
1750
|
@cli.lists
|
1751
1751
|
expect($stdout.string).to eq <<-eos
|
1752
1752
|
ID Created at Screen name Slug Members Subscribers Mode ...
|
1753
1753
|
1129440 Oct 30 2009 @pengwynn rubyists 499 39 public
|
1754
|
-
574 Sep 22 2009 @twitter team 1199 78078
|
1754
|
+
574 Sep 22 2009 @twitter team 1199 78078 other
|
1755
1755
|
73546689 Jul 8 14:19 @sferik test 2 0 private
|
1756
1756
|
eos
|
1757
1757
|
end
|
1758
1758
|
end
|
1759
|
-
context
|
1759
|
+
context '--reverse' do
|
1760
1760
|
before do
|
1761
|
-
@cli.options = @cli.options.merge(
|
1761
|
+
@cli.options = @cli.options.merge('reverse' => true)
|
1762
1762
|
end
|
1763
|
-
it
|
1763
|
+
it 'reverses the order of the sort' do
|
1764
1764
|
@cli.lists
|
1765
|
-
expect($stdout.string.chomp).to eq
|
1765
|
+
expect($stdout.string.chomp).to eq '@sferik/test @twitter/team @pengwynn/rubyists'
|
1766
1766
|
end
|
1767
1767
|
end
|
1768
|
-
context
|
1768
|
+
context '--sort=members' do
|
1769
1769
|
before do
|
1770
|
-
@cli.options = @cli.options.merge(
|
1770
|
+
@cli.options = @cli.options.merge('sort' => 'members')
|
1771
1771
|
end
|
1772
|
-
it
|
1772
|
+
it 'sorts by the number of members' do
|
1773
1773
|
@cli.lists
|
1774
|
-
expect($stdout.string.chomp).to eq
|
1774
|
+
expect($stdout.string.chomp).to eq '@sferik/test @pengwynn/rubyists @twitter/team'
|
1775
1775
|
end
|
1776
1776
|
end
|
1777
|
-
context
|
1777
|
+
context '--sort=mode' do
|
1778
1778
|
before do
|
1779
|
-
@cli.options = @cli.options.merge(
|
1779
|
+
@cli.options = @cli.options.merge('sort' => 'mode')
|
1780
1780
|
end
|
1781
|
-
it
|
1781
|
+
it 'sorts by the mode' do
|
1782
1782
|
@cli.lists
|
1783
|
-
expect($stdout.string.chomp).to eq
|
1783
|
+
expect($stdout.string.chomp).to eq '@twitter/team @sferik/test @pengwynn/rubyists'
|
1784
1784
|
end
|
1785
1785
|
end
|
1786
|
-
context
|
1786
|
+
context '--sort=since' do
|
1787
1787
|
before do
|
1788
|
-
@cli.options = @cli.options.merge(
|
1788
|
+
@cli.options = @cli.options.merge('sort' => 'since')
|
1789
1789
|
end
|
1790
|
-
it
|
1790
|
+
it 'sorts by the time when Twitter list was created' do
|
1791
1791
|
@cli.lists
|
1792
|
-
expect($stdout.string.chomp).to eq
|
1792
|
+
expect($stdout.string.chomp).to eq '@twitter/team @pengwynn/rubyists @sferik/test'
|
1793
1793
|
end
|
1794
1794
|
end
|
1795
|
-
context
|
1795
|
+
context '--sort=subscribers' do
|
1796
1796
|
before do
|
1797
|
-
@cli.options = @cli.options.merge(
|
1797
|
+
@cli.options = @cli.options.merge('sort' => 'subscribers')
|
1798
1798
|
end
|
1799
|
-
it
|
1799
|
+
it 'sorts by the number of subscribers' do
|
1800
1800
|
@cli.lists
|
1801
|
-
expect($stdout.string.chomp).to eq
|
1801
|
+
expect($stdout.string.chomp).to eq '@sferik/test @pengwynn/rubyists @twitter/team'
|
1802
1802
|
end
|
1803
1803
|
end
|
1804
|
-
context
|
1804
|
+
context '--unsorted' do
|
1805
1805
|
before do
|
1806
|
-
@cli.options = @cli.options.merge(
|
1806
|
+
@cli.options = @cli.options.merge('unsorted' => true)
|
1807
1807
|
end
|
1808
|
-
it
|
1808
|
+
it 'is not sorted' do
|
1809
1809
|
@cli.lists
|
1810
|
-
expect($stdout.string.chomp).to eq
|
1810
|
+
expect($stdout.string.chomp).to eq '@pengwynn/rubyists @twitter/team @sferik/test'
|
1811
1811
|
end
|
1812
1812
|
end
|
1813
|
-
context
|
1813
|
+
context 'with a user passed' do
|
1814
1814
|
before do
|
1815
|
-
stub_get(
|
1815
|
+
stub_get('/1.1/lists/list.json').with(:query => {:screen_name => 'sferik'}).to_return(:body => fixture('lists.json'))
|
1816
1816
|
end
|
1817
|
-
it
|
1818
|
-
@cli.lists(
|
1819
|
-
expect(a_get(
|
1817
|
+
it 'requests the correct resource' do
|
1818
|
+
@cli.lists('sferik')
|
1819
|
+
expect(a_get('/1.1/lists/list.json').with(:query => {:screen_name => 'sferik'})).to have_been_made
|
1820
1820
|
end
|
1821
|
-
context
|
1821
|
+
context '--id' do
|
1822
1822
|
before do
|
1823
|
-
@cli.options = @cli.options.merge(
|
1824
|
-
stub_get(
|
1823
|
+
@cli.options = @cli.options.merge('id' => true)
|
1824
|
+
stub_get('/1.1/lists/list.json').with(:query => {:user_id => '7505382'}).to_return(:body => fixture('lists.json'))
|
1825
1825
|
end
|
1826
|
-
it
|
1827
|
-
@cli.lists(
|
1828
|
-
expect(a_get(
|
1826
|
+
it 'requests the correct resource' do
|
1827
|
+
@cli.lists('7505382')
|
1828
|
+
expect(a_get('/1.1/lists/list.json').with(:query => {:user_id => '7505382'})).to have_been_made
|
1829
1829
|
end
|
1830
1830
|
end
|
1831
1831
|
end
|
1832
1832
|
end
|
1833
1833
|
|
1834
|
-
describe
|
1834
|
+
describe '#mentions' do
|
1835
1835
|
before do
|
1836
|
-
stub_get(
|
1836
|
+
stub_get('/1.1/statuses/mentions_timeline.json').with(:query => {:count => '20'}).to_return(:body => fixture('statuses.json'))
|
1837
1837
|
end
|
1838
|
-
it
|
1838
|
+
it 'requests the correct resource' do
|
1839
1839
|
@cli.mentions
|
1840
|
-
expect(a_get(
|
1840
|
+
expect(a_get('/1.1/statuses/mentions_timeline.json').with(:query => {:count => '20'})).to have_been_made
|
1841
1841
|
end
|
1842
|
-
it
|
1842
|
+
it 'has the correct output' do
|
1843
1843
|
@cli.mentions
|
1844
1844
|
expect($stdout.string).to eq <<-eos
|
1845
1845
|
@mutgoff
|
@@ -1919,11 +1919,11 @@ ID Created at Screen name Slug Members Subscribers Mode ...
|
|
1919
1919
|
|
1920
1920
|
eos
|
1921
1921
|
end
|
1922
|
-
context
|
1922
|
+
context '--csv' do
|
1923
1923
|
before do
|
1924
|
-
@cli.options = @cli.options.merge(
|
1924
|
+
@cli.options = @cli.options.merge('csv' => true)
|
1925
1925
|
end
|
1926
|
-
it
|
1926
|
+
it 'outputs in CSV format' do
|
1927
1927
|
@cli.mentions
|
1928
1928
|
expect($stdout.string).to eq <<-eos
|
1929
1929
|
ID,Posted at,Screen name,Text
|
@@ -1950,11 +1950,11 @@ ID,Posted at,Screen name,Text
|
|
1950
1950
|
eos
|
1951
1951
|
end
|
1952
1952
|
end
|
1953
|
-
context
|
1953
|
+
context '--long' do
|
1954
1954
|
before do
|
1955
|
-
@cli.options = @cli.options.merge(
|
1955
|
+
@cli.options = @cli.options.merge('long' => true)
|
1956
1956
|
end
|
1957
|
-
it
|
1957
|
+
it 'outputs in long format' do
|
1958
1958
|
@cli.mentions
|
1959
1959
|
expect($stdout.string).to eq <<-eos
|
1960
1960
|
ID Posted at Screen name Text
|
@@ -1980,11 +1980,11 @@ ID Posted at Screen name Text
|
|
1980
1980
|
244099460672679938 Sep 7 07:47 @dwiskus Gentlemen, you can't fig...
|
1981
1981
|
eos
|
1982
1982
|
end
|
1983
|
-
context
|
1983
|
+
context '--reverse' do
|
1984
1984
|
before do
|
1985
|
-
@cli.options = @cli.options.merge(
|
1985
|
+
@cli.options = @cli.options.merge('reverse' => true)
|
1986
1986
|
end
|
1987
|
-
it
|
1987
|
+
it 'reverses the order of the sort' do
|
1988
1988
|
@cli.mentions
|
1989
1989
|
expect($stdout.string).to eq <<-eos
|
1990
1990
|
ID Posted at Screen name Text
|
@@ -2012,187 +2012,188 @@ ID Posted at Screen name Text
|
|
2012
2012
|
end
|
2013
2013
|
end
|
2014
2014
|
end
|
2015
|
-
context
|
2015
|
+
context '--number' do
|
2016
2016
|
before do
|
2017
|
-
stub_get(
|
2018
|
-
stub_get(
|
2019
|
-
stub_get(
|
2017
|
+
stub_get('/1.1/statuses/mentions_timeline.json').with(:query => {:count => '1'}).to_return(:body => fixture('statuses.json'))
|
2018
|
+
stub_get('/1.1/statuses/mentions_timeline.json').with(:query => {:count => '200'}).to_return(:body => fixture('200_statuses.json'))
|
2019
|
+
stub_get('/1.1/statuses/mentions_timeline.json').with(:query => {:count => '1', :max_id => '265500541700956160'}).to_return(:body => fixture('statuses.json'))
|
2020
2020
|
end
|
2021
|
-
it
|
2022
|
-
@cli.options = @cli.options.merge(
|
2021
|
+
it 'limits the number of results to 1' do
|
2022
|
+
@cli.options = @cli.options.merge('number' => 1)
|
2023
2023
|
@cli.mentions
|
2024
|
-
expect(a_get(
|
2024
|
+
expect(a_get('/1.1/statuses/mentions_timeline.json').with(:query => {:count => '1'})).to have_been_made
|
2025
2025
|
end
|
2026
|
-
it
|
2027
|
-
@cli.options = @cli.options.merge(
|
2026
|
+
it 'limits the number of results to 201' do
|
2027
|
+
@cli.options = @cli.options.merge('number' => 201)
|
2028
2028
|
@cli.mentions
|
2029
|
-
expect(a_get(
|
2030
|
-
expect(a_get(
|
2029
|
+
expect(a_get('/1.1/statuses/mentions_timeline.json').with(:query => {:count => '200'})).to have_been_made
|
2030
|
+
expect(a_get('/1.1/statuses/mentions_timeline.json').with(:query => {:count => '1', :max_id => '265500541700956160'})).to have_been_made
|
2031
2031
|
end
|
2032
2032
|
end
|
2033
2033
|
end
|
2034
2034
|
|
2035
|
-
describe
|
2035
|
+
describe '#open' do
|
2036
2036
|
before do
|
2037
|
-
@cli.options = @cli.options.merge(
|
2037
|
+
@cli.options = @cli.options.merge('display-uri' => true)
|
2038
2038
|
end
|
2039
|
-
it
|
2039
|
+
it 'has the correct output' do
|
2040
2040
|
expect do
|
2041
|
-
@cli.open(
|
2041
|
+
@cli.open('sferik')
|
2042
2042
|
end.not_to raise_error
|
2043
2043
|
end
|
2044
|
-
context
|
2044
|
+
context '--id' do
|
2045
2045
|
before do
|
2046
|
-
@cli.options = @cli.options.merge(
|
2047
|
-
stub_get(
|
2046
|
+
@cli.options = @cli.options.merge('id' => true)
|
2047
|
+
stub_get('/1.1/users/show.json').with(:query => {:user_id => '420'}).to_return(:body => fixture('sferik.json'))
|
2048
2048
|
end
|
2049
|
-
it
|
2050
|
-
@cli.open(
|
2051
|
-
expect(a_get(
|
2049
|
+
it 'requests the correct resource' do
|
2050
|
+
@cli.open('420')
|
2051
|
+
expect(a_get('/1.1/users/show.json').with(:query => {:user_id => '420'})).to have_been_made
|
2052
2052
|
end
|
2053
2053
|
end
|
2054
|
-
context
|
2054
|
+
context '--status' do
|
2055
2055
|
before do
|
2056
|
-
@cli.options = @cli.options.merge(
|
2057
|
-
stub_get(
|
2056
|
+
@cli.options = @cli.options.merge('status' => true)
|
2057
|
+
stub_get('/1.1/statuses/show/55709764298092545.json').with(:query => {:include_my_retweet => 'false'}).to_return(:body => fixture('status.json'))
|
2058
2058
|
end
|
2059
|
-
it
|
2060
|
-
@cli.open(
|
2061
|
-
expect(a_get(
|
2059
|
+
it 'requests the correct resource' do
|
2060
|
+
@cli.open('55709764298092545')
|
2061
|
+
expect(a_get('/1.1/statuses/show/55709764298092545.json').with(:query => {:include_my_retweet => 'false'})).to have_been_made
|
2062
2062
|
end
|
2063
|
-
it
|
2063
|
+
it 'has the correct output' do
|
2064
2064
|
expect do
|
2065
|
-
@cli.open(
|
2065
|
+
@cli.open('55709764298092545')
|
2066
2066
|
end.not_to raise_error
|
2067
2067
|
end
|
2068
2068
|
end
|
2069
2069
|
end
|
2070
2070
|
|
2071
|
-
describe
|
2071
|
+
describe '#reply' do
|
2072
2072
|
before do
|
2073
|
-
@cli.options = @cli.options.merge(
|
2074
|
-
stub_get(
|
2075
|
-
stub_post(
|
2076
|
-
stub_request(:get,
|
2077
|
-
stub_request(:get,
|
2073
|
+
@cli.options = @cli.options.merge('profile' => fixture_path + '/.trc', 'location' => nil)
|
2074
|
+
stub_get('/1.1/statuses/show/263813522369159169.json').with(:query => {:include_my_retweet => 'false'}).to_return(:body => fixture('status_with_mention.json'))
|
2075
|
+
stub_post('/1.1/statuses/update.json').with(:body => {:in_reply_to_status_id => '263813522369159169', :status => '@joshfrench Testing', :trim_user => 'true'}).to_return(:body => fixture('status.json'))
|
2076
|
+
stub_request(:get, 'http://checkip.dyndns.org/').to_return(:body => fixture('checkip.html'), :headers => {:content_type => 'text/html'})
|
2077
|
+
stub_request(:get, 'http://www.geoplugin.net/xml.gp?ip=50.131.22.169').to_return(:body => fixture('geoplugin.xml'), :headers => {:content_type => 'application/xml'})
|
2078
2078
|
end
|
2079
|
-
it
|
2080
|
-
@cli.reply(
|
2081
|
-
expect(a_get(
|
2082
|
-
expect(a_post(
|
2083
|
-
expect(a_request(:get,
|
2084
|
-
expect(a_request(:get,
|
2079
|
+
it 'requests the correct resource' do
|
2080
|
+
@cli.reply('263813522369159169', 'Testing')
|
2081
|
+
expect(a_get('/1.1/statuses/show/263813522369159169.json').with(:query => {:include_my_retweet => 'false'})).to have_been_made
|
2082
|
+
expect(a_post('/1.1/statuses/update.json').with(:body => {:in_reply_to_status_id => '263813522369159169', :status => '@joshfrench Testing', :trim_user => 'true'})).to have_been_made
|
2083
|
+
expect(a_request(:get, 'http://checkip.dyndns.org/')).not_to have_been_made
|
2084
|
+
expect(a_request(:get, 'http://www.geoplugin.net/xml.gp?ip=50.131.22.169')).not_to have_been_made
|
2085
2085
|
end
|
2086
|
-
it
|
2087
|
-
@cli.reply(
|
2088
|
-
expect($stdout.string.split("\n").first).to eq
|
2086
|
+
it 'has the correct output' do
|
2087
|
+
@cli.reply('263813522369159169', 'Testing')
|
2088
|
+
expect($stdout.string.split("\n").first).to eq 'Reply posted by @testcli to @joshfrench.'
|
2089
2089
|
end
|
2090
|
-
context
|
2090
|
+
context '--all' do
|
2091
2091
|
before do
|
2092
|
-
@cli.options = @cli.options.merge(
|
2093
|
-
stub_post(
|
2092
|
+
@cli.options = @cli.options.merge('all' => true)
|
2093
|
+
stub_post('/1.1/statuses/update.json').with(:body => {:in_reply_to_status_id => '263813522369159169', :status => '@joshfrench @sferik Testing', :trim_user => 'true'}).to_return(:body => fixture('status.json'))
|
2094
2094
|
end
|
2095
|
-
it
|
2096
|
-
@cli.reply(
|
2097
|
-
expect(a_get(
|
2098
|
-
expect(a_post(
|
2099
|
-
expect(a_request(:get,
|
2100
|
-
expect(a_request(:get,
|
2095
|
+
it 'requests the correct resource' do
|
2096
|
+
@cli.reply('263813522369159169', 'Testing')
|
2097
|
+
expect(a_get('/1.1/statuses/show/263813522369159169.json').with(:query => {:include_my_retweet => 'false'})).to have_been_made
|
2098
|
+
expect(a_post('/1.1/statuses/update.json').with(:body => {:in_reply_to_status_id => '263813522369159169', :status => '@joshfrench @sferik Testing', :trim_user => 'true'})).to have_been_made
|
2099
|
+
expect(a_request(:get, 'http://checkip.dyndns.org/')).not_to have_been_made
|
2100
|
+
expect(a_request(:get, 'http://www.geoplugin.net/xml.gp?ip=50.131.22.169')).not_to have_been_made
|
2101
2101
|
end
|
2102
|
-
it
|
2103
|
-
@cli.reply(
|
2104
|
-
expect($stdout.string.split("\n").first).to eq
|
2102
|
+
it 'has the correct output' do
|
2103
|
+
@cli.reply('263813522369159169', 'Testing')
|
2104
|
+
expect($stdout.string.split("\n").first).to eq 'Reply posted by @testcli to @joshfrench @sferik.'
|
2105
2105
|
end
|
2106
2106
|
end
|
2107
|
-
context
|
2107
|
+
context '--location' do
|
2108
2108
|
before do
|
2109
|
-
@cli.options = @cli.options.merge(
|
2110
|
-
stub_get(
|
2111
|
-
stub_post(
|
2109
|
+
@cli.options = @cli.options.merge('location' => 'location')
|
2110
|
+
stub_get('/1.1/statuses/show/263813522369159169.json').with(:query => {:include_my_retweet => 'false'}).to_return(:body => fixture('status_with_mention.json'))
|
2111
|
+
stub_post('/1.1/statuses/update.json').with(:body => {:in_reply_to_status_id => '263813522369159169', :status => '@joshfrench Testing', :lat => '37.76969909668', :long => '-122.39330291748', :trim_user => 'true'}).to_return(:body => fixture('status.json'))
|
2112
2112
|
end
|
2113
|
-
it
|
2114
|
-
@cli.reply(
|
2115
|
-
expect(a_get(
|
2116
|
-
expect(a_post(
|
2117
|
-
expect(a_request(:get,
|
2118
|
-
expect(a_request(:get,
|
2113
|
+
it 'requests the correct resource' do
|
2114
|
+
@cli.reply('263813522369159169', 'Testing')
|
2115
|
+
expect(a_get('/1.1/statuses/show/263813522369159169.json').with(:query => {:include_my_retweet => 'false'})).to have_been_made
|
2116
|
+
expect(a_post('/1.1/statuses/update.json').with(:body => {:in_reply_to_status_id => '263813522369159169', :status => '@joshfrench Testing', :lat => '37.76969909668', :long => '-122.39330291748', :trim_user => 'true'})).to have_been_made
|
2117
|
+
expect(a_request(:get, 'http://checkip.dyndns.org/')).to have_been_made
|
2118
|
+
expect(a_request(:get, 'http://www.geoplugin.net/xml.gp?ip=50.131.22.169')).to have_been_made
|
2119
2119
|
end
|
2120
|
-
it
|
2121
|
-
@cli.reply(
|
2122
|
-
expect($stdout.string.split("\n").first).to eq
|
2120
|
+
it 'has the correct output' do
|
2121
|
+
@cli.reply('263813522369159169', 'Testing')
|
2122
|
+
expect($stdout.string.split("\n").first).to eq 'Reply posted by @testcli to @joshfrench.'
|
2123
2123
|
end
|
2124
2124
|
end
|
2125
2125
|
context "--location 'latitude,longitude'" do
|
2126
2126
|
before do
|
2127
|
-
@cli.options = @cli.options.merge(
|
2128
|
-
stub_get(
|
2129
|
-
stub_post(
|
2127
|
+
@cli.options = @cli.options.merge('location' => '41.03132,28.9869')
|
2128
|
+
stub_get('/1.1/statuses/show/263813522369159169.json').with(:query => {:include_my_retweet => 'false'}).to_return(:body => fixture('status_with_mention.json'))
|
2129
|
+
stub_post('/1.1/statuses/update.json').with(:body => {:in_reply_to_status_id => '263813522369159169', :status => '@joshfrench Testing', :lat => '41.03132', :long => '28.9869', :trim_user => 'true'}).to_return(:body => fixture('status.json'))
|
2130
2130
|
end
|
2131
|
-
it
|
2132
|
-
@cli.reply(
|
2133
|
-
expect(a_get(
|
2134
|
-
expect(a_post(
|
2135
|
-
expect(a_request(:get,
|
2136
|
-
expect(a_request(:get,
|
2131
|
+
it 'requests the correct resource' do
|
2132
|
+
@cli.reply('263813522369159169', 'Testing')
|
2133
|
+
expect(a_get('/1.1/statuses/show/263813522369159169.json').with(:query => {:include_my_retweet => 'false'})).to have_been_made
|
2134
|
+
expect(a_post('/1.1/statuses/update.json').with(:body => {:in_reply_to_status_id => '263813522369159169', :status => '@joshfrench Testing', :lat => '41.03132', :long => '28.9869', :trim_user => 'true'})).to have_been_made
|
2135
|
+
expect(a_request(:get, 'http://checkip.dyndns.org/')).not_to have_been_made
|
2136
|
+
expect(a_request(:get, 'http://www.geoplugin.net/xml.gp?ip=50.131.22.169')).not_to have_been_made
|
2137
2137
|
end
|
2138
|
-
it
|
2139
|
-
@cli.reply(
|
2140
|
-
expect($stdout.string.split("\n").first).to eq
|
2138
|
+
it 'has the correct output' do
|
2139
|
+
@cli.reply('263813522369159169', 'Testing')
|
2140
|
+
expect($stdout.string.split("\n").first).to eq 'Reply posted by @testcli to @joshfrench.'
|
2141
2141
|
end
|
2142
|
-
end
|
2142
|
+
end
|
2143
|
+
end
|
2143
2144
|
|
2144
|
-
describe
|
2145
|
+
describe '#report_spam' do
|
2145
2146
|
before do
|
2146
|
-
@cli.options = @cli.options.merge(
|
2147
|
-
stub_post(
|
2147
|
+
@cli.options = @cli.options.merge('profile' => fixture_path + '/.trc')
|
2148
|
+
stub_post('/1.1/users/report_spam.json').with(:body => {:screen_name => 'sferik'}).to_return(:body => fixture('sferik.json'))
|
2148
2149
|
end
|
2149
|
-
it
|
2150
|
-
@cli.report_spam(
|
2151
|
-
expect(a_post(
|
2150
|
+
it 'requests the correct resource' do
|
2151
|
+
@cli.report_spam('sferik')
|
2152
|
+
expect(a_post('/1.1/users/report_spam.json').with(:body => {:screen_name => 'sferik'})).to have_been_made
|
2152
2153
|
end
|
2153
|
-
it
|
2154
|
-
@cli.report_spam(
|
2154
|
+
it 'has the correct output' do
|
2155
|
+
@cli.report_spam('sferik')
|
2155
2156
|
expect($stdout.string).to match /^@testcli reported 1 user/
|
2156
2157
|
end
|
2157
|
-
context
|
2158
|
+
context '--id' do
|
2158
2159
|
before do
|
2159
|
-
@cli.options = @cli.options.merge(
|
2160
|
-
stub_post(
|
2160
|
+
@cli.options = @cli.options.merge('id' => true)
|
2161
|
+
stub_post('/1.1/users/report_spam.json').with(:body => {:user_id => '7505382'}).to_return(:body => fixture('sferik.json'))
|
2161
2162
|
end
|
2162
|
-
it
|
2163
|
-
@cli.report_spam(
|
2164
|
-
expect(a_post(
|
2163
|
+
it 'requests the correct resource' do
|
2164
|
+
@cli.report_spam('7505382')
|
2165
|
+
expect(a_post('/1.1/users/report_spam.json').with(:body => {:user_id => '7505382'})).to have_been_made
|
2165
2166
|
end
|
2166
2167
|
end
|
2167
2168
|
end
|
2168
2169
|
|
2169
|
-
describe
|
2170
|
+
describe '#retweet' do
|
2170
2171
|
before do
|
2171
|
-
@cli.options = @cli.options.merge(
|
2172
|
-
stub_post(
|
2172
|
+
@cli.options = @cli.options.merge('profile' => fixture_path + '/.trc')
|
2173
|
+
stub_post('/1.1/statuses/retweet/26755176471724032.json').to_return(:body => fixture('retweet.json'))
|
2173
2174
|
end
|
2174
|
-
it
|
2175
|
-
@cli.retweet(
|
2176
|
-
expect(a_post(
|
2175
|
+
it 'requests the correct resource' do
|
2176
|
+
@cli.retweet('26755176471724032')
|
2177
|
+
expect(a_post('/1.1/statuses/retweet/26755176471724032.json')).to have_been_made
|
2177
2178
|
end
|
2178
|
-
it
|
2179
|
-
@cli.retweet(
|
2179
|
+
it 'has the correct output' do
|
2180
|
+
@cli.retweet('26755176471724032')
|
2180
2181
|
expect($stdout.string).to match /^@testcli retweeted 1 tweet.$/
|
2181
2182
|
end
|
2182
2183
|
end
|
2183
2184
|
|
2184
|
-
describe
|
2185
|
+
describe '#retweets' do
|
2185
2186
|
before do
|
2186
|
-
stub_get(
|
2187
|
-
stub_get(
|
2187
|
+
stub_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :include_rts => 'true'}).to_return(:body => fixture('statuses.json'))
|
2188
|
+
stub_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :include_rts => 'true', :max_id => '244102729860009983'}).to_return(:body => fixture('statuses.json'))
|
2188
2189
|
end
|
2189
|
-
context
|
2190
|
-
it
|
2190
|
+
context 'without arguments' do
|
2191
|
+
it 'requests the correct resource' do
|
2191
2192
|
@cli.retweets
|
2192
|
-
expect(a_get(
|
2193
|
-
expect(a_get(
|
2193
|
+
expect(a_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :include_rts => 'true'})).to have_been_made
|
2194
|
+
expect(a_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :include_rts => 'true', :max_id => '244102729860009983'})).to have_been_made.times(3)
|
2194
2195
|
end
|
2195
|
-
it
|
2196
|
+
it 'has the correct output' do
|
2196
2197
|
@cli.retweets
|
2197
2198
|
expect($stdout.string).to eq <<-eos
|
2198
2199
|
@calebelston
|
@@ -2278,11 +2279,11 @@ ID Posted at Screen name Text
|
|
2278
2279
|
eos
|
2279
2280
|
end
|
2280
2281
|
end
|
2281
|
-
context
|
2282
|
+
context '--csv' do
|
2282
2283
|
before do
|
2283
|
-
@cli.options = @cli.options.merge(
|
2284
|
+
@cli.options = @cli.options.merge('csv' => true)
|
2284
2285
|
end
|
2285
|
-
it
|
2286
|
+
it 'outputs in CSV format' do
|
2286
2287
|
@cli.retweets
|
2287
2288
|
expect($stdout.string).to eq <<-eos
|
2288
2289
|
ID,Posted at,Screen name,Text
|
@@ -2309,11 +2310,11 @@ ID,Posted at,Screen name,Text
|
|
2309
2310
|
eos
|
2310
2311
|
end
|
2311
2312
|
end
|
2312
|
-
context
|
2313
|
+
context '--long' do
|
2313
2314
|
before do
|
2314
|
-
@cli.options = @cli.options.merge(
|
2315
|
+
@cli.options = @cli.options.merge('long' => true)
|
2315
2316
|
end
|
2316
|
-
it
|
2317
|
+
it 'outputs in long format' do
|
2317
2318
|
@cli.retweets
|
2318
2319
|
expect($stdout.string).to eq <<-eos
|
2319
2320
|
ID Posted at Screen name Text
|
@@ -2339,11 +2340,11 @@ ID Posted at Screen name Text
|
|
2339
2340
|
244107823733174272 Sep 7 08:20 @codeforamerica RT @randomhacks: Going to ...
|
2340
2341
|
eos
|
2341
2342
|
end
|
2342
|
-
context
|
2343
|
+
context '--reverse' do
|
2343
2344
|
before do
|
2344
|
-
@cli.options = @cli.options.merge(
|
2345
|
+
@cli.options = @cli.options.merge('reverse' => true)
|
2345
2346
|
end
|
2346
|
-
it
|
2347
|
+
it 'reverses the order of the sort' do
|
2347
2348
|
@cli.retweets
|
2348
2349
|
expect($stdout.string).to eq <<-eos
|
2349
2350
|
ID Posted at Screen name Text
|
@@ -2371,76 +2372,76 @@ ID Posted at Screen name Text
|
|
2371
2372
|
end
|
2372
2373
|
end
|
2373
2374
|
end
|
2374
|
-
context
|
2375
|
+
context '--number' do
|
2375
2376
|
before do
|
2376
|
-
stub_get(
|
2377
|
-
stub_get(
|
2377
|
+
stub_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :include_rts => 'true'}).to_return(:body => fixture('statuses.json'))
|
2378
|
+
stub_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :include_rts => 'true', :max_id => '244107823733174271'}).to_return(:body => fixture('statuses.json'))
|
2378
2379
|
end
|
2379
|
-
it
|
2380
|
-
@cli.options = @cli.options.merge(
|
2380
|
+
it 'limits the number of results to 1' do
|
2381
|
+
@cli.options = @cli.options.merge('number' => 1)
|
2381
2382
|
@cli.retweets
|
2382
|
-
expect(a_get(
|
2383
|
+
expect(a_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :include_rts => 'true'})).to have_been_made
|
2383
2384
|
end
|
2384
|
-
it
|
2385
|
-
@cli.options = @cli.options.merge(
|
2385
|
+
it 'limits the number of results to 201' do
|
2386
|
+
@cli.options = @cli.options.merge('number' => 201)
|
2386
2387
|
@cli.retweets
|
2387
|
-
expect(a_get(
|
2388
|
-
expect(a_get(
|
2388
|
+
expect(a_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :include_rts => 'true'})).to have_been_made
|
2389
|
+
expect(a_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :include_rts => 'true', :max_id => '244107823733174271'})).to have_been_made
|
2389
2390
|
end
|
2390
2391
|
end
|
2391
|
-
context
|
2392
|
+
context 'with a user passed' do
|
2392
2393
|
before do
|
2393
|
-
stub_get(
|
2394
|
-
stub_get(
|
2394
|
+
stub_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :include_rts => 'true', :screen_name => 'sferik'}).to_return(:body => fixture('statuses.json'))
|
2395
|
+
stub_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :include_rts => 'true', :screen_name => 'sferik', :max_id => '244102729860009983'}).to_return(:body => fixture('statuses.json'))
|
2395
2396
|
end
|
2396
|
-
it
|
2397
|
-
@cli.retweets(
|
2398
|
-
expect(a_get(
|
2399
|
-
expect(a_get(
|
2397
|
+
it 'requests the correct resource' do
|
2398
|
+
@cli.retweets('sferik')
|
2399
|
+
expect(a_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :include_rts => 'true', :screen_name => 'sferik'})).to have_been_made
|
2400
|
+
expect(a_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :include_rts => 'true', :screen_name => 'sferik', :max_id => '244102729860009983'})).to have_been_made.times(3)
|
2400
2401
|
end
|
2401
|
-
context
|
2402
|
+
context '--id' do
|
2402
2403
|
before do
|
2403
|
-
@cli.options = @cli.options.merge(
|
2404
|
-
stub_get(
|
2405
|
-
stub_get(
|
2404
|
+
@cli.options = @cli.options.merge('id' => true)
|
2405
|
+
stub_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :include_rts => 'true', :user_id => '7505382'}).to_return(:body => fixture('statuses.json'))
|
2406
|
+
stub_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :include_rts => 'true', :user_id => '7505382', :max_id => '244102729860009983'}).to_return(:body => fixture('statuses.json'))
|
2406
2407
|
end
|
2407
|
-
it
|
2408
|
-
@cli.retweets(
|
2409
|
-
expect(a_get(
|
2410
|
-
expect(a_get(
|
2408
|
+
it 'requests the correct resource' do
|
2409
|
+
@cli.retweets('7505382')
|
2410
|
+
expect(a_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :include_rts => 'true', :user_id => '7505382'})).to have_been_made
|
2411
|
+
expect(a_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :include_rts => 'true', :user_id => '7505382', :max_id => '244102729860009983'})).to have_been_made.times(3)
|
2411
2412
|
end
|
2412
2413
|
end
|
2413
2414
|
end
|
2414
2415
|
end
|
2415
2416
|
|
2416
|
-
describe
|
2417
|
-
it
|
2417
|
+
describe '#ruler' do
|
2418
|
+
it 'has the correct output' do
|
2418
2419
|
@cli.ruler
|
2419
2420
|
expect($stdout.string.chomp.size).to eq 140
|
2420
|
-
expect($stdout.string.chomp).to eq
|
2421
|
+
expect($stdout.string.chomp).to eq '----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|'
|
2421
2422
|
end
|
2422
|
-
context
|
2423
|
+
context 'with indentation' do
|
2423
2424
|
before do
|
2424
|
-
@cli.options = @cli.options.merge(
|
2425
|
+
@cli.options = @cli.options.merge('indent' => 2)
|
2425
2426
|
end
|
2426
|
-
it
|
2427
|
+
it 'has the correct output' do
|
2427
2428
|
@cli.ruler
|
2428
2429
|
expect($stdout.string.chomp.size).to eq 142
|
2429
|
-
expect($stdout.string.chomp).to eq
|
2430
|
+
expect($stdout.string.chomp).to eq ' ----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|'
|
2430
2431
|
end
|
2431
2432
|
end
|
2432
2433
|
end
|
2433
2434
|
|
2434
|
-
describe
|
2435
|
+
describe '#status' do
|
2435
2436
|
before do
|
2436
|
-
stub_get(
|
2437
|
+
stub_get('/1.1/statuses/show/55709764298092545.json').with(:query => {:include_my_retweet => 'false'}).to_return(:body => fixture('status.json'))
|
2437
2438
|
end
|
2438
|
-
it
|
2439
|
-
@cli.status(
|
2440
|
-
expect(a_get(
|
2439
|
+
it 'requests the correct resources' do
|
2440
|
+
@cli.status('55709764298092545')
|
2441
|
+
expect(a_get('/1.1/statuses/show/55709764298092545.json').with(:query => {:include_my_retweet => 'false'})).to have_been_made
|
2441
2442
|
end
|
2442
|
-
it
|
2443
|
-
@cli.status(
|
2443
|
+
it 'has the correct output' do
|
2444
|
+
@cli.status('55709764298092545')
|
2444
2445
|
expect($stdout.string).to eq <<-eos
|
2445
2446
|
ID 55709764298092545
|
2446
2447
|
Text The problem with your code is that it's doing exactly what you told it to do.
|
@@ -2452,24 +2453,24 @@ Source Twitter for iPhone
|
|
2452
2453
|
Location Blowfish Sushi To Die For, 2170 Bryant St, San Francisco, California, United States
|
2453
2454
|
eos
|
2454
2455
|
end
|
2455
|
-
context
|
2456
|
+
context '--csv' do
|
2456
2457
|
before do
|
2457
|
-
@cli.options = @cli.options.merge(
|
2458
|
+
@cli.options = @cli.options.merge('csv' => true)
|
2458
2459
|
end
|
2459
|
-
it
|
2460
|
-
@cli.status(
|
2460
|
+
it 'has the correct output' do
|
2461
|
+
@cli.status('55709764298092545')
|
2461
2462
|
expect($stdout.string).to eq <<-eos
|
2462
2463
|
ID,Posted at,Screen name,Text,Retweets,Favorites,Source,Location
|
2463
2464
|
55709764298092545,2011-04-06 19:13:37 +0000,sferik,The problem with your code is that it's doing exactly what you told it to do.,320,50,Twitter for iPhone,"Blowfish Sushi To Die For, 2170 Bryant St, San Francisco, California, United States"
|
2464
2465
|
eos
|
2465
2466
|
end
|
2466
2467
|
end
|
2467
|
-
context
|
2468
|
+
context 'with no street address' do
|
2468
2469
|
before do
|
2469
|
-
stub_get(
|
2470
|
+
stub_get('/1.1/statuses/show/55709764298092545.json').with(:query => {:include_my_retweet => 'false'}).to_return(:body => fixture('status_no_street_address.json'))
|
2470
2471
|
end
|
2471
|
-
it
|
2472
|
-
@cli.status(
|
2472
|
+
it 'has the correct output' do
|
2473
|
+
@cli.status('55709764298092545')
|
2473
2474
|
expect($stdout.string).to eq <<-eos
|
2474
2475
|
ID 55709764298092550
|
2475
2476
|
Text The problem with your code is that it's doing exactly what you told it to do.
|
@@ -2482,12 +2483,12 @@ Location Blowfish Sushi To Die For, San Francisco, California, United States
|
|
2482
2483
|
eos
|
2483
2484
|
end
|
2484
2485
|
end
|
2485
|
-
context
|
2486
|
+
context 'with no locality' do
|
2486
2487
|
before do
|
2487
|
-
stub_get(
|
2488
|
+
stub_get('/1.1/statuses/show/55709764298092545.json').with(:query => {:include_my_retweet => 'false'}).to_return(:body => fixture('status_no_locality.json'))
|
2488
2489
|
end
|
2489
|
-
it
|
2490
|
-
@cli.status(
|
2490
|
+
it 'has the correct output' do
|
2491
|
+
@cli.status('55709764298092545')
|
2491
2492
|
expect($stdout.string).to eq <<-eos
|
2492
2493
|
ID 55709764298092549
|
2493
2494
|
Text The problem with your code is that it's doing exactly what you told it to do.
|
@@ -2500,12 +2501,12 @@ Location Blowfish Sushi To Die For, San Francisco, California, United States
|
|
2500
2501
|
eos
|
2501
2502
|
end
|
2502
2503
|
end
|
2503
|
-
context
|
2504
|
+
context 'with no attributes' do
|
2504
2505
|
before do
|
2505
|
-
stub_get(
|
2506
|
+
stub_get('/1.1/statuses/show/55709764298092545.json').with(:query => {:include_my_retweet => 'false'}).to_return(:body => fixture('status_no_attributes.json'))
|
2506
2507
|
end
|
2507
|
-
it
|
2508
|
-
@cli.status(
|
2508
|
+
it 'has the correct output' do
|
2509
|
+
@cli.status('55709764298092545')
|
2509
2510
|
expect($stdout.string).to eq <<-eos
|
2510
2511
|
ID 55709764298092546
|
2511
2512
|
Text The problem with your code is that it's doing exactly what you told it to do.
|
@@ -2518,12 +2519,12 @@ Location Blowfish Sushi To Die For, San Francisco, United States
|
|
2518
2519
|
eos
|
2519
2520
|
end
|
2520
2521
|
end
|
2521
|
-
context
|
2522
|
+
context 'with no country' do
|
2522
2523
|
before do
|
2523
|
-
stub_get(
|
2524
|
+
stub_get('/1.1/statuses/show/55709764298092545.json').with(:query => {:include_my_retweet => 'false'}).to_return(:body => fixture('status_no_country.json'))
|
2524
2525
|
end
|
2525
|
-
it
|
2526
|
-
@cli.status(
|
2526
|
+
it 'has the correct output' do
|
2527
|
+
@cli.status('55709764298092545')
|
2527
2528
|
expect($stdout.string).to eq <<-eos
|
2528
2529
|
ID 55709764298092547
|
2529
2530
|
Text The problem with your code is that it's doing exactly what you told it to do.
|
@@ -2536,12 +2537,12 @@ Location Blowfish Sushi To Die For, San Francisco
|
|
2536
2537
|
eos
|
2537
2538
|
end
|
2538
2539
|
end
|
2539
|
-
context
|
2540
|
+
context 'with no full name' do
|
2540
2541
|
before do
|
2541
|
-
stub_get(
|
2542
|
+
stub_get('/1.1/statuses/show/55709764298092545.json').with(:query => {:include_my_retweet => 'false'}).to_return(:body => fixture('status_no_full_name.json'))
|
2542
2543
|
end
|
2543
|
-
it
|
2544
|
-
@cli.status(
|
2544
|
+
it 'has the correct output' do
|
2545
|
+
@cli.status('55709764298092545')
|
2545
2546
|
expect($stdout.string).to eq <<-eos
|
2546
2547
|
ID 55709764298092548
|
2547
2548
|
Text The problem with your code is that it's doing exactly what you told it to do.
|
@@ -2554,13 +2555,13 @@ Location Blowfish Sushi To Die For
|
|
2554
2555
|
eos
|
2555
2556
|
end
|
2556
2557
|
end
|
2557
|
-
context
|
2558
|
+
context 'with no place' do
|
2558
2559
|
before do
|
2559
|
-
stub_get(
|
2560
|
-
stub_request(:get,
|
2560
|
+
stub_get('/1.1/statuses/show/55709764298092545.json').with(:query => {:include_my_retweet => 'false'}).to_return(:body => fixture('status_no_place.json'))
|
2561
|
+
stub_request(:get, 'http://maps.google.com/maps/geo').with(:query => hash_including(:key => 'REPLACE_WITH_YOUR_GOOGLE_KEY', :oe => 'utf-8', :output => 'xml')).to_return(:body => fixture('geo.kml'), :headers => {:content_type => 'text/xml; charset=UTF-8'})
|
2561
2562
|
end
|
2562
|
-
it
|
2563
|
-
@cli.status(
|
2563
|
+
it 'has the correct output' do
|
2564
|
+
@cli.status('55709764298092545')
|
2564
2565
|
expect($stdout.string).to eq <<-eos
|
2565
2566
|
ID 55709764298092551
|
2566
2567
|
Text The problem with your code is that it's doing exactly what you told it to do.
|
@@ -2572,13 +2573,13 @@ Source Twitter for iPhone
|
|
2572
2573
|
Location San Francisco, CA, USA
|
2573
2574
|
eos
|
2574
2575
|
end
|
2575
|
-
context
|
2576
|
+
context 'with no city' do
|
2576
2577
|
before do
|
2577
|
-
stub_get(
|
2578
|
-
stub_request(:get,
|
2578
|
+
stub_get('/1.1/statuses/show/55709764298092545.json').with(:query => {:include_my_retweet => 'false'}).to_return(:body => fixture('status_no_place.json'))
|
2579
|
+
stub_request(:get, 'http://maps.google.com/maps/geo').with(:query => hash_including(:key => 'REPLACE_WITH_YOUR_GOOGLE_KEY', :oe => 'utf-8', :output => 'xml')).to_return(:body => fixture('geo_no_city.kml'), :headers => {:content_type => 'text/xml; charset=UTF-8'})
|
2579
2580
|
end
|
2580
|
-
it
|
2581
|
-
@cli.status(
|
2581
|
+
it 'has the correct output' do
|
2582
|
+
@cli.status('55709764298092545')
|
2582
2583
|
expect($stdout.string).to eq <<-eos
|
2583
2584
|
ID 55709764298092551
|
2584
2585
|
Text The problem with your code is that it's doing exactly what you told it to do.
|
@@ -2591,13 +2592,13 @@ Location CA, USA
|
|
2591
2592
|
eos
|
2592
2593
|
end
|
2593
2594
|
end
|
2594
|
-
context
|
2595
|
+
context 'with no state' do
|
2595
2596
|
before do
|
2596
|
-
stub_get(
|
2597
|
-
stub_request(:get,
|
2597
|
+
stub_get('/1.1/statuses/show/55709764298092545.json').with(:query => {:include_my_retweet => 'false'}).to_return(:body => fixture('status_no_place.json'))
|
2598
|
+
stub_request(:get, 'http://maps.google.com/maps/geo').with(:query => hash_including(:key => 'REPLACE_WITH_YOUR_GOOGLE_KEY', :oe => 'utf-8', :output => 'xml')).to_return(:body => fixture('geo_no_state.kml'), :headers => {:content_type => 'text/xml; charset=UTF-8'})
|
2598
2599
|
end
|
2599
|
-
it
|
2600
|
-
@cli.status(
|
2600
|
+
it 'has the correct output' do
|
2601
|
+
@cli.status('55709764298092545')
|
2601
2602
|
expect($stdout.string).to eq <<-eos
|
2602
2603
|
ID 55709764298092551
|
2603
2604
|
Text The problem with your code is that it's doing exactly what you told it to do.
|
@@ -2611,12 +2612,12 @@ Location USA
|
|
2611
2612
|
end
|
2612
2613
|
end
|
2613
2614
|
end
|
2614
|
-
context
|
2615
|
+
context '--long' do
|
2615
2616
|
before do
|
2616
|
-
@cli.options = @cli.options.merge(
|
2617
|
+
@cli.options = @cli.options.merge('long' => true)
|
2617
2618
|
end
|
2618
|
-
it
|
2619
|
-
@cli.status(
|
2619
|
+
it 'outputs in long format' do
|
2620
|
+
@cli.status('55709764298092545')
|
2620
2621
|
expect($stdout.string).to eq <<-eos
|
2621
2622
|
ID Posted at Screen name Text ...
|
2622
2623
|
55709764298092545 Apr 6 2011 @sferik The problem with your code is t...
|
@@ -2625,16 +2626,16 @@ ID Posted at Screen name Text ...
|
|
2625
2626
|
end
|
2626
2627
|
end
|
2627
2628
|
|
2628
|
-
describe
|
2629
|
+
describe '#timeline' do
|
2629
2630
|
before do
|
2630
|
-
stub_get(
|
2631
|
+
stub_get('/1.1/statuses/home_timeline.json').with(:query => {:count => '20'}).to_return(:body => fixture('statuses.json'))
|
2631
2632
|
end
|
2632
|
-
context
|
2633
|
-
it
|
2633
|
+
context 'without user' do
|
2634
|
+
it 'requests the correct resource' do
|
2634
2635
|
@cli.timeline
|
2635
|
-
expect(a_get(
|
2636
|
+
expect(a_get('/1.1/statuses/home_timeline.json').with(:query => {:count => '20'})).to have_been_made
|
2636
2637
|
end
|
2637
|
-
it
|
2638
|
+
it 'has the correct output' do
|
2638
2639
|
@cli.timeline
|
2639
2640
|
expect($stdout.string).to eq <<-eos
|
2640
2641
|
@mutgoff
|
@@ -2715,11 +2716,11 @@ ID Posted at Screen name Text ...
|
|
2715
2716
|
eos
|
2716
2717
|
end
|
2717
2718
|
end
|
2718
|
-
context
|
2719
|
+
context '--csv' do
|
2719
2720
|
before do
|
2720
|
-
@cli.options = @cli.options.merge(
|
2721
|
+
@cli.options = @cli.options.merge('csv' => true)
|
2721
2722
|
end
|
2722
|
-
it
|
2723
|
+
it 'outputs in CSV format' do
|
2723
2724
|
@cli.timeline
|
2724
2725
|
expect($stdout.string).to eq <<-eos
|
2725
2726
|
ID,Posted at,Screen name,Text
|
@@ -2746,31 +2747,31 @@ ID,Posted at,Screen name,Text
|
|
2746
2747
|
eos
|
2747
2748
|
end
|
2748
2749
|
end
|
2749
|
-
context
|
2750
|
+
context '--exclude=replies' do
|
2750
2751
|
before do
|
2751
|
-
@cli.options = @cli.options.merge(
|
2752
|
-
stub_get(
|
2752
|
+
@cli.options = @cli.options.merge('exclude' => 'replies')
|
2753
|
+
stub_get('/1.1/statuses/home_timeline.json').with(:query => {:count => '20', :exclude_replies => 'true'}).to_return(:body => fixture('statuses.json'))
|
2753
2754
|
end
|
2754
|
-
it
|
2755
|
+
it 'excludes replies' do
|
2755
2756
|
@cli.timeline
|
2756
|
-
expect(a_get(
|
2757
|
+
expect(a_get('/1.1/statuses/home_timeline.json').with(:query => {:count => '20', :exclude_replies => 'true'})).to have_been_made
|
2757
2758
|
end
|
2758
2759
|
end
|
2759
|
-
context
|
2760
|
+
context '--exclude=retweets' do
|
2760
2761
|
before do
|
2761
|
-
@cli.options = @cli.options.merge(
|
2762
|
-
stub_get(
|
2762
|
+
@cli.options = @cli.options.merge('exclude' => 'retweets')
|
2763
|
+
stub_get('/1.1/statuses/home_timeline.json').with(:query => {:count => '20', :include_rts => 'false'}).to_return(:body => fixture('statuses.json'))
|
2763
2764
|
end
|
2764
|
-
it
|
2765
|
+
it 'excludes retweets' do
|
2765
2766
|
@cli.timeline
|
2766
|
-
expect(a_get(
|
2767
|
+
expect(a_get('/1.1/statuses/home_timeline.json').with(:query => {:count => '20', :include_rts => 'false'})).to have_been_made
|
2767
2768
|
end
|
2768
2769
|
end
|
2769
|
-
context
|
2770
|
+
context '--long' do
|
2770
2771
|
before do
|
2771
|
-
@cli.options = @cli.options.merge(
|
2772
|
+
@cli.options = @cli.options.merge('long' => true)
|
2772
2773
|
end
|
2773
|
-
it
|
2774
|
+
it 'outputs in long format' do
|
2774
2775
|
@cli.timeline
|
2775
2776
|
expect($stdout.string).to eq <<-eos
|
2776
2777
|
ID Posted at Screen name Text
|
@@ -2796,11 +2797,11 @@ ID Posted at Screen name Text
|
|
2796
2797
|
244099460672679938 Sep 7 07:47 @dwiskus Gentlemen, you can't fig...
|
2797
2798
|
eos
|
2798
2799
|
end
|
2799
|
-
context
|
2800
|
+
context '--reverse' do
|
2800
2801
|
before do
|
2801
|
-
@cli.options = @cli.options.merge(
|
2802
|
+
@cli.options = @cli.options.merge('reverse' => true)
|
2802
2803
|
end
|
2803
|
-
it
|
2804
|
+
it 'reverses the order of the sort' do
|
2804
2805
|
@cli.timeline
|
2805
2806
|
expect($stdout.string).to eq <<-eos
|
2806
2807
|
ID Posted at Screen name Text
|
@@ -2828,364 +2829,362 @@ ID Posted at Screen name Text
|
|
2828
2829
|
end
|
2829
2830
|
end
|
2830
2831
|
end
|
2831
|
-
context
|
2832
|
+
context '--max-id' do
|
2832
2833
|
before do
|
2833
|
-
@cli.options = @cli.options.merge(
|
2834
|
-
stub_get(
|
2834
|
+
@cli.options = @cli.options.merge('max_id' => 244_104_558_433_951_744)
|
2835
|
+
stub_get('/1.1/statuses/home_timeline.json').with(:query => {:count => '20', :max_id => '244104558433951744'}).to_return(:body => fixture('statuses.json'))
|
2835
2836
|
end
|
2836
|
-
it
|
2837
|
+
it 'requests the correct resource' do
|
2837
2838
|
@cli.timeline
|
2838
|
-
expect(a_get(
|
2839
|
+
expect(a_get('/1.1/statuses/home_timeline.json').with(:query => {:count => '20', :max_id => '244104558433951744'})).to have_been_made
|
2839
2840
|
end
|
2840
2841
|
end
|
2841
|
-
context
|
2842
|
+
context '--number' do
|
2842
2843
|
before do
|
2843
|
-
stub_get(
|
2844
|
-
stub_get(
|
2845
|
-
stub_get(
|
2844
|
+
stub_get('/1.1/statuses/home_timeline.json').with(:query => {:count => '1'}).to_return(:body => fixture('statuses.json'))
|
2845
|
+
stub_get('/1.1/statuses/home_timeline.json').with(:query => {:count => '200'}).to_return(:body => fixture('200_statuses.json'))
|
2846
|
+
stub_get('/1.1/statuses/home_timeline.json').with(:query => {:count => '1', :max_id => '265500541700956160'}).to_return(:body => fixture('statuses.json'))
|
2846
2847
|
end
|
2847
|
-
it
|
2848
|
-
@cli.options = @cli.options.merge(
|
2848
|
+
it 'limits the number of results to 1' do
|
2849
|
+
@cli.options = @cli.options.merge('number' => 1)
|
2849
2850
|
@cli.timeline
|
2850
|
-
expect(a_get(
|
2851
|
+
expect(a_get('/1.1/statuses/home_timeline.json').with(:query => {:count => '1'})).to have_been_made
|
2851
2852
|
end
|
2852
|
-
it
|
2853
|
-
@cli.options = @cli.options.merge(
|
2853
|
+
it 'limits the number of results to 201' do
|
2854
|
+
@cli.options = @cli.options.merge('number' => 201)
|
2854
2855
|
@cli.timeline
|
2855
|
-
expect(a_get(
|
2856
|
-
expect(a_get(
|
2856
|
+
expect(a_get('/1.1/statuses/home_timeline.json').with(:query => {:count => '200'})).to have_been_made
|
2857
|
+
expect(a_get('/1.1/statuses/home_timeline.json').with(:query => {:count => '1', :max_id => '265500541700956160'})).to have_been_made
|
2857
2858
|
end
|
2858
2859
|
end
|
2859
|
-
context
|
2860
|
+
context '--since-id' do
|
2860
2861
|
before do
|
2861
|
-
@cli.options = @cli.options.merge(
|
2862
|
-
stub_get(
|
2862
|
+
@cli.options = @cli.options.merge('since_id' => 244_104_558_433_951_744)
|
2863
|
+
stub_get('/1.1/statuses/home_timeline.json').with(:query => {:count => '20', :since_id => '244104558433951744'}).to_return(:body => fixture('statuses.json'))
|
2863
2864
|
end
|
2864
|
-
it
|
2865
|
+
it 'requests the correct resource' do
|
2865
2866
|
@cli.timeline
|
2866
|
-
expect(a_get(
|
2867
|
+
expect(a_get('/1.1/statuses/home_timeline.json').with(:query => {:count => '20', :since_id => '244104558433951744'})).to have_been_made
|
2867
2868
|
end
|
2868
2869
|
end
|
2869
|
-
context
|
2870
|
+
context 'with a user passed' do
|
2870
2871
|
before do
|
2871
|
-
stub_get(
|
2872
|
+
stub_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '20', :screen_name => 'sferik'}).to_return(:body => fixture('statuses.json'))
|
2872
2873
|
end
|
2873
|
-
it
|
2874
|
-
@cli.timeline(
|
2875
|
-
expect(a_get(
|
2874
|
+
it 'requests the correct resource' do
|
2875
|
+
@cli.timeline('sferik')
|
2876
|
+
expect(a_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '20', :screen_name => 'sferik'})).to have_been_made
|
2876
2877
|
end
|
2877
|
-
context
|
2878
|
+
context '--id' do
|
2878
2879
|
before do
|
2879
|
-
@cli.options = @cli.options.merge(
|
2880
|
-
stub_get(
|
2880
|
+
@cli.options = @cli.options.merge('id' => true)
|
2881
|
+
stub_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '20', :user_id => '7505382'}).to_return(:body => fixture('statuses.json'))
|
2881
2882
|
end
|
2882
|
-
it
|
2883
|
-
@cli.timeline(
|
2884
|
-
expect(a_get(
|
2883
|
+
it 'requests the correct resource' do
|
2884
|
+
@cli.timeline('7505382')
|
2885
|
+
expect(a_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '20', :user_id => '7505382'})).to have_been_made
|
2885
2886
|
end
|
2886
2887
|
end
|
2887
|
-
context
|
2888
|
+
context '--max-id' do
|
2888
2889
|
before do
|
2889
|
-
@cli.options = @cli.options.merge(
|
2890
|
-
stub_get(
|
2890
|
+
@cli.options = @cli.options.merge('max_id' => 244_104_558_433_951_744)
|
2891
|
+
stub_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '20', :screen_name => 'sferik', :max_id => '244104558433951744'}).to_return(:body => fixture('statuses.json'))
|
2891
2892
|
end
|
2892
|
-
it
|
2893
|
-
@cli.timeline(
|
2894
|
-
expect(a_get(
|
2893
|
+
it 'requests the correct resource' do
|
2894
|
+
@cli.timeline('sferik')
|
2895
|
+
expect(a_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '20', :screen_name => 'sferik', :max_id => '244104558433951744'})).to have_been_made
|
2895
2896
|
end
|
2896
2897
|
end
|
2897
|
-
context
|
2898
|
+
context '--number' do
|
2898
2899
|
before do
|
2899
|
-
stub_get(
|
2900
|
-
stub_get(
|
2901
|
-
stub_get(
|
2900
|
+
stub_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '1', :screen_name => 'sferik'}).to_return(:body => fixture('statuses.json'))
|
2901
|
+
stub_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :screen_name => 'sferik'}).to_return(:body => fixture('200_statuses.json'))
|
2902
|
+
stub_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '1', :screen_name => 'sferik', :max_id => '265500541700956160'}).to_return(:body => fixture('statuses.json'))
|
2902
2903
|
end
|
2903
|
-
it
|
2904
|
-
@cli.options = @cli.options.merge(
|
2905
|
-
@cli.timeline(
|
2906
|
-
expect(a_get(
|
2904
|
+
it 'limits the number of results to 1' do
|
2905
|
+
@cli.options = @cli.options.merge('number' => 1)
|
2906
|
+
@cli.timeline('sferik')
|
2907
|
+
expect(a_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '1', :screen_name => 'sferik'})).to have_been_made
|
2907
2908
|
end
|
2908
|
-
it
|
2909
|
-
@cli.options = @cli.options.merge(
|
2910
|
-
@cli.timeline(
|
2911
|
-
expect(a_get(
|
2912
|
-
expect(a_get(
|
2909
|
+
it 'limits the number of results to 201' do
|
2910
|
+
@cli.options = @cli.options.merge('number' => 201)
|
2911
|
+
@cli.timeline('sferik')
|
2912
|
+
expect(a_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :screen_name => 'sferik'})).to have_been_made
|
2913
|
+
expect(a_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '1', :screen_name => 'sferik', :max_id => '265500541700956160'})).to have_been_made
|
2913
2914
|
end
|
2914
2915
|
end
|
2915
|
-
context
|
2916
|
+
context '--since-id' do
|
2916
2917
|
before do
|
2917
|
-
@cli.options = @cli.options.merge(
|
2918
|
-
stub_get(
|
2918
|
+
@cli.options = @cli.options.merge('since_id' => 244_104_558_433_951_744)
|
2919
|
+
stub_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '20', :screen_name => 'sferik', :since_id => '244104558433951744'}).to_return(:body => fixture('statuses.json'))
|
2919
2920
|
end
|
2920
|
-
it
|
2921
|
-
@cli.timeline(
|
2922
|
-
expect(a_get(
|
2921
|
+
it 'requests the correct resource' do
|
2922
|
+
@cli.timeline('sferik')
|
2923
|
+
expect(a_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '20', :screen_name => 'sferik', :since_id => '244104558433951744'})).to have_been_made
|
2923
2924
|
end
|
2924
2925
|
end
|
2925
2926
|
end
|
2926
2927
|
end
|
2927
2928
|
|
2928
|
-
describe
|
2929
|
+
describe '#trends' do
|
2929
2930
|
before do
|
2930
|
-
stub_get(
|
2931
|
+
stub_get('/1.1/trends/place.json').with(:query => {:id => '1'}).to_return(:body => fixture('trends.json'))
|
2931
2932
|
end
|
2932
|
-
it
|
2933
|
+
it 'requests the correct resource' do
|
2933
2934
|
@cli.trends
|
2934
|
-
expect(a_get(
|
2935
|
+
expect(a_get('/1.1/trends/place.json').with(:query => {:id => '1'})).to have_been_made
|
2935
2936
|
end
|
2936
|
-
it
|
2937
|
+
it 'has the correct output' do
|
2937
2938
|
@cli.trends
|
2938
|
-
expect($stdout.string.chomp).to eq
|
2939
|
+
expect($stdout.string.chomp).to eq '#sevenwordsaftersex Walkman Allen Iverson'
|
2939
2940
|
end
|
2940
|
-
context
|
2941
|
+
context '--exclude-hashtags' do
|
2941
2942
|
before do
|
2942
|
-
@cli.options = @cli.options.merge(
|
2943
|
-
stub_get(
|
2943
|
+
@cli.options = @cli.options.merge('exclude-hashtags' => true)
|
2944
|
+
stub_get('/1.1/trends/place.json').with(:query => {:id => '1', :exclude => 'hashtags'}).to_return(:body => fixture('trends.json'))
|
2944
2945
|
end
|
2945
|
-
it
|
2946
|
+
it 'requests the correct resource' do
|
2946
2947
|
@cli.trends
|
2947
|
-
expect(a_get(
|
2948
|
+
expect(a_get('/1.1/trends/place.json').with(:query => {:id => '1', :exclude => 'hashtags'})).to have_been_made
|
2948
2949
|
end
|
2949
|
-
it
|
2950
|
+
it 'has the correct output' do
|
2950
2951
|
@cli.trends
|
2951
|
-
expect($stdout.string.chomp).to eq
|
2952
|
+
expect($stdout.string.chomp).to eq '#sevenwordsaftersex Walkman Allen Iverson'
|
2952
2953
|
end
|
2953
2954
|
end
|
2954
|
-
context
|
2955
|
+
context 'with a WOEID passed' do
|
2955
2956
|
before do
|
2956
|
-
stub_get(
|
2957
|
+
stub_get('/1.1/trends/place.json').with(:query => {:id => '2487956'}).to_return(:body => fixture('trends.json'))
|
2957
2958
|
end
|
2958
|
-
it
|
2959
|
-
@cli.trends(
|
2960
|
-
expect(a_get(
|
2959
|
+
it 'requests the correct resource' do
|
2960
|
+
@cli.trends('2487956')
|
2961
|
+
expect(a_get('/1.1/trends/place.json').with(:query => {:id => '2487956'})).to have_been_made
|
2961
2962
|
end
|
2962
|
-
it
|
2963
|
-
@cli.trends(
|
2964
|
-
expect($stdout.string.chomp).to eq
|
2963
|
+
it 'has the correct output' do
|
2964
|
+
@cli.trends('2487956')
|
2965
|
+
expect($stdout.string.chomp).to eq '#sevenwordsaftersex Walkman Allen Iverson'
|
2965
2966
|
end
|
2966
2967
|
end
|
2967
2968
|
end
|
2968
2969
|
|
2969
|
-
describe
|
2970
|
+
describe '#trend_locations' do
|
2970
2971
|
before do
|
2971
|
-
stub_get(
|
2972
|
+
stub_get('/1.1/trends/available.json').to_return(:body => fixture('locations.json'))
|
2972
2973
|
end
|
2973
|
-
it
|
2974
|
+
it 'requests the correct resource' do
|
2974
2975
|
@cli.trend_locations
|
2975
|
-
expect(a_get(
|
2976
|
+
expect(a_get('/1.1/trends/available.json')).to have_been_made
|
2976
2977
|
end
|
2977
|
-
it
|
2978
|
+
it 'has the correct output' do
|
2978
2979
|
@cli.trend_locations
|
2979
|
-
expect($stdout.string.chomp).to eq
|
2980
|
+
expect($stdout.string.chomp).to eq 'San Francisco Soweto United States Worldwide'
|
2980
2981
|
end
|
2981
|
-
context
|
2982
|
+
context '--csv' do
|
2982
2983
|
before do
|
2983
|
-
@cli.options = @cli.options.merge(
|
2984
|
+
@cli.options = @cli.options.merge('csv' => true)
|
2984
2985
|
end
|
2985
|
-
it
|
2986
|
+
it 'outputs in CSV format' do
|
2986
2987
|
@cli.trend_locations
|
2987
2988
|
expect($stdout.string.chomp).to eq <<-eos.chomp
|
2988
2989
|
WOEID,Parent ID,Type,Name,Country
|
2989
|
-
|
2990
|
-
|
2991
|
-
|
2992
|
-
|
2993
|
-
1,,Supername,Worldwide,""
|
2990
|
+
2487956,23424977,Town,San Francisco,United States
|
2991
|
+
1587677,23424942,Unknown,Soweto,South Africa
|
2992
|
+
23424977,1,Country,United States,United States
|
2993
|
+
1,0,Supername,Worldwide,""
|
2994
2994
|
eos
|
2995
2995
|
end
|
2996
2996
|
end
|
2997
|
-
context
|
2997
|
+
context '--long' do
|
2998
2998
|
before do
|
2999
|
-
@cli.options = @cli.options.merge(
|
2999
|
+
@cli.options = @cli.options.merge('long' => true)
|
3000
3000
|
end
|
3001
|
-
it
|
3001
|
+
it 'outputs in long format' do
|
3002
3002
|
@cli.trend_locations
|
3003
3003
|
expect($stdout.string.chomp).to eq <<-eos.chomp
|
3004
3004
|
WOEID Parent ID Type Name Country
|
3005
|
-
|
3006
|
-
|
3007
|
-
|
3008
|
-
|
3009
|
-
1 Supername Worldwide
|
3005
|
+
2487956 23424977 Town San Francisco United States
|
3006
|
+
1587677 23424942 Unknown Soweto South Africa
|
3007
|
+
23424977 1 Country United States United States
|
3008
|
+
1 0 Supername Worldwide
|
3010
3009
|
eos
|
3011
3010
|
end
|
3012
3011
|
end
|
3013
|
-
context
|
3012
|
+
context '--reverse' do
|
3014
3013
|
before do
|
3015
|
-
@cli.options = @cli.options.merge(
|
3014
|
+
@cli.options = @cli.options.merge('reverse' => true)
|
3016
3015
|
end
|
3017
|
-
it
|
3016
|
+
it 'reverses the order of the sort' do
|
3018
3017
|
@cli.trend_locations
|
3019
|
-
expect($stdout.string.chomp).to eq
|
3018
|
+
expect($stdout.string.chomp).to eq 'Worldwide United States Soweto San Francisco'
|
3020
3019
|
end
|
3021
3020
|
end
|
3022
|
-
context
|
3021
|
+
context '--sort=country' do
|
3023
3022
|
before do
|
3024
|
-
@cli.options = @cli.options.merge(
|
3023
|
+
@cli.options = @cli.options.merge('sort' => 'country')
|
3025
3024
|
end
|
3026
|
-
it
|
3025
|
+
it 'sorts by the country name' do
|
3027
3026
|
@cli.trend_locations
|
3028
|
-
expect($stdout.string.chomp).to
|
3027
|
+
expect($stdout.string.chomp).to match 'Worldwide Soweto San Francisco United States'
|
3029
3028
|
end
|
3030
3029
|
end
|
3031
|
-
context
|
3030
|
+
context '--sort=parent' do
|
3032
3031
|
before do
|
3033
|
-
@cli.options = @cli.options.merge(
|
3032
|
+
@cli.options = @cli.options.merge('sort' => 'parent')
|
3034
3033
|
end
|
3035
|
-
it
|
3034
|
+
it 'sorts by the parent ID' do
|
3036
3035
|
@cli.trend_locations
|
3037
|
-
expect($stdout.string.chomp).to eq
|
3036
|
+
expect($stdout.string.chomp).to eq 'Worldwide United States Soweto San Francisco'
|
3038
3037
|
end
|
3039
3038
|
end
|
3040
|
-
context
|
3039
|
+
context '--sort=type' do
|
3041
3040
|
before do
|
3042
|
-
@cli.options = @cli.options.merge(
|
3041
|
+
@cli.options = @cli.options.merge('sort' => 'type')
|
3043
3042
|
end
|
3044
|
-
it
|
3043
|
+
it 'sorts by the type' do
|
3045
3044
|
@cli.trend_locations
|
3046
|
-
expect($stdout.string.chomp).to eq
|
3045
|
+
expect($stdout.string.chomp).to eq 'United States Worldwide San Francisco Soweto'
|
3047
3046
|
end
|
3048
3047
|
end
|
3049
|
-
context
|
3048
|
+
context '--sort=woeid' do
|
3050
3049
|
before do
|
3051
|
-
@cli.options = @cli.options.merge(
|
3050
|
+
@cli.options = @cli.options.merge('sort' => 'woeid')
|
3052
3051
|
end
|
3053
|
-
it
|
3052
|
+
it 'sorts by the WOEID' do
|
3054
3053
|
@cli.trend_locations
|
3055
|
-
expect($stdout.string.chomp).to eq
|
3054
|
+
expect($stdout.string.chomp).to eq 'Worldwide Soweto San Francisco United States'
|
3056
3055
|
end
|
3057
3056
|
end
|
3058
|
-
context
|
3057
|
+
context '--unsorted' do
|
3059
3058
|
before do
|
3060
|
-
@cli.options = @cli.options.merge(
|
3059
|
+
@cli.options = @cli.options.merge('unsorted' => true)
|
3061
3060
|
end
|
3062
|
-
it
|
3061
|
+
it 'is not sorted' do
|
3063
3062
|
@cli.trend_locations
|
3064
|
-
expect($stdout.string.chomp).to eq
|
3063
|
+
expect($stdout.string.chomp).to eq 'Worldwide San Francisco United States Soweto'
|
3065
3064
|
end
|
3066
3065
|
end
|
3067
3066
|
end
|
3068
3067
|
|
3069
|
-
describe
|
3068
|
+
describe '#unfollow' do
|
3070
3069
|
before do
|
3071
|
-
@cli.options = @cli.options.merge(
|
3070
|
+
@cli.options = @cli.options.merge('profile' => fixture_path + '/.trc')
|
3072
3071
|
end
|
3073
|
-
context
|
3074
|
-
it
|
3075
|
-
stub_post(
|
3076
|
-
@cli.unfollow(
|
3077
|
-
expect(a_post(
|
3072
|
+
context 'one user' do
|
3073
|
+
it 'requests the correct resource' do
|
3074
|
+
stub_post('/1.1/friendships/destroy.json').with(:body => {:screen_name => 'sferik'}).to_return(:body => fixture('sferik.json'))
|
3075
|
+
@cli.unfollow('sferik')
|
3076
|
+
expect(a_post('/1.1/friendships/destroy.json').with(:body => {:screen_name => 'sferik'})).to have_been_made
|
3078
3077
|
end
|
3079
|
-
it
|
3080
|
-
stub_post(
|
3081
|
-
@cli.unfollow(
|
3078
|
+
it 'has the correct output' do
|
3079
|
+
stub_post('/1.1/friendships/destroy.json').with(:body => {:screen_name => 'sferik'}).to_return(:body => fixture('sferik.json'))
|
3080
|
+
@cli.unfollow('sferik')
|
3082
3081
|
expect($stdout.string).to match /^@testcli is no longer following 1 user\.$/
|
3083
3082
|
end
|
3084
|
-
context
|
3083
|
+
context '--id' do
|
3085
3084
|
before do
|
3086
|
-
@cli.options = @cli.options.merge(
|
3087
|
-
stub_post(
|
3085
|
+
@cli.options = @cli.options.merge('id' => true)
|
3086
|
+
stub_post('/1.1/friendships/destroy.json').with(:body => {:user_id => '7505382'}).to_return(:body => fixture('sferik.json'))
|
3088
3087
|
end
|
3089
|
-
it
|
3090
|
-
@cli.unfollow(
|
3091
|
-
expect(a_post(
|
3088
|
+
it 'requests the correct resource' do
|
3089
|
+
@cli.unfollow('7505382')
|
3090
|
+
expect(a_post('/1.1/friendships/destroy.json').with(:body => {:user_id => '7505382'})).to have_been_made
|
3092
3091
|
end
|
3093
3092
|
end
|
3094
|
-
context
|
3095
|
-
it
|
3096
|
-
stub_post(
|
3093
|
+
context 'Twitter is down' do
|
3094
|
+
it 'retries 3 times and then raise an error' do
|
3095
|
+
stub_post('/1.1/friendships/destroy.json').with(:body => {:screen_name => 'sferik'}).to_return(:status => 502)
|
3097
3096
|
expect do
|
3098
|
-
@cli.unfollow(
|
3097
|
+
@cli.unfollow('sferik')
|
3099
3098
|
end.to raise_error(Twitter::Error::BadGateway)
|
3100
|
-
expect(a_post(
|
3099
|
+
expect(a_post('/1.1/friendships/destroy.json').with(:body => {:screen_name => 'sferik'})).to have_been_made.times(3)
|
3101
3100
|
end
|
3102
3101
|
end
|
3103
3102
|
end
|
3104
3103
|
end
|
3105
3104
|
|
3106
|
-
describe
|
3105
|
+
describe '#update' do
|
3107
3106
|
before do
|
3108
|
-
@cli.options = @cli.options.merge(
|
3109
|
-
stub_post(
|
3110
|
-
stub_request(:get,
|
3111
|
-
stub_request(:get,
|
3107
|
+
@cli.options = @cli.options.merge('profile' => fixture_path + '/.trc')
|
3108
|
+
stub_post('/1.1/statuses/update.json').with(:body => {:status => 'Testing', :trim_user => 'true'}).to_return(:body => fixture('status.json'))
|
3109
|
+
stub_request(:get, 'http://checkip.dyndns.org/').to_return(:body => fixture('checkip.html'), :headers => {:content_type => 'text/html'})
|
3110
|
+
stub_request(:get, 'http://www.geoplugin.net/xml.gp?ip=50.131.22.169').to_return(:body => fixture('geoplugin.xml'), :headers => {:content_type => 'application/xml'})
|
3112
3111
|
end
|
3113
|
-
it
|
3114
|
-
@cli.update(
|
3115
|
-
expect(a_post(
|
3116
|
-
expect(a_request(:get,
|
3117
|
-
expect(a_request(:get,
|
3112
|
+
it 'requests the correct resource' do
|
3113
|
+
@cli.update('Testing')
|
3114
|
+
expect(a_post('/1.1/statuses/update.json').with(:body => {:status => 'Testing', :trim_user => 'true'})).to have_been_made
|
3115
|
+
expect(a_request(:get, 'http://checkip.dyndns.org/')).not_to have_been_made
|
3116
|
+
expect(a_request(:get, 'http://www.geoplugin.net/xml.gp?ip=50.131.22.169')).not_to have_been_made
|
3118
3117
|
end
|
3119
|
-
it
|
3120
|
-
@cli.update(
|
3121
|
-
expect($stdout.string.split("\n").first).to eq
|
3118
|
+
it 'has the correct output' do
|
3119
|
+
@cli.update('Testing')
|
3120
|
+
expect($stdout.string.split("\n").first).to eq 'Tweet posted by @testcli.'
|
3122
3121
|
end
|
3123
|
-
context
|
3122
|
+
context 'with file' do
|
3124
3123
|
before do
|
3125
|
-
@cli.options = @cli.options.merge(
|
3126
|
-
stub_post(
|
3124
|
+
@cli.options = @cli.options.merge('file' => fixture_path + '/long.png')
|
3125
|
+
stub_post('/1.1/statuses/update_with_media.json').to_return(:body => fixture('status.json'))
|
3127
3126
|
end
|
3128
|
-
it
|
3129
|
-
@cli.update(
|
3130
|
-
expect(a_post(
|
3127
|
+
it 'requests the correct resource' do
|
3128
|
+
@cli.update('Testing')
|
3129
|
+
expect(a_post('/1.1/statuses/update_with_media.json')).to have_been_made
|
3131
3130
|
end
|
3132
|
-
it
|
3133
|
-
@cli.update(
|
3134
|
-
expect($stdout.string.split("\n").first).to eq
|
3131
|
+
it 'has the correct output' do
|
3132
|
+
@cli.update('Testing')
|
3133
|
+
expect($stdout.string.split("\n").first).to eq 'Tweet posted by @testcli.'
|
3135
3134
|
end
|
3136
3135
|
end
|
3137
|
-
context
|
3136
|
+
context '--location' do
|
3138
3137
|
before do
|
3139
|
-
@cli.options = @cli.options.merge(
|
3140
|
-
stub_post(
|
3138
|
+
@cli.options = @cli.options.merge('location' => 'location')
|
3139
|
+
stub_post('/1.1/statuses/update.json').with(:body => {:status => 'Testing', :lat => '37.76969909668', :long => '-122.39330291748', :trim_user => 'true'}).to_return(:body => fixture('status.json'))
|
3141
3140
|
end
|
3142
|
-
it
|
3143
|
-
@cli.update(
|
3144
|
-
expect(a_post(
|
3145
|
-
expect(a_request(:get,
|
3146
|
-
expect(a_request(:get,
|
3141
|
+
it 'requests the correct resource' do
|
3142
|
+
@cli.update('Testing')
|
3143
|
+
expect(a_post('/1.1/statuses/update.json').with(:body => {:status => 'Testing', :lat => '37.76969909668', :long => '-122.39330291748', :trim_user => 'true'})).to have_been_made
|
3144
|
+
expect(a_request(:get, 'http://checkip.dyndns.org/')).to have_been_made
|
3145
|
+
expect(a_request(:get, 'http://www.geoplugin.net/xml.gp?ip=50.131.22.169')).to have_been_made
|
3147
3146
|
end
|
3148
|
-
it
|
3149
|
-
@cli.update(
|
3150
|
-
expect($stdout.string.split("\n").first).to eq
|
3147
|
+
it 'has the correct output' do
|
3148
|
+
@cli.update('Testing')
|
3149
|
+
expect($stdout.string.split("\n").first).to eq 'Tweet posted by @testcli.'
|
3151
3150
|
end
|
3152
3151
|
end
|
3153
3152
|
context "--location 'latitude,longitude'" do
|
3154
3153
|
before do
|
3155
|
-
@cli.options = @cli.options.merge(
|
3156
|
-
stub_post(
|
3154
|
+
@cli.options = @cli.options.merge('location' => '41.03132,28.9869')
|
3155
|
+
stub_post('/1.1/statuses/update.json').with(:body => {:status => 'Testing', :lat => '41.03132', :long => '28.9869', :trim_user => 'true'}).to_return(:body => fixture('status.json'))
|
3157
3156
|
end
|
3158
|
-
it
|
3159
|
-
@cli.update(
|
3160
|
-
expect(a_post(
|
3161
|
-
expect(a_request(:get,
|
3162
|
-
expect(a_request(:get,
|
3157
|
+
it 'requests the correct resource' do
|
3158
|
+
@cli.update('Testing')
|
3159
|
+
expect(a_post('/1.1/statuses/update.json').with(:body => {:status => 'Testing', :lat => '41.03132', :long => '28.9869', :trim_user => 'true'})).to have_been_made
|
3160
|
+
expect(a_request(:get, 'http://checkip.dyndns.org/')).not_to have_been_made
|
3161
|
+
expect(a_request(:get, 'http://www.geoplugin.net/xml.gp?ip=50.131.22.169')).not_to have_been_made
|
3163
3162
|
end
|
3164
|
-
it
|
3165
|
-
@cli.update(
|
3166
|
-
expect($stdout.string.split("\n").first).to eq
|
3163
|
+
it 'has the correct output' do
|
3164
|
+
@cli.update('Testing')
|
3165
|
+
expect($stdout.string.split("\n").first).to eq 'Tweet posted by @testcli.'
|
3167
3166
|
end
|
3168
3167
|
end
|
3169
3168
|
end
|
3170
3169
|
|
3171
|
-
describe
|
3170
|
+
describe '#users' do
|
3172
3171
|
before do
|
3173
|
-
stub_post(
|
3172
|
+
stub_post('/1.1/users/lookup.json').with(:body => {:screen_name => 'sferik,pengwynn'}).to_return(:body => fixture('users.json'))
|
3174
3173
|
end
|
3175
|
-
it
|
3176
|
-
@cli.users(
|
3177
|
-
expect(a_post(
|
3174
|
+
it 'requests the correct resource' do
|
3175
|
+
@cli.users('sferik', 'pengwynn')
|
3176
|
+
expect(a_post('/1.1/users/lookup.json').with(:body => {:screen_name => 'sferik,pengwynn'})).to have_been_made
|
3178
3177
|
end
|
3179
|
-
it
|
3180
|
-
@cli.users(
|
3181
|
-
expect($stdout.string.chomp).to eq
|
3178
|
+
it 'has the correct output' do
|
3179
|
+
@cli.users('sferik', 'pengwynn')
|
3180
|
+
expect($stdout.string.chomp).to eq 'pengwynn sferik'
|
3182
3181
|
end
|
3183
|
-
context
|
3182
|
+
context '--csv' do
|
3184
3183
|
before do
|
3185
|
-
@cli.options = @cli.options.merge(
|
3184
|
+
@cli.options = @cli.options.merge('csv' => true)
|
3186
3185
|
end
|
3187
|
-
it
|
3188
|
-
@cli.users(
|
3186
|
+
it 'outputs in CSV format' do
|
3187
|
+
@cli.users('sferik', 'pengwynn')
|
3189
3188
|
expect($stdout.string).to eq <<-eos
|
3190
3189
|
ID,Since,Last tweeted at,Tweets,Favorites,Listed,Following,Followers,Screen name,Name,Verified,Protected,Bio,Status,Location,URL
|
3191
3190
|
14100886,2008-03-08 16:34:22 +0000,2012-07-07 20:33:19 +0000,6940,192,358,3427,5457,pengwynn,Wynn Netherland,false,false,"Christian, husband, father, GitHubber, Co-host of @thechangelog, Co-author of Sass, Compass, #CSS book http://wynn.fm/sass-meap",@akosmasoftware Sass book! @hcatlin @nex3 are the brains behind Sass. :-),"Denton, TX",http://wynnnetherland.com
|
@@ -3193,12 +3192,12 @@ ID,Since,Last tweeted at,Tweets,Favorites,Listed,Following,Followers,Screen name
|
|
3193
3192
|
eos
|
3194
3193
|
end
|
3195
3194
|
end
|
3196
|
-
context
|
3195
|
+
context '--long' do
|
3197
3196
|
before do
|
3198
|
-
@cli.options = @cli.options.merge(
|
3197
|
+
@cli.options = @cli.options.merge('long' => true)
|
3199
3198
|
end
|
3200
|
-
it
|
3201
|
-
@cli.users(
|
3199
|
+
it 'outputs in long format' do
|
3200
|
+
@cli.users('sferik', 'pengwynn')
|
3202
3201
|
expect($stdout.string).to eq <<-eos
|
3203
3202
|
ID Since Last tweeted at Tweets Favorites Listed Following...
|
3204
3203
|
14100886 Mar 8 2008 Jul 7 12:33 6940 192 358 3427...
|
@@ -3206,116 +3205,116 @@ ID Since Last tweeted at Tweets Favorites Listed Following...
|
|
3206
3205
|
eos
|
3207
3206
|
end
|
3208
3207
|
end
|
3209
|
-
context
|
3208
|
+
context '--reverse' do
|
3210
3209
|
before do
|
3211
|
-
@cli.options = @cli.options.merge(
|
3210
|
+
@cli.options = @cli.options.merge('reverse' => true)
|
3212
3211
|
end
|
3213
|
-
it
|
3214
|
-
@cli.users(
|
3215
|
-
expect($stdout.string.chomp).to eq
|
3212
|
+
it 'reverses the order of the sort' do
|
3213
|
+
@cli.users('sferik', 'pengwynn')
|
3214
|
+
expect($stdout.string.chomp).to eq 'sferik pengwynn'
|
3216
3215
|
end
|
3217
3216
|
end
|
3218
|
-
context
|
3217
|
+
context '--sort=favorites' do
|
3219
3218
|
before do
|
3220
|
-
@cli.options = @cli.options.merge(
|
3219
|
+
@cli.options = @cli.options.merge('sort' => 'favorites')
|
3221
3220
|
end
|
3222
|
-
it
|
3223
|
-
@cli.users(
|
3224
|
-
expect($stdout.string.chomp).to eq
|
3221
|
+
it 'sorts by the number of favorites' do
|
3222
|
+
@cli.users('sferik', 'pengwynn')
|
3223
|
+
expect($stdout.string.chomp).to eq 'pengwynn sferik'
|
3225
3224
|
end
|
3226
3225
|
end
|
3227
|
-
context
|
3226
|
+
context '--sort=followers' do
|
3228
3227
|
before do
|
3229
|
-
@cli.options = @cli.options.merge(
|
3228
|
+
@cli.options = @cli.options.merge('sort' => 'followers')
|
3230
3229
|
end
|
3231
|
-
it
|
3232
|
-
@cli.users(
|
3233
|
-
expect($stdout.string.chomp).to eq
|
3230
|
+
it 'sorts by the number of followers' do
|
3231
|
+
@cli.users('sferik', 'pengwynn')
|
3232
|
+
expect($stdout.string.chomp).to eq 'sferik pengwynn'
|
3234
3233
|
end
|
3235
3234
|
end
|
3236
|
-
context
|
3235
|
+
context '--sort=friends' do
|
3237
3236
|
before do
|
3238
|
-
@cli.options = @cli.options.merge(
|
3237
|
+
@cli.options = @cli.options.merge('sort' => 'friends')
|
3239
3238
|
end
|
3240
|
-
it
|
3241
|
-
@cli.users(
|
3242
|
-
expect($stdout.string.chomp).to eq
|
3239
|
+
it 'sorts by the number of friends' do
|
3240
|
+
@cli.users('sferik', 'pengwynn')
|
3241
|
+
expect($stdout.string.chomp).to eq 'sferik pengwynn'
|
3243
3242
|
end
|
3244
3243
|
end
|
3245
|
-
context
|
3244
|
+
context '--id' do
|
3246
3245
|
before do
|
3247
|
-
@cli.options = @cli.options.merge(
|
3248
|
-
stub_post(
|
3246
|
+
@cli.options = @cli.options.merge('id' => true)
|
3247
|
+
stub_post('/1.1/users/lookup.json').with(:body => {:user_id => '7505382,14100886'}).to_return(:body => fixture('users.json'))
|
3249
3248
|
end
|
3250
|
-
it
|
3251
|
-
@cli.users(
|
3252
|
-
expect(a_post(
|
3249
|
+
it 'requests the correct resource' do
|
3250
|
+
@cli.users('7505382', '14100886')
|
3251
|
+
expect(a_post('/1.1/users/lookup.json').with(:body => {:user_id => '7505382,14100886'})).to have_been_made
|
3253
3252
|
end
|
3254
3253
|
end
|
3255
|
-
context
|
3254
|
+
context '--sort=listed' do
|
3256
3255
|
before do
|
3257
|
-
@cli.options = @cli.options.merge(
|
3256
|
+
@cli.options = @cli.options.merge('sort' => 'listed')
|
3258
3257
|
end
|
3259
|
-
it
|
3260
|
-
@cli.users(
|
3261
|
-
expect($stdout.string.chomp).to eq
|
3258
|
+
it 'sorts by the number of list memberships' do
|
3259
|
+
@cli.users('sferik', 'pengwynn')
|
3260
|
+
expect($stdout.string.chomp).to eq 'sferik pengwynn'
|
3262
3261
|
end
|
3263
3262
|
end
|
3264
|
-
context
|
3263
|
+
context '--sort=since' do
|
3265
3264
|
before do
|
3266
|
-
@cli.options = @cli.options.merge(
|
3265
|
+
@cli.options = @cli.options.merge('sort' => 'since')
|
3267
3266
|
end
|
3268
|
-
it
|
3269
|
-
@cli.users(
|
3270
|
-
expect($stdout.string.chomp).to eq
|
3267
|
+
it 'sorts by the time when Twitter acount was created' do
|
3268
|
+
@cli.users('sferik', 'pengwynn')
|
3269
|
+
expect($stdout.string.chomp).to eq 'sferik pengwynn'
|
3271
3270
|
end
|
3272
3271
|
end
|
3273
|
-
context
|
3272
|
+
context '--sort=tweets' do
|
3274
3273
|
before do
|
3275
|
-
@cli.options = @cli.options.merge(
|
3274
|
+
@cli.options = @cli.options.merge('sort' => 'tweets')
|
3276
3275
|
end
|
3277
|
-
it
|
3278
|
-
@cli.users(
|
3279
|
-
expect($stdout.string.chomp).to eq
|
3276
|
+
it 'sorts by the number of Tweets' do
|
3277
|
+
@cli.users('sferik', 'pengwynn')
|
3278
|
+
expect($stdout.string.chomp).to eq 'pengwynn sferik'
|
3280
3279
|
end
|
3281
3280
|
end
|
3282
|
-
context
|
3281
|
+
context '--sort=tweeted' do
|
3283
3282
|
before do
|
3284
|
-
@cli.options = @cli.options.merge(
|
3283
|
+
@cli.options = @cli.options.merge('sort' => 'tweeted')
|
3285
3284
|
end
|
3286
|
-
it
|
3287
|
-
@cli.users(
|
3288
|
-
expect($stdout.string.chomp).to eq
|
3285
|
+
it 'sorts by the time of the last Tweet' do
|
3286
|
+
@cli.users('sferik', 'pengwynn')
|
3287
|
+
expect($stdout.string.chomp).to eq 'pengwynn sferik'
|
3289
3288
|
end
|
3290
3289
|
end
|
3291
|
-
context
|
3290
|
+
context '--unsorted' do
|
3292
3291
|
before do
|
3293
|
-
@cli.options = @cli.options.merge(
|
3292
|
+
@cli.options = @cli.options.merge('unsorted' => true)
|
3294
3293
|
end
|
3295
|
-
it
|
3296
|
-
@cli.users(
|
3297
|
-
expect($stdout.string.chomp).to eq
|
3294
|
+
it 'is not sorted' do
|
3295
|
+
@cli.users('sferik', 'pengwynn')
|
3296
|
+
expect($stdout.string.chomp).to eq 'pengwynn sferik'
|
3298
3297
|
end
|
3299
3298
|
end
|
3300
3299
|
end
|
3301
3300
|
|
3302
|
-
describe
|
3303
|
-
it
|
3301
|
+
describe '#version' do
|
3302
|
+
it 'has the correct output' do
|
3304
3303
|
@cli.version
|
3305
3304
|
expect($stdout.string.chomp).to eq T::Version.to_s
|
3306
3305
|
end
|
3307
3306
|
end
|
3308
3307
|
|
3309
|
-
describe
|
3308
|
+
describe '#whois' do
|
3310
3309
|
before do
|
3311
|
-
stub_get(
|
3310
|
+
stub_get('/1.1/users/show.json').with(:query => {:screen_name => 'sferik'}).to_return(:body => fixture('sferik.json'))
|
3312
3311
|
end
|
3313
|
-
it
|
3314
|
-
@cli.whois(
|
3315
|
-
expect(a_get(
|
3312
|
+
it 'requests the correct resource' do
|
3313
|
+
@cli.whois('sferik')
|
3314
|
+
expect(a_get('/1.1/users/show.json').with(:query => {:screen_name => 'sferik'})).to have_been_made
|
3316
3315
|
end
|
3317
|
-
it
|
3318
|
-
@cli.whois(
|
3316
|
+
it 'has the correct output' do
|
3317
|
+
@cli.whois('sferik')
|
3319
3318
|
expect($stdout.string).to eq <<-eos
|
3320
3319
|
ID 7505382
|
3321
3320
|
Since Jul 16 2007 (4 years ago)
|
@@ -3332,34 +3331,34 @@ Location San Francisco
|
|
3332
3331
|
URL https://github.com/sferik
|
3333
3332
|
eos
|
3334
3333
|
end
|
3335
|
-
context
|
3334
|
+
context '--csv' do
|
3336
3335
|
before do
|
3337
|
-
@cli.options = @cli.options.merge(
|
3336
|
+
@cli.options = @cli.options.merge('csv' => true)
|
3338
3337
|
end
|
3339
|
-
it
|
3340
|
-
@cli.whois(
|
3338
|
+
it 'has the correct output' do
|
3339
|
+
@cli.whois('sferik')
|
3341
3340
|
expect($stdout.string).to eq <<-eos
|
3342
3341
|
ID,Since,Last tweeted at,Tweets,Favorites,Listed,Following,Followers,Screen name,Name,Verified,Protected,Bio,Status,Location,URL
|
3343
3342
|
7505382,2007-07-16 12:59:01 +0000,2012-07-08 18:29:20 +0000,7890,3755,118,212,2262,sferik,Erik Michaels-Ober,false,false,Vagabond.,@goldman You're near my home town! Say hi to Woodstock for me.,San Francisco,https://github.com/sferik
|
3344
3343
|
eos
|
3345
3344
|
end
|
3346
3345
|
end
|
3347
|
-
context
|
3346
|
+
context '--id' do
|
3348
3347
|
before do
|
3349
|
-
@cli.options = @cli.options.merge(
|
3350
|
-
stub_get(
|
3348
|
+
@cli.options = @cli.options.merge('id' => true)
|
3349
|
+
stub_get('/1.1/users/show.json').with(:query => {:user_id => '7505382'}).to_return(:body => fixture('sferik.json'))
|
3351
3350
|
end
|
3352
|
-
it
|
3353
|
-
@cli.whois(
|
3354
|
-
expect(a_get(
|
3351
|
+
it 'requests the correct resource' do
|
3352
|
+
@cli.whois('7505382')
|
3353
|
+
expect(a_get('/1.1/users/show.json').with(:query => {:user_id => '7505382'})).to have_been_made
|
3355
3354
|
end
|
3356
3355
|
end
|
3357
|
-
context
|
3356
|
+
context '--long' do
|
3358
3357
|
before do
|
3359
|
-
@cli.options = @cli.options.merge(
|
3358
|
+
@cli.options = @cli.options.merge('long' => true)
|
3360
3359
|
end
|
3361
|
-
it
|
3362
|
-
@cli.whois(
|
3360
|
+
it 'outputs in long format' do
|
3361
|
+
@cli.whois('sferik')
|
3363
3362
|
expect($stdout.string).to eq <<-eos
|
3364
3363
|
ID Since Last tweeted at Tweets Favorites Listed Following ...
|
3365
3364
|
7505382 Jul 16 2007 Jul 8 10:29 7890 3755 118 212 ...
|