t 2.7.0 → 2.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +4 -4
  3. data/bin/t +1 -1
  4. data/lib/t/cli.rb +26 -2
  5. data/lib/t/list.rb +0 -2
  6. data/lib/t/printable.rb +6 -5
  7. data/lib/t/stream.rb +0 -20
  8. data/lib/t/version.rb +1 -1
  9. data/t.gemspec +4 -8
  10. metadata +6 -131
  11. data/Rakefile +0 -21
  12. data/spec/cli_spec.rb +0 -4141
  13. data/spec/delete_spec.rb +0 -250
  14. data/spec/editor_spec.rb +0 -102
  15. data/spec/fixtures/200_direct_messages.json +0 -1
  16. data/spec/fixtures/200_statuses.json +0 -1
  17. data/spec/fixtures/501_ids.json +0 -1
  18. data/spec/fixtures/501_users_list.json +0 -1
  19. data/spec/fixtures/access_token +0 -1
  20. data/spec/fixtures/bearer_token.json +0 -1
  21. data/spec/fixtures/checkip.html +0 -1
  22. data/spec/fixtures/direct_message.json +0 -1
  23. data/spec/fixtures/direct_messages.json +0 -1
  24. data/spec/fixtures/empty_array.json +0 -1
  25. data/spec/fixtures/empty_cursor.json +0 -1
  26. data/spec/fixtures/favorites.json +0 -1
  27. data/spec/fixtures/followers_ids.json +0 -1
  28. data/spec/fixtures/following.json +0 -1
  29. data/spec/fixtures/friends_ids.json +0 -1
  30. data/spec/fixtures/gem.json +0 -1
  31. data/spec/fixtures/geo.json +0 -414
  32. data/spec/fixtures/geo_no_city.json +0 -344
  33. data/spec/fixtures/geo_no_state.json +0 -299
  34. data/spec/fixtures/geoplugin.xml +0 -17
  35. data/spec/fixtures/ids_list.json +0 -1
  36. data/spec/fixtures/ids_list2.json +0 -1
  37. data/spec/fixtures/list.json +0 -1
  38. data/spec/fixtures/lists.json +0 -1
  39. data/spec/fixtures/locations.json +0 -1
  40. data/spec/fixtures/long.png +0 -0
  41. data/spec/fixtures/matrix.json +0 -1
  42. data/spec/fixtures/me.jpg +0 -0
  43. data/spec/fixtures/not_following.json +0 -1
  44. data/spec/fixtures/not_found.json +0 -1
  45. data/spec/fixtures/rate_limit_status.json +0 -1
  46. data/spec/fixtures/recommendations.json +0 -1
  47. data/spec/fixtures/request_token +0 -1
  48. data/spec/fixtures/retweet.json +0 -1
  49. data/spec/fixtures/search.json +0 -1
  50. data/spec/fixtures/search2.json +0 -1
  51. data/spec/fixtures/search_with_entities.json +0 -1
  52. data/spec/fixtures/settings.json +0 -1
  53. data/spec/fixtures/sferik.json +0 -1
  54. data/spec/fixtures/status.json +0 -1
  55. data/spec/fixtures/status_no_attributes.json +0 -1
  56. data/spec/fixtures/status_no_country.json +0 -1
  57. data/spec/fixtures/status_no_full_name.json +0 -1
  58. data/spec/fixtures/status_no_locality.json +0 -1
  59. data/spec/fixtures/status_no_place.json +0 -1
  60. data/spec/fixtures/status_no_street_address.json +0 -1
  61. data/spec/fixtures/status_with_mention.json +0 -1
  62. data/spec/fixtures/statuses.json +0 -1
  63. data/spec/fixtures/trends.json +0 -1
  64. data/spec/fixtures/users.json +0 -1
  65. data/spec/fixtures/users_list.json +0 -1
  66. data/spec/fixtures/we_concept_bg2.png +0 -0
  67. data/spec/helper.rb +0 -78
  68. data/spec/list_spec.rb +0 -812
  69. data/spec/rcfile_spec.rb +0 -221
  70. data/spec/search_spec.rb +0 -944
  71. data/spec/set_spec.rb +0 -154
  72. data/spec/stream_spec.rb +0 -286
  73. data/spec/utils_spec.rb +0 -96
data/Rakefile DELETED
@@ -1,21 +0,0 @@
1
- require 'bundler'
2
- Bundler::GemHelper.install_tasks
3
-
4
- require 'rspec/core/rake_task'
5
- RSpec::Core::RakeTask.new(:spec)
6
-
7
- begin
8
- require 'rubocop/rake_task'
9
- RuboCop::RakeTask.new
10
- rescue LoadError
11
- desc 'Run RuboCop'
12
- task :rubocop do
13
- $stderr.puts 'Rubocop is disabled'
14
- end
15
- end
16
-
17
- Dir.glob('tasks/*.rake').each { |r| import r }
18
-
19
- task :release => ['completion:zsh', 'completion:bash']
20
- task :test => :spec
21
- task :default => [:spec, :rubocop]
@@ -1,4141 +0,0 @@
1
- # encoding: utf-8
2
- require 'helper'
3
-
4
- describe T::CLI do
5
-
6
- before :all do
7
- Timecop.freeze(Time.utc(2011, 11, 24, 16, 20, 0))
8
- T.utc_offset = 'PST'
9
- end
10
-
11
- before do
12
- T::RCFile.instance.path = fixture_path + '/.trc'
13
- @cli = T::CLI.new
14
- @cli.options = @cli.options.merge('color' => 'always')
15
- @old_stderr = $stderr
16
- $stderr = StringIO.new
17
- @old_stdout = $stdout
18
- $stdout = StringIO.new
19
- end
20
-
21
- after do
22
- T::RCFile.instance.reset
23
- $stderr = @old_stderr
24
- $stdout = @old_stdout
25
- end
26
-
27
- after :all do
28
- T.utc_offset = nil
29
- Timecop.return
30
- end
31
-
32
- describe '#account' do
33
- before do
34
- @cli.options = @cli.options.merge('profile' => fixture_path + '/.trc')
35
- end
36
- it 'has the correct output' do
37
- @cli.accounts
38
- expect($stdout.string).to eq <<-eos
39
- testcli
40
- abc123 (active)
41
- eos
42
- end
43
- end
44
-
45
- describe '#authorize' do
46
- before do
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 => {:skip_status => 'true'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
51
- end
52
- it 'requests the correct resource' do
53
- expect(Readline).to receive(:readline).with('Press [Enter] to open the Twitter Developer site. ', true).and_return("\n")
54
- expect(Readline).to receive(:readline).with('Enter your API key: ', true).and_return('abc123')
55
- expect(Readline).to receive(:readline).with('Enter your API secret: ', true).and_return('asdfasd223sd2')
56
- expect(Readline).to receive(:readline).with('Press [Enter] to open the Twitter app authorization page. ', true).and_return("\n")
57
- expect(Readline).to receive(:readline).with('Enter the supplied PIN: ', true).and_return('1234567890')
58
- @cli.authorize
59
- expect(a_post('/oauth/request_token')).to have_been_made
60
- expect(a_post('/oauth/access_token')).to have_been_made
61
- expect(a_get('/1.1/account/verify_credentials.json').with(:query => {:skip_status => 'true'})).to have_been_made
62
- end
63
- it 'does not raise error' do
64
- expect do
65
- expect(Readline).to receive(:readline).with('Press [Enter] to open the Twitter Developer site. ', true).and_return("\n")
66
- expect(Readline).to receive(:readline).with('Enter your API key: ', true).and_return('abc123')
67
- expect(Readline).to receive(:readline).with('Enter your API secret: ', true).and_return('asdfasd223sd2')
68
- expect(Readline).to receive(:readline).with('Press [Enter] to open the Twitter app authorization page. ', true).and_return("\n")
69
- expect(Readline).to receive(:readline).with('Enter the supplied PIN: ', true).and_return('1234567890')
70
- @cli.authorize
71
- end.not_to raise_error
72
- end
73
- context 'empty RC file' do
74
- before do
75
- @cli.options = @cli.options.merge('profile' => project_path + '/tmp/empty', 'display-uri' => true)
76
- end
77
- after do
78
- File.delete(project_path + '/tmp/empty')
79
- end
80
- it 'requests the correct resource' do
81
- expect(Readline).to receive(:readline).with('Press [Enter] to open the Twitter Developer site. ', true).and_return("\n")
82
- expect(Readline).to receive(:readline).with('Enter your API key: ', true).and_return('abc123')
83
- expect(Readline).to receive(:readline).with('Enter your API secret: ', true).and_return('asdfasd223sd2')
84
- expect(Readline).to receive(:readline).with('Press [Enter] to open the Twitter app authorization page. ', true).and_return("\n")
85
- expect(Readline).to receive(:readline).with('Enter the supplied PIN: ', true).and_return('1234567890')
86
- @cli.authorize
87
- expect(a_post('/oauth/request_token')).to have_been_made
88
- expect(a_post('/oauth/access_token')).to have_been_made
89
- expect(a_get('/1.1/account/verify_credentials.json').with(:query => {:skip_status => 'true'})).to have_been_made
90
- end
91
- it 'does not raise error' do
92
- expect do
93
- expect(Readline).to receive(:readline).with('Press [Enter] to open the Twitter Developer site. ', true).and_return("\n")
94
- expect(Readline).to receive(:readline).with('Enter your API key: ', true).and_return('abc123')
95
- expect(Readline).to receive(:readline).with('Enter your API secret: ', true).and_return('asdfasd223sd2')
96
- expect(Readline).to receive(:readline).with('Press [Enter] to open the Twitter app authorization page. ', true).and_return("\n")
97
- expect(Readline).to receive(:readline).with('Enter the supplied PIN: ', true).and_return('1234567890')
98
- @cli.authorize
99
- end.not_to raise_error
100
- end
101
- end
102
- end
103
-
104
- describe '#block' do
105
- before do
106
- @cli.options = @cli.options.merge('profile' => fixture_path + '/.trc')
107
- stub_post('/1.1/blocks/create.json').with(:body => {:screen_name => 'sferik'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
108
- end
109
- it 'requests the correct resource' do
110
- @cli.block('sferik')
111
- expect(a_post('/1.1/blocks/create.json').with(:body => {:screen_name => 'sferik'})).to have_been_made
112
- end
113
- it 'has the correct output' do
114
- @cli.block('sferik')
115
- expect($stdout.string).to match(/^@testcli blocked 1 user/)
116
- end
117
- context '--id' do
118
- before do
119
- @cli.options = @cli.options.merge('id' => true)
120
- stub_post('/1.1/blocks/create.json').with(:body => {:user_id => '7505382'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
121
- end
122
- it 'requests the correct resource' do
123
- @cli.block('7505382')
124
- expect(a_post('/1.1/blocks/create.json').with(:body => {:user_id => '7505382'})).to have_been_made
125
- end
126
- end
127
- end
128
-
129
- describe '#direct_messages' do
130
- before do
131
- stub_get('/1.1/direct_messages.json').with(:query => {:count => '20', :include_entities => 'false'}).to_return(:body => fixture('direct_messages.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
132
- stub_get('/1.1/direct_messages.json').with(:query => {:count => '10', :max_id => '1624782205', :include_entities => 'false'}).to_return(:body => fixture('empty_array.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
133
- end
134
- it 'requests the correct resource' do
135
- @cli.direct_messages
136
- expect(a_get('/1.1/direct_messages.json').with(:query => {:count => '20', :include_entities => 'false'})).to have_been_made
137
- end
138
- it 'has the correct output' do
139
- @cli.direct_messages
140
- expect($stdout.string).to eq <<-eos
141
- @sferik
142
- Sounds good. Meeting Tuesday is fine.
143
-
144
- @sferik
145
- That's great news! Let's plan to chat around 8 AM tomorrow Pacific time. Does
146
- that work for you?
147
-
148
- @sferik
149
- I asked Yehuda about the stipend. I believe it has already been sent. Glad
150
- you're feeling better.
151
-
152
- @sferik
153
- Just checking in. How's everything going?
154
-
155
- @sferik
156
- Not sure about the payment. Feel free to ask Leah or Yehuda directly. Think
157
- you'll be able to finish up your work on graphs this weekend?
158
-
159
- @sferik
160
- How are the graph enhancements coming?
161
-
162
- @sferik
163
- How are the graphs coming? I'm really looking forward to seeing what you do
164
- with Raphaël.
165
-
166
- @sferik
167
- Awesome! Any luck duplicating the Gemfile.lock error with Ruby 1.9.2 final?
168
-
169
- @sferik
170
- I just committed a bunch of cleanup and fixes to RailsAdmin that touched many
171
- of files. Make sure you pull to avoid conflicts.
172
-
173
- @sferik
174
- I'm trying to debug the issue you were having with the Bundler Gemfile.lock
175
- shortref. What version of Ruby and RubyGems are you running?
176
-
177
- eos
178
- end
179
- context '--csv' do
180
- before do
181
- @cli.options = @cli.options.merge('csv' => true)
182
- end
183
- it 'outputs in CSV format' do
184
- @cli.direct_messages
185
- expect($stdout.string).to eq <<-eos
186
- ID,Posted at,Screen name,Text
187
- 1773478249,2010-10-17 20:48:55 +0000,sferik,Sounds good. Meeting Tuesday is fine.
188
- 1762960771,2010-10-14 21:43:30 +0000,sferik,That's great news! Let's plan to chat around 8 AM tomorrow Pacific time. Does that work for you?
189
- 1711812216,2010-10-01 15:07:12 +0000,sferik,I asked Yehuda about the stipend. I believe it has already been sent. Glad you're feeling better.
190
- 1711417617,2010-10-01 13:09:27 +0000,sferik,Just checking in. How's everything going?
191
- 1653301471,2010-09-16 16:13:27 +0000,sferik,Not sure about the payment. Feel free to ask Leah or Yehuda directly. Think you'll be able to finish up your work on graphs this weekend?
192
- 1645324992,2010-09-14 18:44:10 +0000,sferik,How are the graph enhancements coming?
193
- 1632933616,2010-09-11 17:45:46 +0000,sferik,How are the graphs coming? I'm really looking forward to seeing what you do with Raphaël.
194
- 1629239903,2010-09-10 18:21:36 +0000,sferik,Awesome! Any luck duplicating the Gemfile.lock error with Ruby 1.9.2 final?
195
- 1629166212,2010-09-10 17:56:53 +0000,sferik,I just committed a bunch of cleanup and fixes to RailsAdmin that touched many of files. Make sure you pull to avoid conflicts.
196
- 1624782206,2010-09-09 18:11:48 +0000,sferik,I'm trying to debug the issue you were having with the Bundler Gemfile.lock shortref. What version of Ruby and RubyGems are you running?
197
- eos
198
- end
199
- end
200
- context '--decode-uris' do
201
- before do
202
- @cli.options = @cli.options.merge('decode_uris' => true)
203
- stub_get('/1.1/direct_messages.json').with(:query => {:count => '20', :include_entities => 'true'}).to_return(:body => fixture('direct_messages.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
204
- stub_get('/1.1/direct_messages.json').with(:query => {:count => '10', :max_id => '1624782205', :include_entities => 'true'}).to_return(:body => fixture('empty_array.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
205
- end
206
- it 'requests the correct resource' do
207
- @cli.direct_messages
208
- expect(a_get('/1.1/direct_messages.json').with(:query => {:count => '20', :include_entities => 'true'})).to have_been_made
209
- end
210
- end
211
- context '--long' do
212
- before do
213
- @cli.options = @cli.options.merge('long' => true)
214
- end
215
- it 'outputs in long format' do
216
- @cli.direct_messages
217
- expect($stdout.string).to eq <<-eos
218
- ID Posted at Screen name Text
219
- 1773478249 Oct 17 2010 @sferik Sounds good. Meeting Tuesday is fine.
220
- 1762960771 Oct 14 2010 @sferik That's great news! Let's plan to chat ...
221
- 1711812216 Oct 1 2010 @sferik I asked Yehuda about the stipend. I be...
222
- 1711417617 Oct 1 2010 @sferik Just checking in. How's everything going?
223
- 1653301471 Sep 16 2010 @sferik Not sure about the payment. Feel free ...
224
- 1645324992 Sep 14 2010 @sferik How are the graph enhancements coming?
225
- 1632933616 Sep 11 2010 @sferik How are the graphs coming? I'm really ...
226
- 1629239903 Sep 10 2010 @sferik Awesome! Any luck duplicating the Gemf...
227
- 1629166212 Sep 10 2010 @sferik I just committed a bunch of cleanup an...
228
- 1624782206 Sep 9 2010 @sferik I'm trying to debug the issue you were...
229
- eos
230
- end
231
- end
232
- context '--number' do
233
- before do
234
- stub_get('/1.1/direct_messages.json').with(:query => {:count => '1', :include_entities => 'false'}).to_return(:body => fixture('direct_messages.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
235
- stub_get('/1.1/direct_messages.json').with(:query => {:count => '200', :include_entities => 'false'}).to_return(:body => fixture('200_direct_messages.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
236
- stub_get('/1.1/direct_messages.json').with(:query => {:count => '1', :max_id => '235851563443306495', :include_entities => 'false'}).to_return(:body => fixture('direct_messages.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
237
- end
238
- it 'limits the number of results to 1' do
239
- @cli.options = @cli.options.merge('number' => 1)
240
- @cli.direct_messages
241
- expect(a_get('/1.1/direct_messages.json').with(:query => {:count => '1', :include_entities => 'false'})).to have_been_made
242
- end
243
- it 'limits the number of results to 201' do
244
- @cli.options = @cli.options.merge('number' => 201)
245
- @cli.direct_messages
246
- expect(a_get('/1.1/direct_messages.json').with(:query => {:count => '200', :include_entities => 'false'})).to have_been_made
247
- expect(a_get('/1.1/direct_messages.json').with(:query => {:count => '1', :max_id => '235851563443306495', :include_entities => 'false'})).to have_been_made
248
- end
249
- end
250
- context '--reverse' do
251
- before do
252
- @cli.options = @cli.options.merge('reverse' => true)
253
- end
254
- it 'reverses the order of the sort' do
255
- @cli.direct_messages
256
- expect($stdout.string).to eq <<-eos
257
- @sferik
258
- I'm trying to debug the issue you were having with the Bundler Gemfile.lock
259
- shortref. What version of Ruby and RubyGems are you running?
260
-
261
- @sferik
262
- I just committed a bunch of cleanup and fixes to RailsAdmin that touched many
263
- of files. Make sure you pull to avoid conflicts.
264
-
265
- @sferik
266
- Awesome! Any luck duplicating the Gemfile.lock error with Ruby 1.9.2 final?
267
-
268
- @sferik
269
- How are the graphs coming? I'm really looking forward to seeing what you do
270
- with Raphaël.
271
-
272
- @sferik
273
- How are the graph enhancements coming?
274
-
275
- @sferik
276
- Not sure about the payment. Feel free to ask Leah or Yehuda directly. Think
277
- you'll be able to finish up your work on graphs this weekend?
278
-
279
- @sferik
280
- Just checking in. How's everything going?
281
-
282
- @sferik
283
- I asked Yehuda about the stipend. I believe it has already been sent. Glad
284
- you're feeling better.
285
-
286
- @sferik
287
- That's great news! Let's plan to chat around 8 AM tomorrow Pacific time. Does
288
- that work for you?
289
-
290
- @sferik
291
- Sounds good. Meeting Tuesday is fine.
292
-
293
- eos
294
- end
295
- end
296
- end
297
-
298
- describe '#direct_messages_sent' do
299
- before do
300
- stub_get('/1.1/direct_messages/sent.json').with(:query => {:count => '20', :include_entities => 'false'}).to_return(:body => fixture('direct_messages.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
301
- stub_get('/1.1/direct_messages/sent.json').with(:query => {:count => '10', :max_id => '1624782205', :include_entities => 'false'}).to_return(:body => fixture('empty_array.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
302
- end
303
- it 'requests the correct resource' do
304
- @cli.direct_messages_sent
305
- expect(a_get('/1.1/direct_messages/sent.json').with(:query => {:count => '20', :include_entities => 'false'})).to have_been_made
306
- end
307
- it 'has the correct output' do
308
- @cli.direct_messages_sent
309
- expect($stdout.string).to eq <<-eos
310
- @hurrycane
311
- Sounds good. Meeting Tuesday is fine.
312
-
313
- @hurrycane
314
- That's great news! Let's plan to chat around 8 AM tomorrow Pacific time. Does
315
- that work for you?
316
-
317
- @hurrycane
318
- I asked Yehuda about the stipend. I believe it has already been sent. Glad
319
- you're feeling better.
320
-
321
- @hurrycane
322
- Just checking in. How's everything going?
323
-
324
- @hurrycane
325
- Not sure about the payment. Feel free to ask Leah or Yehuda directly. Think
326
- you'll be able to finish up your work on graphs this weekend?
327
-
328
- @hurrycane
329
- How are the graph enhancements coming?
330
-
331
- @hurrycane
332
- How are the graphs coming? I'm really looking forward to seeing what you do
333
- with Raphaël.
334
-
335
- @hurrycane
336
- Awesome! Any luck duplicating the Gemfile.lock error with Ruby 1.9.2 final?
337
-
338
- @hurrycane
339
- I just committed a bunch of cleanup and fixes to RailsAdmin that touched many
340
- of files. Make sure you pull to avoid conflicts.
341
-
342
- @hurrycane
343
- I'm trying to debug the issue you were having with the Bundler Gemfile.lock
344
- shortref. What version of Ruby and RubyGems are you running?
345
-
346
- eos
347
- end
348
- context '--csv' do
349
- before do
350
- @cli.options = @cli.options.merge('csv' => true)
351
- end
352
- it 'outputs in CSV format' do
353
- @cli.direct_messages_sent
354
- expect($stdout.string).to eq <<-eos
355
- ID,Posted at,Screen name,Text
356
- 1773478249,2010-10-17 20:48:55 +0000,hurrycane,Sounds good. Meeting Tuesday is fine.
357
- 1762960771,2010-10-14 21:43:30 +0000,hurrycane,That's great news! Let's plan to chat around 8 AM tomorrow Pacific time. Does that work for you?
358
- 1711812216,2010-10-01 15:07:12 +0000,hurrycane,I asked Yehuda about the stipend. I believe it has already been sent. Glad you're feeling better.
359
- 1711417617,2010-10-01 13:09:27 +0000,hurrycane,Just checking in. How's everything going?
360
- 1653301471,2010-09-16 16:13:27 +0000,hurrycane,Not sure about the payment. Feel free to ask Leah or Yehuda directly. Think you'll be able to finish up your work on graphs this weekend?
361
- 1645324992,2010-09-14 18:44:10 +0000,hurrycane,How are the graph enhancements coming?
362
- 1632933616,2010-09-11 17:45:46 +0000,hurrycane,How are the graphs coming? I'm really looking forward to seeing what you do with Raphaël.
363
- 1629239903,2010-09-10 18:21:36 +0000,hurrycane,Awesome! Any luck duplicating the Gemfile.lock error with Ruby 1.9.2 final?
364
- 1629166212,2010-09-10 17:56:53 +0000,hurrycane,I just committed a bunch of cleanup and fixes to RailsAdmin that touched many of files. Make sure you pull to avoid conflicts.
365
- 1624782206,2010-09-09 18:11:48 +0000,hurrycane,I'm trying to debug the issue you were having with the Bundler Gemfile.lock shortref. What version of Ruby and RubyGems are you running?
366
- eos
367
- end
368
- end
369
- context '--decode-uris' do
370
- before do
371
- @cli.options = @cli.options.merge('decode_uris' => true)
372
- stub_get('/1.1/direct_messages/sent.json').with(:query => {:count => '20', :include_entities => 'true'}).to_return(:body => fixture('direct_messages.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
373
- stub_get('/1.1/direct_messages/sent.json').with(:query => {:count => '10', :max_id => '1624782205', :include_entities => 'true'}).to_return(:body => fixture('empty_array.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
374
- end
375
- it 'requests the correct resource' do
376
- @cli.direct_messages_sent
377
- expect(a_get('/1.1/direct_messages/sent.json').with(:query => {:count => '20', :include_entities => 'true'})).to have_been_made
378
- end
379
- end
380
- context '--long' do
381
- before do
382
- @cli.options = @cli.options.merge('long' => true)
383
- end
384
- it 'outputs in long format' do
385
- @cli.direct_messages_sent
386
- expect($stdout.string).to eq <<-eos
387
- ID Posted at Screen name Text
388
- 1773478249 Oct 17 2010 @hurrycane Sounds good. Meeting Tuesday is fine.
389
- 1762960771 Oct 14 2010 @hurrycane That's great news! Let's plan to chat ...
390
- 1711812216 Oct 1 2010 @hurrycane I asked Yehuda about the stipend. I be...
391
- 1711417617 Oct 1 2010 @hurrycane Just checking in. How's everything going?
392
- 1653301471 Sep 16 2010 @hurrycane Not sure about the payment. Feel free ...
393
- 1645324992 Sep 14 2010 @hurrycane How are the graph enhancements coming?
394
- 1632933616 Sep 11 2010 @hurrycane How are the graphs coming? I'm really ...
395
- 1629239903 Sep 10 2010 @hurrycane Awesome! Any luck duplicating the Gemf...
396
- 1629166212 Sep 10 2010 @hurrycane I just committed a bunch of cleanup an...
397
- 1624782206 Sep 9 2010 @hurrycane I'm trying to debug the issue you were...
398
- eos
399
- end
400
- end
401
- context '--number' do
402
- before do
403
- stub_get('/1.1/direct_messages/sent.json').with(:query => {:count => '1', :include_entities => 'false'}).to_return(:body => fixture('direct_messages.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
404
- stub_get('/1.1/direct_messages/sent.json').with(:query => {:count => '200', :include_entities => 'false'}).to_return(:body => fixture('200_direct_messages.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
405
- stub_get('/1.1/direct_messages/sent.json').with(:query => {:count => '1', :max_id => '235851563443306495', :include_entities => 'false'}).to_return(:body => fixture('direct_messages.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
406
- end
407
- it 'limits the number of results 1' do
408
- @cli.options = @cli.options.merge('number' => 1)
409
- @cli.direct_messages_sent
410
- expect(a_get('/1.1/direct_messages/sent.json').with(:query => {:count => '1', :include_entities => 'false'})).to have_been_made
411
- end
412
- it 'limits the number of results to 201' do
413
- @cli.options = @cli.options.merge('number' => 201)
414
- @cli.direct_messages_sent
415
- expect(a_get('/1.1/direct_messages/sent.json').with(:query => {:count => '200', :include_entities => 'false'})).to have_been_made
416
- expect(a_get('/1.1/direct_messages/sent.json').with(:query => {:count => '1', :max_id => '235851563443306495', :include_entities => 'false'})).to have_been_made
417
- end
418
- end
419
- context '--reverse' do
420
- before do
421
- @cli.options = @cli.options.merge('reverse' => true)
422
- end
423
- it 'reverses the order of the sort' do
424
- @cli.direct_messages_sent
425
- expect($stdout.string).to eq <<-eos
426
- @hurrycane
427
- I'm trying to debug the issue you were having with the Bundler Gemfile.lock
428
- shortref. What version of Ruby and RubyGems are you running?
429
-
430
- @hurrycane
431
- I just committed a bunch of cleanup and fixes to RailsAdmin that touched many
432
- of files. Make sure you pull to avoid conflicts.
433
-
434
- @hurrycane
435
- Awesome! Any luck duplicating the Gemfile.lock error with Ruby 1.9.2 final?
436
-
437
- @hurrycane
438
- How are the graphs coming? I'm really looking forward to seeing what you do
439
- with Raphaël.
440
-
441
- @hurrycane
442
- How are the graph enhancements coming?
443
-
444
- @hurrycane
445
- Not sure about the payment. Feel free to ask Leah or Yehuda directly. Think
446
- you'll be able to finish up your work on graphs this weekend?
447
-
448
- @hurrycane
449
- Just checking in. How's everything going?
450
-
451
- @hurrycane
452
- I asked Yehuda about the stipend. I believe it has already been sent. Glad
453
- you're feeling better.
454
-
455
- @hurrycane
456
- That's great news! Let's plan to chat around 8 AM tomorrow Pacific time. Does
457
- that work for you?
458
-
459
- @hurrycane
460
- Sounds good. Meeting Tuesday is fine.
461
-
462
- eos
463
- end
464
- end
465
- end
466
-
467
- describe '#dm' do
468
- before do
469
- @cli.options = @cli.options.merge('profile' => fixture_path + '/.trc')
470
- 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'), :headers => {:content_type => 'application/json; charset=utf-8'})
471
- end
472
- it 'requests the correct resource' do
473
- @cli.dm('pengwynn', 'Creating a fixture for the Twitter gem')
474
- 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
475
- end
476
- it 'has the correct output' do
477
- @cli.dm('pengwynn', 'Creating a fixture for the Twitter gem')
478
- expect($stdout.string.chomp).to eq 'Direct Message sent from @testcli to @pengwynn.'
479
- end
480
- context '--id' do
481
- before do
482
- @cli.options = @cli.options.merge('id' => true)
483
- 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'), :headers => {:content_type => 'application/json; charset=utf-8'})
484
- end
485
- it 'requests the correct resource' do
486
- @cli.dm('14100886', 'Creating a fixture for the Twitter gem')
487
- 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
488
- end
489
- end
490
- end
491
-
492
- describe '#does_contain' do
493
- before do
494
- @cli.options = @cli.options.merge('profile' => fixture_path + '/.trc')
495
- 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'), :headers => {:content_type => 'application/json; charset=utf-8'})
496
- end
497
- it 'requests the correct resource' do
498
- @cli.does_contain('presidents')
499
- expect(a_get('/1.1/lists/members/show.json').with(:query => {:owner_screen_name => 'testcli', :screen_name => 'testcli', :slug => 'presidents'})).to have_been_made
500
- end
501
- it 'has the correct output' do
502
- @cli.does_contain('presidents')
503
- expect($stdout.string.chomp).to eq 'Yes, presidents contains @testcli.'
504
- end
505
- context '--id' do
506
- before do
507
- @cli.options = @cli.options.merge('id' => true)
508
- stub_get('/1.1/users/show.json').with(:query => {:user_id => '7505382'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
509
- 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'), :headers => {:content_type => 'application/json; charset=utf-8'})
510
- end
511
- it 'requests the correct resource' do
512
- @cli.does_contain('presidents', '7505382')
513
- expect(a_get('/1.1/users/show.json').with(:query => {:user_id => '7505382'})).to have_been_made
514
- expect(a_get('/1.1/lists/members/show.json').with(:query => {:owner_screen_name => 'testcli', :screen_name => 'sferik', :slug => 'presidents'})).to have_been_made
515
- end
516
- end
517
- context 'with an owner passed' do
518
- it 'has the correct output' do
519
- @cli.does_contain('testcli/presidents', 'testcli')
520
- expect($stdout.string.chomp).to eq 'Yes, presidents contains @testcli.'
521
- end
522
- context '--id' do
523
- before do
524
- @cli.options = @cli.options.merge('id' => true)
525
- stub_get('/1.1/users/show.json').with(:query => {:user_id => '7505382'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
526
- stub_get('/1.1/lists/members/show.json').with(:query => {:owner_id => '7505382', :screen_name => 'sferik', :slug => 'presidents'}).to_return(:body => fixture('list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
527
- end
528
- it 'requests the correct resource' do
529
- @cli.does_contain('7505382/presidents', '7505382')
530
- expect(a_get('/1.1/users/show.json').with(:query => {:user_id => '7505382'})).to have_been_made
531
- expect(a_get('/1.1/lists/members/show.json').with(:query => {:owner_id => '7505382', :screen_name => 'sferik', :slug => 'presidents'})).to have_been_made
532
- end
533
- end
534
- end
535
- context 'with a user passed' do
536
- it 'has the correct output' do
537
- @cli.does_contain('presidents', 'testcli')
538
- expect($stdout.string.chomp).to eq 'Yes, presidents contains @testcli.'
539
- end
540
- end
541
- context 'false' do
542
- before do
543
- 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, :headers => {:content_type => 'application/json; charset=utf-8'})
544
- end
545
- it 'exits' do
546
- expect do
547
- @cli.does_contain('presidents')
548
- end.to raise_error(SystemExit)
549
- expect(a_get('/1.1/lists/members/show.json').with(:query => {:owner_screen_name => 'testcli', :screen_name => 'testcli', :slug => 'presidents'})).to have_been_made
550
- end
551
- end
552
- end
553
-
554
- describe '#does_follow' do
555
- before do
556
- @cli.options = @cli.options.merge('profile' => fixture_path + '/.trc')
557
- stub_get('/1.1/friendships/show.json').with(:query => {:source_screen_name => 'ev', :target_screen_name => 'testcli'}).to_return(:body => fixture('following.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
558
- end
559
- it 'requests the correct resource' do
560
- @cli.does_follow('ev')
561
- expect(a_get('/1.1/friendships/show.json').with(:query => {:source_screen_name => 'ev', :target_screen_name => 'testcli'})).to have_been_made
562
- end
563
- it 'has the correct output' do
564
- @cli.does_follow('ev')
565
- expect($stdout.string.chomp).to eq 'Yes, @ev follows @testcli.'
566
- end
567
- context '--id' do
568
- before do
569
- @cli.options = @cli.options.merge('id' => true)
570
- stub_get('/1.1/users/show.json').with(:query => {:user_id => '20'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
571
- stub_get('/1.1/friendships/show.json').with(:query => {:source_screen_name => 'sferik', :target_screen_name => 'testcli'}).to_return(:body => fixture('following.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
572
- end
573
- it 'requests the correct resource' do
574
- @cli.does_follow('20')
575
- expect(a_get('/1.1/users/show.json').with(:query => {:user_id => '20'})).to have_been_made
576
- expect(a_get('/1.1/friendships/show.json').with(:query => {:source_screen_name => 'sferik', :target_screen_name => 'testcli'})).to have_been_made
577
- end
578
- it 'has the correct output' do
579
- @cli.does_follow('20')
580
- expect($stdout.string.chomp).to eq 'Yes, @sferik follows @testcli.'
581
- end
582
- end
583
- context 'with a user passed' do
584
- before do
585
- stub_get('/1.1/friendships/show.json').with(:query => {:source_screen_name => 'ev', :target_screen_name => 'sferik'}).to_return(:body => fixture('following.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
586
- end
587
- it 'requests the correct resource' do
588
- @cli.does_follow('ev', 'sferik')
589
- expect(a_get('/1.1/friendships/show.json').with(:query => {:source_screen_name => 'ev', :target_screen_name => 'sferik'})).to have_been_made
590
- end
591
- it 'has the correct output' do
592
- @cli.does_follow('ev', 'sferik')
593
- expect($stdout.string.chomp).to eq 'Yes, @ev follows @sferik.'
594
- end
595
- context '--id' do
596
- before do
597
- @cli.options = @cli.options.merge('id' => true)
598
- stub_get('/1.1/users/show.json').with(:query => {:user_id => '20'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
599
- stub_get('/1.1/users/show.json').with(:query => {:user_id => '428004849'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
600
- stub_get('/1.1/friendships/show.json').with(:query => {:source_screen_name => 'sferik', :target_screen_name => 'sferik'}).to_return(:body => fixture('following.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
601
- end
602
- it 'requests the correct resource' do
603
- @cli.does_follow('20', '428004849')
604
- expect(a_get('/1.1/users/show.json').with(:query => {:user_id => '20'})).to have_been_made
605
- expect(a_get('/1.1/users/show.json').with(:query => {:user_id => '428004849'})).to have_been_made
606
- expect(a_get('/1.1/friendships/show.json').with(:query => {:source_screen_name => 'sferik', :target_screen_name => 'sferik'})).to have_been_made
607
- end
608
- it 'has the correct output' do
609
- @cli.does_follow('20', '428004849')
610
- expect($stdout.string.chomp).to eq 'Yes, @sferik follows @sferik.'
611
- end
612
- end
613
- end
614
- context 'false' do
615
- before do
616
- stub_get('/1.1/friendships/show.json').with(:query => {:source_screen_name => 'ev', :target_screen_name => 'testcli'}).to_return(:body => fixture('not_following.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
617
- end
618
- it 'exits' do
619
- expect do
620
- @cli.does_follow('ev')
621
- end.to raise_error(SystemExit)
622
- expect(a_get('/1.1/friendships/show.json').with(:query => {:source_screen_name => 'ev', :target_screen_name => 'testcli'})).to have_been_made
623
- end
624
- end
625
- end
626
-
627
- describe '#favorite' do
628
- before do
629
- @cli.options = @cli.options.merge('profile' => fixture_path + '/.trc')
630
- stub_post('/1.1/favorites/create.json').with(:body => {:id => '26755176471724032'}).to_return(:body => fixture('status.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
631
- end
632
- it 'requests the correct resource' do
633
- @cli.favorite('26755176471724032')
634
- expect(a_post('/1.1/favorites/create.json').with(:body => {:id => '26755176471724032'})).to have_been_made
635
- end
636
- it 'has the correct output' do
637
- @cli.favorite('26755176471724032')
638
- expect($stdout.string).to match(/^@testcli favorited 1 tweet.$/)
639
- end
640
- end
641
-
642
- describe '#favorites' do
643
- before do
644
- stub_get('/1.1/favorites/list.json').with(:query => {:count => '20', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
645
- end
646
- it 'requests the correct resource' do
647
- @cli.favorites
648
- expect(a_get('/1.1/favorites/list.json').with(:query => {:count => '20', :include_entities => 'false'})).to have_been_made
649
- end
650
- it 'has the correct output' do
651
- @cli.favorites
652
- expect($stdout.string).to eq <<-eos
653
- @mutgoff
654
- Happy Birthday @imdane. Watch out for those @rally pranksters!
655
-
656
- @ironicsans
657
- If you like good real-life stories, check out @NarrativelyNY's just-launched
658
- site http://t.co/wiUL07jE (and also visit http://t.co/ZoyQxqWA)
659
-
660
- @pat_shaughnessy
661
- Something else to vote for: "New Rails workshops to bring more women into the
662
- Boston software scene" http://t.co/eNBuckHc /cc @bostonrb
663
-
664
- @calebelston
665
- Pushing the button to launch the site. http://t.co/qLoEn5jG
666
-
667
- @calebelston
668
- RT @olivercameron: Mosaic looks cool: http://t.co/A8013C9k
669
-
670
- @fivethirtyeight
671
- The Weatherman is Not a Moron: http://t.co/ZwL5Gnq5. An excerpt from my book,
672
- THE SIGNAL AND THE NOISE (http://t.co/fNXj8vCE)
673
-
674
- @codeforamerica
675
- RT @randomhacks: Going to Code Across Austin II: Y'all Come Hack Now, Sat,
676
- Sep 8 http://t.co/Sk5BM7U3 We'll see y'all there! #rhok @codeforamerica
677
- @TheaClay
678
-
679
- @fbjork
680
- RT @jondot: Just published: "Pragmatic Concurrency With #Ruby"
681
- http://t.co/kGEykswZ /cc @JRuby @headius
682
-
683
- @mbostock
684
- If you are wondering how we computed the split bubbles: http://t.co/BcaqSs5u
685
-
686
- @FakeDorsey
687
- "Write drunk. Edit sober."—Ernest Hemingway
688
-
689
- @al3x
690
- RT @wcmaier: Better banking through better ops: build something new with us
691
- @Simplify (remote, PDX) http://t.co/8WgzKZH3
692
-
693
- @calebelston
694
- We just announced Mosaic, what we've been working on since the Yobongo
695
- acquisition. My personal post, http://t.co/ELOyIRZU @heymosaic
696
-
697
- @BarackObama
698
- Donate $10 or more --> get your favorite car magnet: http://t.co/NfRhl2s2
699
- #Obama2012
700
-
701
- @JEG2
702
- RT @tenderlove: If corporations are people, can we use them to drive in the
703
- carpool lane?
704
-
705
- @eveningedition
706
- LDN—Obama's nomination; Putin woos APEC; Bombs hit Damascus; Quakes shake
707
- China; Canada cuts Iran ties; weekend read: http://t.co/OFs6dVW4
708
-
709
- @dhh
710
- RT @ggreenwald: Democrats parade Osama bin Laden's corpse as their proudest
711
- achievement: why this goulish jingoism is so warped http://t.co/kood278s
712
-
713
- @jasonfried
714
- The story of Mars Curiosity's gears, made by a factory in Rockford, IL:
715
- http://t.co/MwCRsHQg
716
-
717
- @sferik
718
- @episod @twitterapi now https://t.co/I17jUTu2 and https://t.co/deDu4Hgw seem
719
- to be missing "1.1" from the URL.
720
-
721
- @sferik
722
- @episod @twitterapi Did you catch https://t.co/VHsQvZT0 as well?
723
-
724
- @dwiskus
725
- Gentlemen, you can't fight in here! This is the war room!
726
- http://t.co/kMxMYyqF
727
-
728
- eos
729
- end
730
- context '--csv' do
731
- before do
732
- @cli.options = @cli.options.merge('csv' => true)
733
- end
734
- it 'outputs in CSV format' do
735
- @cli.favorites
736
- expect($stdout.string).to eq <<-eos
737
- ID,Posted at,Screen name,Text
738
- 4611686018427387904,2012-09-07 16:35:24 +0000,mutgoff,Happy Birthday @imdane. Watch out for those @rally pranksters!
739
- 244111183165157376,2012-09-07 16:33:36 +0000,ironicsans,"If you like good real-life stories, check out @NarrativelyNY's just-launched site http://t.co/wiUL07jE (and also visit http://t.co/ZoyQxqWA)"
740
- 244110336414859264,2012-09-07 16:30:14 +0000,pat_shaughnessy,"Something else to vote for: ""New Rails workshops to bring more women into the Boston software scene"" http://t.co/eNBuckHc /cc @bostonrb"
741
- 244109797308379136,2012-09-07 16:28:05 +0000,calebelston,Pushing the button to launch the site. http://t.co/qLoEn5jG
742
- 244108728834592770,2012-09-07 16:23:50 +0000,calebelston,RT @olivercameron: Mosaic looks cool: http://t.co/A8013C9k
743
- 244107890632294400,2012-09-07 16:20:31 +0000,fivethirtyeight,"The Weatherman is Not a Moron: http://t.co/ZwL5Gnq5. An excerpt from my book, THE SIGNAL AND THE NOISE (http://t.co/fNXj8vCE)"
744
- 244107823733174272,2012-09-07 16:20:15 +0000,codeforamerica,"RT @randomhacks: Going to Code Across Austin II: Y'all Come Hack Now, Sat, Sep 8 http://t.co/Sk5BM7U3 We'll see y'all there! #rhok @codeforamerica @TheaClay"
745
- 244107236262170624,2012-09-07 16:17:55 +0000,fbjork,"RT @jondot: Just published: ""Pragmatic Concurrency With #Ruby"" http://t.co/kGEykswZ /cc @JRuby @headius"
746
- 244106476048764928,2012-09-07 16:14:53 +0000,mbostock,If you are wondering how we computed the split bubbles: http://t.co/BcaqSs5u
747
- 244105599351148544,2012-09-07 16:11:24 +0000,FakeDorsey,"""Write drunk. Edit sober.""—Ernest Hemingway"
748
- 244104558433951744,2012-09-07 16:07:16 +0000,al3x,"RT @wcmaier: Better banking through better ops: build something new with us @Simplify (remote, PDX) http://t.co/8WgzKZH3"
749
- 244104146997870594,2012-09-07 16:05:38 +0000,calebelston,"We just announced Mosaic, what we've been working on since the Yobongo acquisition. My personal post, http://t.co/ELOyIRZU @heymosaic"
750
- 244103057175113729,2012-09-07 16:01:18 +0000,BarackObama,Donate $10 or more --> get your favorite car magnet: http://t.co/NfRhl2s2 #Obama2012
751
- 244102834398851073,2012-09-07 16:00:25 +0000,JEG2,"RT @tenderlove: If corporations are people, can we use them to drive in the carpool lane?"
752
- 244102741125890048,2012-09-07 16:00:03 +0000,eveningedition,LDN—Obama's nomination; Putin woos APEC; Bombs hit Damascus; Quakes shake China; Canada cuts Iran ties; weekend read: http://t.co/OFs6dVW4
753
- 244102729860009984,2012-09-07 16:00:00 +0000,dhh,RT @ggreenwald: Democrats parade Osama bin Laden's corpse as their proudest achievement: why this goulish jingoism is so warped http://t.co/kood278s
754
- 244102490646278146,2012-09-07 15:59:03 +0000,jasonfried,"The story of Mars Curiosity's gears, made by a factory in Rockford, IL: http://t.co/MwCRsHQg"
755
- 244102209942458368,2012-09-07 15:57:56 +0000,sferik,"@episod @twitterapi now https://t.co/I17jUTu2 and https://t.co/deDu4Hgw seem to be missing ""1.1"" from the URL."
756
- 244100411563339777,2012-09-07 15:50:47 +0000,sferik,@episod @twitterapi Did you catch https://t.co/VHsQvZT0 as well?
757
- 244099460672679938,2012-09-07 15:47:01 +0000,dwiskus,"Gentlemen, you can't fight in here! This is the war room! http://t.co/kMxMYyqF"
758
- eos
759
- end
760
- end
761
- context '--decode-uris' do
762
- before do
763
- @cli.options = @cli.options.merge('decode_uris' => true)
764
- stub_get('/1.1/favorites/list.json').with(:query => {:count => '20', :include_entities => 'true'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
765
- end
766
- it 'requests the correct resource' do
767
- @cli.favorites
768
- expect(a_get('/1.1/favorites/list.json').with(:query => {:count => '20', :include_entities => 'true'})).to have_been_made
769
- end
770
- it 'decodes URLs' do
771
- @cli.favorites
772
- expect($stdout.string).to include 'https://twitter.com/sferik/status/243988000076337152'
773
- end
774
- end
775
- context '--long' do
776
- before do
777
- @cli.options = @cli.options.merge('long' => true)
778
- end
779
- it 'outputs in long format' do
780
- @cli.favorites
781
- expect($stdout.string).to eq <<-eos
782
- ID Posted at Screen name Text
783
- 4611686018427387904 Sep 7 08:35 @mutgoff Happy Birthday @imdane. ...
784
- 244111183165157376 Sep 7 08:33 @ironicsans If you like good real-li...
785
- 244110336414859264 Sep 7 08:30 @pat_shaughnessy Something else to vote f...
786
- 244109797308379136 Sep 7 08:28 @calebelston Pushing the button to la...
787
- 244108728834592770 Sep 7 08:23 @calebelston RT @olivercameron: Mosai...
788
- 244107890632294400 Sep 7 08:20 @fivethirtyeight The Weatherman is Not a ...
789
- 244107823733174272 Sep 7 08:20 @codeforamerica RT @randomhacks: Going t...
790
- 244107236262170624 Sep 7 08:17 @fbjork RT @jondot: Just publish...
791
- 244106476048764928 Sep 7 08:14 @mbostock If you are wondering how...
792
- 244105599351148544 Sep 7 08:11 @FakeDorsey "Write drunk. Edit sober...
793
- 244104558433951744 Sep 7 08:07 @al3x RT @wcmaier: Better bank...
794
- 244104146997870594 Sep 7 08:05 @calebelston We just announced Mosaic...
795
- 244103057175113729 Sep 7 08:01 @BarackObama Donate $10 or more --> g...
796
- 244102834398851073 Sep 7 08:00 @JEG2 RT @tenderlove: If corpo...
797
- 244102741125890048 Sep 7 08:00 @eveningedition LDN—Obama's nomination; ...
798
- 244102729860009984 Sep 7 08:00 @dhh RT @ggreenwald: Democrat...
799
- 244102490646278146 Sep 7 07:59 @jasonfried The story of Mars Curios...
800
- 244102209942458368 Sep 7 07:57 @sferik @episod @twitterapi now ...
801
- 244100411563339777 Sep 7 07:50 @sferik @episod @twitterapi Did ...
802
- 244099460672679938 Sep 7 07:47 @dwiskus Gentlemen, you can't fig...
803
- eos
804
- end
805
- context '--reverse' do
806
- before do
807
- @cli.options = @cli.options.merge('reverse' => true)
808
- end
809
- it 'reverses the order of the sort' do
810
- @cli.favorites
811
- expect($stdout.string).to eq <<-eos
812
- ID Posted at Screen name Text
813
- 244099460672679938 Sep 7 07:47 @dwiskus Gentlemen, you can't fig...
814
- 244100411563339777 Sep 7 07:50 @sferik @episod @twitterapi Did ...
815
- 244102209942458368 Sep 7 07:57 @sferik @episod @twitterapi now ...
816
- 244102490646278146 Sep 7 07:59 @jasonfried The story of Mars Curios...
817
- 244102729860009984 Sep 7 08:00 @dhh RT @ggreenwald: Democrat...
818
- 244102741125890048 Sep 7 08:00 @eveningedition LDN—Obama's nomination; ...
819
- 244102834398851073 Sep 7 08:00 @JEG2 RT @tenderlove: If corpo...
820
- 244103057175113729 Sep 7 08:01 @BarackObama Donate $10 or more --> g...
821
- 244104146997870594 Sep 7 08:05 @calebelston We just announced Mosaic...
822
- 244104558433951744 Sep 7 08:07 @al3x RT @wcmaier: Better bank...
823
- 244105599351148544 Sep 7 08:11 @FakeDorsey "Write drunk. Edit sober...
824
- 244106476048764928 Sep 7 08:14 @mbostock If you are wondering how...
825
- 244107236262170624 Sep 7 08:17 @fbjork RT @jondot: Just publish...
826
- 244107823733174272 Sep 7 08:20 @codeforamerica RT @randomhacks: Going t...
827
- 244107890632294400 Sep 7 08:20 @fivethirtyeight The Weatherman is Not a ...
828
- 244108728834592770 Sep 7 08:23 @calebelston RT @olivercameron: Mosai...
829
- 244109797308379136 Sep 7 08:28 @calebelston Pushing the button to la...
830
- 244110336414859264 Sep 7 08:30 @pat_shaughnessy Something else to vote f...
831
- 244111183165157376 Sep 7 08:33 @ironicsans If you like good real-li...
832
- 4611686018427387904 Sep 7 08:35 @mutgoff Happy Birthday @imdane. ...
833
- eos
834
- end
835
- end
836
- end
837
- context '--max-id' do
838
- before do
839
- @cli.options = @cli.options.merge('max_id' => 244_104_558_433_951_744)
840
- stub_get('/1.1/favorites/list.json').with(:query => {:count => '20', :max_id => '244104558433951744', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
841
- end
842
- it 'requests the correct resource' do
843
- @cli.favorites
844
- expect(a_get('/1.1/favorites/list.json').with(:query => {:count => '20', :max_id => '244104558433951744', :include_entities => 'false'})).to have_been_made
845
- end
846
- end
847
- context '--number' do
848
- before do
849
- stub_get('/1.1/favorites/list.json').with(:query => {:count => '1', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
850
- stub_get('/1.1/favorites/list.json').with(:query => {:count => '200', :include_entities => 'false'}).to_return(:body => fixture('200_statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
851
- stub_get('/1.1/favorites/list.json').with(:query => {:count => '1', :max_id => '265500541700956160', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
852
- end
853
- it 'limits the number of results to 1' do
854
- @cli.options = @cli.options.merge('number' => 1)
855
- @cli.favorites
856
- expect(a_get('/1.1/favorites/list.json').with(:query => {:count => '1', :include_entities => 'false'})).to have_been_made
857
- end
858
- it 'limits the number of results to 201' do
859
- @cli.options = @cli.options.merge('number' => 201)
860
- @cli.favorites
861
- expect(a_get('/1.1/favorites/list.json').with(:query => {:count => '200', :include_entities => 'false'})).to have_been_made
862
- expect(a_get('/1.1/favorites/list.json').with(:query => {:count => '1', :max_id => '265500541700956160', :include_entities => 'false'})).to have_been_made
863
- end
864
- end
865
- context '--since-id' do
866
- before do
867
- @cli.options = @cli.options.merge('since_id' => 244_104_558_433_951_744)
868
- stub_get('/1.1/favorites/list.json').with(:query => {:count => '20', :since_id => '244104558433951744', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
869
- end
870
- it 'requests the correct resource' do
871
- @cli.favorites
872
- expect(a_get('/1.1/favorites/list.json').with(:query => {:count => '20', :since_id => '244104558433951744', :include_entities => 'false'})).to have_been_made
873
- end
874
- end
875
- context 'with a user passed' do
876
- before do
877
- stub_get('/1.1/favorites/list.json').with(:query => {:count => '20', :screen_name => 'sferik', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
878
- end
879
- it 'requests the correct resource' do
880
- @cli.favorites('sferik')
881
- expect(a_get('/1.1/favorites/list.json').with(:query => {:count => '20', :screen_name => 'sferik', :include_entities => 'false'})).to have_been_made
882
- end
883
- context '--id' do
884
- before do
885
- @cli.options = @cli.options.merge('id' => true)
886
- stub_get('/1.1/favorites/list.json').with(:query => {:user_id => '7505382', :count => '20', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
887
- end
888
- it 'requests the correct resource' do
889
- @cli.favorites('7505382')
890
- expect(a_get('/1.1/favorites/list.json').with(:query => {:user_id => '7505382', :count => '20', :include_entities => 'false'})).to have_been_made
891
- end
892
- end
893
- context '--max-id' do
894
- before do
895
- @cli.options = @cli.options.merge('max_id' => 244_104_558_433_951_744)
896
- stub_get('/1.1/favorites/list.json').with(:query => {:count => '20', :screen_name => 'sferik', :max_id => '244104558433951744', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
897
- end
898
- it 'requests the correct resource' do
899
- @cli.favorites('sferik')
900
- expect(a_get('/1.1/favorites/list.json').with(:query => {:count => '20', :screen_name => 'sferik', :max_id => '244104558433951744', :include_entities => 'false'})).to have_been_made
901
- end
902
- end
903
- context '--number' do
904
- before do
905
- stub_get('/1.1/favorites/list.json').with(:query => {:count => '1', :screen_name => 'sferik', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
906
- stub_get('/1.1/favorites/list.json').with(:query => {:count => '200', :screen_name => 'sferik', :include_entities => 'false'}).to_return(:body => fixture('200_statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
907
- stub_get('/1.1/favorites/list.json').with(:query => {:count => '1', :screen_name => 'sferik', :max_id => '265500541700956160', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
908
- end
909
- it 'limits the number of results to 1' do
910
- @cli.options = @cli.options.merge('number' => 1)
911
- @cli.favorites('sferik')
912
- expect(a_get('/1.1/favorites/list.json').with(:query => {:count => '1', :screen_name => 'sferik', :include_entities => 'false'})).to have_been_made
913
- end
914
- it 'limits the number of results to 201' do
915
- @cli.options = @cli.options.merge('number' => 201)
916
- @cli.favorites('sferik')
917
- expect(a_get('/1.1/favorites/list.json').with(:query => {:count => '200', :screen_name => 'sferik', :include_entities => 'false'})).to have_been_made
918
- expect(a_get('/1.1/favorites/list.json').with(:query => {:count => '1', :screen_name => 'sferik', :max_id => '265500541700956160', :include_entities => 'false'})).to have_been_made
919
- end
920
- end
921
- context '--since-id' do
922
- before do
923
- @cli.options = @cli.options.merge('since_id' => 244_104_558_433_951_744)
924
- stub_get('/1.1/favorites/list.json').with(:query => {:count => '20', :screen_name => 'sferik', :since_id => '244104558433951744', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
925
- end
926
- it 'requests the correct resource' do
927
- @cli.favorites('sferik')
928
- expect(a_get('/1.1/favorites/list.json').with(:query => {:count => '20', :screen_name => 'sferik', :since_id => '244104558433951744', :include_entities => 'false'})).to have_been_made
929
- end
930
- end
931
- end
932
- end
933
-
934
- describe '#follow' do
935
- before do
936
- @cli.options = @cli.options.merge('profile' => fixture_path + '/.trc')
937
- end
938
- context 'one user' do
939
- before do
940
- stub_get('/1.1/account/verify_credentials.json').with(:query => {:skip_status => 'true'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
941
- stub_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :user_id => '7505382'}).to_return(:body => fixture('friends_ids.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
942
- stub_post('/1.1/users/lookup.json').with(:body => {:screen_name => 'sferik,pengwynn'}).to_return(:body => fixture('users.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
943
- stub_post('/1.1/friendships/create.json').with(:body => {:user_id => '14100886'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
944
- end
945
- it 'requests the correct resource' do
946
- @cli.follow('sferik', 'pengwynn')
947
- expect(a_get('/1.1/account/verify_credentials.json').with(:query => {:skip_status => 'true'})).to have_been_made
948
- expect(a_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :user_id => '7505382'})).to have_been_made
949
- expect(a_post('/1.1/users/lookup.json').with(:body => {:screen_name => 'sferik,pengwynn'})).to have_been_made
950
- expect(a_post('/1.1/friendships/create.json').with(:body => {:user_id => '14100886'})).to have_been_made
951
- end
952
- it 'has the correct output' do
953
- @cli.follow('sferik', 'pengwynn')
954
- expect($stdout.string).to match(/^@testcli is now following 1 more user\.$/)
955
- end
956
- context '--id' do
957
- before do
958
- @cli.options = @cli.options.merge('id' => true)
959
- stub_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :user_id => '7505382'}).to_return(:body => fixture('friends_ids.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
960
- stub_post('/1.1/users/lookup.json').with(:body => {:user_id => '7505382,14100886'}).to_return(:body => fixture('users.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
961
- stub_post('/1.1/friendships/create.json').with(:body => {:user_id => '14100886'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
962
- end
963
- it 'requests the correct resource' do
964
- @cli.follow('7505382', '14100886')
965
- expect(a_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :user_id => '7505382'})).to have_been_made
966
- expect(a_post('/1.1/users/lookup.json').with(:body => {:user_id => '7505382,14100886'})).to have_been_made
967
- expect(a_post('/1.1/friendships/create.json').with(:body => {:user_id => '14100886'})).to have_been_made
968
- end
969
- end
970
- context 'Twitter is down' do
971
- it 'retries 3 times and then raise an error' do
972
- stub_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :user_id => '7505382'}).to_return(:body => fixture('friends_ids.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
973
- stub_post('/1.1/users/lookup.json').with(:body => {:screen_name => 'sferik,pengwynn'}).to_return(:body => fixture('users.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
974
- stub_post('/1.1/friendships/create.json').with(:body => {:user_id => '14100886'}).to_return(:status => 502, :headers => {:content_type => 'application/json; charset=utf-8'})
975
- expect do
976
- @cli.follow('sferik', 'pengwynn')
977
- end.to raise_error(Twitter::Error::BadGateway)
978
- expect(a_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :user_id => '7505382'})).to have_been_made.times(3)
979
- expect(a_post('/1.1/users/lookup.json').with(:body => {:screen_name => 'sferik,pengwynn'})).to have_been_made.times(3)
980
- expect(a_post('/1.1/friendships/create.json').with(:body => {:user_id => '14100886'})).to have_been_made.times(3)
981
- end
982
- end
983
- end
984
- end
985
-
986
- describe '#followings' do
987
- before do
988
- stub_get('/1.1/account/verify_credentials.json').with(:query => {:skip_status => 'true'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
989
- stub_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :user_id => '7505382'}).to_return(:body => fixture('friends_ids.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
990
- stub_post('/1.1/users/lookup.json').with(:body => {:user_id => '7505382'}).to_return(:body => fixture('users.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
991
- end
992
- it 'requests the correct resource' do
993
- @cli.followings
994
- expect(a_get('/1.1/account/verify_credentials.json').with(:query => {:skip_status => 'true'})).to have_been_made
995
- expect(a_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :user_id => '7505382'})).to have_been_made
996
- expect(a_post('/1.1/users/lookup.json').with(:body => {:user_id => '7505382'})).to have_been_made
997
- end
998
- it 'has the correct output' do
999
- @cli.followings
1000
- expect($stdout.string.chomp).to eq 'pengwynn sferik'
1001
- end
1002
- context '--csv' do
1003
- before do
1004
- @cli.options = @cli.options.merge('csv' => true)
1005
- end
1006
- it 'outputs in CSV format' do
1007
- @cli.followings
1008
- expect($stdout.string).to eq <<-eos
1009
- ID,Since,Last tweeted at,Tweets,Favorites,Listed,Following,Followers,Screen name,Name,Verified,Protected,Bio,Status,Location,URL
1010
- 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
1011
- 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
1012
- eos
1013
- end
1014
- end
1015
- context '--long' do
1016
- before do
1017
- @cli.options = @cli.options.merge('long' => true)
1018
- end
1019
- it 'outputs in long format' do
1020
- @cli.followings
1021
- expect($stdout.string).to eq <<-eos
1022
- ID Since Last tweeted at Tweets Favorites Listed Following...
1023
- 14100886 Mar 8 2008 Jul 7 12:33 6940 192 358 3427...
1024
- 7505382 Jul 16 2007 Jul 8 10:29 7890 3755 118 212...
1025
- eos
1026
- end
1027
- end
1028
- context '--reverse' do
1029
- before do
1030
- @cli.options = @cli.options.merge('reverse' => true)
1031
- end
1032
- it 'reverses the order of the sort' do
1033
- @cli.followings
1034
- expect($stdout.string.chomp).to eq 'sferik pengwynn'
1035
- end
1036
- end
1037
- context '--sort=favorites' do
1038
- before do
1039
- @cli.options = @cli.options.merge('sort' => 'favorites')
1040
- end
1041
- it 'sorts by the number of favorites' do
1042
- @cli.followings
1043
- expect($stdout.string.chomp).to eq 'pengwynn sferik'
1044
- end
1045
- end
1046
- context '--sort=followers' do
1047
- before do
1048
- @cli.options = @cli.options.merge('sort' => 'followers')
1049
- end
1050
- it 'sorts by the number of followers' do
1051
- @cli.followings
1052
- expect($stdout.string.chomp).to eq 'sferik pengwynn'
1053
- end
1054
- end
1055
- context '--sort=friends' do
1056
- before do
1057
- @cli.options = @cli.options.merge('sort' => 'friends')
1058
- end
1059
- it 'sorts by the number of friends' do
1060
- @cli.followings
1061
- expect($stdout.string.chomp).to eq 'sferik pengwynn'
1062
- end
1063
- end
1064
- context '--sort=listed' do
1065
- before do
1066
- @cli.options = @cli.options.merge('sort' => 'listed')
1067
- end
1068
- it 'sorts by the number of list memberships' do
1069
- @cli.followings
1070
- expect($stdout.string.chomp).to eq 'sferik pengwynn'
1071
- end
1072
- end
1073
- context '--sort=since' do
1074
- before do
1075
- @cli.options = @cli.options.merge('sort' => 'since')
1076
- end
1077
- it 'sorts by the time when Twitter acount was created' do
1078
- @cli.followings
1079
- expect($stdout.string.chomp).to eq 'sferik pengwynn'
1080
- end
1081
- end
1082
- context '--sort=tweets' do
1083
- before do
1084
- @cli.options = @cli.options.merge('sort' => 'tweets')
1085
- end
1086
- it 'sorts by the number of Tweets' do
1087
- @cli.followings
1088
- expect($stdout.string.chomp).to eq 'pengwynn sferik'
1089
- end
1090
- end
1091
- context '--sort=tweeted' do
1092
- before do
1093
- @cli.options = @cli.options.merge('sort' => 'tweeted')
1094
- end
1095
- it 'sorts by the time of the last Tweet' do
1096
- @cli.followings
1097
- expect($stdout.string.chomp).to eq 'pengwynn sferik'
1098
- end
1099
- end
1100
- context '--unsorted' do
1101
- before do
1102
- @cli.options = @cli.options.merge('unsorted' => true)
1103
- end
1104
- it 'is not sorted' do
1105
- @cli.followings
1106
- expect($stdout.string.chomp).to eq 'pengwynn sferik'
1107
- end
1108
- end
1109
- context 'with a user passed' do
1110
- before do
1111
- stub_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'}).to_return(:body => fixture('friends_ids.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
1112
- end
1113
- it 'requests the correct resource' do
1114
- @cli.followings('sferik')
1115
- expect(a_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'})).to have_been_made
1116
- expect(a_post('/1.1/users/lookup.json').with(:body => {:user_id => '7505382'})).to have_been_made
1117
- end
1118
- end
1119
- context '--id' do
1120
- before do
1121
- @cli.options = @cli.options.merge('id' => true)
1122
- stub_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :user_id => '7505382'}).to_return(:body => fixture('friends_ids.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
1123
- end
1124
- it 'requests the correct resource' do
1125
- @cli.followings('7505382')
1126
- expect(a_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :user_id => '7505382'})).to have_been_made
1127
- expect(a_post('/1.1/users/lookup.json').with(:body => {:user_id => '7505382'})).to have_been_made
1128
- end
1129
- end
1130
- end
1131
-
1132
- describe '#followings_following' do
1133
- before do
1134
- stub_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :screen_name => 'testcli'}).to_return(:body => fixture('friends_ids.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
1135
- stub_get('/1.1/followers/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'}).to_return(:body => fixture('friends_ids.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
1136
- stub_post('/1.1/users/lookup.json').with(:body => {:user_id => '7505382'}).to_return(:body => fixture('users.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
1137
- end
1138
- it 'requests the correct resource' do
1139
- @cli.followings_following('sferik')
1140
- expect(a_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :screen_name => 'testcli'})).to have_been_made
1141
- expect(a_get('/1.1/followers/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'})).to have_been_made
1142
- expect(a_post('/1.1/users/lookup.json').with(:body => {:user_id => '7505382'})).to have_been_made
1143
- end
1144
- it 'has the correct output' do
1145
- @cli.followings_following('sferik')
1146
- expect($stdout.string.chomp).to eq 'pengwynn sferik'
1147
- end
1148
- context '--csv' do
1149
- before do
1150
- @cli.options = @cli.options.merge('csv' => true)
1151
- end
1152
- it 'outputs in CSV format' do
1153
- @cli.followings_following('sferik')
1154
- expect($stdout.string).to eq <<-eos
1155
- ID,Since,Last tweeted at,Tweets,Favorites,Listed,Following,Followers,Screen name,Name,Verified,Protected,Bio,Status,Location,URL
1156
- 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
1157
- 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
1158
- eos
1159
- end
1160
- end
1161
- context '--long' do
1162
- before do
1163
- @cli.options = @cli.options.merge('long' => true)
1164
- end
1165
- it 'outputs in long format' do
1166
- @cli.followings_following('sferik')
1167
- expect($stdout.string).to eq <<-eos
1168
- ID Since Last tweeted at Tweets Favorites Listed Following...
1169
- 14100886 Mar 8 2008 Jul 7 12:33 6940 192 358 3427...
1170
- 7505382 Jul 16 2007 Jul 8 10:29 7890 3755 118 212...
1171
- eos
1172
- end
1173
- end
1174
- context '--reverse' do
1175
- before do
1176
- @cli.options = @cli.options.merge('reverse' => true)
1177
- end
1178
- it 'reverses the order of the sort' do
1179
- @cli.followings_following('sferik')
1180
- expect($stdout.string.chomp).to eq 'sferik pengwynn'
1181
- end
1182
- end
1183
- context '--sort=favorites' do
1184
- before do
1185
- @cli.options = @cli.options.merge('sort' => 'favorites')
1186
- end
1187
- it 'sorts by the number of favorites' do
1188
- @cli.followings_following('sferik')
1189
- expect($stdout.string.chomp).to eq 'pengwynn sferik'
1190
- end
1191
- end
1192
- context '--sort=followers' do
1193
- before do
1194
- @cli.options = @cli.options.merge('sort' => 'followers')
1195
- end
1196
- it 'sorts by the number of followers' do
1197
- @cli.followings_following('sferik')
1198
- expect($stdout.string.chomp).to eq 'sferik pengwynn'
1199
- end
1200
- end
1201
- context '--sort=friends' do
1202
- before do
1203
- @cli.options = @cli.options.merge('sort' => 'friends')
1204
- end
1205
- it 'sorts by the number of friends' do
1206
- @cli.followings_following('sferik')
1207
- expect($stdout.string.chomp).to eq 'sferik pengwynn'
1208
- end
1209
- end
1210
- context '--sort=listed' do
1211
- before do
1212
- @cli.options = @cli.options.merge('sort' => 'listed')
1213
- end
1214
- it 'sorts by the number of list memberships' do
1215
- @cli.followings_following('sferik')
1216
- expect($stdout.string.chomp).to eq 'sferik pengwynn'
1217
- end
1218
- end
1219
- context '--sort=since' do
1220
- before do
1221
- @cli.options = @cli.options.merge('sort' => 'since')
1222
- end
1223
- it 'sorts by the time when Twitter acount was created' do
1224
- @cli.followings_following('sferik')
1225
- expect($stdout.string.chomp).to eq 'sferik pengwynn'
1226
- end
1227
- end
1228
- context '--sort=tweets' do
1229
- before do
1230
- @cli.options = @cli.options.merge('sort' => 'tweets')
1231
- end
1232
- it 'sorts by the number of Tweets' do
1233
- @cli.followings_following('sferik')
1234
- expect($stdout.string.chomp).to eq 'pengwynn sferik'
1235
- end
1236
- end
1237
- context '--sort=tweeted' do
1238
- before do
1239
- @cli.options = @cli.options.merge('sort' => 'tweeted')
1240
- end
1241
- it 'sorts by the time of the last Tweet' do
1242
- @cli.followings_following('sferik')
1243
- expect($stdout.string.chomp).to eq 'pengwynn sferik'
1244
- end
1245
- end
1246
- context '--unsorted' do
1247
- before do
1248
- @cli.options = @cli.options.merge('unsorted' => true)
1249
- end
1250
- it 'is not sorted' do
1251
- @cli.followings_following('sferik')
1252
- expect($stdout.string.chomp).to eq 'pengwynn sferik'
1253
- end
1254
- end
1255
- context 'with two users passed' do
1256
- before do
1257
- stub_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :screen_name => 'pengwynn'}).to_return(:body => fixture('friends_ids.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
1258
- stub_get('/1.1/followers/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'}).to_return(:body => fixture('friends_ids.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
1259
- end
1260
- it 'requests the correct resource' do
1261
- @cli.followings_following('sferik', 'pengwynn')
1262
- expect(a_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :screen_name => 'pengwynn'})).to have_been_made
1263
- expect(a_get('/1.1/followers/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'})).to have_been_made
1264
- expect(a_post('/1.1/users/lookup.json').with(:body => {:user_id => '7505382'})).to have_been_made
1265
- end
1266
- context '--id' do
1267
- before do
1268
- @cli.options = @cli.options.merge('id' => true)
1269
- stub_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :user_id => '14100886'}).to_return(:body => fixture('friends_ids.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
1270
- stub_get('/1.1/followers/ids.json').with(:query => {:cursor => '-1', :user_id => '7505382'}).to_return(:body => fixture('friends_ids.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
1271
- end
1272
- it 'requests the correct resource' do
1273
- @cli.followings_following('7505382', '14100886')
1274
- expect(a_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :user_id => '14100886'})).to have_been_made
1275
- expect(a_get('/1.1/followers/ids.json').with(:query => {:cursor => '-1', :user_id => '7505382'})).to have_been_made
1276
- expect(a_post('/1.1/users/lookup.json').with(:body => {:user_id => '7505382'})).to have_been_made
1277
- end
1278
- end
1279
- end
1280
- end
1281
-
1282
- describe '#followers' do
1283
- before do
1284
- stub_get('/1.1/account/verify_credentials.json').with(:query => {:skip_status => 'true'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
1285
- stub_get('/1.1/followers/ids.json').with(:query => {:cursor => '-1', :user_id => '7505382'}).to_return(:body => fixture('friends_ids.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
1286
- stub_post('/1.1/users/lookup.json').with(:body => {:user_id => '7505382'}).to_return(:body => fixture('users.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
1287
- end
1288
- it 'requests the correct resource' do
1289
- @cli.followers
1290
- expect(a_get('/1.1/account/verify_credentials.json').with(:query => {:skip_status => 'true'})).to have_been_made
1291
- expect(a_get('/1.1/followers/ids.json').with(:query => {:cursor => '-1', :user_id => '7505382'})).to have_been_made
1292
- expect(a_post('/1.1/users/lookup.json').with(:body => {:user_id => '7505382'})).to have_been_made
1293
- end
1294
- it 'has the correct output' do
1295
- @cli.followers
1296
- expect($stdout.string.chomp).to eq 'pengwynn sferik'
1297
- end
1298
- context '--csv' do
1299
- before do
1300
- @cli.options = @cli.options.merge('csv' => true)
1301
- end
1302
- it 'outputs in CSV format' do
1303
- @cli.followers
1304
- expect($stdout.string).to eq <<-eos
1305
- ID,Since,Last tweeted at,Tweets,Favorites,Listed,Following,Followers,Screen name,Name,Verified,Protected,Bio,Status,Location,URL
1306
- 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
1307
- 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
1308
- eos
1309
- end
1310
- end
1311
- context '--long' do
1312
- before do
1313
- @cli.options = @cli.options.merge('long' => true)
1314
- end
1315
- it 'outputs in long format' do
1316
- @cli.followers
1317
- expect($stdout.string).to eq <<-eos
1318
- ID Since Last tweeted at Tweets Favorites Listed Following...
1319
- 14100886 Mar 8 2008 Jul 7 12:33 6940 192 358 3427...
1320
- 7505382 Jul 16 2007 Jul 8 10:29 7890 3755 118 212...
1321
- eos
1322
- end
1323
- end
1324
- context '--reverse' do
1325
- before do
1326
- @cli.options = @cli.options.merge('reverse' => true)
1327
- end
1328
- it 'reverses the order of the sort' do
1329
- @cli.followers
1330
- expect($stdout.string.chomp).to eq 'sferik pengwynn'
1331
- end
1332
- end
1333
- context '--sort=favorites' do
1334
- before do
1335
- @cli.options = @cli.options.merge('sort' => 'favorites')
1336
- end
1337
- it 'sorts by the number of favorites' do
1338
- @cli.followers
1339
- expect($stdout.string.chomp).to eq 'pengwynn sferik'
1340
- end
1341
- end
1342
- context '--sort=followers' do
1343
- before do
1344
- @cli.options = @cli.options.merge('sort' => 'followers')
1345
- end
1346
- it 'sorts by the number of followers' do
1347
- @cli.followers
1348
- expect($stdout.string.chomp).to eq 'sferik pengwynn'
1349
- end
1350
- end
1351
- context '--sort=friends' do
1352
- before do
1353
- @cli.options = @cli.options.merge('sort' => 'friends')
1354
- end
1355
- it 'sorts by the number of friends' do
1356
- @cli.followers
1357
- expect($stdout.string.chomp).to eq 'sferik pengwynn'
1358
- end
1359
- end
1360
- context '--sort=listed' do
1361
- before do
1362
- @cli.options = @cli.options.merge('sort' => 'listed')
1363
- end
1364
- it 'sorts by the number of list memberships' do
1365
- @cli.followers
1366
- expect($stdout.string.chomp).to eq 'sferik pengwynn'
1367
- end
1368
- end
1369
- context '--sort=since' do
1370
- before do
1371
- @cli.options = @cli.options.merge('sort' => 'since')
1372
- end
1373
- it 'sorts by the time when Twitter acount was created' do
1374
- @cli.followers
1375
- expect($stdout.string.chomp).to eq 'sferik pengwynn'
1376
- end
1377
- end
1378
- context '--sort=tweets' do
1379
- before do
1380
- @cli.options = @cli.options.merge('sort' => 'tweets')
1381
- end
1382
- it 'sorts by the number of Tweets' do
1383
- @cli.followers
1384
- expect($stdout.string.chomp).to eq 'pengwynn sferik'
1385
- end
1386
- end
1387
- context '--sort=tweeted' do
1388
- before do
1389
- @cli.options = @cli.options.merge('sort' => 'tweeted')
1390
- end
1391
- it 'sorts by the time of the last Tweet' do
1392
- @cli.followers
1393
- expect($stdout.string.chomp).to eq 'pengwynn sferik'
1394
- end
1395
- end
1396
- context '--unsorted' do
1397
- before do
1398
- @cli.options = @cli.options.merge('unsorted' => true)
1399
- end
1400
- it 'is not sorted' do
1401
- @cli.followers
1402
- expect($stdout.string.chomp).to eq 'pengwynn sferik'
1403
- end
1404
- end
1405
- context 'with a user passed' do
1406
- before do
1407
- stub_get('/1.1/followers/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'}).to_return(:body => fixture('friends_ids.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
1408
- stub_post('/1.1/users/lookup.json').with(:body => {:user_id => '213747670,428004849'}).to_return(:body => fixture('users.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
1409
- end
1410
- it 'requests the correct resource' do
1411
- @cli.followers('sferik')
1412
- expect(a_get('/1.1/followers/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'})).to have_been_made
1413
- expect(a_post('/1.1/users/lookup.json').with(:body => {:user_id => '7505382'})).to have_been_made
1414
- end
1415
- context '--id' do
1416
- before do
1417
- @cli.options = @cli.options.merge('id' => true)
1418
- stub_get('/1.1/followers/ids.json').with(:query => {:cursor => '-1', :user_id => '7505382'}).to_return(:body => fixture('friends_ids.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
1419
- end
1420
- it 'requests the correct resource' do
1421
- @cli.followers('7505382')
1422
- expect(a_get('/1.1/followers/ids.json').with(:query => {:cursor => '-1', :user_id => '7505382'})).to have_been_made
1423
- expect(a_post('/1.1/users/lookup.json').with(:body => {:user_id => '7505382'})).to have_been_made
1424
- end
1425
- end
1426
- end
1427
- end
1428
-
1429
- describe '#friends' do
1430
- before do
1431
- stub_get('/1.1/account/verify_credentials.json').to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
1432
- stub_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'}).to_return(:body => fixture('friends_ids.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
1433
- stub_get('/1.1/followers/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'}).to_return(:body => fixture('friends_ids.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
1434
- stub_post('/1.1/users/lookup.json').with(:body => {:user_id => '7505382'}).to_return(:body => fixture('users.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
1435
- end
1436
- it 'requests the correct resource' do
1437
- @cli.friends
1438
- expect(a_get('/1.1/account/verify_credentials.json')).to have_been_made
1439
- expect(a_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'})).to have_been_made
1440
- expect(a_get('/1.1/followers/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'})).to have_been_made
1441
- expect(a_post('/1.1/users/lookup.json').with(:body => {:user_id => '7505382'})).to have_been_made
1442
- end
1443
- it 'has the correct output' do
1444
- @cli.friends
1445
- expect($stdout.string.chomp).to eq 'pengwynn sferik'
1446
- end
1447
- context '--csv' do
1448
- before do
1449
- @cli.options = @cli.options.merge('csv' => true)
1450
- end
1451
- it 'outputs in CSV format' do
1452
- @cli.friends
1453
- expect($stdout.string).to eq <<-eos
1454
- ID,Since,Last tweeted at,Tweets,Favorites,Listed,Following,Followers,Screen name,Name,Verified,Protected,Bio,Status,Location,URL
1455
- 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
1456
- 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
1457
- eos
1458
- end
1459
- end
1460
- context '--long' do
1461
- before do
1462
- @cli.options = @cli.options.merge('long' => true)
1463
- end
1464
- it 'outputs in long format' do
1465
- @cli.friends
1466
- expect($stdout.string).to eq <<-eos
1467
- ID Since Last tweeted at Tweets Favorites Listed Following...
1468
- 14100886 Mar 8 2008 Jul 7 12:33 6940 192 358 3427...
1469
- 7505382 Jul 16 2007 Jul 8 10:29 7890 3755 118 212...
1470
- eos
1471
- end
1472
- end
1473
- context '--reverse' do
1474
- before do
1475
- @cli.options = @cli.options.merge('reverse' => true)
1476
- end
1477
- it 'reverses the order of the sort' do
1478
- @cli.friends
1479
- expect($stdout.string.chomp).to eq 'sferik pengwynn'
1480
- end
1481
- end
1482
- context '--sort=favorites' do
1483
- before do
1484
- @cli.options = @cli.options.merge('sort' => 'favorites')
1485
- end
1486
- it 'sorts by the number of favorites' do
1487
- @cli.friends
1488
- expect($stdout.string.chomp).to eq 'pengwynn sferik'
1489
- end
1490
- end
1491
- context '--sort=followers' do
1492
- before do
1493
- @cli.options = @cli.options.merge('sort' => 'followers')
1494
- end
1495
- it 'sorts by the number of followers' do
1496
- @cli.friends
1497
- expect($stdout.string.chomp).to eq 'sferik pengwynn'
1498
- end
1499
- end
1500
- context '--sort=friends' do
1501
- before do
1502
- @cli.options = @cli.options.merge('sort' => 'friends')
1503
- end
1504
- it 'sorts by the number of friends' do
1505
- @cli.friends
1506
- expect($stdout.string.chomp).to eq 'sferik pengwynn'
1507
- end
1508
- end
1509
- context '--sort=listed' do
1510
- before do
1511
- @cli.options = @cli.options.merge('sort' => 'listed')
1512
- end
1513
- it 'sorts by the number of list memberships' do
1514
- @cli.friends
1515
- expect($stdout.string.chomp).to eq 'sferik pengwynn'
1516
- end
1517
- end
1518
- context '--sort=since' do
1519
- before do
1520
- @cli.options = @cli.options.merge('sort' => 'since')
1521
- end
1522
- it 'sorts by the time when Twitter acount was created' do
1523
- @cli.friends
1524
- expect($stdout.string.chomp).to eq 'sferik pengwynn'
1525
- end
1526
- end
1527
- context '--sort=tweets' do
1528
- before do
1529
- @cli.options = @cli.options.merge('sort' => 'tweets')
1530
- end
1531
- it 'sorts by the number of Tweets' do
1532
- @cli.friends
1533
- expect($stdout.string.chomp).to eq 'pengwynn sferik'
1534
- end
1535
- end
1536
- context '--sort=tweeted' do
1537
- before do
1538
- @cli.options = @cli.options.merge('sort' => 'tweeted')
1539
- end
1540
- it 'sorts by the time of the last Tweet' do
1541
- @cli.friends
1542
- expect($stdout.string.chomp).to eq 'pengwynn sferik'
1543
- end
1544
- end
1545
- context '--unsorted' do
1546
- before do
1547
- @cli.options = @cli.options.merge('unsorted' => true)
1548
- end
1549
- it 'is not sorted' do
1550
- @cli.friends
1551
- expect($stdout.string.chomp).to eq 'pengwynn sferik'
1552
- end
1553
- end
1554
- context 'with a user passed' do
1555
- before do
1556
- stub_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'}).to_return(:body => fixture('friends_ids.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
1557
- stub_get('/1.1/followers/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'}).to_return(:body => fixture('friends_ids.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
1558
- end
1559
- it 'requests the correct resource' do
1560
- @cli.friends('sferik')
1561
- expect(a_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'})).to have_been_made
1562
- expect(a_get('/1.1/followers/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'})).to have_been_made
1563
- expect(a_post('/1.1/users/lookup.json').with(:body => {:user_id => '7505382'})).to have_been_made
1564
- end
1565
- context '--id' do
1566
- before do
1567
- @cli.options = @cli.options.merge('id' => true)
1568
- stub_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :user_id => '7505382'}).to_return(:body => fixture('friends_ids.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
1569
- stub_get('/1.1/followers/ids.json').with(:query => {:cursor => '-1', :user_id => '7505382'}).to_return(:body => fixture('friends_ids.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
1570
- end
1571
- it 'requests the correct resource' do
1572
- @cli.friends('7505382')
1573
- expect(a_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :user_id => '7505382'})).to have_been_made
1574
- expect(a_get('/1.1/followers/ids.json').with(:query => {:cursor => '-1', :user_id => '7505382'})).to have_been_made
1575
- expect(a_post('/1.1/users/lookup.json').with(:body => {:user_id => '7505382'})).to have_been_made
1576
- end
1577
- end
1578
- end
1579
- end
1580
-
1581
- describe '#groupies' do
1582
- before do
1583
- stub_get('/1.1/account/verify_credentials.json').to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
1584
- stub_get('/1.1/followers/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'}).to_return(:body => fixture('followers_ids.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
1585
- stub_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'}).to_return(:body => fixture('friends_ids.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
1586
- stub_post('/1.1/users/lookup.json').with(:body => {:user_id => '213747670,428004849'}).to_return(:body => fixture('users.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
1587
- end
1588
- it 'requests the correct resource' do
1589
- @cli.groupies
1590
- expect(a_get('/1.1/account/verify_credentials.json')).to have_been_made
1591
- expect(a_get('/1.1/followers/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'})).to have_been_made
1592
- expect(a_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'})).to have_been_made
1593
- expect(a_post('/1.1/users/lookup.json').with(:body => {:user_id => '213747670,428004849'})).to have_been_made
1594
- end
1595
- it 'has the correct output' do
1596
- @cli.groupies
1597
- expect($stdout.string.chomp).to eq 'pengwynn sferik'
1598
- end
1599
- context '--csv' do
1600
- before do
1601
- @cli.options = @cli.options.merge('csv' => true)
1602
- end
1603
- it 'outputs in CSV format' do
1604
- @cli.groupies
1605
- expect($stdout.string).to eq <<-eos
1606
- ID,Since,Last tweeted at,Tweets,Favorites,Listed,Following,Followers,Screen name,Name,Verified,Protected,Bio,Status,Location,URL
1607
- 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
1608
- 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
1609
- eos
1610
- end
1611
- end
1612
- context '--long' do
1613
- before do
1614
- @cli.options = @cli.options.merge('long' => true)
1615
- end
1616
- it 'outputs in long format' do
1617
- @cli.groupies
1618
- expect($stdout.string).to eq <<-eos
1619
- ID Since Last tweeted at Tweets Favorites Listed Following...
1620
- 14100886 Mar 8 2008 Jul 7 12:33 6940 192 358 3427...
1621
- 7505382 Jul 16 2007 Jul 8 10:29 7890 3755 118 212...
1622
- eos
1623
- end
1624
- end
1625
- context '--reverse' do
1626
- before do
1627
- @cli.options = @cli.options.merge('reverse' => true)
1628
- end
1629
- it 'reverses the order of the sort' do
1630
- @cli.groupies
1631
- expect($stdout.string.chomp).to eq 'sferik pengwynn'
1632
- end
1633
- end
1634
- context '--sort=favorites' do
1635
- before do
1636
- @cli.options = @cli.options.merge('sort' => 'favorites')
1637
- end
1638
- it 'sorts by the number of favorites' do
1639
- @cli.groupies
1640
- expect($stdout.string.chomp).to eq 'pengwynn sferik'
1641
- end
1642
- end
1643
- context '--sort=followers' do
1644
- before do
1645
- @cli.options = @cli.options.merge('sort' => 'followers')
1646
- end
1647
- it 'sorts by the number of followers' do
1648
- @cli.groupies
1649
- expect($stdout.string.chomp).to eq 'sferik pengwynn'
1650
- end
1651
- end
1652
- context '--sort=friends' do
1653
- before do
1654
- @cli.options = @cli.options.merge('sort' => 'friends')
1655
- end
1656
- it 'sorts by the number of friends' do
1657
- @cli.groupies
1658
- expect($stdout.string.chomp).to eq 'sferik pengwynn'
1659
- end
1660
- end
1661
- context '--sort=listed' do
1662
- before do
1663
- @cli.options = @cli.options.merge('sort' => 'listed')
1664
- end
1665
- it 'sorts by the number of list memberships' do
1666
- @cli.groupies
1667
- expect($stdout.string.chomp).to eq 'sferik pengwynn'
1668
- end
1669
- end
1670
- context '--sort=since' do
1671
- before do
1672
- @cli.options = @cli.options.merge('sort' => 'since')
1673
- end
1674
- it 'sorts by the time when Twitter acount was created' do
1675
- @cli.groupies
1676
- expect($stdout.string.chomp).to eq 'sferik pengwynn'
1677
- end
1678
- end
1679
- context '--sort=tweets' do
1680
- before do
1681
- @cli.options = @cli.options.merge('sort' => 'tweets')
1682
- end
1683
- it 'sorts by the number of Tweets' do
1684
- @cli.groupies
1685
- expect($stdout.string.chomp).to eq 'pengwynn sferik'
1686
- end
1687
- end
1688
- context '--sort=tweeted' do
1689
- before do
1690
- @cli.options = @cli.options.merge('sort' => 'tweeted')
1691
- end
1692
- it 'sorts by the time of the last Tweet' do
1693
- @cli.groupies
1694
- expect($stdout.string.chomp).to eq 'pengwynn sferik'
1695
- end
1696
- end
1697
- context '--unsorted' do
1698
- before do
1699
- @cli.options = @cli.options.merge('unsorted' => true)
1700
- end
1701
- it 'is not sorted' do
1702
- @cli.groupies
1703
- expect($stdout.string.chomp).to eq 'pengwynn sferik'
1704
- end
1705
- end
1706
- context 'with a user passed' do
1707
- before do
1708
- stub_get('/1.1/followers/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'}).to_return(:body => fixture('followers_ids.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
1709
- stub_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'}).to_return(:body => fixture('friends_ids.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
1710
- end
1711
- it 'requests the correct resource' do
1712
- @cli.groupies('sferik')
1713
- expect(a_get('/1.1/followers/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'})).to have_been_made
1714
- expect(a_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'})).to have_been_made
1715
- expect(a_post('/1.1/users/lookup.json').with(:body => {:user_id => '213747670,428004849'})).to have_been_made
1716
- end
1717
- context '--id' do
1718
- before do
1719
- @cli.options = @cli.options.merge('id' => true)
1720
- stub_get('/1.1/followers/ids.json').with(:query => {:cursor => '-1', :user_id => '7505382'}).to_return(:body => fixture('followers_ids.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
1721
- stub_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :user_id => '7505382'}).to_return(:body => fixture('friends_ids.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
1722
- end
1723
- it 'requests the correct resource' do
1724
- @cli.groupies('7505382')
1725
- expect(a_get('/1.1/followers/ids.json').with(:query => {:cursor => '-1', :user_id => '7505382'})).to have_been_made
1726
- expect(a_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :user_id => '7505382'})).to have_been_made
1727
- expect(a_post('/1.1/users/lookup.json').with(:body => {:user_id => '213747670,428004849'})).to have_been_made
1728
- end
1729
- end
1730
- end
1731
- end
1732
-
1733
- describe '#intersection' do
1734
- before do
1735
- @cli.options = @cli.options.merge('type' => 'followings')
1736
- stub_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :screen_name => 'testcli'}).to_return(:body => fixture('friends_ids.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
1737
- stub_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'}).to_return(:body => fixture('friends_ids.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
1738
- stub_post('/1.1/users/lookup.json').with(:body => {:user_id => '7505382'}).to_return(:body => fixture('users.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
1739
- end
1740
- it 'requests the correct resource' do
1741
- @cli.intersection('sferik')
1742
- expect(a_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :screen_name => 'testcli'})).to have_been_made
1743
- expect(a_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'})).to have_been_made
1744
- expect(a_post('/1.1/users/lookup.json').with(:body => {:user_id => '7505382'})).to have_been_made
1745
- end
1746
- it 'has the correct output' do
1747
- @cli.intersection('sferik')
1748
- expect($stdout.string.chomp).to eq 'pengwynn sferik'
1749
- end
1750
- context '--csv' do
1751
- before do
1752
- @cli.options = @cli.options.merge('csv' => true)
1753
- end
1754
- it 'outputs in CSV format' do
1755
- @cli.intersection('sferik')
1756
- expect($stdout.string).to eq <<-eos
1757
- ID,Since,Last tweeted at,Tweets,Favorites,Listed,Following,Followers,Screen name,Name,Verified,Protected,Bio,Status,Location,URL
1758
- 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
1759
- 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
1760
- eos
1761
- end
1762
- end
1763
- context '--long' do
1764
- before do
1765
- @cli.options = @cli.options.merge('long' => true)
1766
- end
1767
- it 'outputs in long format' do
1768
- @cli.intersection('sferik')
1769
- expect($stdout.string).to eq <<-eos
1770
- ID Since Last tweeted at Tweets Favorites Listed Following...
1771
- 14100886 Mar 8 2008 Jul 7 12:33 6940 192 358 3427...
1772
- 7505382 Jul 16 2007 Jul 8 10:29 7890 3755 118 212...
1773
- eos
1774
- end
1775
- end
1776
- context '--reverse' do
1777
- before do
1778
- @cli.options = @cli.options.merge('reverse' => true)
1779
- end
1780
- it 'reverses the order of the sort' do
1781
- @cli.intersection('sferik')
1782
- expect($stdout.string.chomp).to eq 'sferik pengwynn'
1783
- end
1784
- end
1785
- context '--sort=favorites' do
1786
- before do
1787
- @cli.options = @cli.options.merge('sort' => 'favorites')
1788
- end
1789
- it 'sorts by the number of favorites' do
1790
- @cli.intersection('sferik')
1791
- expect($stdout.string.chomp).to eq 'pengwynn sferik'
1792
- end
1793
- end
1794
- context '--sort=followers' do
1795
- before do
1796
- @cli.options = @cli.options.merge('sort' => 'followers')
1797
- end
1798
- it 'sorts by the number of followers' do
1799
- @cli.intersection('sferik')
1800
- expect($stdout.string.chomp).to eq 'sferik pengwynn'
1801
- end
1802
- end
1803
- context '--sort=friends' do
1804
- before do
1805
- @cli.options = @cli.options.merge('sort' => 'friends')
1806
- end
1807
- it 'sorts by the number of friends' do
1808
- @cli.intersection('sferik')
1809
- expect($stdout.string.chomp).to eq 'sferik pengwynn'
1810
- end
1811
- end
1812
- context '--sort=listed' do
1813
- before do
1814
- @cli.options = @cli.options.merge('sort' => 'listed')
1815
- end
1816
- it 'sorts by the number of list memberships' do
1817
- @cli.intersection('sferik')
1818
- expect($stdout.string.chomp).to eq 'sferik pengwynn'
1819
- end
1820
- end
1821
- context '--sort=since' do
1822
- before do
1823
- @cli.options = @cli.options.merge('sort' => 'since')
1824
- end
1825
- it 'sorts by the time when Twitter acount was created' do
1826
- @cli.intersection('sferik')
1827
- expect($stdout.string.chomp).to eq 'sferik pengwynn'
1828
- end
1829
- end
1830
- context '--sort=tweets' do
1831
- before do
1832
- @cli.options = @cli.options.merge('sort' => 'tweets')
1833
- end
1834
- it 'sorts by the number of Tweets' do
1835
- @cli.intersection('sferik')
1836
- expect($stdout.string.chomp).to eq 'pengwynn sferik'
1837
- end
1838
- end
1839
- context '--sort=tweeted' do
1840
- before do
1841
- @cli.options = @cli.options.merge('sort' => 'tweeted')
1842
- end
1843
- it 'sorts by the time of the last Tweet' do
1844
- @cli.intersection('sferik')
1845
- expect($stdout.string.chomp).to eq 'pengwynn sferik'
1846
- end
1847
- end
1848
- context '--type=followers' do
1849
- before do
1850
- @cli.options = @cli.options.merge('type' => 'followers')
1851
- stub_get('/1.1/followers/ids.json').with(:query => {:cursor => '-1', :screen_name => 'testcli'}).to_return(:body => fixture('followers_ids.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
1852
- stub_get('/1.1/followers/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'}).to_return(:body => fixture('followers_ids.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
1853
- stub_post('/1.1/users/lookup.json').with(:body => {:user_id => '213747670,428004849'}).to_return(:body => fixture('users.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
1854
- end
1855
- it 'requests the correct resource' do
1856
- @cli.intersection('sferik')
1857
- expect(a_get('/1.1/followers/ids.json').with(:query => {:cursor => '-1', :screen_name => 'testcli'})).to have_been_made
1858
- expect(a_get('/1.1/followers/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'})).to have_been_made
1859
- expect(a_post('/1.1/users/lookup.json').with(:body => {:user_id => '213747670,428004849'})).to have_been_made
1860
- end
1861
- it 'has the correct output' do
1862
- @cli.intersection('sferik')
1863
- expect($stdout.string.chomp).to eq 'pengwynn sferik'
1864
- end
1865
- end
1866
- context '--unsorted' do
1867
- before do
1868
- @cli.options = @cli.options.merge('unsorted' => true)
1869
- end
1870
- it 'is not sorted' do
1871
- @cli.intersection('sferik')
1872
- expect($stdout.string.chomp).to eq 'pengwynn sferik'
1873
- end
1874
- end
1875
- context 'with two users passed' do
1876
- before do
1877
- stub_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :screen_name => 'pengwynn'}).to_return(:body => fixture('friends_ids.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
1878
- stub_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'}).to_return(:body => fixture('friends_ids.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
1879
- end
1880
- it 'requests the correct resource' do
1881
- @cli.intersection('sferik', 'pengwynn')
1882
- expect(a_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :screen_name => 'pengwynn'})).to have_been_made
1883
- expect(a_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'})).to have_been_made
1884
- expect(a_post('/1.1/users/lookup.json').with(:body => {:user_id => '7505382'})).to have_been_made
1885
- end
1886
- context '--id' do
1887
- before do
1888
- @cli.options = @cli.options.merge('id' => true)
1889
- stub_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :user_id => '14100886'}).to_return(:body => fixture('friends_ids.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
1890
- stub_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :user_id => '7505382'}).to_return(:body => fixture('friends_ids.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
1891
- end
1892
- it 'requests the correct resource' do
1893
- @cli.intersection('7505382', '14100886')
1894
- expect(a_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :user_id => '14100886'})).to have_been_made
1895
- expect(a_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :user_id => '7505382'})).to have_been_made
1896
- expect(a_post('/1.1/users/lookup.json').with(:body => {:user_id => '7505382'})).to have_been_made
1897
- end
1898
- end
1899
- end
1900
- end
1901
-
1902
- describe '#leaders' do
1903
- before do
1904
- stub_get('/1.1/account/verify_credentials.json').to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
1905
- stub_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'}).to_return(:body => fixture('friends_ids.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
1906
- stub_get('/1.1/followers/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'}).to_return(:body => fixture('followers_ids.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
1907
- stub_post('/1.1/users/lookup.json').with(:body => {:user_id => '7505382'}).to_return(:body => fixture('users.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
1908
- end
1909
- it 'requests the correct resource' do
1910
- @cli.leaders
1911
- expect(a_get('/1.1/account/verify_credentials.json')).to have_been_made
1912
- expect(a_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'})).to have_been_made
1913
- expect(a_get('/1.1/followers/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'})).to have_been_made
1914
- expect(a_post('/1.1/users/lookup.json').with(:body => {:user_id => '7505382'})).to have_been_made
1915
- end
1916
- it 'has the correct output' do
1917
- @cli.leaders
1918
- expect($stdout.string.chomp).to eq 'pengwynn sferik'
1919
- end
1920
- context '--csv' do
1921
- before do
1922
- @cli.options = @cli.options.merge('csv' => true)
1923
- end
1924
- it 'outputs in CSV format' do
1925
- @cli.leaders
1926
- expect($stdout.string).to eq <<-eos
1927
- ID,Since,Last tweeted at,Tweets,Favorites,Listed,Following,Followers,Screen name,Name,Verified,Protected,Bio,Status,Location,URL
1928
- 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
1929
- 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
1930
- eos
1931
- end
1932
- end
1933
- context '--long' do
1934
- before do
1935
- @cli.options = @cli.options.merge('long' => true)
1936
- end
1937
- it 'outputs in long format' do
1938
- @cli.leaders
1939
- expect($stdout.string).to eq <<-eos
1940
- ID Since Last tweeted at Tweets Favorites Listed Following...
1941
- 14100886 Mar 8 2008 Jul 7 12:33 6940 192 358 3427...
1942
- 7505382 Jul 16 2007 Jul 8 10:29 7890 3755 118 212...
1943
- eos
1944
- end
1945
- end
1946
- context '--reverse' do
1947
- before do
1948
- @cli.options = @cli.options.merge('reverse' => true)
1949
- end
1950
- it 'reverses the order of the sort' do
1951
- @cli.leaders
1952
- expect($stdout.string.chomp).to eq 'sferik pengwynn'
1953
- end
1954
- end
1955
- context '--sort=favorites' do
1956
- before do
1957
- @cli.options = @cli.options.merge('sort' => 'favorites')
1958
- end
1959
- it 'sorts by the number of favorites' do
1960
- @cli.leaders
1961
- expect($stdout.string.chomp).to eq 'pengwynn sferik'
1962
- end
1963
- end
1964
- context '--sort=followers' do
1965
- before do
1966
- @cli.options = @cli.options.merge('sort' => 'followers')
1967
- end
1968
- it 'sorts by the number of followers' do
1969
- @cli.leaders
1970
- expect($stdout.string.chomp).to eq 'sferik pengwynn'
1971
- end
1972
- end
1973
- context '--sort=friends' do
1974
- before do
1975
- @cli.options = @cli.options.merge('sort' => 'friends')
1976
- end
1977
- it 'sorts by the number of friends' do
1978
- @cli.leaders
1979
- expect($stdout.string.chomp).to eq 'sferik pengwynn'
1980
- end
1981
- end
1982
- context '--sort=listed' do
1983
- before do
1984
- @cli.options = @cli.options.merge('sort' => 'listed')
1985
- end
1986
- it 'sorts by the number of list memberships' do
1987
- @cli.leaders
1988
- expect($stdout.string.chomp).to eq 'sferik pengwynn'
1989
- end
1990
- end
1991
- context '--sort=since' do
1992
- before do
1993
- @cli.options = @cli.options.merge('sort' => 'since')
1994
- end
1995
- it 'sorts by the time when Twitter acount was created' do
1996
- @cli.leaders
1997
- expect($stdout.string.chomp).to eq 'sferik pengwynn'
1998
- end
1999
- end
2000
- context '--sort=tweets' do
2001
- before do
2002
- @cli.options = @cli.options.merge('sort' => 'tweets')
2003
- end
2004
- it 'sorts by the number of Tweets' do
2005
- @cli.leaders
2006
- expect($stdout.string.chomp).to eq 'pengwynn sferik'
2007
- end
2008
- end
2009
- context '--sort=tweeted' do
2010
- before do
2011
- @cli.options = @cli.options.merge('sort' => 'tweeted')
2012
- end
2013
- it 'sorts by the time of the last Tweet' do
2014
- @cli.leaders
2015
- expect($stdout.string.chomp).to eq 'pengwynn sferik'
2016
- end
2017
- end
2018
- context '--unsorted' do
2019
- before do
2020
- @cli.options = @cli.options.merge('unsorted' => true)
2021
- end
2022
- it 'is not sorted' do
2023
- @cli.leaders
2024
- expect($stdout.string.chomp).to eq 'pengwynn sferik'
2025
- end
2026
- end
2027
- context 'with a user passed' do
2028
- before do
2029
- stub_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'}).to_return(:body => fixture('friends_ids.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
2030
- stub_get('/1.1/followers/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'}).to_return(:body => fixture('followers_ids.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
2031
- end
2032
- it 'requests the correct resource' do
2033
- @cli.leaders('sferik')
2034
- expect(a_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'})).to have_been_made
2035
- expect(a_get('/1.1/followers/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'})).to have_been_made
2036
- expect(a_post('/1.1/users/lookup.json').with(:body => {:user_id => '7505382'})).to have_been_made
2037
- end
2038
- context '--id' do
2039
- before do
2040
- @cli.options = @cli.options.merge('id' => true)
2041
- stub_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :user_id => '7505382'}).to_return(:body => fixture('friends_ids.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
2042
- stub_get('/1.1/followers/ids.json').with(:query => {:cursor => '-1', :user_id => '7505382'}).to_return(:body => fixture('followers_ids.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
2043
- end
2044
- it 'requests the correct resource' do
2045
- @cli.leaders('7505382')
2046
- expect(a_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :user_id => '7505382'})).to have_been_made
2047
- expect(a_get('/1.1/followers/ids.json').with(:query => {:cursor => '-1', :user_id => '7505382'})).to have_been_made
2048
- expect(a_post('/1.1/users/lookup.json').with(:body => {:user_id => '7505382'})).to have_been_made
2049
- end
2050
- end
2051
- end
2052
- end
2053
-
2054
- describe '#lists' do
2055
- before do
2056
- stub_get('/1.1/lists/list.json').to_return(:body => fixture('lists.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
2057
- end
2058
- it 'requests the correct resource' do
2059
- @cli.lists
2060
- expect(a_get('/1.1/lists/list.json')).to have_been_made
2061
- end
2062
- it 'has the correct output' do
2063
- @cli.lists
2064
- expect($stdout.string.chomp).to eq '@pengwynn/rubyists @twitter/team @sferik/test'
2065
- end
2066
- context '--csv' do
2067
- before do
2068
- @cli.options = @cli.options.merge('csv' => true)
2069
- end
2070
- it 'outputs in CSV format' do
2071
- @cli.lists
2072
- expect($stdout.string).to eq <<-eos
2073
- ID,Created at,Screen name,Slug,Members,Subscribers,Mode,Description
2074
- 1129440,2009-10-30 14:39:25 +0000,pengwynn,rubyists,499,39,public,
2075
- 574,2009-09-23 01:18:01 +0000,twitter,team,1199,78078,other,
2076
- 73546689,2012-07-08 22:19:05 +0000,sferik,test,2,0,private,
2077
- eos
2078
- end
2079
- end
2080
- context '--long' do
2081
- before do
2082
- @cli.options = @cli.options.merge('long' => true)
2083
- end
2084
- it 'outputs in long format' do
2085
- @cli.lists
2086
- expect($stdout.string).to eq <<-eos
2087
- ID Created at Screen name Slug Members Subscribers Mode ...
2088
- 1129440 Oct 30 2009 @pengwynn rubyists 499 39 public
2089
- 574 Sep 22 2009 @twitter team 1199 78078 other
2090
- 73546689 Jul 8 14:19 @sferik test 2 0 private
2091
- eos
2092
- end
2093
- end
2094
- context '--reverse' do
2095
- before do
2096
- @cli.options = @cli.options.merge('reverse' => true)
2097
- end
2098
- it 'reverses the order of the sort' do
2099
- @cli.lists
2100
- expect($stdout.string.chomp).to eq '@sferik/test @twitter/team @pengwynn/rubyists'
2101
- end
2102
- end
2103
- context '--sort=members' do
2104
- before do
2105
- @cli.options = @cli.options.merge('sort' => 'members')
2106
- end
2107
- it 'sorts by the number of members' do
2108
- @cli.lists
2109
- expect($stdout.string.chomp).to eq '@sferik/test @pengwynn/rubyists @twitter/team'
2110
- end
2111
- end
2112
- context '--sort=mode' do
2113
- before do
2114
- @cli.options = @cli.options.merge('sort' => 'mode')
2115
- end
2116
- it 'sorts by the mode' do
2117
- @cli.lists
2118
- expect($stdout.string.chomp).to eq '@twitter/team @sferik/test @pengwynn/rubyists'
2119
- end
2120
- end
2121
- context '--sort=since' do
2122
- before do
2123
- @cli.options = @cli.options.merge('sort' => 'since')
2124
- end
2125
- it 'sorts by the time when Twitter list was created' do
2126
- @cli.lists
2127
- expect($stdout.string.chomp).to eq '@twitter/team @pengwynn/rubyists @sferik/test'
2128
- end
2129
- end
2130
- context '--sort=subscribers' do
2131
- before do
2132
- @cli.options = @cli.options.merge('sort' => 'subscribers')
2133
- end
2134
- it 'sorts by the number of subscribers' do
2135
- @cli.lists
2136
- expect($stdout.string.chomp).to eq '@sferik/test @pengwynn/rubyists @twitter/team'
2137
- end
2138
- end
2139
- context '--unsorted' do
2140
- before do
2141
- @cli.options = @cli.options.merge('unsorted' => true)
2142
- end
2143
- it 'is not sorted' do
2144
- @cli.lists
2145
- expect($stdout.string.chomp).to eq '@pengwynn/rubyists @twitter/team @sferik/test'
2146
- end
2147
- end
2148
- context 'with a user passed' do
2149
- before do
2150
- stub_get('/1.1/lists/list.json').with(:query => {:screen_name => 'sferik'}).to_return(:body => fixture('lists.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
2151
- end
2152
- it 'requests the correct resource' do
2153
- @cli.lists('sferik')
2154
- expect(a_get('/1.1/lists/list.json').with(:query => {:screen_name => 'sferik'})).to have_been_made
2155
- end
2156
- context '--id' do
2157
- before do
2158
- @cli.options = @cli.options.merge('id' => true)
2159
- stub_get('/1.1/lists/list.json').with(:query => {:user_id => '7505382'}).to_return(:body => fixture('lists.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
2160
- end
2161
- it 'requests the correct resource' do
2162
- @cli.lists('7505382')
2163
- expect(a_get('/1.1/lists/list.json').with(:query => {:user_id => '7505382'})).to have_been_made
2164
- end
2165
- end
2166
- end
2167
- end
2168
-
2169
- describe '#matrix' do
2170
- before do
2171
- stub_get('/1.1/search/tweets.json').with(:query => {:q => 'lang:ja', :count => 100, :include_entities => 'false'}).to_return(:body => fixture('matrix.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
2172
- stub_get('/1.1/search/tweets.json').with(:query => {:q => 'lang:ja', :count => 100, :max_id => '434642935557021697'}).to_return(:body => fixture('empty_cursor.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
2173
- end
2174
- it 'requests the correct resource' do
2175
- @cli.matrix
2176
- expect(a_get('/1.1/search/tweets.json').with(:query => {:q => 'lang:ja', :count => 100, :include_entities => 'false'})).to have_been_made
2177
- expect(a_get('/1.1/search/tweets.json').with(:query => {:q => 'lang:ja', :count => 100, :max_id => '434642935557021697'})).to have_been_made
2178
- end
2179
- it 'has the correct output' do
2180
- @cli.matrix
2181
- expect($stdout.string).to eq('すまてっんさすでらなるあでかんせまいるきでいおすでいたりにずらさなもはういとざいうよいなしにいおでんせまてっはもらかのはにののずらかかるれらけでついらかがはがすでろこといたいとにいおにばらなくいばれたあんゃちあさかじましたあいしのくうよめやのうとこういうそたみてっがんくをまさかうょしでのるれくていでいてってっねよるれなくとのもなんみばれなくとのがいななんそよいなくしてしかんけでのとのいいゃちめ んくけったっだもどけるあはえたっあてっのやににめたのあたっかしこそあしだうそもなねうろだんるなになとっもらたてっにもしもるうおんぶたすまりなにはにかいちんゃにぃちほでいなしにのいいばれしことななんみわだいわこま  いたきのわふわっふくじたすましらかいならわたでんびにでれそんけやなかのたっゃちしとかよたてちにのねいさだくてきすましにりぱっやにいつがたしまりあはろことうろいろいあまねんもだにうとがりあいなてえかしとこたれらててれさてれさてれさきはいなてえうなるがゃちっめつっおいばやらかたてっすでのいばやいばやまんほねよすでかだんなかたしでうそりはやいわかりきっすしがんせまりあはでのていつにのなかのいなはにいらくるがなもとまてめせるけぬしをるすいならをるすいなてめじなにずらわかかもにのなとんにあにあてうゃちんさばおよすでてくなゃじすではのるてっがんさがすましででのいなおはてっあがつやるすにいたみをるあのとのるでいなきでかしではんくどんえっへすでみらたぎすらかんさのらかれこかすでるけべとっずをねいさだくでんにでのなびなんそてんなだねるめたかとこのせゆるねいがすさたっかはのこいなえりあぇふっぇふっぇふいらくとだらかだいらくでいたみゃちっめっもはてくないくしてっやのゆこそこきとなんこういてみのたしねどけうといぞうどるえもでんなででのみるぐいぬでさのでででべなきでききでるてっでぬいねもでくつりがのうよしうどいなくたきうもわこのだねすでうそええいなえかしおらかてっとおよだのいがのてっなくないがういとだぎゃじなをたっかなえとおでまだんでんをのてきてちおらかかったっかなくきのけにいたけにをいなえかしにでてべすのいらくれそできがにももいたりをのそるえうそとたっかよにとこたえにえかすまりかわかるいてっがすまいでんがいながすでのるすをいむにのるすのるいていかをたまてっよにくいてっがらかりすうよたれさにまさいながいのとのるてったいとっょちぜだんなつやいいるてっなにとこなてれがのそっくみいたきいるあではにずはいがりよえかちてしとにせらがにでたえばつにでのるすをれことんほ いのと すがるかわるてしはのてんないならをれあるあがぁぁぁぐっっべやかえねゃじんすらなれこよてままいがとれそねよいもれそぱっやをいいねてしごをいしうとがりあもうとがりあもいさゃにみすやおいまうがのすましいおばろぉふらたっかよすまきだたいてせさろぉふすまいざごうとがりあのたしまりなくすできらかいのこたみていかたてってっいたみていにすまいざごうよはおすではつつらからかうもちっこうそあわうたっへこどにでとるぎすなんみがのうよてしのかはのいがかだとみゃしくにうよすまりあでるれでがのにのたっやいてっらこいによはらかだたっかなかついかしいらくいえてえかすまてっでねすでりえかおよたっゃちっいさなんめごたしあうろやでらながっええたしましうとがりあうろをできいさなみすやおるらがなえをいなのくべるなかうこでういうどのでかしつかはてさいばやはれそいばやいばやんらまたんらまたうもらかやきたっかとんほいめやおいなけでどけいたき')
2182
- end
2183
- end
2184
-
2185
- describe '#mentions' do
2186
- before do
2187
- stub_get('/1.1/statuses/mentions_timeline.json').with(:query => {:count => '20', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
2188
- end
2189
- it 'requests the correct resource' do
2190
- @cli.mentions
2191
- expect(a_get('/1.1/statuses/mentions_timeline.json').with(:query => {:count => '20', :include_entities => 'false'})).to have_been_made
2192
- end
2193
- it 'has the correct output' do
2194
- @cli.mentions
2195
- expect($stdout.string).to eq <<-eos
2196
- @mutgoff
2197
- Happy Birthday @imdane. Watch out for those @rally pranksters!
2198
-
2199
- @ironicsans
2200
- If you like good real-life stories, check out @NarrativelyNY's just-launched
2201
- site http://t.co/wiUL07jE (and also visit http://t.co/ZoyQxqWA)
2202
-
2203
- @pat_shaughnessy
2204
- Something else to vote for: "New Rails workshops to bring more women into the
2205
- Boston software scene" http://t.co/eNBuckHc /cc @bostonrb
2206
-
2207
- @calebelston
2208
- Pushing the button to launch the site. http://t.co/qLoEn5jG
2209
-
2210
- @calebelston
2211
- RT @olivercameron: Mosaic looks cool: http://t.co/A8013C9k
2212
-
2213
- @fivethirtyeight
2214
- The Weatherman is Not a Moron: http://t.co/ZwL5Gnq5. An excerpt from my book,
2215
- THE SIGNAL AND THE NOISE (http://t.co/fNXj8vCE)
2216
-
2217
- @codeforamerica
2218
- RT @randomhacks: Going to Code Across Austin II: Y'all Come Hack Now, Sat,
2219
- Sep 8 http://t.co/Sk5BM7U3 We'll see y'all there! #rhok @codeforamerica
2220
- @TheaClay
2221
-
2222
- @fbjork
2223
- RT @jondot: Just published: "Pragmatic Concurrency With #Ruby"
2224
- http://t.co/kGEykswZ /cc @JRuby @headius
2225
-
2226
- @mbostock
2227
- If you are wondering how we computed the split bubbles: http://t.co/BcaqSs5u
2228
-
2229
- @FakeDorsey
2230
- "Write drunk. Edit sober."—Ernest Hemingway
2231
-
2232
- @al3x
2233
- RT @wcmaier: Better banking through better ops: build something new with us
2234
- @Simplify (remote, PDX) http://t.co/8WgzKZH3
2235
-
2236
- @calebelston
2237
- We just announced Mosaic, what we've been working on since the Yobongo
2238
- acquisition. My personal post, http://t.co/ELOyIRZU @heymosaic
2239
-
2240
- @BarackObama
2241
- Donate $10 or more --> get your favorite car magnet: http://t.co/NfRhl2s2
2242
- #Obama2012
2243
-
2244
- @JEG2
2245
- RT @tenderlove: If corporations are people, can we use them to drive in the
2246
- carpool lane?
2247
-
2248
- @eveningedition
2249
- LDN—Obama's nomination; Putin woos APEC; Bombs hit Damascus; Quakes shake
2250
- China; Canada cuts Iran ties; weekend read: http://t.co/OFs6dVW4
2251
-
2252
- @dhh
2253
- RT @ggreenwald: Democrats parade Osama bin Laden's corpse as their proudest
2254
- achievement: why this goulish jingoism is so warped http://t.co/kood278s
2255
-
2256
- @jasonfried
2257
- The story of Mars Curiosity's gears, made by a factory in Rockford, IL:
2258
- http://t.co/MwCRsHQg
2259
-
2260
- @sferik
2261
- @episod @twitterapi now https://t.co/I17jUTu2 and https://t.co/deDu4Hgw seem
2262
- to be missing "1.1" from the URL.
2263
-
2264
- @sferik
2265
- @episod @twitterapi Did you catch https://t.co/VHsQvZT0 as well?
2266
-
2267
- @dwiskus
2268
- Gentlemen, you can't fight in here! This is the war room!
2269
- http://t.co/kMxMYyqF
2270
-
2271
- eos
2272
- end
2273
- context '--csv' do
2274
- before do
2275
- @cli.options = @cli.options.merge('csv' => true)
2276
- end
2277
- it 'outputs in CSV format' do
2278
- @cli.mentions
2279
- expect($stdout.string).to eq <<-eos
2280
- ID,Posted at,Screen name,Text
2281
- 4611686018427387904,2012-09-07 16:35:24 +0000,mutgoff,Happy Birthday @imdane. Watch out for those @rally pranksters!
2282
- 244111183165157376,2012-09-07 16:33:36 +0000,ironicsans,"If you like good real-life stories, check out @NarrativelyNY's just-launched site http://t.co/wiUL07jE (and also visit http://t.co/ZoyQxqWA)"
2283
- 244110336414859264,2012-09-07 16:30:14 +0000,pat_shaughnessy,"Something else to vote for: ""New Rails workshops to bring more women into the Boston software scene"" http://t.co/eNBuckHc /cc @bostonrb"
2284
- 244109797308379136,2012-09-07 16:28:05 +0000,calebelston,Pushing the button to launch the site. http://t.co/qLoEn5jG
2285
- 244108728834592770,2012-09-07 16:23:50 +0000,calebelston,RT @olivercameron: Mosaic looks cool: http://t.co/A8013C9k
2286
- 244107890632294400,2012-09-07 16:20:31 +0000,fivethirtyeight,"The Weatherman is Not a Moron: http://t.co/ZwL5Gnq5. An excerpt from my book, THE SIGNAL AND THE NOISE (http://t.co/fNXj8vCE)"
2287
- 244107823733174272,2012-09-07 16:20:15 +0000,codeforamerica,"RT @randomhacks: Going to Code Across Austin II: Y'all Come Hack Now, Sat, Sep 8 http://t.co/Sk5BM7U3 We'll see y'all there! #rhok @codeforamerica @TheaClay"
2288
- 244107236262170624,2012-09-07 16:17:55 +0000,fbjork,"RT @jondot: Just published: ""Pragmatic Concurrency With #Ruby"" http://t.co/kGEykswZ /cc @JRuby @headius"
2289
- 244106476048764928,2012-09-07 16:14:53 +0000,mbostock,If you are wondering how we computed the split bubbles: http://t.co/BcaqSs5u
2290
- 244105599351148544,2012-09-07 16:11:24 +0000,FakeDorsey,"""Write drunk. Edit sober.""—Ernest Hemingway"
2291
- 244104558433951744,2012-09-07 16:07:16 +0000,al3x,"RT @wcmaier: Better banking through better ops: build something new with us @Simplify (remote, PDX) http://t.co/8WgzKZH3"
2292
- 244104146997870594,2012-09-07 16:05:38 +0000,calebelston,"We just announced Mosaic, what we've been working on since the Yobongo acquisition. My personal post, http://t.co/ELOyIRZU @heymosaic"
2293
- 244103057175113729,2012-09-07 16:01:18 +0000,BarackObama,Donate $10 or more --> get your favorite car magnet: http://t.co/NfRhl2s2 #Obama2012
2294
- 244102834398851073,2012-09-07 16:00:25 +0000,JEG2,"RT @tenderlove: If corporations are people, can we use them to drive in the carpool lane?"
2295
- 244102741125890048,2012-09-07 16:00:03 +0000,eveningedition,LDN—Obama's nomination; Putin woos APEC; Bombs hit Damascus; Quakes shake China; Canada cuts Iran ties; weekend read: http://t.co/OFs6dVW4
2296
- 244102729860009984,2012-09-07 16:00:00 +0000,dhh,RT @ggreenwald: Democrats parade Osama bin Laden's corpse as their proudest achievement: why this goulish jingoism is so warped http://t.co/kood278s
2297
- 244102490646278146,2012-09-07 15:59:03 +0000,jasonfried,"The story of Mars Curiosity's gears, made by a factory in Rockford, IL: http://t.co/MwCRsHQg"
2298
- 244102209942458368,2012-09-07 15:57:56 +0000,sferik,"@episod @twitterapi now https://t.co/I17jUTu2 and https://t.co/deDu4Hgw seem to be missing ""1.1"" from the URL."
2299
- 244100411563339777,2012-09-07 15:50:47 +0000,sferik,@episod @twitterapi Did you catch https://t.co/VHsQvZT0 as well?
2300
- 244099460672679938,2012-09-07 15:47:01 +0000,dwiskus,"Gentlemen, you can't fight in here! This is the war room! http://t.co/kMxMYyqF"
2301
- eos
2302
- end
2303
- end
2304
- context '--decode-uris' do
2305
- before do
2306
- @cli.options = @cli.options.merge('decode_uris' => true)
2307
- stub_get('/1.1/statuses/mentions_timeline.json').with(:query => {:count => '20', :include_entities => 'true'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
2308
- end
2309
- it 'requests the correct resource' do
2310
- @cli.mentions
2311
- expect(a_get('/1.1/statuses/mentions_timeline.json').with(:query => {:count => '20', :include_entities => 'true'})).to have_been_made
2312
- end
2313
- it 'decodes URLs' do
2314
- @cli.mentions
2315
- expect($stdout.string).to include 'https://twitter.com/sferik/status/243988000076337152'
2316
- end
2317
- end
2318
- context '--long' do
2319
- before do
2320
- @cli.options = @cli.options.merge('long' => true)
2321
- end
2322
- it 'outputs in long format' do
2323
- @cli.mentions
2324
- expect($stdout.string).to eq <<-eos
2325
- ID Posted at Screen name Text
2326
- 4611686018427387904 Sep 7 08:35 @mutgoff Happy Birthday @imdane. ...
2327
- 244111183165157376 Sep 7 08:33 @ironicsans If you like good real-li...
2328
- 244110336414859264 Sep 7 08:30 @pat_shaughnessy Something else to vote f...
2329
- 244109797308379136 Sep 7 08:28 @calebelston Pushing the button to la...
2330
- 244108728834592770 Sep 7 08:23 @calebelston RT @olivercameron: Mosai...
2331
- 244107890632294400 Sep 7 08:20 @fivethirtyeight The Weatherman is Not a ...
2332
- 244107823733174272 Sep 7 08:20 @codeforamerica RT @randomhacks: Going t...
2333
- 244107236262170624 Sep 7 08:17 @fbjork RT @jondot: Just publish...
2334
- 244106476048764928 Sep 7 08:14 @mbostock If you are wondering how...
2335
- 244105599351148544 Sep 7 08:11 @FakeDorsey "Write drunk. Edit sober...
2336
- 244104558433951744 Sep 7 08:07 @al3x RT @wcmaier: Better bank...
2337
- 244104146997870594 Sep 7 08:05 @calebelston We just announced Mosaic...
2338
- 244103057175113729 Sep 7 08:01 @BarackObama Donate $10 or more --> g...
2339
- 244102834398851073 Sep 7 08:00 @JEG2 RT @tenderlove: If corpo...
2340
- 244102741125890048 Sep 7 08:00 @eveningedition LDN—Obama's nomination; ...
2341
- 244102729860009984 Sep 7 08:00 @dhh RT @ggreenwald: Democrat...
2342
- 244102490646278146 Sep 7 07:59 @jasonfried The story of Mars Curios...
2343
- 244102209942458368 Sep 7 07:57 @sferik @episod @twitterapi now ...
2344
- 244100411563339777 Sep 7 07:50 @sferik @episod @twitterapi Did ...
2345
- 244099460672679938 Sep 7 07:47 @dwiskus Gentlemen, you can't fig...
2346
- eos
2347
- end
2348
- context '--reverse' do
2349
- before do
2350
- @cli.options = @cli.options.merge('reverse' => true)
2351
- end
2352
- it 'reverses the order of the sort' do
2353
- @cli.mentions
2354
- expect($stdout.string).to eq <<-eos
2355
- ID Posted at Screen name Text
2356
- 244099460672679938 Sep 7 07:47 @dwiskus Gentlemen, you can't fig...
2357
- 244100411563339777 Sep 7 07:50 @sferik @episod @twitterapi Did ...
2358
- 244102209942458368 Sep 7 07:57 @sferik @episod @twitterapi now ...
2359
- 244102490646278146 Sep 7 07:59 @jasonfried The story of Mars Curios...
2360
- 244102729860009984 Sep 7 08:00 @dhh RT @ggreenwald: Democrat...
2361
- 244102741125890048 Sep 7 08:00 @eveningedition LDN—Obama's nomination; ...
2362
- 244102834398851073 Sep 7 08:00 @JEG2 RT @tenderlove: If corpo...
2363
- 244103057175113729 Sep 7 08:01 @BarackObama Donate $10 or more --> g...
2364
- 244104146997870594 Sep 7 08:05 @calebelston We just announced Mosaic...
2365
- 244104558433951744 Sep 7 08:07 @al3x RT @wcmaier: Better bank...
2366
- 244105599351148544 Sep 7 08:11 @FakeDorsey "Write drunk. Edit sober...
2367
- 244106476048764928 Sep 7 08:14 @mbostock If you are wondering how...
2368
- 244107236262170624 Sep 7 08:17 @fbjork RT @jondot: Just publish...
2369
- 244107823733174272 Sep 7 08:20 @codeforamerica RT @randomhacks: Going t...
2370
- 244107890632294400 Sep 7 08:20 @fivethirtyeight The Weatherman is Not a ...
2371
- 244108728834592770 Sep 7 08:23 @calebelston RT @olivercameron: Mosai...
2372
- 244109797308379136 Sep 7 08:28 @calebelston Pushing the button to la...
2373
- 244110336414859264 Sep 7 08:30 @pat_shaughnessy Something else to vote f...
2374
- 244111183165157376 Sep 7 08:33 @ironicsans If you like good real-li...
2375
- 4611686018427387904 Sep 7 08:35 @mutgoff Happy Birthday @imdane. ...
2376
- eos
2377
- end
2378
- end
2379
- end
2380
- context '--number' do
2381
- before do
2382
- stub_get('/1.1/statuses/mentions_timeline.json').with(:query => {:count => '1', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
2383
- stub_get('/1.1/statuses/mentions_timeline.json').with(:query => {:count => '200', :include_entities => 'false'}).to_return(:body => fixture('200_statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
2384
- stub_get('/1.1/statuses/mentions_timeline.json').with(:query => {:count => '1', :max_id => '265500541700956160', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
2385
- end
2386
- it 'limits the number of results to 1' do
2387
- @cli.options = @cli.options.merge('number' => 1)
2388
- @cli.mentions
2389
- expect(a_get('/1.1/statuses/mentions_timeline.json').with(:query => {:count => '1', :include_entities => 'false'})).to have_been_made
2390
- end
2391
- it 'limits the number of results to 201' do
2392
- @cli.options = @cli.options.merge('number' => 201)
2393
- @cli.mentions
2394
- expect(a_get('/1.1/statuses/mentions_timeline.json').with(:query => {:count => '200', :include_entities => 'false'})).to have_been_made
2395
- expect(a_get('/1.1/statuses/mentions_timeline.json').with(:query => {:count => '1', :max_id => '265500541700956160', :include_entities => 'false'})).to have_been_made
2396
- end
2397
- end
2398
- end
2399
-
2400
- describe '#mute' do
2401
- before do
2402
- @cli.options = @cli.options.merge('profile' => fixture_path + '/.trc')
2403
- stub_post('/1.1/mutes/users/create.json').with(:body => {:screen_name => 'sferik'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
2404
- end
2405
- it 'requests the correct resource' do
2406
- @cli.mute('sferik')
2407
- expect(a_post('/1.1/mutes/users/create.json').with(:body => {:screen_name => 'sferik'})).to have_been_made
2408
- end
2409
- it 'has the correct output' do
2410
- @cli.mute('sferik')
2411
- expect($stdout.string).to match(/^@testcli muted 1 user/)
2412
- end
2413
- context '--id' do
2414
- before do
2415
- @cli.options = @cli.options.merge('id' => true)
2416
- stub_post('/1.1/mutes/users/create.json').with(:body => {:user_id => '7505382'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
2417
- end
2418
- it 'requests the correct resource' do
2419
- @cli.mute('7505382')
2420
- expect(a_post('/1.1/mutes/users/create.json').with(:body => {:user_id => '7505382'})).to have_been_made
2421
- end
2422
- end
2423
- end
2424
-
2425
- describe '#open' do
2426
- before do
2427
- @cli.options = @cli.options.merge('display-uri' => true)
2428
- end
2429
- it 'has the correct output' do
2430
- expect do
2431
- @cli.open('sferik')
2432
- end.not_to raise_error
2433
- end
2434
- context '--id' do
2435
- before do
2436
- @cli.options = @cli.options.merge('id' => true)
2437
- stub_get('/1.1/users/show.json').with(:query => {:user_id => '420'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
2438
- end
2439
- it 'requests the correct resource' do
2440
- @cli.open('420')
2441
- expect(a_get('/1.1/users/show.json').with(:query => {:user_id => '420'})).to have_been_made
2442
- end
2443
- end
2444
- context '--status' do
2445
- before do
2446
- @cli.options = @cli.options.merge('status' => true)
2447
- stub_get('/1.1/statuses/show/55709764298092545.json').with(:query => {:include_my_retweet => 'false'}).to_return(:body => fixture('status.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
2448
- end
2449
- it 'requests the correct resource' do
2450
- @cli.open('55709764298092545')
2451
- expect(a_get('/1.1/statuses/show/55709764298092545.json').with(:query => {:include_my_retweet => 'false'})).to have_been_made
2452
- end
2453
- it 'has the correct output' do
2454
- expect do
2455
- @cli.open('55709764298092545')
2456
- end.not_to raise_error
2457
- end
2458
- end
2459
- end
2460
-
2461
- describe '#reach' do
2462
- before do
2463
- stub_get('/1.1/statuses/show/55709764298092545.json').with(:query => {:include_my_retweet => 'false'}).to_return(:body => fixture('status.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
2464
- stub_get('/1.1/statuses/retweeters/ids.json').with(:query => {:id => '55709764298092545', :cursor => '-1'}).to_return(:body => fixture('ids_list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
2465
- stub_get('/1.1/statuses/retweeters/ids.json').with(:query => {:id => '55709764298092545', :cursor => '1305102810874389703'}).to_return(:body => fixture('ids_list2.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
2466
- stub_get('/1.1/followers/ids.json').with(:query => {:cursor => '-1', :user_id => '7505382'}).to_return(:body => fixture('followers_ids.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
2467
- stub_get('/1.1/followers/ids.json').with(:query => {:cursor => '-1', :user_id => '20009713'}).to_return(:body => fixture('followers_ids.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
2468
- stub_get('/1.1/followers/ids.json').with(:query => {:cursor => '-1', :user_id => '14100886'}).to_return(:body => fixture('followers_ids.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
2469
- end
2470
- it 'requests the correct resources' do
2471
- @cli.reach('55709764298092545')
2472
- expect(a_get('/1.1/statuses/show/55709764298092545.json').with(:query => {:include_my_retweet => 'false'})).to have_been_made
2473
- expect(a_get('/1.1/statuses/retweeters/ids.json').with(:query => {:id => '55709764298092545', :cursor => '-1'})).to have_been_made
2474
- expect(a_get('/1.1/statuses/retweeters/ids.json').with(:query => {:id => '55709764298092545', :cursor => '1305102810874389703'})).to have_been_made
2475
- expect(a_get('/1.1/followers/ids.json').with(:query => {:cursor => '-1', :user_id => '7505382'})).to have_been_made
2476
- expect(a_get('/1.1/followers/ids.json').with(:query => {:cursor => '-1', :user_id => '20009713'})).to have_been_made
2477
- expect(a_get('/1.1/followers/ids.json').with(:query => {:cursor => '-1', :user_id => '14100886'})).to have_been_made
2478
- end
2479
- it 'has the correct output' do
2480
- @cli.reach('55709764298092545')
2481
- expect($stdout.string.split("\n").first).to eq '2'
2482
- end
2483
- end
2484
-
2485
- describe '#reply' do
2486
- before do
2487
- @cli.options = @cli.options.merge('profile' => fixture_path + '/.trc', 'location' => nil)
2488
- stub_get('/1.1/statuses/show/263813522369159169.json').with(:query => {:include_my_retweet => 'false'}).to_return(:body => fixture('status_with_mention.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
2489
- 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'), :headers => {:content_type => 'application/json; charset=utf-8'})
2490
- stub_request(:get, 'http://checkip.dyndns.org/').to_return(:body => fixture('checkip.html'), :headers => {:content_type => 'text/html'})
2491
- 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'})
2492
- end
2493
- it 'requests the correct resource' do
2494
- @cli.reply('263813522369159169', 'Testing')
2495
- expect(a_get('/1.1/statuses/show/263813522369159169.json').with(:query => {:include_my_retweet => 'false'})).to have_been_made
2496
- 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
2497
- expect(a_request(:get, 'http://checkip.dyndns.org/')).not_to have_been_made
2498
- expect(a_request(:get, 'http://www.geoplugin.net/xml.gp?ip=50.131.22.169')).not_to have_been_made
2499
- end
2500
- it 'has the correct output' do
2501
- @cli.reply('263813522369159169', 'Testing')
2502
- expect($stdout.string.split("\n").first).to eq 'Reply posted by @testcli to @joshfrench.'
2503
- end
2504
- context '--all' do
2505
- before do
2506
- @cli.options = @cli.options.merge('all' => true)
2507
- 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'), :headers => {:content_type => 'application/json; charset=utf-8'})
2508
- end
2509
- it 'requests the correct resource' do
2510
- @cli.reply('263813522369159169', 'Testing')
2511
- expect(a_get('/1.1/statuses/show/263813522369159169.json').with(:query => {:include_my_retweet => 'false'})).to have_been_made
2512
- 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
2513
- expect(a_request(:get, 'http://checkip.dyndns.org/')).not_to have_been_made
2514
- expect(a_request(:get, 'http://www.geoplugin.net/xml.gp?ip=50.131.22.169')).not_to have_been_made
2515
- end
2516
- it 'has the correct output' do
2517
- @cli.reply('263813522369159169', 'Testing')
2518
- expect($stdout.string.split("\n").first).to eq 'Reply posted by @testcli to @joshfrench @sferik.'
2519
- end
2520
- end
2521
- context '--location' do
2522
- before do
2523
- @cli.options = @cli.options.merge('location' => 'location')
2524
- stub_get('/1.1/statuses/show/263813522369159169.json').with(:query => {:include_my_retweet => 'false'}).to_return(:body => fixture('status_with_mention.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
2525
- 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'), :headers => {:content_type => 'application/json; charset=utf-8'})
2526
- end
2527
- it 'requests the correct resource' do
2528
- @cli.reply('263813522369159169', 'Testing')
2529
- expect(a_get('/1.1/statuses/show/263813522369159169.json').with(:query => {:include_my_retweet => 'false'})).to have_been_made
2530
- 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
2531
- expect(a_request(:get, 'http://checkip.dyndns.org/')).to have_been_made
2532
- expect(a_request(:get, 'http://www.geoplugin.net/xml.gp?ip=50.131.22.169')).to have_been_made
2533
- end
2534
- it 'has the correct output' do
2535
- @cli.reply('263813522369159169', 'Testing')
2536
- expect($stdout.string.split("\n").first).to eq 'Reply posted by @testcli to @joshfrench.'
2537
- end
2538
- end
2539
- context "--location 'latitude,longitude'" do
2540
- before do
2541
- @cli.options = @cli.options.merge('location' => '41.03132,28.9869')
2542
- stub_get('/1.1/statuses/show/263813522369159169.json').with(:query => {:include_my_retweet => 'false'}).to_return(:body => fixture('status_with_mention.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
2543
- 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'), :headers => {:content_type => 'application/json; charset=utf-8'})
2544
- end
2545
- it 'requests the correct resource' do
2546
- @cli.reply('263813522369159169', 'Testing')
2547
- expect(a_get('/1.1/statuses/show/263813522369159169.json').with(:query => {:include_my_retweet => 'false'})).to have_been_made
2548
- 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
2549
- expect(a_request(:get, 'http://checkip.dyndns.org/')).not_to have_been_made
2550
- expect(a_request(:get, 'http://www.geoplugin.net/xml.gp?ip=50.131.22.169')).not_to have_been_made
2551
- end
2552
- it 'has the correct output' do
2553
- @cli.reply('263813522369159169', 'Testing')
2554
- expect($stdout.string.split("\n").first).to eq 'Reply posted by @testcli to @joshfrench.'
2555
- end
2556
- end
2557
- end
2558
-
2559
- describe '#report_spam' do
2560
- before do
2561
- @cli.options = @cli.options.merge('profile' => fixture_path + '/.trc')
2562
- stub_post('/1.1/users/report_spam.json').with(:body => {:screen_name => 'sferik'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
2563
- end
2564
- it 'requests the correct resource' do
2565
- @cli.report_spam('sferik')
2566
- expect(a_post('/1.1/users/report_spam.json').with(:body => {:screen_name => 'sferik'})).to have_been_made
2567
- end
2568
- it 'has the correct output' do
2569
- @cli.report_spam('sferik')
2570
- expect($stdout.string).to match(/^@testcli reported 1 user/)
2571
- end
2572
- context '--id' do
2573
- before do
2574
- @cli.options = @cli.options.merge('id' => true)
2575
- stub_post('/1.1/users/report_spam.json').with(:body => {:user_id => '7505382'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
2576
- end
2577
- it 'requests the correct resource' do
2578
- @cli.report_spam('7505382')
2579
- expect(a_post('/1.1/users/report_spam.json').with(:body => {:user_id => '7505382'})).to have_been_made
2580
- end
2581
- end
2582
- end
2583
-
2584
- describe '#retweet' do
2585
- before do
2586
- @cli.options = @cli.options.merge('profile' => fixture_path + '/.trc')
2587
- stub_post('/1.1/statuses/retweet/26755176471724032.json').to_return(:body => fixture('retweet.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
2588
- end
2589
- it 'requests the correct resource' do
2590
- @cli.retweet('26755176471724032')
2591
- expect(a_post('/1.1/statuses/retweet/26755176471724032.json')).to have_been_made
2592
- end
2593
- it 'has the correct output' do
2594
- @cli.retweet('26755176471724032')
2595
- expect($stdout.string).to match(/^@testcli retweeted 1 tweet.$/)
2596
- end
2597
- end
2598
-
2599
- describe '#retweets' do
2600
- before do
2601
- stub_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :include_rts => 'true', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
2602
- stub_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :include_rts => 'true', :max_id => '244102729860009983', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
2603
- end
2604
- context 'without arguments' do
2605
- it 'requests the correct resource' do
2606
- @cli.retweets
2607
- expect(a_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :include_rts => 'true', :include_entities => 'false'})).to have_been_made
2608
- expect(a_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :include_rts => 'true', :max_id => '244102729860009983', :include_entities => 'false'})).to have_been_made.times(3)
2609
- end
2610
- it 'has the correct output' do
2611
- @cli.retweets
2612
- expect($stdout.string).to eq <<-eos
2613
- @calebelston
2614
- RT @olivercameron: Mosaic looks cool: http://t.co/A8013C9k
2615
-
2616
- @codeforamerica
2617
- RT @randomhacks: Going to Code Across Austin II: Y'all Come Hack Now, Sat,
2618
- Sep 8 http://t.co/Sk5BM7U3 We'll see y'all there! #rhok @codeforamerica
2619
- @TheaClay
2620
-
2621
- @fbjork
2622
- RT @jondot: Just published: "Pragmatic Concurrency With #Ruby"
2623
- http://t.co/kGEykswZ /cc @JRuby @headius
2624
-
2625
- @al3x
2626
- RT @wcmaier: Better banking through better ops: build something new with us
2627
- @Simplify (remote, PDX) http://t.co/8WgzKZH3
2628
-
2629
- @JEG2
2630
- RT @tenderlove: If corporations are people, can we use them to drive in the
2631
- carpool lane?
2632
-
2633
- @dhh
2634
- RT @ggreenwald: Democrats parade Osama bin Laden's corpse as their proudest
2635
- achievement: why this goulish jingoism is so warped http://t.co/kood278s
2636
-
2637
- @calebelston
2638
- RT @olivercameron: Mosaic looks cool: http://t.co/A8013C9k
2639
-
2640
- @codeforamerica
2641
- RT @randomhacks: Going to Code Across Austin II: Y'all Come Hack Now, Sat,
2642
- Sep 8 http://t.co/Sk5BM7U3 We'll see y'all there! #rhok @codeforamerica
2643
- @TheaClay
2644
-
2645
- @fbjork
2646
- RT @jondot: Just published: "Pragmatic Concurrency With #Ruby"
2647
- http://t.co/kGEykswZ /cc @JRuby @headius
2648
-
2649
- @al3x
2650
- RT @wcmaier: Better banking through better ops: build something new with us
2651
- @Simplify (remote, PDX) http://t.co/8WgzKZH3
2652
-
2653
- @JEG2
2654
- RT @tenderlove: If corporations are people, can we use them to drive in the
2655
- carpool lane?
2656
-
2657
- @dhh
2658
- RT @ggreenwald: Democrats parade Osama bin Laden's corpse as their proudest
2659
- achievement: why this goulish jingoism is so warped http://t.co/kood278s
2660
-
2661
- @calebelston
2662
- RT @olivercameron: Mosaic looks cool: http://t.co/A8013C9k
2663
-
2664
- @codeforamerica
2665
- RT @randomhacks: Going to Code Across Austin II: Y'all Come Hack Now, Sat,
2666
- Sep 8 http://t.co/Sk5BM7U3 We'll see y'all there! #rhok @codeforamerica
2667
- @TheaClay
2668
-
2669
- @fbjork
2670
- RT @jondot: Just published: "Pragmatic Concurrency With #Ruby"
2671
- http://t.co/kGEykswZ /cc @JRuby @headius
2672
-
2673
- @al3x
2674
- RT @wcmaier: Better banking through better ops: build something new with us
2675
- @Simplify (remote, PDX) http://t.co/8WgzKZH3
2676
-
2677
- @JEG2
2678
- RT @tenderlove: If corporations are people, can we use them to drive in the
2679
- carpool lane?
2680
-
2681
- @dhh
2682
- RT @ggreenwald: Democrats parade Osama bin Laden's corpse as their proudest
2683
- achievement: why this goulish jingoism is so warped http://t.co/kood278s
2684
-
2685
- @calebelston
2686
- RT @olivercameron: Mosaic looks cool: http://t.co/A8013C9k
2687
-
2688
- @codeforamerica
2689
- RT @randomhacks: Going to Code Across Austin II: Y'all Come Hack Now, Sat,
2690
- Sep 8 http://t.co/Sk5BM7U3 We'll see y'all there! #rhok @codeforamerica
2691
- @TheaClay
2692
-
2693
- eos
2694
- end
2695
- end
2696
- context '--csv' do
2697
- before do
2698
- @cli.options = @cli.options.merge('csv' => true)
2699
- end
2700
- it 'outputs in CSV format' do
2701
- @cli.retweets
2702
- expect($stdout.string).to eq <<-eos
2703
- ID,Posted at,Screen name,Text
2704
- 244108728834592770,2012-09-07 16:23:50 +0000,calebelston,RT @olivercameron: Mosaic looks cool: http://t.co/A8013C9k
2705
- 244107823733174272,2012-09-07 16:20:15 +0000,codeforamerica,"RT @randomhacks: Going to Code Across Austin II: Y'all Come Hack Now, Sat, Sep 8 http://t.co/Sk5BM7U3 We'll see y'all there! #rhok @codeforamerica @TheaClay"
2706
- 244107236262170624,2012-09-07 16:17:55 +0000,fbjork,"RT @jondot: Just published: ""Pragmatic Concurrency With #Ruby"" http://t.co/kGEykswZ /cc @JRuby @headius"
2707
- 244104558433951744,2012-09-07 16:07:16 +0000,al3x,"RT @wcmaier: Better banking through better ops: build something new with us @Simplify (remote, PDX) http://t.co/8WgzKZH3"
2708
- 244102834398851073,2012-09-07 16:00:25 +0000,JEG2,"RT @tenderlove: If corporations are people, can we use them to drive in the carpool lane?"
2709
- 244102729860009984,2012-09-07 16:00:00 +0000,dhh,RT @ggreenwald: Democrats parade Osama bin Laden's corpse as their proudest achievement: why this goulish jingoism is so warped http://t.co/kood278s
2710
- 244108728834592770,2012-09-07 16:23:50 +0000,calebelston,RT @olivercameron: Mosaic looks cool: http://t.co/A8013C9k
2711
- 244107823733174272,2012-09-07 16:20:15 +0000,codeforamerica,"RT @randomhacks: Going to Code Across Austin II: Y'all Come Hack Now, Sat, Sep 8 http://t.co/Sk5BM7U3 We'll see y'all there! #rhok @codeforamerica @TheaClay"
2712
- 244107236262170624,2012-09-07 16:17:55 +0000,fbjork,"RT @jondot: Just published: ""Pragmatic Concurrency With #Ruby"" http://t.co/kGEykswZ /cc @JRuby @headius"
2713
- 244104558433951744,2012-09-07 16:07:16 +0000,al3x,"RT @wcmaier: Better banking through better ops: build something new with us @Simplify (remote, PDX) http://t.co/8WgzKZH3"
2714
- 244102834398851073,2012-09-07 16:00:25 +0000,JEG2,"RT @tenderlove: If corporations are people, can we use them to drive in the carpool lane?"
2715
- 244102729860009984,2012-09-07 16:00:00 +0000,dhh,RT @ggreenwald: Democrats parade Osama bin Laden's corpse as their proudest achievement: why this goulish jingoism is so warped http://t.co/kood278s
2716
- 244108728834592770,2012-09-07 16:23:50 +0000,calebelston,RT @olivercameron: Mosaic looks cool: http://t.co/A8013C9k
2717
- 244107823733174272,2012-09-07 16:20:15 +0000,codeforamerica,"RT @randomhacks: Going to Code Across Austin II: Y'all Come Hack Now, Sat, Sep 8 http://t.co/Sk5BM7U3 We'll see y'all there! #rhok @codeforamerica @TheaClay"
2718
- 244107236262170624,2012-09-07 16:17:55 +0000,fbjork,"RT @jondot: Just published: ""Pragmatic Concurrency With #Ruby"" http://t.co/kGEykswZ /cc @JRuby @headius"
2719
- 244104558433951744,2012-09-07 16:07:16 +0000,al3x,"RT @wcmaier: Better banking through better ops: build something new with us @Simplify (remote, PDX) http://t.co/8WgzKZH3"
2720
- 244102834398851073,2012-09-07 16:00:25 +0000,JEG2,"RT @tenderlove: If corporations are people, can we use them to drive in the carpool lane?"
2721
- 244102729860009984,2012-09-07 16:00:00 +0000,dhh,RT @ggreenwald: Democrats parade Osama bin Laden's corpse as their proudest achievement: why this goulish jingoism is so warped http://t.co/kood278s
2722
- 244108728834592770,2012-09-07 16:23:50 +0000,calebelston,RT @olivercameron: Mosaic looks cool: http://t.co/A8013C9k
2723
- 244107823733174272,2012-09-07 16:20:15 +0000,codeforamerica,"RT @randomhacks: Going to Code Across Austin II: Y'all Come Hack Now, Sat, Sep 8 http://t.co/Sk5BM7U3 We'll see y'all there! #rhok @codeforamerica @TheaClay"
2724
- eos
2725
- end
2726
- end
2727
- context '--decode-uris' do
2728
- before do
2729
- @cli.options = @cli.options.merge('decode_uris' => true)
2730
- stub_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :include_rts => 'true', :include_entities => 'true'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
2731
- stub_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :include_rts => 'true', :max_id => '244102729860009983', :include_entities => 'true'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
2732
- end
2733
- it 'requests the correct resource' do
2734
- @cli.retweets
2735
- expect(a_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :include_rts => 'true', :include_entities => 'true'})).to have_been_made
2736
- expect(a_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :include_rts => 'true', :max_id => '244102729860009983', :include_entities => 'true'})).to have_been_made.times(3)
2737
- end
2738
- end
2739
- context '--long' do
2740
- before do
2741
- @cli.options = @cli.options.merge('long' => true)
2742
- end
2743
- it 'outputs in long format' do
2744
- @cli.retweets
2745
- expect($stdout.string).to eq <<-eos
2746
- ID Posted at Screen name Text
2747
- 244108728834592770 Sep 7 08:23 @calebelston RT @olivercameron: Mosaic ...
2748
- 244107823733174272 Sep 7 08:20 @codeforamerica RT @randomhacks: Going to ...
2749
- 244107236262170624 Sep 7 08:17 @fbjork RT @jondot: Just published...
2750
- 244104558433951744 Sep 7 08:07 @al3x RT @wcmaier: Better bankin...
2751
- 244102834398851073 Sep 7 08:00 @JEG2 RT @tenderlove: If corpora...
2752
- 244102729860009984 Sep 7 08:00 @dhh RT @ggreenwald: Democrats ...
2753
- 244108728834592770 Sep 7 08:23 @calebelston RT @olivercameron: Mosaic ...
2754
- 244107823733174272 Sep 7 08:20 @codeforamerica RT @randomhacks: Going to ...
2755
- 244107236262170624 Sep 7 08:17 @fbjork RT @jondot: Just published...
2756
- 244104558433951744 Sep 7 08:07 @al3x RT @wcmaier: Better bankin...
2757
- 244102834398851073 Sep 7 08:00 @JEG2 RT @tenderlove: If corpora...
2758
- 244102729860009984 Sep 7 08:00 @dhh RT @ggreenwald: Democrats ...
2759
- 244108728834592770 Sep 7 08:23 @calebelston RT @olivercameron: Mosaic ...
2760
- 244107823733174272 Sep 7 08:20 @codeforamerica RT @randomhacks: Going to ...
2761
- 244107236262170624 Sep 7 08:17 @fbjork RT @jondot: Just published...
2762
- 244104558433951744 Sep 7 08:07 @al3x RT @wcmaier: Better bankin...
2763
- 244102834398851073 Sep 7 08:00 @JEG2 RT @tenderlove: If corpora...
2764
- 244102729860009984 Sep 7 08:00 @dhh RT @ggreenwald: Democrats ...
2765
- 244108728834592770 Sep 7 08:23 @calebelston RT @olivercameron: Mosaic ...
2766
- 244107823733174272 Sep 7 08:20 @codeforamerica RT @randomhacks: Going to ...
2767
- eos
2768
- end
2769
- context '--reverse' do
2770
- before do
2771
- @cli.options = @cli.options.merge('reverse' => true)
2772
- end
2773
- it 'reverses the order of the sort' do
2774
- @cli.retweets
2775
- expect($stdout.string).to eq <<-eos
2776
- ID Posted at Screen name Text
2777
- 244107823733174272 Sep 7 08:20 @codeforamerica RT @randomhacks: Going to ...
2778
- 244108728834592770 Sep 7 08:23 @calebelston RT @olivercameron: Mosaic ...
2779
- 244102729860009984 Sep 7 08:00 @dhh RT @ggreenwald: Democrats ...
2780
- 244102834398851073 Sep 7 08:00 @JEG2 RT @tenderlove: If corpora...
2781
- 244104558433951744 Sep 7 08:07 @al3x RT @wcmaier: Better bankin...
2782
- 244107236262170624 Sep 7 08:17 @fbjork RT @jondot: Just published...
2783
- 244107823733174272 Sep 7 08:20 @codeforamerica RT @randomhacks: Going to ...
2784
- 244108728834592770 Sep 7 08:23 @calebelston RT @olivercameron: Mosaic ...
2785
- 244102729860009984 Sep 7 08:00 @dhh RT @ggreenwald: Democrats ...
2786
- 244102834398851073 Sep 7 08:00 @JEG2 RT @tenderlove: If corpora...
2787
- 244104558433951744 Sep 7 08:07 @al3x RT @wcmaier: Better bankin...
2788
- 244107236262170624 Sep 7 08:17 @fbjork RT @jondot: Just published...
2789
- 244107823733174272 Sep 7 08:20 @codeforamerica RT @randomhacks: Going to ...
2790
- 244108728834592770 Sep 7 08:23 @calebelston RT @olivercameron: Mosaic ...
2791
- 244102729860009984 Sep 7 08:00 @dhh RT @ggreenwald: Democrats ...
2792
- 244102834398851073 Sep 7 08:00 @JEG2 RT @tenderlove: If corpora...
2793
- 244104558433951744 Sep 7 08:07 @al3x RT @wcmaier: Better bankin...
2794
- 244107236262170624 Sep 7 08:17 @fbjork RT @jondot: Just published...
2795
- 244107823733174272 Sep 7 08:20 @codeforamerica RT @randomhacks: Going to ...
2796
- 244108728834592770 Sep 7 08:23 @calebelston RT @olivercameron: Mosaic ...
2797
- eos
2798
- end
2799
- end
2800
- end
2801
- context '--number' do
2802
- before do
2803
- stub_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :include_rts => 'true', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
2804
- stub_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :include_rts => 'true', :max_id => '244107823733174271', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
2805
- end
2806
- it 'limits the number of results to 1' do
2807
- @cli.options = @cli.options.merge('number' => 1)
2808
- @cli.retweets
2809
- expect(a_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :include_rts => 'true', :include_entities => 'false'})).to have_been_made
2810
- end
2811
- it 'limits the number of results to 201' do
2812
- @cli.options = @cli.options.merge('number' => 201)
2813
- @cli.retweets
2814
- expect(a_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :include_rts => 'true', :include_entities => 'false'})).to have_been_made
2815
- expect(a_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :include_rts => 'true', :max_id => '244107823733174271', :include_entities => 'false'})).to have_been_made
2816
- end
2817
- end
2818
- context 'with a user passed' do
2819
- before do
2820
- stub_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :include_rts => 'true', :screen_name => 'sferik', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
2821
- stub_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :include_rts => 'true', :screen_name => 'sferik', :max_id => '244102729860009983', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
2822
- end
2823
- it 'requests the correct resource' do
2824
- @cli.retweets('sferik')
2825
- expect(a_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :include_rts => 'true', :screen_name => 'sferik', :include_entities => 'false'})).to have_been_made
2826
- expect(a_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :include_rts => 'true', :screen_name => 'sferik', :max_id => '244102729860009983', :include_entities => 'false'})).to have_been_made.times(3)
2827
- end
2828
- context '--id' do
2829
- before do
2830
- @cli.options = @cli.options.merge('id' => true)
2831
- stub_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :include_rts => 'true', :user_id => '7505382', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
2832
- stub_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :include_rts => 'true', :user_id => '7505382', :max_id => '244102729860009983', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
2833
- end
2834
- it 'requests the correct resource' do
2835
- @cli.retweets('7505382')
2836
- expect(a_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :include_rts => 'true', :user_id => '7505382', :include_entities => 'false'})).to have_been_made
2837
- expect(a_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :include_rts => 'true', :user_id => '7505382', :max_id => '244102729860009983', :include_entities => 'false'})).to have_been_made.times(3)
2838
- end
2839
- end
2840
- end
2841
- end
2842
-
2843
- describe '#retweets_of_me' do
2844
- before do
2845
- stub_get('/1.1/statuses/retweets_of_me.json').with(:query => {:count => '20', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
2846
- end
2847
- context 'without arguments' do
2848
- it 'requests the correct resource' do
2849
- @cli.retweets_of_me
2850
- expect(a_get('/1.1/statuses/retweets_of_me.json').with(:query => {:count => '20', :include_entities => 'false'})).to have_been_made
2851
- end
2852
- it 'has the correct output' do
2853
- @cli.retweets_of_me
2854
- expect($stdout.string).to eq <<-eos
2855
- @mutgoff
2856
- Happy Birthday @imdane. Watch out for those @rally pranksters!
2857
-
2858
- @ironicsans
2859
- If you like good real-life stories, check out @NarrativelyNY's just-launched
2860
- site http://t.co/wiUL07jE (and also visit http://t.co/ZoyQxqWA)
2861
-
2862
- @pat_shaughnessy
2863
- Something else to vote for: "New Rails workshops to bring more women into the
2864
- Boston software scene" http://t.co/eNBuckHc /cc @bostonrb
2865
-
2866
- @calebelston
2867
- Pushing the button to launch the site. http://t.co/qLoEn5jG
2868
-
2869
- @calebelston
2870
- RT @olivercameron: Mosaic looks cool: http://t.co/A8013C9k
2871
-
2872
- @fivethirtyeight
2873
- The Weatherman is Not a Moron: http://t.co/ZwL5Gnq5. An excerpt from my book,
2874
- THE SIGNAL AND THE NOISE (http://t.co/fNXj8vCE)
2875
-
2876
- @codeforamerica
2877
- RT @randomhacks: Going to Code Across Austin II: Y'all Come Hack Now, Sat,
2878
- Sep 8 http://t.co/Sk5BM7U3 We'll see y'all there! #rhok @codeforamerica
2879
- @TheaClay
2880
-
2881
- @fbjork
2882
- RT @jondot: Just published: "Pragmatic Concurrency With #Ruby"
2883
- http://t.co/kGEykswZ /cc @JRuby @headius
2884
-
2885
- @mbostock
2886
- If you are wondering how we computed the split bubbles: http://t.co/BcaqSs5u
2887
-
2888
- @FakeDorsey
2889
- "Write drunk. Edit sober."—Ernest Hemingway
2890
-
2891
- @al3x
2892
- RT @wcmaier: Better banking through better ops: build something new with us
2893
- @Simplify (remote, PDX) http://t.co/8WgzKZH3
2894
-
2895
- @calebelston
2896
- We just announced Mosaic, what we've been working on since the Yobongo
2897
- acquisition. My personal post, http://t.co/ELOyIRZU @heymosaic
2898
-
2899
- @BarackObama
2900
- Donate $10 or more --> get your favorite car magnet: http://t.co/NfRhl2s2
2901
- #Obama2012
2902
-
2903
- @JEG2
2904
- RT @tenderlove: If corporations are people, can we use them to drive in the
2905
- carpool lane?
2906
-
2907
- @eveningedition
2908
- LDN—Obama's nomination; Putin woos APEC; Bombs hit Damascus; Quakes shake
2909
- China; Canada cuts Iran ties; weekend read: http://t.co/OFs6dVW4
2910
-
2911
- @dhh
2912
- RT @ggreenwald: Democrats parade Osama bin Laden's corpse as their proudest
2913
- achievement: why this goulish jingoism is so warped http://t.co/kood278s
2914
-
2915
- @jasonfried
2916
- The story of Mars Curiosity's gears, made by a factory in Rockford, IL:
2917
- http://t.co/MwCRsHQg
2918
-
2919
- @sferik
2920
- @episod @twitterapi now https://t.co/I17jUTu2 and https://t.co/deDu4Hgw seem
2921
- to be missing "1.1" from the URL.
2922
-
2923
- @sferik
2924
- @episod @twitterapi Did you catch https://t.co/VHsQvZT0 as well?
2925
-
2926
- @dwiskus
2927
- Gentlemen, you can't fight in here! This is the war room!
2928
- http://t.co/kMxMYyqF
2929
-
2930
- eos
2931
- end
2932
- end
2933
- context '--csv' do
2934
- before do
2935
- @cli.options = @cli.options.merge('csv' => true)
2936
- end
2937
- it 'outputs in CSV format' do
2938
- @cli.retweets_of_me
2939
- expect($stdout.string).to eq <<-eos
2940
- ID,Posted at,Screen name,Text
2941
- 4611686018427387904,2012-09-07 16:35:24 +0000,mutgoff,Happy Birthday @imdane. Watch out for those @rally pranksters!
2942
- 244111183165157376,2012-09-07 16:33:36 +0000,ironicsans,"If you like good real-life stories, check out @NarrativelyNY's just-launched site http://t.co/wiUL07jE (and also visit http://t.co/ZoyQxqWA)"
2943
- 244110336414859264,2012-09-07 16:30:14 +0000,pat_shaughnessy,"Something else to vote for: ""New Rails workshops to bring more women into the Boston software scene"" http://t.co/eNBuckHc /cc @bostonrb"
2944
- 244109797308379136,2012-09-07 16:28:05 +0000,calebelston,Pushing the button to launch the site. http://t.co/qLoEn5jG
2945
- 244108728834592770,2012-09-07 16:23:50 +0000,calebelston,RT @olivercameron: Mosaic looks cool: http://t.co/A8013C9k
2946
- 244107890632294400,2012-09-07 16:20:31 +0000,fivethirtyeight,"The Weatherman is Not a Moron: http://t.co/ZwL5Gnq5. An excerpt from my book, THE SIGNAL AND THE NOISE (http://t.co/fNXj8vCE)"
2947
- 244107823733174272,2012-09-07 16:20:15 +0000,codeforamerica,"RT @randomhacks: Going to Code Across Austin II: Y'all Come Hack Now, Sat, Sep 8 http://t.co/Sk5BM7U3 We'll see y'all there! #rhok @codeforamerica @TheaClay"
2948
- 244107236262170624,2012-09-07 16:17:55 +0000,fbjork,"RT @jondot: Just published: ""Pragmatic Concurrency With #Ruby"" http://t.co/kGEykswZ /cc @JRuby @headius"
2949
- 244106476048764928,2012-09-07 16:14:53 +0000,mbostock,If you are wondering how we computed the split bubbles: http://t.co/BcaqSs5u
2950
- 244105599351148544,2012-09-07 16:11:24 +0000,FakeDorsey,"""Write drunk. Edit sober.""—Ernest Hemingway"
2951
- 244104558433951744,2012-09-07 16:07:16 +0000,al3x,"RT @wcmaier: Better banking through better ops: build something new with us @Simplify (remote, PDX) http://t.co/8WgzKZH3"
2952
- 244104146997870594,2012-09-07 16:05:38 +0000,calebelston,"We just announced Mosaic, what we've been working on since the Yobongo acquisition. My personal post, http://t.co/ELOyIRZU @heymosaic"
2953
- 244103057175113729,2012-09-07 16:01:18 +0000,BarackObama,Donate $10 or more --> get your favorite car magnet: http://t.co/NfRhl2s2 #Obama2012
2954
- 244102834398851073,2012-09-07 16:00:25 +0000,JEG2,"RT @tenderlove: If corporations are people, can we use them to drive in the carpool lane?"
2955
- 244102741125890048,2012-09-07 16:00:03 +0000,eveningedition,LDN—Obama's nomination; Putin woos APEC; Bombs hit Damascus; Quakes shake China; Canada cuts Iran ties; weekend read: http://t.co/OFs6dVW4
2956
- 244102729860009984,2012-09-07 16:00:00 +0000,dhh,RT @ggreenwald: Democrats parade Osama bin Laden's corpse as their proudest achievement: why this goulish jingoism is so warped http://t.co/kood278s
2957
- 244102490646278146,2012-09-07 15:59:03 +0000,jasonfried,"The story of Mars Curiosity's gears, made by a factory in Rockford, IL: http://t.co/MwCRsHQg"
2958
- 244102209942458368,2012-09-07 15:57:56 +0000,sferik,"@episod @twitterapi now https://t.co/I17jUTu2 and https://t.co/deDu4Hgw seem to be missing ""1.1"" from the URL."
2959
- 244100411563339777,2012-09-07 15:50:47 +0000,sferik,@episod @twitterapi Did you catch https://t.co/VHsQvZT0 as well?
2960
- 244099460672679938,2012-09-07 15:47:01 +0000,dwiskus,"Gentlemen, you can't fight in here! This is the war room! http://t.co/kMxMYyqF"
2961
- eos
2962
- end
2963
- end
2964
- context '--decode-uris' do
2965
- before do
2966
- @cli.options = @cli.options.merge('decode_uris' => true)
2967
- stub_get('/1.1/statuses/retweets_of_me.json').with(:query => {:count => '20', :include_entities => 'true'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
2968
- end
2969
- it 'requests the correct resource' do
2970
- @cli.retweets_of_me
2971
- expect(a_get('/1.1/statuses/retweets_of_me.json').with(:query => {:count => '20', :include_entities => 'true'})).to have_been_made
2972
- end
2973
- end
2974
- context '--long' do
2975
- before do
2976
- @cli.options = @cli.options.merge('long' => true)
2977
- end
2978
- it 'outputs in long format' do
2979
- @cli.retweets_of_me
2980
- expect($stdout.string).to eq <<-eos
2981
- ID Posted at Screen name Text
2982
- 4611686018427387904 Sep 7 08:35 @mutgoff Happy Birthday @imdane. ...
2983
- 244111183165157376 Sep 7 08:33 @ironicsans If you like good real-li...
2984
- 244110336414859264 Sep 7 08:30 @pat_shaughnessy Something else to vote f...
2985
- 244109797308379136 Sep 7 08:28 @calebelston Pushing the button to la...
2986
- 244108728834592770 Sep 7 08:23 @calebelston RT @olivercameron: Mosai...
2987
- 244107890632294400 Sep 7 08:20 @fivethirtyeight The Weatherman is Not a ...
2988
- 244107823733174272 Sep 7 08:20 @codeforamerica RT @randomhacks: Going t...
2989
- 244107236262170624 Sep 7 08:17 @fbjork RT @jondot: Just publish...
2990
- 244106476048764928 Sep 7 08:14 @mbostock If you are wondering how...
2991
- 244105599351148544 Sep 7 08:11 @FakeDorsey "Write drunk. Edit sober...
2992
- 244104558433951744 Sep 7 08:07 @al3x RT @wcmaier: Better bank...
2993
- 244104146997870594 Sep 7 08:05 @calebelston We just announced Mosaic...
2994
- 244103057175113729 Sep 7 08:01 @BarackObama Donate $10 or more --> g...
2995
- 244102834398851073 Sep 7 08:00 @JEG2 RT @tenderlove: If corpo...
2996
- 244102741125890048 Sep 7 08:00 @eveningedition LDN—Obama's nomination; ...
2997
- 244102729860009984 Sep 7 08:00 @dhh RT @ggreenwald: Democrat...
2998
- 244102490646278146 Sep 7 07:59 @jasonfried The story of Mars Curios...
2999
- 244102209942458368 Sep 7 07:57 @sferik @episod @twitterapi now ...
3000
- 244100411563339777 Sep 7 07:50 @sferik @episod @twitterapi Did ...
3001
- 244099460672679938 Sep 7 07:47 @dwiskus Gentlemen, you can't fig...
3002
- eos
3003
- end
3004
- context '--reverse' do
3005
- before do
3006
- @cli.options = @cli.options.merge('reverse' => true)
3007
- end
3008
- it 'reverses the order of the sort' do
3009
- @cli.retweets_of_me
3010
- expect($stdout.string).to eq <<-eos
3011
- ID Posted at Screen name Text
3012
- 244099460672679938 Sep 7 07:47 @dwiskus Gentlemen, you can't fig...
3013
- 244100411563339777 Sep 7 07:50 @sferik @episod @twitterapi Did ...
3014
- 244102209942458368 Sep 7 07:57 @sferik @episod @twitterapi now ...
3015
- 244102490646278146 Sep 7 07:59 @jasonfried The story of Mars Curios...
3016
- 244102729860009984 Sep 7 08:00 @dhh RT @ggreenwald: Democrat...
3017
- 244102741125890048 Sep 7 08:00 @eveningedition LDN—Obama's nomination; ...
3018
- 244102834398851073 Sep 7 08:00 @JEG2 RT @tenderlove: If corpo...
3019
- 244103057175113729 Sep 7 08:01 @BarackObama Donate $10 or more --> g...
3020
- 244104146997870594 Sep 7 08:05 @calebelston We just announced Mosaic...
3021
- 244104558433951744 Sep 7 08:07 @al3x RT @wcmaier: Better bank...
3022
- 244105599351148544 Sep 7 08:11 @FakeDorsey "Write drunk. Edit sober...
3023
- 244106476048764928 Sep 7 08:14 @mbostock If you are wondering how...
3024
- 244107236262170624 Sep 7 08:17 @fbjork RT @jondot: Just publish...
3025
- 244107823733174272 Sep 7 08:20 @codeforamerica RT @randomhacks: Going t...
3026
- 244107890632294400 Sep 7 08:20 @fivethirtyeight The Weatherman is Not a ...
3027
- 244108728834592770 Sep 7 08:23 @calebelston RT @olivercameron: Mosai...
3028
- 244109797308379136 Sep 7 08:28 @calebelston Pushing the button to la...
3029
- 244110336414859264 Sep 7 08:30 @pat_shaughnessy Something else to vote f...
3030
- 244111183165157376 Sep 7 08:33 @ironicsans If you like good real-li...
3031
- 4611686018427387904 Sep 7 08:35 @mutgoff Happy Birthday @imdane. ...
3032
- eos
3033
- end
3034
- end
3035
- end
3036
- context '--number' do
3037
- before do
3038
- stub_get('/1.1/statuses/retweets_of_me.json').with(:query => {:count => '1', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
3039
- stub_get('/1.1/statuses/retweets_of_me.json').with(:query => {:count => '200', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
3040
- (1..181).step(20) do |count|
3041
- stub_get('/1.1/statuses/retweets_of_me.json').with(:query => {:count => count, :max_id => '244099460672679937', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
3042
- end
3043
- end
3044
- it 'limits the number of results to 1' do
3045
- @cli.options = @cli.options.merge('number' => 1)
3046
- @cli.retweets_of_me
3047
- expect(a_get('/1.1/statuses/retweets_of_me.json').with(:query => {:count => '1', :include_entities => 'false'})).to have_been_made
3048
- end
3049
- it 'limits the number of results to 201' do
3050
- @cli.options = @cli.options.merge('number' => 201)
3051
- @cli.retweets_of_me
3052
- expect(a_get('/1.1/statuses/retweets_of_me.json').with(:query => {:count => '200', :include_entities => 'false'})).to have_been_made
3053
- (1..181).step(20) do |count|
3054
- expect(a_get('/1.1/statuses/retweets_of_me.json').with(:query => {:count => count, :max_id => '244099460672679937', :include_entities => 'false'})).to have_been_made
3055
- end
3056
- end
3057
- end
3058
- end
3059
-
3060
- describe '#ruler' do
3061
- it 'has the correct output' do
3062
- @cli.ruler
3063
- expect($stdout.string.chomp.size).to eq 140
3064
- expect($stdout.string.chomp).to eq '----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|'
3065
- end
3066
- context 'with indentation' do
3067
- before do
3068
- @cli.options = @cli.options.merge('indent' => 2)
3069
- end
3070
- it 'has the correct output' do
3071
- @cli.ruler
3072
- expect($stdout.string.chomp.size).to eq 142
3073
- expect($stdout.string.chomp).to eq ' ----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|'
3074
- end
3075
- end
3076
- end
3077
-
3078
- describe '#status' do
3079
- before do
3080
- stub_get('/1.1/statuses/show/55709764298092545.json').with(:query => {:include_my_retweet => 'false', :include_entities => 'false'}).to_return(:body => fixture('status.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
3081
- end
3082
- it 'requests the correct resources' do
3083
- @cli.status('55709764298092545')
3084
- expect(a_get('/1.1/statuses/show/55709764298092545.json').with(:query => {:include_my_retweet => 'false', :include_entities => 'false'})).to have_been_made
3085
- end
3086
- it 'has the correct output' do
3087
- @cli.status('55709764298092545')
3088
- expect($stdout.string).to eq <<-eos
3089
- ID 55709764298092545
3090
- Text The problem with your code is that it's doing exactly what you told it to do.
3091
- Screen name @sferik
3092
- Posted at Apr 6 2011 (8 months ago)
3093
- Retweets 320
3094
- Favorites 50
3095
- Source Twitter for iPhone
3096
- Location Blowfish Sushi To Die For, 2170 Bryant St, San Francisco, California, United States
3097
- eos
3098
- end
3099
- context '--csv' do
3100
- before do
3101
- @cli.options = @cli.options.merge('csv' => true)
3102
- end
3103
- it 'has the correct output' do
3104
- @cli.status('55709764298092545')
3105
- expect($stdout.string).to eq <<-eos
3106
- ID,Posted at,Screen name,Text,Retweets,Favorites,Source,Location
3107
- 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"
3108
- eos
3109
- end
3110
- end
3111
- context 'with no street address' do
3112
- before do
3113
- stub_get('/1.1/statuses/show/55709764298092545.json').with(:query => {:include_my_retweet => 'false', :include_entities => 'false'}).to_return(:body => fixture('status_no_street_address.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
3114
- end
3115
- it 'has the correct output' do
3116
- @cli.status('55709764298092545')
3117
- expect($stdout.string).to eq <<-eos
3118
- ID 55709764298092550
3119
- Text The problem with your code is that it's doing exactly what you told it to do.
3120
- Screen name @sferik
3121
- Posted at Apr 6 2011 (8 months ago)
3122
- Retweets 320
3123
- Favorites 50
3124
- Source Twitter for iPhone
3125
- Location Blowfish Sushi To Die For, San Francisco, California, United States
3126
- eos
3127
- end
3128
- end
3129
- context 'with no locality' do
3130
- before do
3131
- stub_get('/1.1/statuses/show/55709764298092545.json').with(:query => {:include_my_retweet => 'false', :include_entities => 'false'}).to_return(:body => fixture('status_no_locality.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
3132
- end
3133
- it 'has the correct output' do
3134
- @cli.status('55709764298092545')
3135
- expect($stdout.string).to eq <<-eos
3136
- ID 55709764298092549
3137
- Text The problem with your code is that it's doing exactly what you told it to do.
3138
- Screen name @sferik
3139
- Posted at Apr 6 2011 (8 months ago)
3140
- Retweets 320
3141
- Favorites 50
3142
- Source Twitter for iPhone
3143
- Location Blowfish Sushi To Die For, San Francisco, California, United States
3144
- eos
3145
- end
3146
- end
3147
- context 'with no attributes' do
3148
- before do
3149
- stub_get('/1.1/statuses/show/55709764298092545.json').with(:query => {:include_my_retweet => 'false', :include_entities => 'false'}).to_return(:body => fixture('status_no_attributes.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
3150
- end
3151
- it 'has the correct output' do
3152
- @cli.status('55709764298092545')
3153
- expect($stdout.string).to eq <<-eos
3154
- ID 55709764298092546
3155
- Text The problem with your code is that it's doing exactly what you told it to do.
3156
- Screen name @sferik
3157
- Posted at Apr 6 2011 (8 months ago)
3158
- Retweets 320
3159
- Favorites 50
3160
- Source Twitter for iPhone
3161
- Location Blowfish Sushi To Die For, San Francisco, United States
3162
- eos
3163
- end
3164
- end
3165
- context 'with no country' do
3166
- before do
3167
- stub_get('/1.1/statuses/show/55709764298092545.json').with(:query => {:include_my_retweet => 'false', :include_entities => 'false'}).to_return(:body => fixture('status_no_country.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
3168
- end
3169
- it 'has the correct output' do
3170
- @cli.status('55709764298092545')
3171
- expect($stdout.string).to eq <<-eos
3172
- ID 55709764298092547
3173
- Text The problem with your code is that it's doing exactly what you told it to do.
3174
- Screen name @sferik
3175
- Posted at Apr 6 2011 (8 months ago)
3176
- Retweets 320
3177
- Favorites 50
3178
- Source Twitter for iPhone
3179
- Location Blowfish Sushi To Die For, San Francisco
3180
- eos
3181
- end
3182
- end
3183
- context 'with no full name' do
3184
- before do
3185
- stub_get('/1.1/statuses/show/55709764298092545.json').with(:query => {:include_my_retweet => 'false', :include_entities => 'false'}).to_return(:body => fixture('status_no_full_name.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
3186
- end
3187
- it 'has the correct output' do
3188
- @cli.status('55709764298092545')
3189
- expect($stdout.string).to eq <<-eos
3190
- ID 55709764298092548
3191
- Text The problem with your code is that it's doing exactly what you told it to do.
3192
- Screen name @sferik
3193
- Posted at Apr 6 2011 (8 months ago)
3194
- Retweets 320
3195
- Favorites 50
3196
- Source Twitter for iPhone
3197
- Location Blowfish Sushi To Die For
3198
- eos
3199
- end
3200
- end
3201
- context 'with no place' do
3202
- before do
3203
- stub_get('/1.1/statuses/show/55709764298092545.json').with(:query => {:include_my_retweet => 'false', :include_entities => 'false'}).to_return(:body => fixture('status_no_place.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
3204
- stub_request(:get, 'https://maps.google.com/maps/api/geocode/json').with(:query => {:latlng => '37.75963095,-122.410067', :sensor => 'false'}).to_return(:body => fixture('geo.json'), :headers => {:content_type => 'application/json; charset=UTF-8'})
3205
- end
3206
- it 'has the correct output' do
3207
- @cli.status('55709764298092545')
3208
- expect($stdout.string).to eq <<-eos
3209
- ID 55709764298092551
3210
- Text The problem with your code is that it's doing exactly what you told it to do.
3211
- Screen name @sferik
3212
- Posted at Apr 6 2011 (8 months ago)
3213
- Retweets 320
3214
- Favorites 50
3215
- Source Twitter for iPhone
3216
- Location San Francisco, CA, United States
3217
- eos
3218
- end
3219
- context 'with no city' do
3220
- before do
3221
- stub_get('/1.1/statuses/show/55709764298092545.json').with(:query => {:include_my_retweet => 'false', :include_entities => 'false'}).to_return(:body => fixture('status_no_place.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
3222
- stub_request(:get, 'https://maps.google.com/maps/api/geocode/json').with(:query => {:latlng => '37.75963095,-122.410067', :sensor => 'false'}).to_return(:body => fixture('geo_no_city.json'), :headers => {:content_type => 'application/json; charset=UTF-8'})
3223
- end
3224
- it 'has the correct output' do
3225
- @cli.status('55709764298092545')
3226
- expect($stdout.string).to eq <<-eos
3227
- ID 55709764298092551
3228
- Text The problem with your code is that it's doing exactly what you told it to do.
3229
- Screen name @sferik
3230
- Posted at Apr 6 2011 (8 months ago)
3231
- Retweets 320
3232
- Favorites 50
3233
- Source Twitter for iPhone
3234
- Location CA, United States
3235
- eos
3236
- end
3237
- end
3238
- context 'with no state' do
3239
- before do
3240
- stub_get('/1.1/statuses/show/55709764298092545.json').with(:query => {:include_my_retweet => 'false', :include_entities => 'false'}).to_return(:body => fixture('status_no_place.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
3241
- stub_request(:get, 'https://maps.google.com/maps/api/geocode/json').with(:query => {:latlng => '37.75963095,-122.410067', :sensor => 'false'}).to_return(:body => fixture('geo_no_state.json'), :headers => {:content_type => 'application/json; charset=UTF-8'})
3242
- end
3243
- it 'has the correct output' do
3244
- @cli.status('55709764298092545')
3245
- expect($stdout.string).to eq <<-eos
3246
- ID 55709764298092551
3247
- Text The problem with your code is that it's doing exactly what you told it to do.
3248
- Screen name @sferik
3249
- Posted at Apr 6 2011 (8 months ago)
3250
- Retweets 320
3251
- Favorites 50
3252
- Source Twitter for iPhone
3253
- Location United States
3254
- eos
3255
- end
3256
- end
3257
- end
3258
- context '--long' do
3259
- before do
3260
- @cli.options = @cli.options.merge('long' => true)
3261
- end
3262
- it 'outputs in long format' do
3263
- @cli.status('55709764298092545')
3264
- expect($stdout.string).to eq <<-eos
3265
- ID Posted at Screen name Text ...
3266
- 55709764298092545 Apr 6 2011 @sferik The problem with your code is t...
3267
- eos
3268
- end
3269
- end
3270
- describe '--relative-dates' do
3271
- before do
3272
- stub_get('/1.1/statuses/show/55709764298092545.json').with(:query => {:include_my_retweet => 'false', :include_entities => 'false'}).to_return(:body => fixture('status.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
3273
- stub_get('/1.1/users/show.json').with(:query => {:screen_name => 'sferik', :include_entities => 'false'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
3274
- @cli.options = @cli.options.merge('relative_dates' => true)
3275
- end
3276
- it 'status has the correct output (absolute and relative date together)' do
3277
- @cli.status('55709764298092545')
3278
- expect($stdout.string).to eq <<-eos
3279
- ID 55709764298092545
3280
- Text The problem with your code is that it's doing exactly what you told it to do.
3281
- Screen name @sferik
3282
- Posted at Apr 6 2011 (8 months ago)
3283
- Retweets 320
3284
- Favorites 50
3285
- Source Twitter for iPhone
3286
- Location Blowfish Sushi To Die For, 2170 Bryant St, San Francisco, California, United States
3287
- eos
3288
- end
3289
- it 'whois has the correct output (absolute and relative date together)' do
3290
- @cli.whois('sferik')
3291
- expect($stdout.string).to eq <<-eos
3292
- ID 7505382
3293
- Since Jul 16 2007 (4 years ago)
3294
- Last update @goldman You're near my home town! Say hi to Woodstock for me. (7 months ago)
3295
- Screen name @sferik
3296
- Name Erik Michaels-Ober
3297
- Tweets 7,890
3298
- Favorites 3,755
3299
- Listed 118
3300
- Following 212
3301
- Followers 2,262
3302
- Bio Vagabond.
3303
- Location San Francisco
3304
- URL https://github.com/sferik
3305
- eos
3306
- end
3307
- context '--csv' do
3308
- before do
3309
- @cli.options = @cli.options.merge('csv' => true)
3310
- end
3311
- it 'has the correct output (absolute date in csv)' do
3312
- @cli.status('55709764298092545')
3313
- expect($stdout.string).to eq <<-eos
3314
- ID,Posted at,Screen name,Text,Retweets,Favorites,Source,Location
3315
- 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"
3316
- eos
3317
- end
3318
- end
3319
- context '--long' do
3320
- before do
3321
- @cli.options = @cli.options.merge('long' => true)
3322
- end
3323
- it 'outputs in long format' do
3324
- @cli.status('55709764298092545')
3325
- expect($stdout.string).to eq <<-eos
3326
- ID Posted at Screen name Text ...
3327
- 55709764298092545 8 months ago @sferik The problem with your code is t...
3328
- eos
3329
- end
3330
- end
3331
- end
3332
- end
3333
-
3334
- describe '#timeline' do
3335
- before do
3336
- stub_get('/1.1/statuses/home_timeline.json').with(:query => {:count => '20', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
3337
- end
3338
- context 'without user' do
3339
- it 'requests the correct resource' do
3340
- @cli.timeline
3341
- expect(a_get('/1.1/statuses/home_timeline.json').with(:query => {:count => '20', :include_entities => 'false'})).to have_been_made
3342
- end
3343
- it 'has the correct output' do
3344
- @cli.timeline
3345
- expect($stdout.string).to eq <<-eos
3346
- @mutgoff
3347
- Happy Birthday @imdane. Watch out for those @rally pranksters!
3348
-
3349
- @ironicsans
3350
- If you like good real-life stories, check out @NarrativelyNY's just-launched
3351
- site http://t.co/wiUL07jE (and also visit http://t.co/ZoyQxqWA)
3352
-
3353
- @pat_shaughnessy
3354
- Something else to vote for: "New Rails workshops to bring more women into the
3355
- Boston software scene" http://t.co/eNBuckHc /cc @bostonrb
3356
-
3357
- @calebelston
3358
- Pushing the button to launch the site. http://t.co/qLoEn5jG
3359
-
3360
- @calebelston
3361
- RT @olivercameron: Mosaic looks cool: http://t.co/A8013C9k
3362
-
3363
- @fivethirtyeight
3364
- The Weatherman is Not a Moron: http://t.co/ZwL5Gnq5. An excerpt from my book,
3365
- THE SIGNAL AND THE NOISE (http://t.co/fNXj8vCE)
3366
-
3367
- @codeforamerica
3368
- RT @randomhacks: Going to Code Across Austin II: Y'all Come Hack Now, Sat,
3369
- Sep 8 http://t.co/Sk5BM7U3 We'll see y'all there! #rhok @codeforamerica
3370
- @TheaClay
3371
-
3372
- @fbjork
3373
- RT @jondot: Just published: "Pragmatic Concurrency With #Ruby"
3374
- http://t.co/kGEykswZ /cc @JRuby @headius
3375
-
3376
- @mbostock
3377
- If you are wondering how we computed the split bubbles: http://t.co/BcaqSs5u
3378
-
3379
- @FakeDorsey
3380
- "Write drunk. Edit sober."—Ernest Hemingway
3381
-
3382
- @al3x
3383
- RT @wcmaier: Better banking through better ops: build something new with us
3384
- @Simplify (remote, PDX) http://t.co/8WgzKZH3
3385
-
3386
- @calebelston
3387
- We just announced Mosaic, what we've been working on since the Yobongo
3388
- acquisition. My personal post, http://t.co/ELOyIRZU @heymosaic
3389
-
3390
- @BarackObama
3391
- Donate $10 or more --> get your favorite car magnet: http://t.co/NfRhl2s2
3392
- #Obama2012
3393
-
3394
- @JEG2
3395
- RT @tenderlove: If corporations are people, can we use them to drive in the
3396
- carpool lane?
3397
-
3398
- @eveningedition
3399
- LDN—Obama's nomination; Putin woos APEC; Bombs hit Damascus; Quakes shake
3400
- China; Canada cuts Iran ties; weekend read: http://t.co/OFs6dVW4
3401
-
3402
- @dhh
3403
- RT @ggreenwald: Democrats parade Osama bin Laden's corpse as their proudest
3404
- achievement: why this goulish jingoism is so warped http://t.co/kood278s
3405
-
3406
- @jasonfried
3407
- The story of Mars Curiosity's gears, made by a factory in Rockford, IL:
3408
- http://t.co/MwCRsHQg
3409
-
3410
- @sferik
3411
- @episod @twitterapi now https://t.co/I17jUTu2 and https://t.co/deDu4Hgw seem
3412
- to be missing "1.1" from the URL.
3413
-
3414
- @sferik
3415
- @episod @twitterapi Did you catch https://t.co/VHsQvZT0 as well?
3416
-
3417
- @dwiskus
3418
- Gentlemen, you can't fight in here! This is the war room!
3419
- http://t.co/kMxMYyqF
3420
-
3421
- eos
3422
- end
3423
- end
3424
- context '--csv' do
3425
- before do
3426
- @cli.options = @cli.options.merge('csv' => true)
3427
- end
3428
- it 'outputs in CSV format' do
3429
- @cli.timeline
3430
- expect($stdout.string).to eq <<-eos
3431
- ID,Posted at,Screen name,Text
3432
- 4611686018427387904,2012-09-07 16:35:24 +0000,mutgoff,Happy Birthday @imdane. Watch out for those @rally pranksters!
3433
- 244111183165157376,2012-09-07 16:33:36 +0000,ironicsans,"If you like good real-life stories, check out @NarrativelyNY's just-launched site http://t.co/wiUL07jE (and also visit http://t.co/ZoyQxqWA)"
3434
- 244110336414859264,2012-09-07 16:30:14 +0000,pat_shaughnessy,"Something else to vote for: ""New Rails workshops to bring more women into the Boston software scene"" http://t.co/eNBuckHc /cc @bostonrb"
3435
- 244109797308379136,2012-09-07 16:28:05 +0000,calebelston,Pushing the button to launch the site. http://t.co/qLoEn5jG
3436
- 244108728834592770,2012-09-07 16:23:50 +0000,calebelston,RT @olivercameron: Mosaic looks cool: http://t.co/A8013C9k
3437
- 244107890632294400,2012-09-07 16:20:31 +0000,fivethirtyeight,"The Weatherman is Not a Moron: http://t.co/ZwL5Gnq5. An excerpt from my book, THE SIGNAL AND THE NOISE (http://t.co/fNXj8vCE)"
3438
- 244107823733174272,2012-09-07 16:20:15 +0000,codeforamerica,"RT @randomhacks: Going to Code Across Austin II: Y'all Come Hack Now, Sat, Sep 8 http://t.co/Sk5BM7U3 We'll see y'all there! #rhok @codeforamerica @TheaClay"
3439
- 244107236262170624,2012-09-07 16:17:55 +0000,fbjork,"RT @jondot: Just published: ""Pragmatic Concurrency With #Ruby"" http://t.co/kGEykswZ /cc @JRuby @headius"
3440
- 244106476048764928,2012-09-07 16:14:53 +0000,mbostock,If you are wondering how we computed the split bubbles: http://t.co/BcaqSs5u
3441
- 244105599351148544,2012-09-07 16:11:24 +0000,FakeDorsey,"""Write drunk. Edit sober.""—Ernest Hemingway"
3442
- 244104558433951744,2012-09-07 16:07:16 +0000,al3x,"RT @wcmaier: Better banking through better ops: build something new with us @Simplify (remote, PDX) http://t.co/8WgzKZH3"
3443
- 244104146997870594,2012-09-07 16:05:38 +0000,calebelston,"We just announced Mosaic, what we've been working on since the Yobongo acquisition. My personal post, http://t.co/ELOyIRZU @heymosaic"
3444
- 244103057175113729,2012-09-07 16:01:18 +0000,BarackObama,Donate $10 or more --> get your favorite car magnet: http://t.co/NfRhl2s2 #Obama2012
3445
- 244102834398851073,2012-09-07 16:00:25 +0000,JEG2,"RT @tenderlove: If corporations are people, can we use them to drive in the carpool lane?"
3446
- 244102741125890048,2012-09-07 16:00:03 +0000,eveningedition,LDN—Obama's nomination; Putin woos APEC; Bombs hit Damascus; Quakes shake China; Canada cuts Iran ties; weekend read: http://t.co/OFs6dVW4
3447
- 244102729860009984,2012-09-07 16:00:00 +0000,dhh,RT @ggreenwald: Democrats parade Osama bin Laden's corpse as their proudest achievement: why this goulish jingoism is so warped http://t.co/kood278s
3448
- 244102490646278146,2012-09-07 15:59:03 +0000,jasonfried,"The story of Mars Curiosity's gears, made by a factory in Rockford, IL: http://t.co/MwCRsHQg"
3449
- 244102209942458368,2012-09-07 15:57:56 +0000,sferik,"@episod @twitterapi now https://t.co/I17jUTu2 and https://t.co/deDu4Hgw seem to be missing ""1.1"" from the URL."
3450
- 244100411563339777,2012-09-07 15:50:47 +0000,sferik,@episod @twitterapi Did you catch https://t.co/VHsQvZT0 as well?
3451
- 244099460672679938,2012-09-07 15:47:01 +0000,dwiskus,"Gentlemen, you can't fight in here! This is the war room! http://t.co/kMxMYyqF"
3452
- eos
3453
- end
3454
- end
3455
- context '--decode-uris' do
3456
- before do
3457
- @cli.options = @cli.options.merge('decode_uris' => true)
3458
- stub_get('/1.1/statuses/home_timeline.json').with(:query => {:count => '20', :include_entities => 'true'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
3459
- end
3460
- it 'requests the correct resource' do
3461
- @cli.timeline
3462
- expect(a_get('/1.1/statuses/home_timeline.json').with(:query => {:count => '20', :include_entities => 'true'})).to have_been_made
3463
- end
3464
- it 'decodes URLs' do
3465
- @cli.timeline
3466
- expect($stdout.string).to include 'https://twitter.com/sferik/status/243988000076337152'
3467
- end
3468
- end
3469
- context '--exclude=replies' do
3470
- before do
3471
- @cli.options = @cli.options.merge('exclude' => 'replies')
3472
- stub_get('/1.1/statuses/home_timeline.json').with(:query => {:count => '20', :exclude_replies => 'true', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
3473
- end
3474
- it 'excludes replies' do
3475
- @cli.timeline
3476
- expect(a_get('/1.1/statuses/home_timeline.json').with(:query => {:count => '20', :exclude_replies => 'true', :include_entities => 'false'})).to have_been_made
3477
- end
3478
- end
3479
- context '--exclude=retweets' do
3480
- before do
3481
- @cli.options = @cli.options.merge('exclude' => 'retweets')
3482
- stub_get('/1.1/statuses/home_timeline.json').with(:query => {:count => '20', :include_rts => 'false', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
3483
- end
3484
- it 'excludes retweets' do
3485
- @cli.timeline
3486
- expect(a_get('/1.1/statuses/home_timeline.json').with(:query => {:count => '20', :include_rts => 'false', :include_entities => 'false'})).to have_been_made
3487
- end
3488
- end
3489
- context '--long' do
3490
- before do
3491
- @cli.options = @cli.options.merge('long' => true)
3492
- end
3493
- it 'outputs in long format' do
3494
- @cli.timeline
3495
- expect($stdout.string).to eq <<-eos
3496
- ID Posted at Screen name Text
3497
- 4611686018427387904 Sep 7 08:35 @mutgoff Happy Birthday @imdane. ...
3498
- 244111183165157376 Sep 7 08:33 @ironicsans If you like good real-li...
3499
- 244110336414859264 Sep 7 08:30 @pat_shaughnessy Something else to vote f...
3500
- 244109797308379136 Sep 7 08:28 @calebelston Pushing the button to la...
3501
- 244108728834592770 Sep 7 08:23 @calebelston RT @olivercameron: Mosai...
3502
- 244107890632294400 Sep 7 08:20 @fivethirtyeight The Weatherman is Not a ...
3503
- 244107823733174272 Sep 7 08:20 @codeforamerica RT @randomhacks: Going t...
3504
- 244107236262170624 Sep 7 08:17 @fbjork RT @jondot: Just publish...
3505
- 244106476048764928 Sep 7 08:14 @mbostock If you are wondering how...
3506
- 244105599351148544 Sep 7 08:11 @FakeDorsey "Write drunk. Edit sober...
3507
- 244104558433951744 Sep 7 08:07 @al3x RT @wcmaier: Better bank...
3508
- 244104146997870594 Sep 7 08:05 @calebelston We just announced Mosaic...
3509
- 244103057175113729 Sep 7 08:01 @BarackObama Donate $10 or more --> g...
3510
- 244102834398851073 Sep 7 08:00 @JEG2 RT @tenderlove: If corpo...
3511
- 244102741125890048 Sep 7 08:00 @eveningedition LDN—Obama's nomination; ...
3512
- 244102729860009984 Sep 7 08:00 @dhh RT @ggreenwald: Democrat...
3513
- 244102490646278146 Sep 7 07:59 @jasonfried The story of Mars Curios...
3514
- 244102209942458368 Sep 7 07:57 @sferik @episod @twitterapi now ...
3515
- 244100411563339777 Sep 7 07:50 @sferik @episod @twitterapi Did ...
3516
- 244099460672679938 Sep 7 07:47 @dwiskus Gentlemen, you can't fig...
3517
- eos
3518
- end
3519
- context '--reverse' do
3520
- before do
3521
- @cli.options = @cli.options.merge('reverse' => true)
3522
- end
3523
- it 'reverses the order of the sort' do
3524
- @cli.timeline
3525
- expect($stdout.string).to eq <<-eos
3526
- ID Posted at Screen name Text
3527
- 244099460672679938 Sep 7 07:47 @dwiskus Gentlemen, you can't fig...
3528
- 244100411563339777 Sep 7 07:50 @sferik @episod @twitterapi Did ...
3529
- 244102209942458368 Sep 7 07:57 @sferik @episod @twitterapi now ...
3530
- 244102490646278146 Sep 7 07:59 @jasonfried The story of Mars Curios...
3531
- 244102729860009984 Sep 7 08:00 @dhh RT @ggreenwald: Democrat...
3532
- 244102741125890048 Sep 7 08:00 @eveningedition LDN—Obama's nomination; ...
3533
- 244102834398851073 Sep 7 08:00 @JEG2 RT @tenderlove: If corpo...
3534
- 244103057175113729 Sep 7 08:01 @BarackObama Donate $10 or more --> g...
3535
- 244104146997870594 Sep 7 08:05 @calebelston We just announced Mosaic...
3536
- 244104558433951744 Sep 7 08:07 @al3x RT @wcmaier: Better bank...
3537
- 244105599351148544 Sep 7 08:11 @FakeDorsey "Write drunk. Edit sober...
3538
- 244106476048764928 Sep 7 08:14 @mbostock If you are wondering how...
3539
- 244107236262170624 Sep 7 08:17 @fbjork RT @jondot: Just publish...
3540
- 244107823733174272 Sep 7 08:20 @codeforamerica RT @randomhacks: Going t...
3541
- 244107890632294400 Sep 7 08:20 @fivethirtyeight The Weatherman is Not a ...
3542
- 244108728834592770 Sep 7 08:23 @calebelston RT @olivercameron: Mosai...
3543
- 244109797308379136 Sep 7 08:28 @calebelston Pushing the button to la...
3544
- 244110336414859264 Sep 7 08:30 @pat_shaughnessy Something else to vote f...
3545
- 244111183165157376 Sep 7 08:33 @ironicsans If you like good real-li...
3546
- 4611686018427387904 Sep 7 08:35 @mutgoff Happy Birthday @imdane. ...
3547
- eos
3548
- end
3549
- end
3550
- end
3551
- context '--max-id' do
3552
- before do
3553
- @cli.options = @cli.options.merge('max_id' => 244_104_558_433_951_744)
3554
- stub_get('/1.1/statuses/home_timeline.json').with(:query => {:count => '20', :max_id => '244104558433951744', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
3555
- end
3556
- it 'requests the correct resource' do
3557
- @cli.timeline
3558
- expect(a_get('/1.1/statuses/home_timeline.json').with(:query => {:count => '20', :max_id => '244104558433951744', :include_entities => 'false'})).to have_been_made
3559
- end
3560
- end
3561
- context '--number' do
3562
- before do
3563
- stub_get('/1.1/statuses/home_timeline.json').with(:query => {:count => '1', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
3564
- stub_get('/1.1/statuses/home_timeline.json').with(:query => {:count => '200', :include_entities => 'false'}).to_return(:body => fixture('200_statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
3565
- stub_get('/1.1/statuses/home_timeline.json').with(:query => {:count => '1', :max_id => '265500541700956160', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
3566
- end
3567
- it 'limits the number of results to 1' do
3568
- @cli.options = @cli.options.merge('number' => 1)
3569
- @cli.timeline
3570
- expect(a_get('/1.1/statuses/home_timeline.json').with(:query => {:count => '1', :include_entities => 'false'})).to have_been_made
3571
- end
3572
- it 'limits the number of results to 201' do
3573
- @cli.options = @cli.options.merge('number' => 201)
3574
- @cli.timeline
3575
- expect(a_get('/1.1/statuses/home_timeline.json').with(:query => {:count => '200', :include_entities => 'false'})).to have_been_made
3576
- expect(a_get('/1.1/statuses/home_timeline.json').with(:query => {:count => '1', :max_id => '265500541700956160', :include_entities => 'false'})).to have_been_made
3577
- end
3578
- end
3579
- context '--since-id' do
3580
- before do
3581
- @cli.options = @cli.options.merge('since_id' => 244_104_558_433_951_744)
3582
- stub_get('/1.1/statuses/home_timeline.json').with(:query => {:count => '20', :since_id => '244104558433951744', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
3583
- end
3584
- it 'requests the correct resource' do
3585
- @cli.timeline
3586
- expect(a_get('/1.1/statuses/home_timeline.json').with(:query => {:count => '20', :since_id => '244104558433951744', :include_entities => 'false'})).to have_been_made
3587
- end
3588
- end
3589
- context 'with a user passed' do
3590
- before do
3591
- stub_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '20', :screen_name => 'sferik', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
3592
- end
3593
- it 'requests the correct resource' do
3594
- @cli.timeline('sferik')
3595
- expect(a_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '20', :screen_name => 'sferik', :include_entities => 'false'})).to have_been_made
3596
- end
3597
- context '--id' do
3598
- before do
3599
- @cli.options = @cli.options.merge('id' => true)
3600
- stub_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '20', :user_id => '7505382', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
3601
- end
3602
- it 'requests the correct resource' do
3603
- @cli.timeline('7505382')
3604
- expect(a_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '20', :user_id => '7505382', :include_entities => 'false'})).to have_been_made
3605
- end
3606
- end
3607
- context '--max-id' do
3608
- before do
3609
- @cli.options = @cli.options.merge('max_id' => 244_104_558_433_951_744)
3610
- stub_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '20', :screen_name => 'sferik', :max_id => '244104558433951744', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
3611
- end
3612
- it 'requests the correct resource' do
3613
- @cli.timeline('sferik')
3614
- expect(a_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '20', :screen_name => 'sferik', :max_id => '244104558433951744', :include_entities => 'false'})).to have_been_made
3615
- end
3616
- end
3617
- context '--number' do
3618
- before do
3619
- stub_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '1', :screen_name => 'sferik', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
3620
- stub_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :screen_name => 'sferik', :include_entities => 'false'}).to_return(:body => fixture('200_statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
3621
- stub_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '1', :screen_name => 'sferik', :max_id => '265500541700956160', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
3622
- end
3623
- it 'limits the number of results to 1' do
3624
- @cli.options = @cli.options.merge('number' => 1)
3625
- @cli.timeline('sferik')
3626
- expect(a_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '1', :screen_name => 'sferik', :include_entities => 'false'})).to have_been_made
3627
- end
3628
- it 'limits the number of results to 201' do
3629
- @cli.options = @cli.options.merge('number' => 201)
3630
- @cli.timeline('sferik')
3631
- expect(a_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :screen_name => 'sferik', :include_entities => 'false'})).to have_been_made
3632
- expect(a_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '1', :screen_name => 'sferik', :max_id => '265500541700956160', :include_entities => 'false'})).to have_been_made
3633
- end
3634
- end
3635
- context '--since-id' do
3636
- before do
3637
- @cli.options = @cli.options.merge('since_id' => 244_104_558_433_951_744)
3638
- stub_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '20', :screen_name => 'sferik', :since_id => '244104558433951744', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
3639
- end
3640
- it 'requests the correct resource' do
3641
- @cli.timeline('sferik')
3642
- expect(a_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '20', :screen_name => 'sferik', :since_id => '244104558433951744', :include_entities => 'false'})).to have_been_made
3643
- end
3644
- end
3645
- end
3646
- end
3647
-
3648
- describe '#trends' do
3649
- before do
3650
- stub_get('/1.1/trends/place.json').with(:query => {:id => '1'}).to_return(:body => fixture('trends.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
3651
- end
3652
- it 'requests the correct resource' do
3653
- @cli.trends
3654
- expect(a_get('/1.1/trends/place.json').with(:query => {:id => '1'})).to have_been_made
3655
- end
3656
- it 'has the correct output' do
3657
- @cli.trends
3658
- expect($stdout.string.chomp).to eq '#sevenwordsaftersex Walkman Allen Iverson'
3659
- end
3660
- context '--exclude-hashtags' do
3661
- before do
3662
- @cli.options = @cli.options.merge('exclude-hashtags' => true)
3663
- stub_get('/1.1/trends/place.json').with(:query => {:id => '1', :exclude => 'hashtags'}).to_return(:body => fixture('trends.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
3664
- end
3665
- it 'requests the correct resource' do
3666
- @cli.trends
3667
- expect(a_get('/1.1/trends/place.json').with(:query => {:id => '1', :exclude => 'hashtags'})).to have_been_made
3668
- end
3669
- it 'has the correct output' do
3670
- @cli.trends
3671
- expect($stdout.string.chomp).to eq '#sevenwordsaftersex Walkman Allen Iverson'
3672
- end
3673
- end
3674
- context 'with a WOEID passed' do
3675
- before do
3676
- stub_get('/1.1/trends/place.json').with(:query => {:id => '2487956'}).to_return(:body => fixture('trends.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
3677
- end
3678
- it 'requests the correct resource' do
3679
- @cli.trends('2487956')
3680
- expect(a_get('/1.1/trends/place.json').with(:query => {:id => '2487956'})).to have_been_made
3681
- end
3682
- it 'has the correct output' do
3683
- @cli.trends('2487956')
3684
- expect($stdout.string.chomp).to eq '#sevenwordsaftersex Walkman Allen Iverson'
3685
- end
3686
- end
3687
- end
3688
-
3689
- describe '#trend_locations' do
3690
- before do
3691
- stub_get('/1.1/trends/available.json').to_return(:body => fixture('locations.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
3692
- end
3693
- it 'requests the correct resource' do
3694
- @cli.trend_locations
3695
- expect(a_get('/1.1/trends/available.json')).to have_been_made
3696
- end
3697
- it 'has the correct output' do
3698
- @cli.trend_locations
3699
- expect($stdout.string.chomp).to eq 'San Francisco Soweto United States Worldwide'
3700
- end
3701
- context '--csv' do
3702
- before do
3703
- @cli.options = @cli.options.merge('csv' => true)
3704
- end
3705
- it 'outputs in CSV format' do
3706
- @cli.trend_locations
3707
- expect($stdout.string.chomp).to eq <<-eos.chomp
3708
- WOEID,Parent ID,Type,Name,Country
3709
- 2487956,23424977,Town,San Francisco,United States
3710
- 1587677,23424942,Unknown,Soweto,South Africa
3711
- 23424977,1,Country,United States,United States
3712
- 1,0,Supername,Worldwide,
3713
- eos
3714
- end
3715
- end
3716
- context '--long' do
3717
- before do
3718
- @cli.options = @cli.options.merge('long' => true)
3719
- end
3720
- it 'outputs in long format' do
3721
- @cli.trend_locations
3722
- expect($stdout.string.chomp).to eq <<-eos.chomp
3723
- WOEID Parent ID Type Name Country
3724
- 2487956 23424977 Town San Francisco United States
3725
- 1587677 23424942 Unknown Soweto South Africa
3726
- 23424977 1 Country United States United States
3727
- 1 0 Supername Worldwide
3728
- eos
3729
- end
3730
- end
3731
- context '--reverse' do
3732
- before do
3733
- @cli.options = @cli.options.merge('reverse' => true)
3734
- end
3735
- it 'reverses the order of the sort' do
3736
- @cli.trend_locations
3737
- expect($stdout.string.chomp).to eq 'Worldwide United States Soweto San Francisco'
3738
- end
3739
- end
3740
- context '--sort=country' do
3741
- before do
3742
- @cli.options = @cli.options.merge('sort' => 'country')
3743
- end
3744
- it 'sorts by the country name' do
3745
- @cli.trend_locations
3746
- expect($stdout.string.chomp).to eq 'Soweto San Francisco United States Worldwide'
3747
- end
3748
- end
3749
- context '--sort=parent' do
3750
- before do
3751
- @cli.options = @cli.options.merge('sort' => 'parent')
3752
- end
3753
- it 'sorts by the parent ID' do
3754
- @cli.trend_locations
3755
- expect($stdout.string.chomp).to eq 'Worldwide United States Soweto San Francisco'
3756
- end
3757
- end
3758
- context '--sort=type' do
3759
- before do
3760
- @cli.options = @cli.options.merge('sort' => 'type')
3761
- end
3762
- it 'sorts by the type' do
3763
- @cli.trend_locations
3764
- expect($stdout.string.chomp).to eq 'United States Worldwide San Francisco Soweto'
3765
- end
3766
- end
3767
- context '--sort=woeid' do
3768
- before do
3769
- @cli.options = @cli.options.merge('sort' => 'woeid')
3770
- end
3771
- it 'sorts by the WOEID' do
3772
- @cli.trend_locations
3773
- expect($stdout.string.chomp).to eq 'Worldwide Soweto San Francisco United States'
3774
- end
3775
- end
3776
- context '--unsorted' do
3777
- before do
3778
- @cli.options = @cli.options.merge('unsorted' => true)
3779
- end
3780
- it 'is not sorted' do
3781
- @cli.trend_locations
3782
- expect($stdout.string.chomp).to eq 'Worldwide San Francisco United States Soweto'
3783
- end
3784
- end
3785
- end
3786
-
3787
- describe '#unfollow' do
3788
- before do
3789
- @cli.options = @cli.options.merge('profile' => fixture_path + '/.trc')
3790
- end
3791
- context 'one user' do
3792
- it 'requests the correct resource' do
3793
- stub_post('/1.1/friendships/destroy.json').with(:body => {:screen_name => 'sferik'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
3794
- @cli.unfollow('sferik')
3795
- expect(a_post('/1.1/friendships/destroy.json').with(:body => {:screen_name => 'sferik'})).to have_been_made
3796
- end
3797
- it 'has the correct output' do
3798
- stub_post('/1.1/friendships/destroy.json').with(:body => {:screen_name => 'sferik'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
3799
- @cli.unfollow('sferik')
3800
- expect($stdout.string).to match(/^@testcli is no longer following 1 user\.$/)
3801
- end
3802
- context '--id' do
3803
- before do
3804
- @cli.options = @cli.options.merge('id' => true)
3805
- stub_post('/1.1/friendships/destroy.json').with(:body => {:user_id => '7505382'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
3806
- end
3807
- it 'requests the correct resource' do
3808
- @cli.unfollow('7505382')
3809
- expect(a_post('/1.1/friendships/destroy.json').with(:body => {:user_id => '7505382'})).to have_been_made
3810
- end
3811
- end
3812
- context 'Twitter is down' do
3813
- it 'retries 3 times and then raise an error' do
3814
- stub_post('/1.1/friendships/destroy.json').with(:body => {:screen_name => 'sferik'}).to_return(:status => 502, :headers => {:content_type => 'application/json; charset=utf-8'})
3815
- expect do
3816
- @cli.unfollow('sferik')
3817
- end.to raise_error(Twitter::Error::BadGateway)
3818
- expect(a_post('/1.1/friendships/destroy.json').with(:body => {:screen_name => 'sferik'})).to have_been_made.times(3)
3819
- end
3820
- end
3821
- end
3822
- end
3823
-
3824
- describe '#update' do
3825
- before do
3826
- @cli.options = @cli.options.merge('profile' => fixture_path + '/.trc')
3827
- stub_post('/1.1/statuses/update.json').with(:body => {:status => 'Testing', :trim_user => 'true'}).to_return(:body => fixture('status.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
3828
- stub_request(:get, 'http://checkip.dyndns.org/').to_return(:body => fixture('checkip.html'), :headers => {:content_type => 'text/html'})
3829
- 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'})
3830
- end
3831
- it 'requests the correct resource' do
3832
- @cli.update('Testing')
3833
- expect(a_post('/1.1/statuses/update.json').with(:body => {:status => 'Testing', :trim_user => 'true'})).to have_been_made
3834
- expect(a_request(:get, 'http://checkip.dyndns.org/')).not_to have_been_made
3835
- expect(a_request(:get, 'http://www.geoplugin.net/xml.gp?ip=50.131.22.169')).not_to have_been_made
3836
- end
3837
- it 'has the correct output' do
3838
- @cli.update('Testing')
3839
- expect($stdout.string.split("\n").first).to eq 'Tweet posted by @testcli.'
3840
- end
3841
- context 'with file' do
3842
- before do
3843
- @cli.options = @cli.options.merge('file' => fixture_path + '/long.png')
3844
- stub_post('/1.1/statuses/update_with_media.json').to_return(:body => fixture('status.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
3845
- end
3846
- it 'requests the correct resource' do
3847
- @cli.update('Testing')
3848
- expect(a_post('/1.1/statuses/update_with_media.json')).to have_been_made
3849
- end
3850
- it 'has the correct output' do
3851
- @cli.update('Testing')
3852
- expect($stdout.string.split("\n").first).to eq 'Tweet posted by @testcli.'
3853
- end
3854
- end
3855
- context '--location' do
3856
- before do
3857
- @cli.options = @cli.options.merge('location' => 'location')
3858
- 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'), :headers => {:content_type => 'application/json; charset=utf-8'})
3859
- end
3860
- it 'requests the correct resource' do
3861
- @cli.update('Testing')
3862
- 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
3863
- expect(a_request(:get, 'http://checkip.dyndns.org/')).to have_been_made
3864
- expect(a_request(:get, 'http://www.geoplugin.net/xml.gp?ip=50.131.22.169')).to have_been_made
3865
- end
3866
- it 'has the correct output' do
3867
- @cli.update('Testing')
3868
- expect($stdout.string.split("\n").first).to eq 'Tweet posted by @testcli.'
3869
- end
3870
- end
3871
- context "--location 'latitude,longitude'" do
3872
- before do
3873
- @cli.options = @cli.options.merge('location' => '41.03132,28.9869')
3874
- 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'), :headers => {:content_type => 'application/json; charset=utf-8'})
3875
- end
3876
- it 'requests the correct resource' do
3877
- @cli.update('Testing')
3878
- 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
3879
- expect(a_request(:get, 'http://checkip.dyndns.org/')).not_to have_been_made
3880
- expect(a_request(:get, 'http://www.geoplugin.net/xml.gp?ip=50.131.22.169')).not_to have_been_made
3881
- end
3882
- it 'has the correct output' do
3883
- @cli.update('Testing')
3884
- expect($stdout.string.split("\n").first).to eq 'Tweet posted by @testcli.'
3885
- end
3886
- end
3887
- end
3888
-
3889
- describe '#users' do
3890
- before do
3891
- stub_post('/1.1/users/lookup.json').with(:body => {:screen_name => 'sferik,pengwynn'}).to_return(:body => fixture('users.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
3892
- end
3893
- it 'requests the correct resource' do
3894
- @cli.users('sferik', 'pengwynn')
3895
- expect(a_post('/1.1/users/lookup.json').with(:body => {:screen_name => 'sferik,pengwynn'})).to have_been_made
3896
- end
3897
- it 'has the correct output' do
3898
- @cli.users('sferik', 'pengwynn')
3899
- expect($stdout.string.chomp).to eq 'pengwynn sferik'
3900
- end
3901
- context '--csv' do
3902
- before do
3903
- @cli.options = @cli.options.merge('csv' => true)
3904
- end
3905
- it 'outputs in CSV format' do
3906
- @cli.users('sferik', 'pengwynn')
3907
- expect($stdout.string).to eq <<-eos
3908
- ID,Since,Last tweeted at,Tweets,Favorites,Listed,Following,Followers,Screen name,Name,Verified,Protected,Bio,Status,Location,URL
3909
- 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
3910
- 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
3911
- eos
3912
- end
3913
- end
3914
- context '--long' do
3915
- before do
3916
- @cli.options = @cli.options.merge('long' => true)
3917
- end
3918
- it 'outputs in long format' do
3919
- @cli.users('sferik', 'pengwynn')
3920
- expect($stdout.string).to eq <<-eos
3921
- ID Since Last tweeted at Tweets Favorites Listed Following...
3922
- 14100886 Mar 8 2008 Jul 7 12:33 6940 192 358 3427...
3923
- 7505382 Jul 16 2007 Jul 8 10:29 7890 3755 118 212...
3924
- eos
3925
- end
3926
- end
3927
- context '--reverse' do
3928
- before do
3929
- @cli.options = @cli.options.merge('reverse' => true)
3930
- end
3931
- it 'reverses the order of the sort' do
3932
- @cli.users('sferik', 'pengwynn')
3933
- expect($stdout.string.chomp).to eq 'sferik pengwynn'
3934
- end
3935
- end
3936
- context '--sort=favorites' do
3937
- before do
3938
- @cli.options = @cli.options.merge('sort' => 'favorites')
3939
- end
3940
- it 'sorts by the number of favorites' do
3941
- @cli.users('sferik', 'pengwynn')
3942
- expect($stdout.string.chomp).to eq 'pengwynn sferik'
3943
- end
3944
- end
3945
- context '--sort=followers' do
3946
- before do
3947
- @cli.options = @cli.options.merge('sort' => 'followers')
3948
- end
3949
- it 'sorts by the number of followers' do
3950
- @cli.users('sferik', 'pengwynn')
3951
- expect($stdout.string.chomp).to eq 'sferik pengwynn'
3952
- end
3953
- end
3954
- context '--sort=friends' do
3955
- before do
3956
- @cli.options = @cli.options.merge('sort' => 'friends')
3957
- end
3958
- it 'sorts by the number of friends' do
3959
- @cli.users('sferik', 'pengwynn')
3960
- expect($stdout.string.chomp).to eq 'sferik pengwynn'
3961
- end
3962
- end
3963
- context '--id' do
3964
- before do
3965
- @cli.options = @cli.options.merge('id' => true)
3966
- stub_post('/1.1/users/lookup.json').with(:body => {:user_id => '7505382,14100886'}).to_return(:body => fixture('users.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
3967
- end
3968
- it 'requests the correct resource' do
3969
- @cli.users('7505382', '14100886')
3970
- expect(a_post('/1.1/users/lookup.json').with(:body => {:user_id => '7505382,14100886'})).to have_been_made
3971
- end
3972
- end
3973
- context '--sort=listed' do
3974
- before do
3975
- @cli.options = @cli.options.merge('sort' => 'listed')
3976
- end
3977
- it 'sorts by the number of list memberships' do
3978
- @cli.users('sferik', 'pengwynn')
3979
- expect($stdout.string.chomp).to eq 'sferik pengwynn'
3980
- end
3981
- end
3982
- context '--sort=since' do
3983
- before do
3984
- @cli.options = @cli.options.merge('sort' => 'since')
3985
- end
3986
- it 'sorts by the time when Twitter acount was created' do
3987
- @cli.users('sferik', 'pengwynn')
3988
- expect($stdout.string.chomp).to eq 'sferik pengwynn'
3989
- end
3990
- end
3991
- context '--sort=tweets' do
3992
- before do
3993
- @cli.options = @cli.options.merge('sort' => 'tweets')
3994
- end
3995
- it 'sorts by the number of Tweets' do
3996
- @cli.users('sferik', 'pengwynn')
3997
- expect($stdout.string.chomp).to eq 'pengwynn sferik'
3998
- end
3999
- end
4000
- context '--sort=tweeted' do
4001
- before do
4002
- @cli.options = @cli.options.merge('sort' => 'tweeted')
4003
- end
4004
- it 'sorts by the time of the last Tweet' do
4005
- @cli.users('sferik', 'pengwynn')
4006
- expect($stdout.string.chomp).to eq 'pengwynn sferik'
4007
- end
4008
- end
4009
- context '--unsorted' do
4010
- before do
4011
- @cli.options = @cli.options.merge('unsorted' => true)
4012
- end
4013
- it 'is not sorted' do
4014
- @cli.users('sferik', 'pengwynn')
4015
- expect($stdout.string.chomp).to eq 'pengwynn sferik'
4016
- end
4017
- end
4018
- end
4019
-
4020
- describe '#version' do
4021
- it 'has the correct output' do
4022
- @cli.version
4023
- expect($stdout.string.chomp).to eq T::Version.to_s
4024
- end
4025
- end
4026
-
4027
- describe '#whois' do
4028
- before do
4029
- stub_get('/1.1/users/show.json').with(:query => {:screen_name => 'sferik', :include_entities => 'false'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
4030
- end
4031
- it 'requests the correct resource' do
4032
- @cli.whois('sferik')
4033
- expect(a_get('/1.1/users/show.json').with(:query => {:screen_name => 'sferik', :include_entities => 'false'})).to have_been_made
4034
- end
4035
- it 'has the correct output' do
4036
- @cli.whois('sferik')
4037
- expect($stdout.string).to eq <<-eos
4038
- ID 7505382
4039
- Since Jul 16 2007 (4 years ago)
4040
- Last update @goldman You're near my home town! Say hi to Woodstock for me. (7 months ago)
4041
- Screen name @sferik
4042
- Name Erik Michaels-Ober
4043
- Tweets 7,890
4044
- Favorites 3,755
4045
- Listed 118
4046
- Following 212
4047
- Followers 2,262
4048
- Bio Vagabond.
4049
- Location San Francisco
4050
- URL https://github.com/sferik
4051
- eos
4052
- end
4053
- context '--csv' do
4054
- before do
4055
- @cli.options = @cli.options.merge('csv' => true)
4056
- end
4057
- it 'has the correct output' do
4058
- @cli.whois('sferik')
4059
- expect($stdout.string).to eq <<-eos
4060
- ID,Since,Last tweeted at,Tweets,Favorites,Listed,Following,Followers,Screen name,Name,Verified,Protected,Bio,Status,Location,URL
4061
- 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
4062
- eos
4063
- end
4064
- end
4065
- context '--id' do
4066
- before do
4067
- @cli.options = @cli.options.merge('id' => true)
4068
- stub_get('/1.1/users/show.json').with(:query => {:user_id => '7505382', :include_entities => 'false'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
4069
- end
4070
- it 'requests the correct resource' do
4071
- @cli.whois('7505382')
4072
- expect(a_get('/1.1/users/show.json').with(:query => {:user_id => '7505382', :include_entities => 'false'})).to have_been_made
4073
- end
4074
- end
4075
- context '--long' do
4076
- before do
4077
- @cli.options = @cli.options.merge('long' => true)
4078
- end
4079
- it 'outputs in long format' do
4080
- @cli.whois('sferik')
4081
- expect($stdout.string).to eq <<-eos
4082
- ID Since Last tweeted at Tweets Favorites Listed Following ...
4083
- 7505382 Jul 16 2007 Jul 8 10:29 7890 3755 118 212 ...
4084
- eos
4085
- end
4086
- end
4087
- end
4088
-
4089
- describe '#whoami' do
4090
- before do
4091
- stub_get('/1.1/users/show.json').with(:query => {:screen_name => 'testcli', :include_entities => 'false'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
4092
- end
4093
- it 'requests the correct resource' do
4094
- @cli.whoami
4095
- expect(a_get('/1.1/users/show.json').with(:query => {:screen_name => 'testcli', :include_entities => 'false'})).to have_been_made
4096
- end
4097
- it 'has the correct output' do
4098
- @cli.whoami
4099
- expect($stdout.string).to eq <<-eos
4100
- ID 7505382
4101
- Since Jul 16 2007 (4 years ago)
4102
- Last update @goldman You're near my home town! Say hi to Woodstock for me. (7 months ago)
4103
- Screen name @sferik
4104
- Name Erik Michaels-Ober
4105
- Tweets 7,890
4106
- Favorites 3,755
4107
- Listed 118
4108
- Following 212
4109
- Followers 2,262
4110
- Bio Vagabond.
4111
- Location San Francisco
4112
- URL https://github.com/sferik
4113
- eos
4114
- end
4115
- context '--csv' do
4116
- before do
4117
- @cli.options = @cli.options.merge('csv' => true)
4118
- end
4119
- it 'has the correct output' do
4120
- @cli.whoami
4121
- expect($stdout.string).to eq <<-eos
4122
- ID,Since,Last tweeted at,Tweets,Favorites,Listed,Following,Followers,Screen name,Name,Verified,Protected,Bio,Status,Location,URL
4123
- 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
4124
- eos
4125
- end
4126
- end
4127
- context '--long' do
4128
- before do
4129
- @cli.options = @cli.options.merge('long' => true)
4130
- end
4131
- it 'outputs in long format' do
4132
- @cli.whoami
4133
- expect($stdout.string).to eq <<-eos
4134
- ID Since Last tweeted at Tweets Favorites Listed Following ...
4135
- 7505382 Jul 16 2007 Jul 8 10:29 7890 3755 118 212 ...
4136
- eos
4137
- end
4138
- end
4139
- end
4140
-
4141
- end