t 2.3.0 → 2.4.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.
data/spec/delete_spec.rb CHANGED
@@ -3,7 +3,7 @@ require 'helper'
3
3
 
4
4
  describe T::Delete do
5
5
 
6
- before :each do
6
+ before do
7
7
  T::RCFile.instance.path = fixture_path + '/.trc'
8
8
  @delete = T::Delete.new
9
9
  @old_stderr = $stderr
@@ -12,7 +12,7 @@ describe T::Delete do
12
12
  $stdout = StringIO.new
13
13
  end
14
14
 
15
- after :each do
15
+ after do
16
16
  T::RCFile.instance.reset
17
17
  $stderr = @old_stderr
18
18
  $stdout = @old_stdout
data/spec/helper.rb CHANGED
@@ -10,7 +10,7 @@ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
10
10
 
11
11
  SimpleCov.start do
12
12
  add_filter '/spec/'
13
- minimum_coverage(99.21)
13
+ minimum_coverage(99.24)
14
14
  end
15
15
 
16
16
  require 't'
data/spec/list_spec.rb CHANGED
@@ -8,12 +8,7 @@ describe T::List do
8
8
  T.utc_offset = 'PST'
9
9
  end
10
10
 
11
- after :all do
12
- T.utc_offset = nil
13
- Timecop.return
14
- end
15
-
16
- before :each do
11
+ before do
17
12
  T::RCFile.instance.path = fixture_path + '/.trc'
18
13
  @list = T::List.new
19
14
  @old_stderr = $stderr
@@ -22,12 +17,17 @@ describe T::List do
22
17
  $stdout = StringIO.new
23
18
  end
24
19
 
25
- after :each do
20
+ after do
26
21
  T::RCFile.instance.reset
27
22
  $stderr = @old_stderr
28
23
  $stdout = @old_stdout
29
24
  end
30
25
 
26
+ after :all do
27
+ T.utc_offset = nil
28
+ Timecop.return
29
+ end
30
+
31
31
  describe '#add' do
32
32
  before do
33
33
  @list.options = @list.options.merge('profile' => fixture_path + '/.trc')
data/spec/rcfile_spec.rb CHANGED
@@ -3,7 +3,7 @@ require 'helper'
3
3
 
4
4
  describe T::RCFile do
5
5
 
6
- after :each do
6
+ after do
7
7
  T::RCFile.instance.reset
8
8
  File.delete(project_path + '/tmp/trc') if File.exist?(project_path + '/tmp/trc')
9
9
  end
data/spec/search_spec.rb CHANGED
@@ -8,12 +8,7 @@ describe T::Search do
8
8
  T.utc_offset = 'PST'
9
9
  end
10
10
 
11
- after :all do
12
- T.utc_offset = nil
13
- Timecop.return
14
- end
15
-
16
- before :each do
11
+ before do
17
12
  T::RCFile.instance.path = fixture_path + '/.trc'
18
13
  @search = T::Search.new
19
14
  @search.options = @search.options.merge('color' => 'always')
@@ -23,12 +18,17 @@ describe T::Search do
23
18
  $stdout = StringIO.new
24
19
  end
25
20
 
26
- after :each do
21
+ after do
27
22
  T::RCFile.instance.reset
28
23
  $stderr = @old_stderr
29
24
  $stdout = @old_stdout
30
25
  end
31
26
 
27
+ after :all do
28
+ T.utc_offset = nil
29
+ Timecop.return
30
+ end
31
+
32
32
  describe '#all' do
33
33
  before do
34
34
  stub_get('/1.1/search/tweets.json').with(:query => {:q => 'twitter', :count => '100', :include_entities => 'false'}).to_return(:body => fixture('search.json'))
data/spec/set_spec.rb CHANGED
@@ -3,7 +3,7 @@ require 'helper'
3
3
 
4
4
  describe T::Set do
5
5
 
6
- before :each do
6
+ before do
7
7
  T::RCFile.instance.path = fixture_path + '/.trc'
8
8
  @set = T::Set.new
9
9
  @old_stderr = $stderr
@@ -12,7 +12,7 @@ describe T::Set do
12
12
  $stdout = StringIO.new
13
13
  end
14
14
 
15
- after :each do
15
+ after do
16
16
  T::RCFile.instance.reset
17
17
  $stderr = @old_stderr
18
18
  $stdout = @old_stdout
data/spec/stream_spec.rb CHANGED
@@ -12,270 +12,265 @@ describe T::Stream do
12
12
  @status = status_from_fixture('status.json')
13
13
  end
14
14
 
15
- before :each do
15
+ before do
16
16
  T::RCFile.instance.path = fixture_path + '/.trc'
17
- @client = double('Twitter::Streaming::Client').as_null_object
17
+ @streaming_client = double('Twitter::Streaming::Client').as_null_object
18
18
  @stream = T::Stream.new
19
- allow(@stream).to receive(:client) { @client }
19
+ allow(@stream).to receive(:streaming_client) { @streaming_client }
20
20
  allow(@stream).to receive(:say).and_return
21
21
  allow(STDOUT).to receive(:tty?).and_return(true)
22
22
  end
23
23
 
24
24
  describe '#all' do
25
+ before do
26
+ allow(@streaming_client).to receive(:sample).and_yield(@status)
27
+ end
28
+ it 'prints the tweet status' do
29
+ expect(@stream).to receive(:print_message)
30
+ @stream.all
31
+ end
25
32
  context '--csv' do
26
- before :each do
33
+ before do
27
34
  @stream.options = @stream.options.merge('csv' => true)
28
35
  end
29
36
  it 'outputs headings when the stream initializes' do
30
- allow(@client).to receive(:sample).and_return
31
- allow(@client).to receive(:before_request).and_yield
37
+ allow(@streaming_client).to receive(:before_request).and_yield
38
+ allow(@streaming_client).to receive(:sample).and_return
32
39
  expect(@stream).to receive(:say).with("ID,Posted at,Screen name,Text\n")
33
40
  @stream.all
34
41
  end
35
42
  it 'outputs in CSV format' do
36
- allow(@client).to receive(:before_request).and_return
37
- allow(@client).to receive(:sample).
38
- and_yield(@status)
43
+ allow(@streaming_client).to receive(:before_request).and_return
44
+ allow(@streaming_client).to receive(:sample).and_yield(@status)
39
45
  expect(@stream).to receive(:print_csv_tweet).with(any_args)
40
46
  @stream.all
41
47
  end
42
48
  end
43
-
44
49
  context '--long' do
45
- before :each do
50
+ before do
46
51
  @stream.options = @stream.options.merge('long' => true)
47
52
  end
48
-
49
53
  it 'outputs headings when the stream initializes' do
50
- allow(@client).to receive(:before_request).and_yield
51
- allow(@client).to receive(:sample).and_return
54
+ allow(@streaming_client).to receive(:before_request).and_yield
55
+ allow(@streaming_client).to receive(:sample).and_return
52
56
  expect(@stream).to receive(:print_table).with(any_args)
53
57
  @stream.all
54
58
  end
55
-
56
59
  it 'outputs in long text format' do
57
- allow(@client).to receive(:before_request).and_return
58
- allow(@client).to receive(:sample).
59
- and_yield(@status)
60
+ allow(@streaming_client).to receive(:before_request).and_return
61
+ allow(@streaming_client).to receive(:sample).and_yield(@status)
60
62
  expect(@stream).to receive(:print_table).with(any_args)
61
63
  @stream.all
62
64
  end
63
65
  end
66
+ it 'invokes Twitter::Streaming::Client#sample' do
67
+ allow(@streaming_client).to receive(:before_request).and_return
68
+ allow(@streaming_client).to receive(:sample).and_return
69
+ expect(@streaming_client).to receive(:sample)
70
+ @stream.all
71
+ end
72
+ end
64
73
 
65
- context 'normal usage' do
66
- before :each do
67
- allow(@client).to receive(:sample).
68
- and_yield(@status)
74
+ describe '#list' do
75
+ before do
76
+ stub_get('/1.1/lists/members.json').with(:query => {:cursor => '-1', :owner_screen_name => 'testcli', :slug => 'presidents'}).to_return(:body => fixture('users_list.json'))
77
+ end
78
+ it 'prints the tweet status' do
79
+ expect(@stream).to receive(:print_message)
80
+ allow(@streaming_client).to receive(:filter).and_yield(@status)
81
+ @stream.list('presidents')
82
+ end
83
+ it 'requests the correct resource' do
84
+ @stream.list('presidents')
85
+ expect(a_get('/1.1/lists/members.json').with(:query => {:cursor => '-1', :owner_screen_name => 'testcli', :slug => 'presidents'})).to have_been_made
86
+ end
87
+ context '--csv' do
88
+ before do
89
+ @stream.options = @stream.options.merge('csv' => true)
69
90
  end
70
-
71
- it 'prints the tweet status' do
72
- expect(@stream).to receive(:print_message)
73
- @stream.all
91
+ it 'outputs in CSV format' do
92
+ allow(@streaming_client).to receive(:before_request).and_return
93
+ allow(@streaming_client).to receive(:filter).and_yield(@status)
94
+ expect(@stream).to receive(:print_csv_tweet).with(any_args)
95
+ @stream.list('presidents')
96
+ end
97
+ it 'requests the correct resource' do
98
+ @stream.list('presidents')
99
+ expect(a_get('/1.1/lists/members.json').with(:query => {:cursor => '-1', :owner_screen_name => 'testcli', :slug => 'presidents'})).to have_been_made
74
100
  end
75
101
  end
76
-
77
- it 'invokes Twitter::Streaming::Client#sample' do
78
- expect(@client).to receive(:sample)
79
- @stream.all
102
+ context '--long' do
103
+ before do
104
+ @stream.options = @stream.options.merge('long' => true)
105
+ end
106
+ it 'outputs in long text format' do
107
+ allow(@streaming_client).to receive(:before_request).and_return
108
+ allow(@streaming_client).to receive(:filter).and_yield(@status)
109
+ expect(@stream).to receive(:print_table).with(any_args)
110
+ @stream.list('presidents')
111
+ end
112
+ it 'requests the correct resource' do
113
+ @stream.list('presidents')
114
+ expect(a_get('/1.1/lists/members.json').with(:query => {:cursor => '-1', :owner_screen_name => 'testcli', :slug => 'presidents'})).to have_been_made
115
+ end
116
+ end
117
+ it 'performs a REST search when the stream initializes' do
118
+ allow(@streaming_client).to receive(:before_request).and_yield
119
+ allow(@streaming_client).to receive(:filter).and_return
120
+ allow(T::List).to receive(:new).and_return(t_class)
121
+ expect(t_class).to receive(:timeline).and_return
122
+ @stream.list('presidents')
123
+ end
124
+ it 'invokes Twitter::Streaming::Client#userstream' do
125
+ allow(@streaming_client).to receive(:filter).and_return
126
+ expect(@streaming_client).to receive(:filter)
127
+ @stream.list('presidents')
80
128
  end
81
129
  end
82
130
 
83
131
  describe '#matrix' do
84
- before :each do
85
- allow(@client).to receive(:sample).
86
- and_yield(@status)
132
+ before do
133
+ allow(@streaming_client).to receive(:sample).and_yield(@status)
87
134
  end
88
-
89
135
  it 'outputs the tweet status' do
90
136
  expect(@stream).to receive(:say).with(any_args)
91
137
  @stream.matrix
92
138
  end
93
-
94
139
  it 'invokes Twitter::Streaming::Client.sample' do
95
- expect(@client).to receive(:sample)
140
+ expect(@streaming_client).to receive(:sample)
96
141
  @stream.matrix
97
142
  end
98
143
  end
99
144
 
100
145
  describe '#search' do
101
- before :each do
102
- allow(@client).to receive(:filter).with(:track => 'twitter,gem').
103
- and_yield(@status)
146
+ before do
147
+ allow(@streaming_client).to receive(:filter).with(:track => 'twitter,gem').and_yield(@status)
148
+ end
149
+ it 'prints the tweet status' do
150
+ expect(@stream).to receive(:print_message)
151
+ @stream.search(%w[twitter gem])
104
152
  end
105
-
106
153
  context '--csv' do
107
- before :each do
154
+ before do
108
155
  @stream.options = @stream.options.merge('csv' => true)
109
156
  end
110
-
111
157
  it 'outputs in CSV format' do
112
- allow(@client).to receive(:before_request).and_return
158
+ allow(@streaming_client).to receive(:before_request).and_return
113
159
  expect(@stream).to receive(:print_csv_tweet).with(any_args)
114
160
  @stream.search(%w[twitter gem])
115
161
  end
116
162
  end
117
-
118
163
  context '--long' do
119
- before :each do
164
+ before do
120
165
  @stream.options = @stream.options.merge('long' => true)
121
166
  end
122
-
123
167
  it 'outputs in long text format' do
124
- allow(@client).to receive(:before_request).and_return
125
- allow(@client).to receive(:filter).with(:track => 'twitter,gem').
126
- and_yield(@status)
168
+ allow(@streaming_client).to receive(:before_request).and_return
169
+ allow(@streaming_client).to receive(:filter).with(:track => 'twitter,gem').and_yield(@status)
127
170
  expect(@stream).to receive(:print_table).with(any_args)
128
171
  @stream.search(%w[twitter gem])
129
172
  end
130
173
  end
131
-
132
- context 'normal usage' do
133
- before :each do
134
- allow(@client).to receive(:filter).with(:track => 'twitter,gem').
135
- and_yield(@status)
136
- end
137
- it 'prints the tweet status' do
138
- expect(@stream).to receive(:print_message)
139
- @stream.search(%w[twitter gem])
140
- end
141
- end
142
-
143
174
  it 'performs a REST search when the stream initializes' do
144
- allow(@client).to receive(:filter).and_return
145
- allow(@client).to receive(:before_request).and_yield
175
+ allow(@streaming_client).to receive(:before_request).and_yield
176
+ allow(@streaming_client).to receive(:filter).and_return
146
177
  allow(T::Search).to receive(:new).and_return(t_class)
147
178
  expect(t_class).to receive(:all).with('t OR gem').and_return
148
179
  @stream.search('t', 'gem')
149
180
  end
150
-
151
181
  it 'invokes Twitter::Streaming::Client#filter' do
152
- allow(@client).to receive(:filter).and_return
153
- expect(@client).to receive(:filter).with(:track => 'twitter,gem')
182
+ allow(@streaming_client).to receive(:filter).and_return
183
+ expect(@streaming_client).to receive(:filter).with(:track => 'twitter,gem')
154
184
  @stream.search(%w[twitter gem])
155
185
  end
156
186
  end
157
187
 
158
188
  describe '#timeline' do
159
- before :each do
160
- allow(@client).to receive(:user).
161
- and_yield(@status)
189
+ before do
190
+ allow(@streaming_client).to receive(:user).and_yield(@status)
191
+ end
192
+ it 'prints the tweet status' do
193
+ expect(@stream).to receive(:print_message)
194
+ @stream.timeline
162
195
  end
163
-
164
196
  context '--csv' do
165
- before :each do
197
+ before do
166
198
  @stream.options = @stream.options.merge('csv' => true)
167
199
  end
168
-
169
200
  it 'outputs in CSV format' do
170
- allow(@client).to receive(:before_request).and_return
201
+ allow(@streaming_client).to receive(:before_request).and_return
171
202
  expect(@stream).to receive(:print_csv_tweet).with(any_args)
172
203
  @stream.timeline
173
204
  end
174
205
  end
175
-
176
206
  context '--long' do
177
- before :each do
207
+ before do
178
208
  @stream.options = @stream.options.merge('long' => true)
179
209
  end
180
-
181
210
  it 'outputs in long text format' do
182
- allow(@client).to receive(:before_request).and_return
183
- allow(@client).to receive(:user).
184
- and_yield(@status)
211
+ allow(@streaming_client).to receive(:before_request).and_return
185
212
  expect(@stream).to receive(:print_table).with(any_args)
186
213
  @stream.timeline
187
214
  end
188
215
  end
189
-
190
- context 'normal usage' do
191
- before :each do
192
- allow(@client).to receive(:user).
193
- and_yield(@status)
194
- end
195
-
196
- it 'prints the tweet status' do
197
- expect(@stream).to receive(:print_message)
198
- @stream.timeline
199
- end
200
- end
201
-
202
216
  it 'performs a REST search when the stream initializes' do
203
- allow(@client).to receive(:user).and_return
204
- allow(@client).to receive(:before_request).and_yield
217
+ allow(@streaming_client).to receive(:before_request).and_yield
218
+ allow(@streaming_client).to receive(:user).and_return
205
219
  allow(T::CLI).to receive(:new).and_return(t_class)
206
220
  expect(t_class).to receive(:timeline).and_return
207
-
208
221
  @stream.timeline
209
222
  end
210
-
211
223
  it 'invokes Twitter::Streaming::Client#userstream' do
212
- allow(@client).to receive(:user).and_return
213
- expect(@client).to receive(:user)
224
+ allow(@streaming_client).to receive(:user).and_return
225
+ expect(@streaming_client).to receive(:user)
214
226
  @stream.timeline
215
227
  end
216
228
  end
217
229
 
218
230
  describe '#users' do
219
- before :each do
220
- allow(@client).to receive(:filter).
221
- and_yield(@status)
231
+ before do
232
+ allow(@streaming_client).to receive(:filter).and_yield(@status)
233
+ end
234
+ it 'prints the tweet status' do
235
+ expect(@stream).to receive(:print_message)
236
+ @stream.users('123')
222
237
  end
223
-
224
238
  context '--csv' do
225
- before :each do
239
+ before do
226
240
  @stream.options = @stream.options.merge('csv' => true)
227
241
  end
228
-
229
242
  it 'outputs headings when the stream initializes' do
230
- allow(@client).to receive(:filter).and_return
231
- allow(@client).to receive(:before_request).and_yield
243
+ allow(@streaming_client).to receive(:before_request).and_yield
244
+ allow(@streaming_client).to receive(:filter).and_return
232
245
  expect(@stream).to receive(:say).with("ID,Posted at,Screen name,Text\n")
233
246
  @stream.users('123')
234
247
  end
235
-
236
248
  it 'outputs in CSV format' do
237
- allow(@client).to receive(:before_request).and_return
249
+ allow(@streaming_client).to receive(:before_request).and_return
238
250
  expect(@stream).to receive(:print_csv_tweet).with(any_args)
239
251
  @stream.users('123')
240
252
  end
241
253
  end
242
-
243
254
  context '--long' do
244
- before :each do
255
+ before do
245
256
  @stream.options = @stream.options.merge('long' => true)
246
257
  end
247
-
248
258
  it 'outputs headings when the stream initializes' do
249
- allow(@client).to receive(:before_request).and_yield
250
- allow(@client).to receive(:filter).and_return
259
+ allow(@streaming_client).to receive(:before_request).and_yield
260
+ allow(@streaming_client).to receive(:filter).and_return
251
261
  expect(@stream).to receive(:print_table).with(any_args)
252
262
  @stream.users('123')
253
263
  end
254
-
255
264
  it 'outputs in long text format' do
256
- allow(@client).to receive(:before_request).and_return
257
- allow(@client).to receive(:filter).
258
- and_yield(@status)
265
+ allow(@streaming_client).to receive(:before_request).and_return
266
+ allow(@streaming_client).to receive(:filter).and_yield(@status)
259
267
  expect(@stream).to receive(:print_table).with(any_args)
260
268
  @stream.users('123')
261
269
  end
262
270
  end
263
-
264
- context 'normal usage' do
265
- before :each do
266
- allow(@client).to receive(:filter).
267
- and_yield(@status)
268
- end
269
-
270
- it 'prints the tweet status' do
271
- expect(@stream).to receive(:print_message)
272
- @stream.users('123')
273
- end
274
- end
275
-
276
271
  it 'invokes Twitter::Streaming::Client#follow' do
277
- allow(@client).to receive(:filter).and_return
278
- expect(@client).to receive(:filter).with(:follow => '123,456,789')
272
+ allow(@streaming_client).to receive(:filter).and_return
273
+ expect(@streaming_client).to receive(:filter).with(:follow => '123,456,789')
279
274
  @stream.users('123', '456', '789')
280
275
  end
281
276
  end