t 1.1.1 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/spec/set_spec.rb CHANGED
@@ -49,13 +49,13 @@ describe T::Set do
49
49
  describe "#bio" do
50
50
  before do
51
51
  @set.options = @set.options.merge("profile" => fixture_path + "/.trc")
52
- stub_post("/1/account/update_profile.json").
52
+ stub_post("/1.1/account/update_profile.json").
53
53
  with(:body => {:description => "Vagabond."}).
54
54
  to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
55
55
  end
56
56
  it "should request the correct resource" do
57
57
  @set.bio("Vagabond.")
58
- a_post("/1/account/update_profile.json").
58
+ a_post("/1.1/account/update_profile.json").
59
59
  with(:body => {:description => "Vagabond."}).
60
60
  should have_been_made
61
61
  end
@@ -68,13 +68,13 @@ describe T::Set do
68
68
  describe "#language" do
69
69
  before do
70
70
  @set.options = @set.options.merge("profile" => fixture_path + "/.trc")
71
- stub_post("/1/account/settings.json").
71
+ stub_post("/1.1/account/settings.json").
72
72
  with(:body => {:lang => "en"}).
73
73
  to_return(:body => fixture("settings.json"), :headers => {:content_type => "application/json; charset=utf-8"})
74
74
  end
75
75
  it "should request the correct resource" do
76
76
  @set.language("en")
77
- a_post("/1/account/settings.json").
77
+ a_post("/1.1/account/settings.json").
78
78
  with(:body => {:lang => "en"}).
79
79
  should have_been_made
80
80
  end
@@ -87,13 +87,13 @@ describe T::Set do
87
87
  describe "#location" do
88
88
  before do
89
89
  @set.options = @set.options.merge("profile" => fixture_path + "/.trc")
90
- stub_post("/1/account/update_profile.json").
90
+ stub_post("/1.1/account/update_profile.json").
91
91
  with(:body => {:location => "San Francisco"}).
92
92
  to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
93
93
  end
94
94
  it "should request the correct resource" do
95
95
  @set.location("San Francisco")
96
- a_post("/1/account/update_profile.json").
96
+ a_post("/1.1/account/update_profile.json").
97
97
  with(:body => {:location => "San Francisco"}).
98
98
  should have_been_made
99
99
  end
@@ -106,13 +106,13 @@ describe T::Set do
106
106
  describe "#name" do
107
107
  before do
108
108
  @set.options = @set.options.merge("profile" => fixture_path + "/.trc")
109
- stub_post("/1/account/update_profile.json").
109
+ stub_post("/1.1/account/update_profile.json").
110
110
  with(:body => {:name => "Erik Michaels-Ober"}).
111
111
  to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
112
112
  end
113
113
  it "should request the correct resource" do
114
114
  @set.name("Erik Michaels-Ober")
115
- a_post("/1/account/update_profile.json").
115
+ a_post("/1.1/account/update_profile.json").
116
116
  with(:body => {:name => "Erik Michaels-Ober"}).
117
117
  should have_been_made
118
118
  end
@@ -125,12 +125,12 @@ describe T::Set do
125
125
  describe "#profile_background_image" do
126
126
  before do
127
127
  @set.options = @set.options.merge("profile" => fixture_path + "/.trc")
128
- stub_post("/1/account/update_profile_background_image.json").
128
+ stub_post("/1.1/account/update_profile_background_image.json").
129
129
  to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
130
130
  end
131
131
  it "should request the correct resource" do
132
132
  @set.profile_background_image(fixture_path + "/we_concept_bg2.png")
133
- a_post("/1/account/update_profile_background_image.json").
133
+ a_post("/1.1/account/update_profile_background_image.json").
134
134
  should have_been_made
135
135
  end
136
136
  it "should have the correct output" do
@@ -142,12 +142,12 @@ describe T::Set do
142
142
  describe "#profile_image" do
143
143
  before do
144
144
  @set.options = @set.options.merge("profile" => fixture_path + "/.trc")
145
- stub_post("/1/account/update_profile_image.json").
145
+ stub_post("/1.1/account/update_profile_image.json").
146
146
  to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
147
147
  end
148
148
  it "should request the correct resource" do
149
149
  @set.profile_image(fixture_path + "/me.jpg")
150
- a_post("/1/account/update_profile_image.json").
150
+ a_post("/1.1/account/update_profile_image.json").
151
151
  should have_been_made
152
152
  end
153
153
  it "should have the correct output" do
@@ -159,13 +159,13 @@ describe T::Set do
159
159
  describe "#url" do
160
160
  before do
161
161
  @set.options = @set.options.merge("profile" => fixture_path + "/.trc")
162
- stub_post("/1/account/update_profile.json").
162
+ stub_post("/1.1/account/update_profile.json").
163
163
  with(:body => {:url => "https://github.com/sferik"}).
164
164
  to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
165
165
  end
166
166
  it "should request the correct resource" do
167
167
  @set.url("https://github.com/sferik")
168
- a_post("/1/account/update_profile.json").
168
+ a_post("/1.1/account/update_profile.json").
169
169
  with(:body => {:url => "https://github.com/sferik"}).
170
170
  should have_been_made
171
171
  end
@@ -0,0 +1,307 @@
1
+ require 'helper'
2
+
3
+ describe T::Stream do
4
+ let(:t_class) {
5
+ klass = Class.new
6
+ klass.stub(:options=).and_return
7
+ klass.stub(:options).and_return({})
8
+ klass
9
+ }
10
+
11
+ before :all do
12
+ @status = status_from_fixture("status.json")
13
+ end
14
+
15
+ before :each do
16
+ T::RCFile.instance.path = fixture_path + "/.trc"
17
+
18
+ @tweetstream_client = stub('TweetStream::Client').as_null_object
19
+
20
+ @stream = T::Stream.new
21
+ @stream.stub(:client) { @tweetstream_client }
22
+ @stream.stub(:say).and_return
23
+
24
+ STDOUT.stub(:tty?).and_return(true)
25
+ end
26
+
27
+
28
+ describe '#all' do
29
+ context '--csv' do
30
+ before :each do
31
+ @stream.options = @stream.options.merge("csv" => true)
32
+ end
33
+
34
+ it 'outputs headings when the stream initializes' do
35
+ @tweetstream_client.stub(:on_timeline_status).and_return
36
+ @tweetstream_client.stub(:on_inited).and_yield
37
+
38
+ @stream.should_receive(:say).with("ID,Posted at,Screen name,Text\n")
39
+ @stream.all
40
+ end
41
+
42
+ it "outputs in CSV format" do
43
+ @tweetstream_client.stub(:on_inited).and_return
44
+ @tweetstream_client.stub(:on_timeline_status).
45
+ and_yield(@status)
46
+
47
+ @stream.should_receive(:print_csv_tweet).with(any_args)
48
+ @stream.all
49
+ end
50
+ end
51
+
52
+ context '--long' do
53
+ before :each do
54
+ @stream.options = @stream.options.merge("long" => true)
55
+ end
56
+
57
+ it 'outputs headings when the stream initializes' do
58
+ @tweetstream_client.stub(:on_inited).and_yield
59
+ @tweetstream_client.stub(:on_timeline_status).and_return
60
+
61
+ @stream.should_receive(:print_table).with(any_args)
62
+ @stream.all
63
+ end
64
+
65
+ it "outputs in long text format" do
66
+ @tweetstream_client.stub(:on_inited).and_return
67
+ @tweetstream_client.stub(:on_timeline_status).
68
+ and_yield(@status)
69
+
70
+ @stream.should_receive(:print_table).with(any_args)
71
+ @stream.all
72
+ end
73
+ end
74
+
75
+ context 'normal usage' do
76
+ before :each do
77
+ @tweetstream_client.stub(:on_timeline_status).
78
+ and_yield(@status)
79
+ end
80
+
81
+ it 'prints the tweet status' do
82
+ @stream.should_receive(:print_message)
83
+ @stream.all
84
+ end
85
+ end
86
+
87
+ it 'invokes TweetStream::Client#sample' do
88
+ @tweetstream_client.should_receive(:sample)
89
+ @stream.all
90
+ end
91
+ end
92
+
93
+ describe '#matrix' do
94
+ before :each do
95
+ @tweetstream_client.stub(:on_timeline_status).
96
+ and_yield(@status)
97
+ end
98
+
99
+ it 'outputs the tweet status' do
100
+ @stream.should_receive(:say).with(any_args)
101
+ @stream.matrix
102
+ end
103
+
104
+ it 'invokes TweetStream::Client.sample' do
105
+ @tweetstream_client.should_receive(:sample)
106
+ @stream.matrix
107
+ end
108
+ end
109
+
110
+ describe '#search' do
111
+ before :each do
112
+ @tweetstream_client.stub(:on_timeline_status).
113
+ and_yield(@status)
114
+ end
115
+
116
+ context '--csv' do
117
+ before :each do
118
+ @stream.options = @stream.options.merge("csv" => true)
119
+ end
120
+
121
+ it "outputs in CSV format" do
122
+ @tweetstream_client.stub(:on_inited).and_return
123
+
124
+ @stream.should_receive(:print_csv_tweet).with(any_args)
125
+ @stream.search('t gem')
126
+ end
127
+ end
128
+
129
+ context '--long' do
130
+ before :each do
131
+ @stream.options = @stream.options.merge("long" => true)
132
+ end
133
+
134
+ it "outputs in long text format" do
135
+ @tweetstream_client.stub(:on_inited).and_return
136
+ @tweetstream_client.stub(:on_timeline_status).
137
+ and_yield(@status)
138
+
139
+ @stream.should_receive(:print_table).with(any_args)
140
+ @stream.search('t gem')
141
+ end
142
+ end
143
+
144
+ context 'normal usage' do
145
+ before :each do
146
+ @tweetstream_client.stub(:on_timeline_status).
147
+ and_yield(@status)
148
+ end
149
+
150
+ it 'prints the tweet status' do
151
+ @stream.should_receive(:print_message)
152
+ @stream.search('t gem')
153
+ end
154
+ end
155
+
156
+ it 'performs a REST search when the stream initializes' do
157
+ @tweetstream_client.stub(:on_timeline_status).and_return
158
+ @tweetstream_client.stub(:on_inited).and_yield
159
+
160
+ T::Search.stub(:new).and_return(t_class)
161
+ t_class.should_receive(:all).with('t OR gem').and_return
162
+
163
+ @stream.search('t', 'gem')
164
+ end
165
+
166
+ it 'invokes TweetStream::Client#track' do
167
+ @tweetstream_client.stub(:on_timeline_status).and_return
168
+
169
+ @tweetstream_client.should_receive(:track).with(['t gem'])
170
+ @stream.search('t gem')
171
+ end
172
+ end
173
+
174
+ describe '#timeline' do
175
+ before :each do
176
+ @tweetstream_client.stub(:on_timeline_status).
177
+ and_yield(@status)
178
+ end
179
+
180
+ context '--csv' do
181
+ before :each do
182
+ @stream.options = @stream.options.merge("csv" => true)
183
+ end
184
+
185
+ it "outputs in CSV format" do
186
+ @tweetstream_client.stub(:on_inited).and_return
187
+
188
+ @stream.should_receive(:print_csv_tweet).with(any_args)
189
+ @stream.timeline
190
+ end
191
+ end
192
+
193
+ context '--long' do
194
+ before :each do
195
+ @stream.options = @stream.options.merge("long" => true)
196
+ end
197
+
198
+ it "outputs in long text format" do
199
+ @tweetstream_client.stub(:on_inited).and_return
200
+ @tweetstream_client.stub(:on_timeline_status).
201
+ and_yield(@status)
202
+
203
+ @stream.should_receive(:print_table).with(any_args)
204
+ @stream.timeline
205
+ end
206
+ end
207
+
208
+ context 'normal usage' do
209
+ before :each do
210
+ @tweetstream_client.stub(:on_timeline_status).
211
+ and_yield(@status)
212
+ end
213
+
214
+ it 'prints the tweet status' do
215
+ @stream.should_receive(:print_message)
216
+ @stream.timeline
217
+ end
218
+ end
219
+
220
+ it 'performs a REST search when the stream initializes' do
221
+ @tweetstream_client.stub(:on_timeline_status).and_return
222
+ @tweetstream_client.stub(:on_inited).and_yield
223
+
224
+ T::CLI.stub(:new).and_return(t_class)
225
+ t_class.should_receive(:timeline).and_return
226
+
227
+ @stream.timeline
228
+ end
229
+
230
+ it 'invokes TweetStream::Client#userstream' do
231
+ @tweetstream_client.stub(:on_timeline_status).and_return
232
+
233
+ @tweetstream_client.should_receive(:userstream)
234
+ @stream.timeline
235
+ end
236
+ end
237
+
238
+ describe '#users' do
239
+ before :each do
240
+ @tweetstream_client.stub(:on_timeline_status).
241
+ and_yield(@status)
242
+ end
243
+
244
+ context '--csv' do
245
+ before :each do
246
+ @stream.options = @stream.options.merge("csv" => true)
247
+ end
248
+
249
+ it 'outputs headings when the stream initializes' do
250
+ @tweetstream_client.stub(:on_timeline_status).and_return
251
+ @tweetstream_client.stub(:on_inited).and_yield
252
+
253
+ @stream.should_receive(:say).with("ID,Posted at,Screen name,Text\n")
254
+ @stream.users('123')
255
+ end
256
+
257
+ it "outputs in CSV format" do
258
+ @tweetstream_client.stub(:on_inited).and_return
259
+
260
+ @stream.should_receive(:print_csv_tweet).with(any_args)
261
+ @stream.users('123')
262
+ end
263
+ end
264
+
265
+ context '--long' do
266
+ before :each do
267
+ @stream.options = @stream.options.merge("long" => true)
268
+ end
269
+
270
+ it 'outputs headings when the stream initializes' do
271
+ @tweetstream_client.stub(:on_inited).and_yield
272
+ @tweetstream_client.stub(:on_timeline_status).and_return
273
+
274
+ @stream.should_receive(:print_table).with(any_args)
275
+ @stream.users('123')
276
+ end
277
+
278
+ it "outputs in long text format" do
279
+ @tweetstream_client.stub(:on_inited).and_return
280
+ @tweetstream_client.stub(:on_timeline_status).
281
+ and_yield(@status)
282
+
283
+ @stream.should_receive(:print_table).with(any_args)
284
+ @stream.users('123')
285
+ end
286
+ end
287
+
288
+ context 'normal usage' do
289
+ before :each do
290
+ @tweetstream_client.stub(:on_timeline_status).
291
+ and_yield(@status)
292
+ end
293
+
294
+ it 'prints the tweet status' do
295
+ @stream.should_receive(:print_message)
296
+ @stream.users('123')
297
+ end
298
+ end
299
+
300
+ it 'invokes TweetStream::Client#follow' do
301
+ @tweetstream_client.stub(:on_timeline_status).and_return
302
+
303
+ @tweetstream_client.should_receive(:follow).with([123, 456, 789])
304
+ @stream.users('123', '456', '789')
305
+ end
306
+ end
307
+ end
data/t.gemspec CHANGED
@@ -10,8 +10,8 @@ Gem::Specification.new do |gem|
10
10
  gem.add_dependency 'oauth', '~> 0.4'
11
11
  gem.add_dependency 'retryable', '~> 1.2'
12
12
  gem.add_dependency 'thor', ['>= 0.16', '< 2']
13
- gem.add_dependency 'tweetstream', '~> 2.0'
14
- gem.add_dependency 'twitter', '~> 3.4'
13
+ gem.add_dependency 'tweetstream', '~> 2.2'
14
+ gem.add_dependency 'twitter', '~> 4.0'
15
15
  gem.add_development_dependency 'pry'
16
16
  gem.add_development_dependency 'rake'
17
17
  gem.add_development_dependency 'rspec'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: t
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-06 00:00:00.000000000 Z
12
+ date: 2012-09-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: launchy
@@ -152,7 +152,7 @@ dependencies:
152
152
  requirements:
153
153
  - - ~>
154
154
  - !ruby/object:Gem::Version
155
- version: '2.0'
155
+ version: '2.2'
156
156
  type: :runtime
157
157
  prerelease: false
158
158
  version_requirements: !ruby/object:Gem::Requirement
@@ -160,7 +160,7 @@ dependencies:
160
160
  requirements:
161
161
  - - ~>
162
162
  - !ruby/object:Gem::Version
163
- version: '2.0'
163
+ version: '2.2'
164
164
  - !ruby/object:Gem::Dependency
165
165
  name: twitter
166
166
  requirement: !ruby/object:Gem::Requirement
@@ -168,7 +168,7 @@ dependencies:
168
168
  requirements:
169
169
  - - ~>
170
170
  - !ruby/object:Gem::Version
171
- version: '3.4'
171
+ version: '4.0'
172
172
  type: :runtime
173
173
  prerelease: false
174
174
  version_requirements: !ruby/object:Gem::Requirement
@@ -176,7 +176,7 @@ dependencies:
176
176
  requirements:
177
177
  - - ~>
178
178
  - !ruby/object:Gem::Version
179
- version: '3.4'
179
+ version: '4.0'
180
180
  - !ruby/object:Gem::Dependency
181
181
  name: pry
182
182
  requirement: !ruby/object:Gem::Requirement
@@ -313,6 +313,7 @@ files:
313
313
  - spec/fixtures/false.json
314
314
  - spec/fixtures/favorites.json
315
315
  - spec/fixtures/followers_ids.json
316
+ - spec/fixtures/following.json
316
317
  - spec/fixtures/friends_ids.json
317
318
  - spec/fixtures/gem.json
318
319
  - spec/fixtures/geoplugin.xml
@@ -321,6 +322,7 @@ files:
321
322
  - spec/fixtures/locations.json
322
323
  - spec/fixtures/long.png
323
324
  - spec/fixtures/me.jpg
325
+ - spec/fixtures/not_following.json
324
326
  - spec/fixtures/not_found.json
325
327
  - spec/fixtures/rate_limit_status.json
326
328
  - spec/fixtures/recommendations.json
@@ -346,6 +348,7 @@ files:
346
348
  - spec/rcfile_spec.rb
347
349
  - spec/search_spec.rb
348
350
  - spec/set_spec.rb
351
+ - spec/stream_spec.rb
349
352
  - spec/utils_spec.rb
350
353
  homepage: http://sferik.github.com/t/
351
354
  licenses: []
@@ -385,6 +388,7 @@ test_files:
385
388
  - spec/fixtures/false.json
386
389
  - spec/fixtures/favorites.json
387
390
  - spec/fixtures/followers_ids.json
391
+ - spec/fixtures/following.json
388
392
  - spec/fixtures/friends_ids.json
389
393
  - spec/fixtures/gem.json
390
394
  - spec/fixtures/geoplugin.xml
@@ -393,6 +397,7 @@ test_files:
393
397
  - spec/fixtures/locations.json
394
398
  - spec/fixtures/long.png
395
399
  - spec/fixtures/me.jpg
400
+ - spec/fixtures/not_following.json
396
401
  - spec/fixtures/not_found.json
397
402
  - spec/fixtures/rate_limit_status.json
398
403
  - spec/fixtures/recommendations.json
@@ -418,5 +423,6 @@ test_files:
418
423
  - spec/rcfile_spec.rb
419
424
  - spec/search_spec.rb
420
425
  - spec/set_spec.rb
426
+ - spec/stream_spec.rb
421
427
  - spec/utils_spec.rb
422
428
  has_rdoc: