t 2.7.0 → 2.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -1,221 +0,0 @@
1
- # encoding: utf-8
2
- require 'helper'
3
-
4
- describe T::RCFile do
5
-
6
- after do
7
- T::RCFile.instance.reset
8
- File.delete(project_path + '/tmp/trc') if File.exist?(project_path + '/tmp/trc')
9
- end
10
-
11
- it 'is a singleton' do
12
- expect(T::RCFile).to be_a Class
13
- expect do
14
- T::RCFile.new
15
- end.to raise_error(NoMethodError, /private method `new' called/)
16
- end
17
-
18
- describe '#[]' do
19
- it 'returns the profiles for a user' do
20
- rcfile = T::RCFile.instance
21
- rcfile.path = fixture_path + '/.trc'
22
- expect(rcfile['testcli'].keys).to eq %w[abc123]
23
- end
24
- end
25
-
26
- describe '#[]=' do
27
- it 'adds a profile for a user' do
28
- rcfile = T::RCFile.instance
29
- rcfile.path = project_path + '/tmp/trc'
30
- rcfile['testcli'] = {
31
- 'abc123' => {
32
- :username => 'testcli',
33
- :consumer_key => 'abc123',
34
- :consumer_secret => 'def456',
35
- :token => 'ghi789',
36
- :secret => 'jkl012',
37
- }
38
- }
39
- expect(rcfile['testcli'].keys).to eq %w[abc123]
40
- end
41
- it 'writes the data to a file' do
42
- rcfile = T::RCFile.instance
43
- rcfile.path = project_path + '/tmp/trc'
44
- rcfile['testcli'] = {
45
- 'abc123' => {
46
- :username => 'testcli',
47
- :consumer_key => 'abc123',
48
- :consumer_secret => 'def456',
49
- :token => 'ghi789',
50
- :secret => 'jkl012',
51
- }
52
- }
53
- expect(rcfile['testcli'].keys).to eq %w[abc123]
54
- end
55
- it 'is not be world writable' do
56
- rcfile = T::RCFile.instance
57
- rcfile.path = project_path + '/tmp/trc'
58
- rcfile['testcli'] = {
59
- 'abc123' => {
60
- :username => 'testcli',
61
- :consumer_key => 'abc123',
62
- :consumer_secret => 'def456',
63
- :token => 'ghi789',
64
- :secret => 'jkl012',
65
- }
66
- }
67
- expect(File.world_writable?(rcfile.path)).to be nil
68
- end
69
- it 'is not be world readable' do
70
- rcfile = T::RCFile.instance
71
- rcfile.path = project_path + '/tmp/trc'
72
- rcfile['testcli'] = {
73
- 'abc123' => {
74
- :username => 'testcli',
75
- :consumer_key => 'abc123',
76
- :consumer_secret => 'def456',
77
- :token => 'ghi789',
78
- :secret => 'jkl012',
79
- }
80
- }
81
- expect(File.world_readable?(rcfile.path)).to be nil
82
- end
83
- end
84
-
85
- describe '#configuration' do
86
- it 'returns configuration' do
87
- rcfile = T::RCFile.instance
88
- rcfile.path = fixture_path + '/.trc'
89
- expect(rcfile.configuration.keys).to eq %w[default_profile]
90
- end
91
- end
92
-
93
- describe '#active_consumer_key' do
94
- it 'returns default consumer key' do
95
- rcfile = T::RCFile.instance
96
- rcfile.path = fixture_path + '/.trc'
97
- expect(rcfile.active_consumer_key).to eq 'abc123'
98
- end
99
- end
100
-
101
- describe '#active_consumer_secret' do
102
- it 'returns default consumer secret' do
103
- rcfile = T::RCFile.instance
104
- rcfile.path = fixture_path + '/.trc'
105
- expect(rcfile.active_consumer_secret).to eq 'asdfasd223sd2'
106
- end
107
- end
108
-
109
- describe '#active_profile' do
110
- it 'returns default profile' do
111
- rcfile = T::RCFile.instance
112
- rcfile.path = fixture_path + '/.trc'
113
- expect(rcfile.active_profile).to eq %w[testcli abc123]
114
- end
115
- end
116
-
117
- describe '#active_profile=' do
118
- it 'sets default profile' do
119
- rcfile = T::RCFile.instance
120
- rcfile.path = project_path + '/tmp/trc'
121
- rcfile.active_profile = {'username' => 'testcli', 'consumer_key' => 'abc123'}
122
- expect(rcfile.active_profile).to eq %w[testcli abc123]
123
- end
124
- it 'writes the data to a file' do
125
- rcfile = T::RCFile.instance
126
- rcfile.path = project_path + '/tmp/trc'
127
- rcfile.active_profile = {'username' => 'testcli', 'consumer_key' => 'abc123'}
128
- expect(rcfile.active_profile).to eq %w[testcli abc123]
129
- end
130
- end
131
-
132
- describe '#active_token' do
133
- it 'returns default token' do
134
- rcfile = T::RCFile.instance
135
- rcfile.path = fixture_path + '/.trc'
136
- expect(rcfile.active_token).to eq '428004849-cebdct6bwobn'
137
- end
138
- end
139
-
140
- describe '#active_secret' do
141
- it 'returns default secret' do
142
- rcfile = T::RCFile.instance
143
- rcfile.path = fixture_path + '/.trc'
144
- expect(rcfile.active_secret).to eq 'epzrjvxtumoc'
145
- end
146
- end
147
-
148
- describe '#delete' do
149
- it 'deletes the rcfile' do
150
- path = project_path + '/tmp/trc'
151
- File.open(path, 'w') { |file| file.write(YAML.dump({})) }
152
- expect(File.exist?(path)).to be true
153
- rcfile = T::RCFile.instance
154
- rcfile.path = path
155
- rcfile.delete
156
- expect(File.exist?(path)).to be false
157
- end
158
- end
159
-
160
- describe '#empty?' do
161
- context 'when a non-empty file exists' do
162
- it 'returns false' do
163
- rcfile = T::RCFile.instance
164
- rcfile.path = fixture_path + '/.trc'
165
- expect(rcfile.empty?).to be false
166
- end
167
- end
168
- context 'when file does not exist at path' do
169
- it 'returns true' do
170
- rcfile = T::RCFile.instance
171
- rcfile.path = File.expand_path('../fixtures/foo', __FILE__)
172
- expect(rcfile.empty?).to be true
173
- end
174
- end
175
- end
176
-
177
- describe '#load_file' do
178
- context 'when file exists at path' do
179
- it 'loads data from file' do
180
- rcfile = T::RCFile.instance
181
- rcfile.path = fixture_path + '/.trc'
182
- expect(rcfile.load_file['profiles']['testcli']['abc123']['username']).to eq 'testcli'
183
- end
184
- end
185
- context 'when file does not exist at path' do
186
- it 'loads default structure' do
187
- rcfile = T::RCFile.instance
188
- rcfile.path = File.expand_path('../fixtures/foo', __FILE__)
189
- expect(rcfile.load_file.keys.sort).to eq %w[configuration profiles]
190
- end
191
- end
192
- end
193
-
194
- describe '#path' do
195
- it 'defaults to ~/.trc' do
196
- expect(T::RCFile.instance.path).to eq File.join(File.expand_path('~'), '.trc')
197
- end
198
- end
199
-
200
- describe '#path=' do
201
- it 'overrides path' do
202
- rcfile = T::RCFile.instance
203
- rcfile.path = project_path + '/tmp/trc'
204
- expect(rcfile.path).to eq project_path + '/tmp/trc'
205
- end
206
- it 'reloads data' do
207
- rcfile = T::RCFile.instance
208
- rcfile.path = fixture_path + '/.trc'
209
- expect(rcfile['testcli']['abc123']['username']).to eq 'testcli'
210
- end
211
- end
212
-
213
- describe '#profiles' do
214
- it 'returns profiles' do
215
- rcfile = T::RCFile.instance
216
- rcfile.path = fixture_path + '/.trc'
217
- expect(rcfile.profiles.keys).to eq %w[testcli]
218
- end
219
- end
220
-
221
- end
@@ -1,944 +0,0 @@
1
- # encoding: utf-8
2
- require 'helper'
3
-
4
- describe T::Search 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
- @search = T::Search.new
14
- @search.options = @search.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 '#all' do
33
- before do
34
- stub_get('/1.1/search/tweets.json').with(:query => {:q => 'twitter', :count => '100', :include_entities => 'false'}).to_return(:body => fixture('search.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
35
- end
36
- it 'requests the correct resource' do
37
- @search.all('twitter')
38
- expect(a_get('/1.1/search/tweets.json').with(:query => {:q => 'twitter', :count => '100', :include_entities => 'false'})).to have_been_made
39
- end
40
- it 'has the correct output' do
41
- @search.all('twitter')
42
- expect($stdout.string).to eq <<-eos
43
-
44
- @amaliasafitri2
45
- RT @heartCOBOYJR: @AlvaroMaldini1 :-) http://t.co/Oxce0Tob3n
46
-
47
- @BPDPipesDrums
48
- Here is a picture of us getting ready to Santa into @CITCBoston! #Boston
49
- http://t.co/INACljvLLC
50
-
51
- @yunistosun6034
52
- RT @sevilayyaziyor: gerçekten @ademyavuza ?Nasıl elin vardı böyle bi twit
53
- atmaya?Yolsuzlukla olmadı terörle mi şantaj yaparız diyosunuz?
54
- http://t.co/YPtNVYhLxl
55
-
56
- @_KAIRYALS
57
- My birthday cake was bomb http://t.co/LquXc7JXj4
58
-
59
- @frozenharryx
60
- RT @LouisTexts: whos tessa? http://t.co/7DJQlmCfuu
61
-
62
- @MIKEFANTASMA
63
- Pues nada, aquí armando mi regalo de navidad solo me falta la cara y ya hago
64
- mi pedido con santa!.. http://t.co/iDC7bE9o4M
65
-
66
- @EleManera
67
- RT @xmyband: La gente che si arrabbia perché Harry non ha fatto gli auguri a
68
- Lou su Twitter. Non vorrei smontarvi, ma esistono i cellulari e i messaggi.
69
-
70
- @BigAlFerguson
71
- “@IrishRace; Merry Christmas to all our friends and followers from all
72
- @IrishRaceRally have a good one! http://t.co/rXFsC2ncFo” @Danloi1
73
-
74
- @goksantezgel
75
- RT @nederlandline: Tayyip bey evladımızı severiz Biz ona dua
76
- ediyoruz.Fitnelere SAKIN HA! Mahmud Efndi (ks) #BedduayaLanetDuayaDavet
77
- http://t.co/h6MUyHxr9x"
78
-
79
- @MaimounaLvb
80
- RT @sissokodiaro: Miss mali pa pour les moche mon ga http://t.co/4WnwzoLgAD
81
-
82
- @MrSilpy
83
- @MrKATANI http://t.co/psk7K8rcND
84
-
85
- @hunterdl19
86
- RT @MadisonBertini: Jakes turnt http://t.co/P60gYZNL8z
87
-
88
- @jayjay42__
89
- RT @SteveStfler: Megan Fox Naked >> http://t.co/hMKlUMydFp
90
-
91
- @Bs1972Bill
92
- RT @erorin691: おはよう♪ http://t.co/v5YIFriCW3
93
-
94
- @naked_gypsy
95
- All my friends are here 😂 http://t.co/w66iG4XXpL
96
-
97
- @whoa_lashton
98
- @Ashton5SOS http://t.co/uhYwoRY0Iz
99
-
100
- @seyfullaharpaci
101
- RT @Dedekorkut11: Utanmadıktan sonra... #CamiayaİftiraYolsuzluğuÖrtmez
102
- http://t.co/sXPn17D2md
103
-
104
- @NNGrilli
105
- esperando la Navidad :D http://t.co/iwBL2Xj3g7
106
-
107
- @omersafak74
108
- RT @1903Rc: Ben Beşiktaşlıyım.. http://t.co/qnEpDJwI3b
109
-
110
- @bryony_thfc
111
- merry christmas you arse X http://t.co/yRiWFgqr7p
112
-
113
- eos
114
- end
115
- context '--csv' do
116
- before do
117
- @search.options = @search.options.merge('csv' => true)
118
- end
119
- it 'outputs in CSV format' do
120
- @search.all('twitter')
121
- expect($stdout.string).to eq <<-eos
122
- ID,Posted at,Screen name,Text
123
- 415600159511158784,2013-12-24 21:49:34 +0000,amaliasafitri2,RT @heartCOBOYJR: @AlvaroMaldini1 :-) http://t.co/Oxce0Tob3n
124
- 415600159490580480,2013-12-24 21:49:34 +0000,BPDPipesDrums,Here is a picture of us getting ready to Santa into @CITCBoston! #Boston http://t.co/INACljvLLC
125
- 415600159486406656,2013-12-24 21:49:34 +0000,yunistosun6034,RT @sevilayyaziyor: gerçekten @ademyavuza ?Nasıl elin vardı böyle bi twit atmaya?Yolsuzlukla olmadı terörle mi şantaj yaparız diyosunuz? http://t.co/YPtNVYhLxl
126
- 415600159486005248,2013-12-24 21:49:34 +0000,_KAIRYALS,My birthday cake was bomb http://t.co/LquXc7JXj4
127
- 415600159456632832,2013-12-24 21:49:34 +0000,frozenharryx,RT @LouisTexts: whos tessa? http://t.co/7DJQlmCfuu
128
- 415600159452438528,2013-12-24 21:49:34 +0000,MIKEFANTASMA,"Pues nada, aquí armando mi regalo de navidad solo me falta la cara y ya hago mi pedido con santa!.. http://t.co/iDC7bE9o4M"
129
- 415600159444439040,2013-12-24 21:49:34 +0000,EleManera,"RT @xmyband: La gente che si arrabbia perché Harry non ha fatto gli auguri a Lou su Twitter.
130
- Non vorrei smontarvi, ma esistono i cellulari e i messaggi."
131
- 415600159444434944,2013-12-24 21:49:34 +0000,BigAlFerguson,“@IrishRace; Merry Christmas to all our friends and followers from all @IrishRaceRally have a good one! http://t.co/rXFsC2ncFo” @Danloi1
132
- 415600159436066816,2013-12-24 21:49:34 +0000,goksantezgel,"RT @nederlandline: Tayyip bey evladımızı severiz Biz ona dua ediyoruz.Fitnelere SAKIN HA!
133
- Mahmud Efndi (ks)
134
- #BedduayaLanetDuayaDavet
135
- http://t.co/h6MUyHxr9x"""
136
- 415600159427670016,2013-12-24 21:49:34 +0000,MaimounaLvb,RT @sissokodiaro: Miss mali pa pour les moche mon ga http://t.co/4WnwzoLgAD
137
- 415600159423483904,2013-12-24 21:49:34 +0000,MrSilpy,@MrKATANI http://t.co/psk7K8rcND
138
- 415600159423094784,2013-12-24 21:49:34 +0000,hunterdl19,RT @MadisonBertini: Jakes turnt http://t.co/P60gYZNL8z
139
- 415600159419277312,2013-12-24 21:49:34 +0000,jayjay42__,RT @SteveStfler: Megan Fox Naked >> http://t.co/hMKlUMydFp
140
- 415600159415103488,2013-12-24 21:49:34 +0000,Bs1972Bill,RT @erorin691: おはよう♪ http://t.co/v5YIFriCW3
141
- 415600159415091200,2013-12-24 21:49:34 +0000,naked_gypsy,All my friends are here 😂 http://t.co/w66iG4XXpL
142
- 415600159398313984,2013-12-24 21:49:34 +0000,whoa_lashton,@Ashton5SOS http://t.co/uhYwoRY0Iz
143
- 415600159389937664,2013-12-24 21:49:34 +0000,seyfullaharpaci,RT @Dedekorkut11: Utanmadıktan sonra... #CamiayaİftiraYolsuzluğuÖrtmez http://t.co/sXPn17D2md
144
- 415600159389519872,2013-12-24 21:49:34 +0000,NNGrilli,esperando la Navidad :D http://t.co/iwBL2Xj3g7
145
- 415600159373144064,2013-12-24 21:49:34 +0000,omersafak74,RT @1903Rc: Ben Beşiktaşlıyım.. http://t.co/qnEpDJwI3b
146
- 415600159372767232,2013-12-24 21:49:34 +0000,bryony_thfc,merry christmas you arse X http://t.co/yRiWFgqr7p
147
- eos
148
- end
149
- end
150
- context '--long' do
151
- before do
152
- @search.options = @search.options.merge('long' => true)
153
- end
154
- it 'outputs in long format' do
155
- @search.all('twitter')
156
- expect($stdout.string).to eq <<-eos
157
- ID Posted at Screen name Text
158
- 415600159511158784 Dec 24 13:49 @amaliasafitri2 RT @heartCOBOYJR: @Alvaro...
159
- 415600159490580480 Dec 24 13:49 @BPDPipesDrums Here is a picture of us g...
160
- 415600159486406656 Dec 24 13:49 @yunistosun6034 RT @sevilayyaziyor: gerçe...
161
- 415600159486005248 Dec 24 13:49 @_KAIRYALS My birthday cake was bomb...
162
- 415600159456632832 Dec 24 13:49 @frozenharryx RT @LouisTexts: whos tess...
163
- 415600159452438528 Dec 24 13:49 @MIKEFANTASMA Pues nada, aquí armando m...
164
- 415600159444439040 Dec 24 13:49 @EleManera RT @xmyband: La gente che...
165
- 415600159444434944 Dec 24 13:49 @BigAlFerguson “@IrishRace; Merry Christ...
166
- 415600159436066816 Dec 24 13:49 @goksantezgel RT @nederlandline: Tayyip...
167
- 415600159427670016 Dec 24 13:49 @MaimounaLvb RT @sissokodiaro: Miss ma...
168
- 415600159423483904 Dec 24 13:49 @MrSilpy @MrKATANI http://t.co/psk...
169
- 415600159423094784 Dec 24 13:49 @hunterdl19 RT @MadisonBertini: Jakes...
170
- 415600159419277312 Dec 24 13:49 @jayjay42__ RT @SteveStfler: Megan Fo...
171
- 415600159415103488 Dec 24 13:49 @Bs1972Bill RT @erorin691: おはよう♪ http...
172
- 415600159415091200 Dec 24 13:49 @naked_gypsy All my friends are here 😂...
173
- 415600159398313984 Dec 24 13:49 @whoa_lashton @Ashton5SOS http://t.co/u...
174
- 415600159389937664 Dec 24 13:49 @seyfullaharpaci RT @Dedekorkut11: Utanmad...
175
- 415600159389519872 Dec 24 13:49 @NNGrilli esperando la Navidad :D h...
176
- 415600159373144064 Dec 24 13:49 @omersafak74 RT @1903Rc: Ben Beşiktaşl...
177
- 415600159372767232 Dec 24 13:49 @bryony_thfc merry christmas you arse ...
178
- eos
179
- end
180
- end
181
- context '--number' do
182
- before do
183
- stub_get('/1.1/search/tweets.json').with(:query => {:q => 'twitter', :count => '1', :include_entities => 'false'}).to_return(:body => fixture('search2.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
184
- stub_get('/1.1/search/tweets.json').with(:query => {:q => 'twitter', :count => '100', :include_entities => 'false'}).to_return(:body => fixture('search.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
185
- stub_get('/1.1/search/tweets.json').with(:query => {:q => 'twitter', :count => '100', :include_entities => '1', :max_id => '415600158693675007'}).to_return(:body => fixture('search2.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
186
- end
187
- it 'limits the number of results to 1' do
188
- @search.options = @search.options.merge('number' => 1)
189
- @search.all('twitter')
190
- expect(a_get('/1.1/search/tweets.json').with(:query => {:q => 'twitter', :count => '100', :include_entities => 'false'})).to have_been_made
191
- end
192
- it 'limits the number of results to 201' do
193
- @search.options = @search.options.merge('number' => 201)
194
- @search.all('twitter')
195
- expect(a_get('/1.1/search/tweets.json').with(:query => {:q => 'twitter', :count => '100', :include_entities => 'false'})).to have_been_made
196
- expect(a_get('/1.1/search/tweets.json').with(:query => {:q => 'twitter', :count => '100', :include_entities => '1', :max_id => '415600158693675007'})).to have_been_made
197
- end
198
- end
199
- end
200
-
201
- describe '#favorites' do
202
- before do
203
- stub_get('/1.1/favorites/list.json').with(:query => {:count => '200', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
204
- stub_get('/1.1/favorites/list.json').with(:query => {:count => '200', :max_id => '244099460672679937', :include_entities => 'false'}).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
- @search.favorites('twitter')
208
- expect(a_get('/1.1/favorites/list.json').with(:query => {:count => '200', :include_entities => 'false'})).to have_been_made
209
- expect(a_get('/1.1/favorites/list.json').with(:query => {:count => '200', :max_id => '244099460672679937', :include_entities => 'false'})).to have_been_made
210
- end
211
- it 'has the correct output' do
212
- @search.favorites('twitter')
213
- expect($stdout.string).to eq <<-eos
214
- @sferik
215
- @episod @twitterapi now https://t.co/I17jUTu2 and https://t.co/deDu4Hgw seem
216
- to be missing "1.1" from the URL.
217
-
218
- @sferik
219
- @episod @twitterapi Did you catch https://t.co/VHsQvZT0 as well?
220
-
221
- eos
222
- end
223
- context '--csv' do
224
- before do
225
- @search.options = @search.options.merge('csv' => true)
226
- end
227
- it 'outputs in CSV format' do
228
- @search.favorites('twitter')
229
- expect($stdout.string).to eq <<-eos
230
- ID,Posted at,Screen name,Text
231
- 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."
232
- 244100411563339777,2012-09-07 15:50:47 +0000,sferik,@episod @twitterapi Did you catch https://t.co/VHsQvZT0 as well?
233
- eos
234
- end
235
- end
236
- context '--decode-uris' do
237
- before(:each) do
238
- @search.options = @search.options.merge('decode_uris' => true)
239
- stub_get('/1.1/favorites/list.json').with(:query => {:count => '200', :include_entities => 'true'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
240
- stub_get('/1.1/favorites/list.json').with(:query => {:count => '200', :include_entities => 'true', :max_id => '244099460672679937'}).to_return(:body => fixture('empty_array.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
241
- end
242
- it 'requests the correct resource' do
243
- @search.favorites('twitter')
244
- expect(a_get('/1.1/favorites/list.json').with(:query => {:count => '200', :include_entities => 'true'})).to have_been_made
245
- expect(a_get('/1.1/favorites/list.json').with(:query => {:count => '200', :include_entities => 'true', :max_id => '244099460672679937'})).to have_been_made
246
- end
247
- it 'decodes URLs' do
248
- @search.favorites('twitter')
249
- expect($stdout.string).to include 'https://twitter.com/sferik/status/243988000076337152'
250
- end
251
- end
252
- context '--long' do
253
- before do
254
- @search.options = @search.options.merge('long' => true)
255
- end
256
- it 'outputs in long format' do
257
- @search.favorites('twitter')
258
- expect($stdout.string).to eq <<-eos
259
- ID Posted at Screen name Text
260
- 244102209942458368 Sep 7 07:57 @sferik @episod @twitterapi now https:...
261
- 244100411563339777 Sep 7 07:50 @sferik @episod @twitterapi Did you ca...
262
- eos
263
- end
264
- end
265
- context 'Twitter is down' do
266
- it 'retries 3 times and then raise an error' do
267
- stub_get('/1.1/favorites/list.json').with(:query => {:count => '200', :include_entities => 'false'}).to_return(:status => 502, :headers => {:content_type => 'application/json; charset=utf-8'})
268
- expect do
269
- @search.favorites('twitter')
270
- end.to raise_error(Twitter::Error::BadGateway)
271
- expect(a_get('/1.1/favorites/list.json').with(:query => {:count => '200', :include_entities => 'false'})).to have_been_made.times(3)
272
- end
273
- end
274
- context 'with a user passed' do
275
- before do
276
- stub_get('/1.1/favorites/list.json').with(:query => {:count => '200', :screen_name => 'sferik', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
277
- stub_get('/1.1/favorites/list.json').with(:query => {:count => '200', :max_id => '244099460672679937', :screen_name => 'sferik', :include_entities => 'false'}).to_return(:body => fixture('empty_array.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
278
- end
279
- it 'requests the correct resource' do
280
- @search.favorites('sferik', 'twitter')
281
- expect(a_get('/1.1/favorites/list.json').with(:query => {:count => '200', :screen_name => 'sferik', :include_entities => 'false'})).to have_been_made
282
- expect(a_get('/1.1/favorites/list.json').with(:query => {:count => '200', :max_id => '244099460672679937', :screen_name => 'sferik', :include_entities => 'false'})).to have_been_made
283
- end
284
- it 'has the correct output' do
285
- @search.favorites('sferik', 'twitter')
286
- expect($stdout.string).to eq <<-eos
287
- @sferik
288
- @episod @twitterapi now https://t.co/I17jUTu2 and https://t.co/deDu4Hgw seem
289
- to be missing "1.1" from the URL.
290
-
291
- @sferik
292
- @episod @twitterapi Did you catch https://t.co/VHsQvZT0 as well?
293
-
294
- eos
295
- end
296
- context '--id' do
297
- before do
298
- @search.options = @search.options.merge('id' => true)
299
- stub_get('/1.1/favorites/list.json').with(:query => {:count => '200', :user_id => '7505382', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
300
- stub_get('/1.1/favorites/list.json').with(:query => {:count => '200', :max_id => '244099460672679937', :user_id => '7505382', :include_entities => 'false'}).to_return(:body => fixture('empty_array.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
301
- end
302
- it 'requests the correct resource' do
303
- @search.favorites('7505382', 'twitter')
304
- expect(a_get('/1.1/favorites/list.json').with(:query => {:count => '200', :user_id => '7505382', :include_entities => 'false'})).to have_been_made
305
- expect(a_get('/1.1/favorites/list.json').with(:query => {:count => '200', :max_id => '244099460672679937', :user_id => '7505382', :include_entities => 'false'})).to have_been_made
306
- end
307
- it 'has the correct output' do
308
- @search.favorites('7505382', 'twitter')
309
- expect($stdout.string).to eq <<-eos
310
- @sferik
311
- @episod @twitterapi now https://t.co/I17jUTu2 and https://t.co/deDu4Hgw seem
312
- to be missing "1.1" from the URL.
313
-
314
- @sferik
315
- @episod @twitterapi Did you catch https://t.co/VHsQvZT0 as well?
316
-
317
- eos
318
- end
319
- end
320
- end
321
- end
322
-
323
- describe '#mentions' do
324
- before do
325
- stub_get('/1.1/statuses/mentions_timeline.json').with(:query => {:count => '200', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
326
- stub_get('/1.1/statuses/mentions_timeline.json').with(:query => {:count => '200', :max_id => '244099460672679937', :include_entities => 'false'}).to_return(:body => fixture('empty_array.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
327
- end
328
- it 'requests the correct resource' do
329
- @search.mentions('twitter')
330
- expect(a_get('/1.1/statuses/mentions_timeline.json').with(:query => {:count => '200', :include_entities => 'false'})).to have_been_made
331
- expect(a_get('/1.1/statuses/mentions_timeline.json').with(:query => {:count => '200', :max_id => '244099460672679937', :include_entities => 'false'})).to have_been_made
332
- end
333
- it 'has the correct output' do
334
- @search.mentions('twitter')
335
- expect($stdout.string).to eq <<-eos
336
- @sferik
337
- @episod @twitterapi now https://t.co/I17jUTu2 and https://t.co/deDu4Hgw seem
338
- to be missing "1.1" from the URL.
339
-
340
- @sferik
341
- @episod @twitterapi Did you catch https://t.co/VHsQvZT0 as well?
342
-
343
- eos
344
- end
345
- context '--csv' do
346
- before do
347
- @search.options = @search.options.merge('csv' => true)
348
- end
349
- it 'outputs in CSV format' do
350
- @search.mentions('twitter')
351
- expect($stdout.string).to eq <<-eos
352
- ID,Posted at,Screen name,Text
353
- 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."
354
- 244100411563339777,2012-09-07 15:50:47 +0000,sferik,@episod @twitterapi Did you catch https://t.co/VHsQvZT0 as well?
355
- eos
356
- end
357
- end
358
- context '--decode-uris' do
359
- before(:each) do
360
- @search.options = @search.options.merge('decode_uris' => true)
361
- stub_get('/1.1/statuses/mentions_timeline.json').with(:query => {:count => '200', :include_entities => 'true'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
362
- stub_get('/1.1/statuses/mentions_timeline.json').with(:query => {:count => '200', :include_entities => 'true', :max_id => '244099460672679937'}).to_return(:body => fixture('empty_array.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
363
- end
364
- it 'requests the correct resource' do
365
- @search.mentions('twitter')
366
- expect(a_get('/1.1/statuses/mentions_timeline.json').with(:query => {:count => '200', :include_entities => 'true'})).to have_been_made
367
- expect(a_get('/1.1/statuses/mentions_timeline.json').with(:query => {:count => '200', :include_entities => 'true', :max_id => '244099460672679937'})).to have_been_made
368
- end
369
- it 'decodes URLs' do
370
- @search.mentions('twitter')
371
- expect($stdout.string).to include 'https://twitter.com/sferik/status/243988000076337152'
372
- end
373
- end
374
- context '--long' do
375
- before do
376
- @search.options = @search.options.merge('long' => true)
377
- end
378
- it 'outputs in long format' do
379
- @search.mentions('twitter')
380
- expect($stdout.string).to eq <<-eos
381
- ID Posted at Screen name Text
382
- 244102209942458368 Sep 7 07:57 @sferik @episod @twitterapi now https:...
383
- 244100411563339777 Sep 7 07:50 @sferik @episod @twitterapi Did you ca...
384
- eos
385
- end
386
- end
387
- context 'Twitter is down' do
388
- it 'retries 3 times and then raise an error' do
389
- stub_get('/1.1/statuses/mentions_timeline.json').with(:query => {:count => '200', :include_entities => 'false'}).to_return(:status => 502, :headers => {:content_type => 'application/json; charset=utf-8'})
390
- expect do
391
- @search.mentions('twitter')
392
- end.to raise_error(Twitter::Error::BadGateway)
393
- expect(a_get('/1.1/statuses/mentions_timeline.json').with(:query => {:count => '200', :include_entities => 'false'})).to have_been_made.times(3)
394
- end
395
- end
396
- end
397
-
398
- describe '#list' do
399
- before do
400
- stub_get('/1.1/lists/statuses.json').with(:query => {:count => '200', :owner_screen_name => 'testcli', :slug => 'presidents', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
401
- stub_get('/1.1/lists/statuses.json').with(:query => {:count => '200', :max_id => '244099460672679937', :owner_screen_name => 'testcli', :slug => 'presidents', :include_entities => 'false'}).to_return(:body => fixture('empty_array.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
402
- end
403
- it 'requests the correct resource' do
404
- @search.list('presidents', 'twitter')
405
- expect(a_get('/1.1/lists/statuses.json').with(:query => {:count => '200', :owner_screen_name => 'testcli', :slug => 'presidents', :include_entities => 'false'})).to have_been_made
406
- expect(a_get('/1.1/lists/statuses.json').with(:query => {:count => '200', :max_id => '244099460672679937', :owner_screen_name => 'testcli', :slug => 'presidents', :include_entities => 'false'})).to have_been_made
407
- end
408
- it 'has the correct output' do
409
- @search.list('presidents', 'twitter')
410
- expect($stdout.string).to eq <<-eos
411
- @sferik
412
- @episod @twitterapi now https://t.co/I17jUTu2 and https://t.co/deDu4Hgw seem
413
- to be missing "1.1" from the URL.
414
-
415
- @sferik
416
- @episod @twitterapi Did you catch https://t.co/VHsQvZT0 as well?
417
-
418
- eos
419
- end
420
- context '--csv' do
421
- before do
422
- @search.options = @search.options.merge('csv' => true)
423
- end
424
- it 'outputs in CSV format' do
425
- @search.list('presidents', 'twitter')
426
- expect($stdout.string).to eq <<-eos
427
- ID,Posted at,Screen name,Text
428
- 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."
429
- 244100411563339777,2012-09-07 15:50:47 +0000,sferik,@episod @twitterapi Did you catch https://t.co/VHsQvZT0 as well?
430
- eos
431
- end
432
- end
433
- context '--decode-uris' do
434
- before(:each) do
435
- @search.options = @search.options.merge('decode_uris' => true)
436
- stub_get('/1.1/lists/statuses.json').with(:query => {:count => '200', :owner_screen_name => 'testcli', :slug => 'presidents', :include_entities => 'true'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
437
- stub_get('/1.1/lists/statuses.json').with(:query => {:count => '200', :max_id => '244099460672679937', :owner_screen_name => 'testcli', :slug => 'presidents', :include_entities => 'true'}).to_return(:body => fixture('empty_array.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
438
- end
439
- it 'requests the correct resource' do
440
- @search.list('presidents', 'twitter')
441
- expect(a_get('/1.1/lists/statuses.json').with(:query => {:count => '200', :owner_screen_name => 'testcli', :slug => 'presidents', :include_entities => 'true'})).to have_been_made
442
- expect(a_get('/1.1/lists/statuses.json').with(:query => {:count => '200', :max_id => '244099460672679937', :owner_screen_name => 'testcli', :slug => 'presidents', :include_entities => 'true'})).to have_been_made
443
- end
444
- it 'decodes URLs' do
445
- @search.list('presidents', 'twitter')
446
- expect($stdout.string).to include 'https://dev.twitter.com/docs/api/post/direct_messages/destroy'
447
- end
448
- end
449
- context '--long' do
450
- before do
451
- @search.options = @search.options.merge('long' => true)
452
- end
453
- it 'outputs in long format' do
454
- @search.list('presidents', 'twitter')
455
- expect($stdout.string).to eq <<-eos
456
- ID Posted at Screen name Text
457
- 244102209942458368 Sep 7 07:57 @sferik @episod @twitterapi now https:...
458
- 244100411563339777 Sep 7 07:50 @sferik @episod @twitterapi Did you ca...
459
- eos
460
- end
461
- end
462
- context 'with a user passed' do
463
- it 'requests the correct resource' do
464
- @search.list('testcli/presidents', 'twitter')
465
- expect(a_get('/1.1/lists/statuses.json').with(:query => {:count => '200', :owner_screen_name => 'testcli', :slug => 'presidents', :include_entities => 'false'})).to have_been_made
466
- end
467
- context '--id' do
468
- before do
469
- @search.options = @search.options.merge('id' => true)
470
- stub_get('/1.1/lists/statuses.json').with(:query => {:count => '200', :owner_id => '7505382', :slug => 'presidents', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
471
- stub_get('/1.1/lists/statuses.json').with(:query => {:count => '200', :max_id => '244099460672679937', :owner_id => '7505382', :slug => 'presidents', :include_entities => 'false'}).to_return(:body => fixture('empty_array.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
472
- end
473
- it 'requests the correct resource' do
474
- @search.list('7505382/presidents', 'twitter')
475
- expect(a_get('/1.1/lists/statuses.json').with(:query => {:count => '200', :owner_id => '7505382', :slug => 'presidents', :include_entities => 'false'})).to have_been_made
476
- expect(a_get('/1.1/lists/statuses.json').with(:query => {:count => '200', :max_id => '244099460672679937', :owner_id => '7505382', :slug => 'presidents', :include_entities => 'false'})).to have_been_made
477
- end
478
- end
479
- end
480
- context 'Twitter is down' do
481
- it 'retries 3 times and then raise an error' do
482
- stub_get('/1.1/lists/statuses.json').with(:query => {:count => '200', :owner_screen_name => 'testcli', :slug => 'presidents', :include_entities => 'false'}).to_return(:status => 502, :headers => {:content_type => 'application/json; charset=utf-8'})
483
- expect do
484
- @search.list('presidents', 'twitter')
485
- end.to raise_error(Twitter::Error::BadGateway)
486
- expect(a_get('/1.1/lists/statuses.json').with(:query => {:count => '200', :owner_screen_name => 'testcli', :slug => 'presidents', :include_entities => 'false'})).to have_been_made.times(3)
487
- end
488
- end
489
- end
490
-
491
- describe '#retweets' do
492
- before do
493
- 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'})
494
- 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('empty_array.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
495
- end
496
- it 'requests the correct resource' do
497
- @search.retweets('mosaic')
498
- expect(a_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :include_rts => 'true', :include_entities => 'false'})).to have_been_made
499
- 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(2)
500
- end
501
- it 'has the correct output' do
502
- @search.retweets('mosaic')
503
- expect($stdout.string).to eq <<-eos
504
- @calebelston
505
- RT @olivercameron: Mosaic looks cool: http://t.co/A8013C9k
506
-
507
- eos
508
- end
509
- context '--csv' do
510
- before do
511
- @search.options = @search.options.merge('csv' => true)
512
- end
513
- it 'outputs in CSV format' do
514
- @search.retweets('mosaic')
515
- expect($stdout.string).to eq <<-eos
516
- ID,Posted at,Screen name,Text
517
- 244108728834592770,2012-09-07 16:23:50 +0000,calebelston,RT @olivercameron: Mosaic looks cool: http://t.co/A8013C9k
518
- eos
519
- end
520
- end
521
- context '--decode-uris' do
522
- before(:each) do
523
- @search.options = @search.options.merge('decode_uris' => true)
524
- 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'})
525
- 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('empty_array.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
526
- end
527
- it 'requests the correct resource' do
528
- @search.retweets('mosaic')
529
- expect(a_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :include_rts => 'true', :include_entities => 'true'})).to have_been_made
530
- 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(2)
531
- end
532
- it 'decodes URLs' do
533
- @search.retweets('mosaic')
534
- expect($stdout.string).to include 'http://heymosaic.com/i/1Z8ssK'
535
- end
536
- end
537
- context '--long' do
538
- before do
539
- @search.options = @search.options.merge('long' => true)
540
- end
541
- it 'outputs in long format' do
542
- @search.retweets('mosaic')
543
- expect($stdout.string).to eq <<-eos
544
- ID Posted at Screen name Text
545
- 244108728834592770 Sep 7 08:23 @calebelston RT @olivercameron: Mosaic loo...
546
- eos
547
- end
548
- end
549
- context 'Twitter is down' do
550
- it 'retries 3 times and then raise an error' do
551
- stub_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :include_rts => 'true', :include_entities => 'false'}).to_return(:status => 502, :headers => {:content_type => 'application/json; charset=utf-8'})
552
- expect do
553
- @search.retweets('mosaic')
554
- end.to raise_error(Twitter::Error::BadGateway)
555
- expect(a_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :include_rts => 'true', :include_entities => 'false'})).to have_been_made.times(3)
556
- end
557
- end
558
- context 'with a user passed' do
559
- before do
560
- 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'})
561
- 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('empty_array.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
562
- end
563
- it 'requests the correct resource' do
564
- @search.retweets('sferik', 'mosaic')
565
- 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
566
- 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(2)
567
- end
568
- it 'has the correct output' do
569
- @search.retweets('sferik', 'mosaic')
570
- expect($stdout.string).to eq <<-eos
571
- @calebelston
572
- RT @olivercameron: Mosaic looks cool: http://t.co/A8013C9k
573
-
574
- eos
575
- end
576
- context '--id' do
577
- before do
578
- @search.options = @search.options.merge('id' => true)
579
- 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'})
580
- 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('empty_array.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
581
- end
582
- it 'requests the correct resource' do
583
- @search.retweets('7505382', 'mosaic')
584
- 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
585
- 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(2)
586
- end
587
- it 'has the correct output' do
588
- @search.retweets('7505382', 'mosaic')
589
- expect($stdout.string).to eq <<-eos
590
- @calebelston
591
- RT @olivercameron: Mosaic looks cool: http://t.co/A8013C9k
592
-
593
- eos
594
- end
595
- end
596
- end
597
- end
598
-
599
- describe '#timeline' do
600
- before do
601
- stub_get('/1.1/statuses/home_timeline.json').with(:query => {:count => '200', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
602
- stub_get('/1.1/statuses/home_timeline.json').with(:query => {:count => '200', :max_id => '244099460672679937', :include_entities => 'false'}).to_return(:body => fixture('empty_array.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
603
- end
604
- it 'requests the correct resource' do
605
- @search.timeline('twitter')
606
- expect(a_get('/1.1/statuses/home_timeline.json').with(:query => {:count => '200', :include_entities => 'false'})).to have_been_made
607
- expect(a_get('/1.1/statuses/home_timeline.json').with(:query => {:count => '200', :max_id => '244099460672679937', :include_entities => 'false'})).to have_been_made
608
- end
609
- it 'has the correct output' do
610
- @search.timeline('twitter')
611
- expect($stdout.string).to eq <<-eos
612
- @sferik
613
- @episod @twitterapi now https://t.co/I17jUTu2 and https://t.co/deDu4Hgw seem
614
- to be missing "1.1" from the URL.
615
-
616
- @sferik
617
- @episod @twitterapi Did you catch https://t.co/VHsQvZT0 as well?
618
-
619
- eos
620
- end
621
- context '--csv' do
622
- before do
623
- @search.options = @search.options.merge('csv' => true)
624
- end
625
- it 'outputs in CSV format' do
626
- @search.timeline('twitter')
627
- expect($stdout.string).to eq <<-eos
628
- ID,Posted at,Screen name,Text
629
- 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."
630
- 244100411563339777,2012-09-07 15:50:47 +0000,sferik,@episod @twitterapi Did you catch https://t.co/VHsQvZT0 as well?
631
- eos
632
- end
633
- end
634
- context '--decode-uris' do
635
- before(:each) do
636
- @search.options = @search.options.merge('decode_uris' => true)
637
- stub_get('/1.1/statuses/home_timeline.json').with(:query => {:count => '200', :include_entities => 'true'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
638
- stub_get('/1.1/statuses/home_timeline.json').with(:query => {:count => '200', :max_id => '244099460672679937', :include_entities => 'true'}).to_return(:body => fixture('empty_array.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
639
- end
640
- it 'requests the correct resource' do
641
- @search.timeline('twitter')
642
- expect(a_get('/1.1/statuses/home_timeline.json').with(:query => {:count => '200', :include_entities => 'true'})).to have_been_made
643
- expect(a_get('/1.1/statuses/home_timeline.json').with(:query => {:count => '200', :max_id => '244099460672679937', :include_entities => 'true'})).to have_been_made
644
- end
645
- it 'decodes URLs' do
646
- @search.timeline('twitter')
647
- expect($stdout.string).to include 'https://dev.twitter.com/docs/api/post/direct_messages/destroy'
648
- end
649
- end
650
- context '--exclude=replies' do
651
- before do
652
- @search.options = @search.options.merge('exclude' => 'replies')
653
- stub_get('/1.1/statuses/home_timeline.json').with(:query => {:count => '200', :exclude_replies => 'true', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
654
- stub_get('/1.1/statuses/home_timeline.json').with(:query => {:count => '200', :exclude_replies => 'true', :max_id => '244099460672679937', :include_entities => 'false'}).to_return(:body => fixture('empty_array.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
655
- end
656
- it 'excludes replies' do
657
- @search.timeline
658
- expect(a_get('/1.1/statuses/home_timeline.json').with(:query => {:count => '200', :exclude_replies => 'true', :include_entities => 'false'})).to have_been_made
659
- expect(a_get('/1.1/statuses/home_timeline.json').with(:query => {:count => '200', :exclude_replies => 'true', :max_id => '244099460672679937', :include_entities => 'false'})).to have_been_made
660
- end
661
- end
662
- context '--exclude=retweets' do
663
- before do
664
- @search.options = @search.options.merge('exclude' => 'retweets')
665
- stub_get('/1.1/statuses/home_timeline.json').with(:query => {:count => '200', :include_rts => 'false', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
666
- stub_get('/1.1/statuses/home_timeline.json').with(:query => {:count => '200', :include_rts => 'false', :max_id => '244099460672679937', :include_entities => 'false'}).to_return(:body => fixture('empty_array.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
667
- end
668
- it 'excludes retweets' do
669
- @search.timeline
670
- expect(a_get('/1.1/statuses/home_timeline.json').with(:query => {:count => '200', :include_rts => 'false', :include_entities => 'false'})).to have_been_made
671
- expect(a_get('/1.1/statuses/home_timeline.json').with(:query => {:count => '200', :include_rts => 'false', :max_id => '244099460672679937', :include_entities => 'false'})).to have_been_made
672
- end
673
- end
674
- context '--long' do
675
- before do
676
- @search.options = @search.options.merge('long' => true)
677
- end
678
- it 'outputs in long format' do
679
- @search.timeline('twitter')
680
- expect($stdout.string).to eq <<-eos
681
- ID Posted at Screen name Text
682
- 244102209942458368 Sep 7 07:57 @sferik @episod @twitterapi now https:...
683
- 244100411563339777 Sep 7 07:50 @sferik @episod @twitterapi Did you ca...
684
- eos
685
- end
686
- end
687
- context '--max-id' do
688
- before do
689
- @search.options = @search.options.merge('max_id' => 244_104_558_433_951_744)
690
- stub_get('/1.1/statuses/home_timeline.json').with(:query => {:count => '200', :max_id => '244104558433951744', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
691
- end
692
- it 'requests the correct resource' do
693
- @search.timeline('twitter')
694
- expect(a_get('/1.1/statuses/home_timeline.json').with(:query => {:count => '200', :max_id => '244104558433951744', :include_entities => 'false'})).to have_been_made
695
- end
696
- end
697
- context '--since-id' do
698
- before do
699
- @search.options = @search.options.merge('since_id' => 244_104_558_433_951_744)
700
- stub_get('/1.1/statuses/home_timeline.json').with(:query => {:count => '200', :since_id => '244104558433951744', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
701
- stub_get('/1.1/statuses/home_timeline.json').with(:query => {:count => '200', :max_id => '244099460672679937', :since_id => '244104558433951744', :include_entities => 'false'}).to_return(:body => fixture('empty_array.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
702
- end
703
- it 'requests the correct resource' do
704
- @search.timeline('twitter')
705
- expect(a_get('/1.1/statuses/home_timeline.json').with(:query => {:count => '200', :since_id => '244104558433951744', :include_entities => 'false'})).to have_been_made
706
- expect(a_get('/1.1/statuses/home_timeline.json').with(:query => {:count => '200', :max_id => '244099460672679937', :since_id => '244104558433951744', :include_entities => 'false'})).to have_been_made
707
- end
708
- end
709
- context 'Twitter is down' do
710
- it 'retries 3 times and then raise an error' do
711
- stub_get('/1.1/statuses/home_timeline.json').with(:query => {:count => '200', :include_entities => 'false'}).to_return(:status => 502, :headers => {:content_type => 'application/json; charset=utf-8'})
712
- expect do
713
- @search.timeline('twitter')
714
- end.to raise_error(Twitter::Error::BadGateway)
715
- expect(a_get('/1.1/statuses/home_timeline.json').with(:query => {:count => '200', :include_entities => 'false'})).to have_been_made.times(3)
716
- end
717
- end
718
- context 'with a user passed' do
719
- before do
720
- stub_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :screen_name => 'sferik', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
721
- stub_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :max_id => '244099460672679937', :screen_name => 'sferik', :include_entities => 'false'}).to_return(:body => fixture('empty_array.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
722
- end
723
- it 'requests the correct resource' do
724
- @search.timeline('sferik', 'twitter')
725
- expect(a_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :screen_name => 'sferik', :include_entities => 'false'})).to have_been_made
726
- expect(a_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :max_id => '244099460672679937', :screen_name => 'sferik', :include_entities => 'false'})).to have_been_made
727
- end
728
- it 'has the correct output' do
729
- @search.timeline('sferik', 'twitter')
730
- expect($stdout.string).to eq <<-eos
731
- @sferik
732
- @episod @twitterapi now https://t.co/I17jUTu2 and https://t.co/deDu4Hgw seem
733
- to be missing "1.1" from the URL.
734
-
735
- @sferik
736
- @episod @twitterapi Did you catch https://t.co/VHsQvZT0 as well?
737
-
738
- eos
739
- end
740
- context '--csv' do
741
- before do
742
- @search.options = @search.options.merge('csv' => true)
743
- end
744
- it 'outputs in CSV format' do
745
- @search.timeline('sferik', 'twitter')
746
- expect($stdout.string).to eq <<-eos
747
- ID,Posted at,Screen name,Text
748
- 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."
749
- 244100411563339777,2012-09-07 15:50:47 +0000,sferik,@episod @twitterapi Did you catch https://t.co/VHsQvZT0 as well?
750
- eos
751
- end
752
- end
753
- context '--id' do
754
- before do
755
- @search.options = @search.options.merge('id' => true)
756
- stub_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :user_id => '7505382', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
757
- stub_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :max_id => '244099460672679937', :user_id => '7505382', :include_entities => 'false'}).to_return(:body => fixture('empty_array.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
758
- end
759
- it 'requests the correct resource' do
760
- @search.timeline('7505382', 'twitter')
761
- expect(a_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :user_id => '7505382', :include_entities => 'false'})).to have_been_made
762
- expect(a_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :max_id => '244099460672679937', :user_id => '7505382', :include_entities => 'false'})).to have_been_made
763
- end
764
- end
765
- context '--long' do
766
- before do
767
- @search.options = @search.options.merge('long' => true)
768
- end
769
- it 'outputs in long format' do
770
- @search.timeline('sferik', 'twitter')
771
- expect($stdout.string).to eq <<-eos
772
- ID Posted at Screen name Text
773
- 244102209942458368 Sep 7 07:57 @sferik @episod @twitterapi now https:...
774
- 244100411563339777 Sep 7 07:50 @sferik @episod @twitterapi Did you ca...
775
- eos
776
- end
777
- end
778
- context '--max-id' do
779
- before do
780
- @search.options = @search.options.merge('max_id' => 244_104_558_433_951_744)
781
- stub_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :screen_name => 'sferik', :max_id => '244104558433951744', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
782
- end
783
- it 'requests the correct resource' do
784
- @search.timeline('sferik', 'twitter')
785
- expect(a_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :screen_name => 'sferik', :max_id => '244104558433951744', :include_entities => 'false'})).to have_been_made
786
- end
787
- end
788
- context '--since-id' do
789
- before do
790
- @search.options = @search.options.merge('since_id' => 244_104_558_433_951_744)
791
- stub_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :screen_name => 'sferik', :since_id => '244104558433951744', :include_entities => 'false'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
792
- stub_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :screen_name => 'sferik', :max_id => '244099460672679937', :since_id => '244104558433951744', :include_entities => 'false'}).to_return(:body => fixture('empty_array.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
793
- end
794
- it 'requests the correct resource' do
795
- @search.timeline('sferik', 'twitter')
796
- expect(a_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :screen_name => 'sferik', :since_id => '244104558433951744', :include_entities => 'false'})).to have_been_made
797
- expect(a_get('/1.1/statuses/user_timeline.json').with(:query => {:count => '200', :screen_name => 'sferik', :max_id => '244099460672679937', :since_id => '244104558433951744', :include_entities => 'false'})).to have_been_made
798
- end
799
- end
800
- context 'Twitter is down' do
801
- it 'retries 3 times and then raise an error' do
802
- stub_get('/1.1/statuses/user_timeline.json').with(:query => {:screen_name => 'sferik', :count => '200', :include_entities => 'false'}).to_return(:status => 502, :headers => {:content_type => 'application/json; charset=utf-8'})
803
- expect do
804
- @search.timeline('sferik', 'twitter')
805
- end.to raise_error(Twitter::Error::BadGateway)
806
- expect(a_get('/1.1/statuses/user_timeline.json').with(:query => {:screen_name => 'sferik', :count => '200', :include_entities => 'false'})).to have_been_made.times(3)
807
- end
808
- end
809
- end
810
- end
811
-
812
- describe '#users' do
813
- before do
814
- stub_get('/1.1/users/search.json').with(:query => {:page => '1', :q => 'Erik'}).to_return(:body => fixture('users.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
815
- stub_get('/1.1/users/search.json').with(:query => {:page => '2', :q => 'Erik'}).to_return(:body => fixture('empty_array.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
816
- end
817
- it 'requests the correct resource' do
818
- @search.users('Erik')
819
- expect(a_get('/1.1/users/search.json').with(:query => {:page => '1', :q => 'Erik'})).to have_been_made
820
- expect(a_get('/1.1/users/search.json').with(:query => {:page => '2', :q => 'Erik'})).to have_been_made
821
- end
822
- it 'has the correct output' do
823
- @search.users('Erik')
824
- expect($stdout.string.chomp).to eq 'pengwynn sferik'
825
- end
826
- context '--csv' do
827
- before do
828
- @search.options = @search.options.merge('csv' => true)
829
- end
830
- it 'outputs in CSV format' do
831
- @search.users('Erik')
832
- expect($stdout.string).to eq <<-eos
833
- ID,Since,Last tweeted at,Tweets,Favorites,Listed,Following,Followers,Screen name,Name,Verified,Protected,Bio,Status,Location,URL
834
- 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
835
- 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
836
- eos
837
- end
838
- end
839
- context '--long' do
840
- before do
841
- @search.options = @search.options.merge('long' => true)
842
- end
843
- it 'outputs in long format' do
844
- @search.users('Erik')
845
- expect($stdout.string).to eq <<-eos
846
- ID Since Last tweeted at Tweets Favorites Listed Following...
847
- 14100886 Mar 8 2008 Jul 7 12:33 6940 192 358 3427...
848
- 7505382 Jul 16 2007 Jul 8 10:29 7890 3755 118 212...
849
- eos
850
- end
851
- end
852
- context '--reverse' do
853
- before do
854
- @search.options = @search.options.merge('reverse' => true)
855
- end
856
- it 'reverses the order of the sort' do
857
- @search.users('Erik')
858
- expect($stdout.string.chomp).to eq 'sferik pengwynn'
859
- end
860
- end
861
- context '--sort=favorites' do
862
- before do
863
- @search.options = @search.options.merge('sort' => 'favorites')
864
- end
865
- it 'sorts by the number of favorites' do
866
- @search.users('Erik')
867
- expect($stdout.string.chomp).to eq 'pengwynn sferik'
868
- end
869
- end
870
- context '--sort=followers' do
871
- before do
872
- @search.options = @search.options.merge('sort' => 'followers')
873
- end
874
- it 'sorts by the number of followers' do
875
- @search.users('Erik')
876
- expect($stdout.string.chomp).to eq 'sferik pengwynn'
877
- end
878
- end
879
- context '--sort=friends' do
880
- before do
881
- @search.options = @search.options.merge('sort' => 'friends')
882
- end
883
- it 'sorts by the number of friends' do
884
- @search.users('Erik')
885
- expect($stdout.string.chomp).to eq 'sferik pengwynn'
886
- end
887
- end
888
- context '--sort=listed' do
889
- before do
890
- @search.options = @search.options.merge('sort' => 'listed')
891
- end
892
- it 'sorts by the number of list memberships' do
893
- @search.users('Erik')
894
- expect($stdout.string.chomp).to eq 'sferik pengwynn'
895
- end
896
- end
897
- context '--sort=since' do
898
- before do
899
- @search.options = @search.options.merge('sort' => 'since')
900
- end
901
- it 'sorts by the time when Twitter account was created' do
902
- @search.users('Erik')
903
- expect($stdout.string.chomp).to eq 'sferik pengwynn'
904
- end
905
- end
906
- context '--sort=tweets' do
907
- before do
908
- @search.options = @search.options.merge('sort' => 'tweets')
909
- end
910
- it 'sorts by the number of Tweets' do
911
- @search.users('Erik')
912
- expect($stdout.string.chomp).to eq 'pengwynn sferik'
913
- end
914
- end
915
- context '--sort=tweeted' do
916
- before do
917
- @search.options = @search.options.merge('sort' => 'tweeted')
918
- end
919
- it 'sorts by the time of the last Tweet' do
920
- @search.users('Erik')
921
- expect($stdout.string.chomp).to eq 'pengwynn sferik'
922
- end
923
- end
924
- context '--unsorted' do
925
- before do
926
- @search.options = @search.options.merge('unsorted' => true)
927
- end
928
- it 'is not sorted' do
929
- @search.users('Erik')
930
- expect($stdout.string.chomp).to eq 'pengwynn sferik'
931
- end
932
- end
933
- context 'Twitter is down' do
934
- it 'retries 3 times and then raise an error' do
935
- stub_get('/1.1/users/search.json').with(:query => {:page => '2', :q => 'Erik'}).to_return(:status => 502, :headers => {:content_type => 'application/json; charset=utf-8'})
936
- expect do
937
- @search.users('Erik')
938
- end.to raise_error(Twitter::Error::BadGateway)
939
- expect(a_get('/1.1/users/search.json').with(:query => {:page => '2', :q => 'Erik'})).to have_been_made.times(3)
940
- end
941
- end
942
- end
943
-
944
- end