t 2.7.0 → 2.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -4
- data/bin/t +1 -1
- data/lib/t/cli.rb +26 -2
- data/lib/t/list.rb +0 -2
- data/lib/t/printable.rb +6 -5
- data/lib/t/stream.rb +0 -20
- data/lib/t/version.rb +1 -1
- data/t.gemspec +4 -8
- metadata +6 -131
- data/Rakefile +0 -21
- data/spec/cli_spec.rb +0 -4141
- data/spec/delete_spec.rb +0 -250
- data/spec/editor_spec.rb +0 -102
- data/spec/fixtures/200_direct_messages.json +0 -1
- data/spec/fixtures/200_statuses.json +0 -1
- data/spec/fixtures/501_ids.json +0 -1
- data/spec/fixtures/501_users_list.json +0 -1
- data/spec/fixtures/access_token +0 -1
- data/spec/fixtures/bearer_token.json +0 -1
- data/spec/fixtures/checkip.html +0 -1
- data/spec/fixtures/direct_message.json +0 -1
- data/spec/fixtures/direct_messages.json +0 -1
- data/spec/fixtures/empty_array.json +0 -1
- data/spec/fixtures/empty_cursor.json +0 -1
- data/spec/fixtures/favorites.json +0 -1
- data/spec/fixtures/followers_ids.json +0 -1
- data/spec/fixtures/following.json +0 -1
- data/spec/fixtures/friends_ids.json +0 -1
- data/spec/fixtures/gem.json +0 -1
- data/spec/fixtures/geo.json +0 -414
- data/spec/fixtures/geo_no_city.json +0 -344
- data/spec/fixtures/geo_no_state.json +0 -299
- data/spec/fixtures/geoplugin.xml +0 -17
- data/spec/fixtures/ids_list.json +0 -1
- data/spec/fixtures/ids_list2.json +0 -1
- data/spec/fixtures/list.json +0 -1
- data/spec/fixtures/lists.json +0 -1
- data/spec/fixtures/locations.json +0 -1
- data/spec/fixtures/long.png +0 -0
- data/spec/fixtures/matrix.json +0 -1
- data/spec/fixtures/me.jpg +0 -0
- data/spec/fixtures/not_following.json +0 -1
- data/spec/fixtures/not_found.json +0 -1
- data/spec/fixtures/rate_limit_status.json +0 -1
- data/spec/fixtures/recommendations.json +0 -1
- data/spec/fixtures/request_token +0 -1
- data/spec/fixtures/retweet.json +0 -1
- data/spec/fixtures/search.json +0 -1
- data/spec/fixtures/search2.json +0 -1
- data/spec/fixtures/search_with_entities.json +0 -1
- data/spec/fixtures/settings.json +0 -1
- data/spec/fixtures/sferik.json +0 -1
- data/spec/fixtures/status.json +0 -1
- data/spec/fixtures/status_no_attributes.json +0 -1
- data/spec/fixtures/status_no_country.json +0 -1
- data/spec/fixtures/status_no_full_name.json +0 -1
- data/spec/fixtures/status_no_locality.json +0 -1
- data/spec/fixtures/status_no_place.json +0 -1
- data/spec/fixtures/status_no_street_address.json +0 -1
- data/spec/fixtures/status_with_mention.json +0 -1
- data/spec/fixtures/statuses.json +0 -1
- data/spec/fixtures/trends.json +0 -1
- data/spec/fixtures/users.json +0 -1
- data/spec/fixtures/users_list.json +0 -1
- data/spec/fixtures/we_concept_bg2.png +0 -0
- data/spec/helper.rb +0 -78
- data/spec/list_spec.rb +0 -812
- data/spec/rcfile_spec.rb +0 -221
- data/spec/search_spec.rb +0 -944
- data/spec/set_spec.rb +0 -154
- data/spec/stream_spec.rb +0 -286
- data/spec/utils_spec.rb +0 -96
data/spec/set_spec.rb
DELETED
@@ -1,154 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require 'helper'
|
3
|
-
|
4
|
-
describe T::Set do
|
5
|
-
|
6
|
-
before do
|
7
|
-
T::RCFile.instance.path = fixture_path + '/.trc'
|
8
|
-
@set = T::Set.new
|
9
|
-
@old_stderr = $stderr
|
10
|
-
$stderr = StringIO.new
|
11
|
-
@old_stdout = $stdout
|
12
|
-
$stdout = StringIO.new
|
13
|
-
end
|
14
|
-
|
15
|
-
after do
|
16
|
-
T::RCFile.instance.reset
|
17
|
-
$stderr = @old_stderr
|
18
|
-
$stdout = @old_stdout
|
19
|
-
end
|
20
|
-
|
21
|
-
describe '#active' do
|
22
|
-
before do
|
23
|
-
@set.options = @set.options.merge('profile' => fixture_path + '/.trc_set')
|
24
|
-
end
|
25
|
-
it 'has the correct output' do
|
26
|
-
@set.active('testcli', 'abc123')
|
27
|
-
expect($stdout.string.chomp).to eq 'Active account has been updated to testcli.'
|
28
|
-
end
|
29
|
-
it 'accepts an account name without a consumer key' do
|
30
|
-
@set.active('testcli')
|
31
|
-
expect($stdout.string.chomp).to eq 'Active account has been updated to testcli.'
|
32
|
-
end
|
33
|
-
it 'is case insensitive' do
|
34
|
-
@set.active('TestCLI', 'abc123')
|
35
|
-
expect($stdout.string.chomp).to eq 'Active account has been updated to testcli.'
|
36
|
-
end
|
37
|
-
it 'raises an error if username is ambiguous' do
|
38
|
-
expect do
|
39
|
-
@set.active('test', 'abc123')
|
40
|
-
end.to raise_error(ArgumentError, /Username test is ambiguous/)
|
41
|
-
end
|
42
|
-
it 'raises an error if the username is not found' do
|
43
|
-
expect do
|
44
|
-
@set.active('clitest')
|
45
|
-
end.to raise_error(ArgumentError, /Username clitest is not found/)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
describe '#bio' do
|
50
|
-
before do
|
51
|
-
@set.options = @set.options.merge('profile' => fixture_path + '/.trc')
|
52
|
-
stub_post('/1.1/account/update_profile.json').with(:body => {:description => 'Vagabond.'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
53
|
-
end
|
54
|
-
it 'requests the correct resource' do
|
55
|
-
@set.bio('Vagabond.')
|
56
|
-
expect(a_post('/1.1/account/update_profile.json').with(:body => {:description => 'Vagabond.'})).to have_been_made
|
57
|
-
end
|
58
|
-
it 'has the correct output' do
|
59
|
-
@set.bio('Vagabond.')
|
60
|
-
expect($stdout.string.chomp).to eq "@testcli's bio has been updated."
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
describe '#language' do
|
65
|
-
before do
|
66
|
-
@set.options = @set.options.merge('profile' => fixture_path + '/.trc')
|
67
|
-
stub_post('/1.1/account/settings.json').with(:body => {:lang => 'en'}).to_return(:body => fixture('settings.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
68
|
-
end
|
69
|
-
it 'requests the correct resource' do
|
70
|
-
@set.language('en')
|
71
|
-
expect(a_post('/1.1/account/settings.json').with(:body => {:lang => 'en'})).to have_been_made
|
72
|
-
end
|
73
|
-
it 'has the correct output' do
|
74
|
-
@set.language('en')
|
75
|
-
expect($stdout.string.chomp).to eq "@testcli's language has been updated."
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
describe '#location' do
|
80
|
-
before do
|
81
|
-
@set.options = @set.options.merge('profile' => fixture_path + '/.trc')
|
82
|
-
stub_post('/1.1/account/update_profile.json').with(:body => {:location => 'San Francisco'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
83
|
-
end
|
84
|
-
it 'requests the correct resource' do
|
85
|
-
@set.location('San Francisco')
|
86
|
-
expect(a_post('/1.1/account/update_profile.json').with(:body => {:location => 'San Francisco'})).to have_been_made
|
87
|
-
end
|
88
|
-
it 'has the correct output' do
|
89
|
-
@set.location('San Francisco')
|
90
|
-
expect($stdout.string.chomp).to eq "@testcli's location has been updated."
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
describe '#name' do
|
95
|
-
before do
|
96
|
-
@set.options = @set.options.merge('profile' => fixture_path + '/.trc')
|
97
|
-
stub_post('/1.1/account/update_profile.json').with(:body => {:name => 'Erik Michaels-Ober'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
98
|
-
end
|
99
|
-
it 'requests the correct resource' do
|
100
|
-
@set.name('Erik Michaels-Ober')
|
101
|
-
expect(a_post('/1.1/account/update_profile.json').with(:body => {:name => 'Erik Michaels-Ober'})).to have_been_made
|
102
|
-
end
|
103
|
-
it 'has the correct output' do
|
104
|
-
@set.name('Erik Michaels-Ober')
|
105
|
-
expect($stdout.string.chomp).to eq "@testcli's name has been updated."
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
describe '#profile_background_image' do
|
110
|
-
before do
|
111
|
-
@set.options = @set.options.merge('profile' => fixture_path + '/.trc')
|
112
|
-
stub_post('/1.1/account/update_profile_background_image.json').to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
113
|
-
end
|
114
|
-
it 'requests the correct resource' do
|
115
|
-
@set.profile_background_image(fixture_path + '/we_concept_bg2.png')
|
116
|
-
expect(a_post('/1.1/account/update_profile_background_image.json')).to have_been_made
|
117
|
-
end
|
118
|
-
it 'has the correct output' do
|
119
|
-
@set.profile_background_image(fixture_path + '/we_concept_bg2.png')
|
120
|
-
expect($stdout.string.chomp).to eq "@testcli's background image has been updated."
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
describe '#profile_image' do
|
125
|
-
before do
|
126
|
-
@set.options = @set.options.merge('profile' => fixture_path + '/.trc')
|
127
|
-
stub_post('/1.1/account/update_profile_image.json').to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
128
|
-
end
|
129
|
-
it 'requests the correct resource' do
|
130
|
-
@set.profile_image(fixture_path + '/me.jpg')
|
131
|
-
expect(a_post('/1.1/account/update_profile_image.json')).to have_been_made
|
132
|
-
end
|
133
|
-
it 'has the correct output' do
|
134
|
-
@set.profile_image(fixture_path + '/me.jpg')
|
135
|
-
expect($stdout.string.chomp).to eq "@testcli's image has been updated."
|
136
|
-
end
|
137
|
-
end
|
138
|
-
|
139
|
-
describe '#website' do
|
140
|
-
before do
|
141
|
-
@set.options = @set.options.merge('profile' => fixture_path + '/.trc')
|
142
|
-
stub_post('/1.1/account/update_profile.json').with(:body => {:url => 'https://github.com/sferik'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
143
|
-
end
|
144
|
-
it 'requests the correct resource' do
|
145
|
-
@set.website('https://github.com/sferik')
|
146
|
-
expect(a_post('/1.1/account/update_profile.json').with(:body => {:url => 'https://github.com/sferik'})).to have_been_made
|
147
|
-
end
|
148
|
-
it 'has the correct output' do
|
149
|
-
@set.website('https://github.com/sferik')
|
150
|
-
expect($stdout.string.chomp).to eq "@testcli's website has been updated."
|
151
|
-
end
|
152
|
-
end
|
153
|
-
|
154
|
-
end
|
data/spec/stream_spec.rb
DELETED
@@ -1,286 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
describe T::Stream do
|
4
|
-
let(:t_class) do
|
5
|
-
klass = Class.new
|
6
|
-
allow(klass).to receive(:options=)
|
7
|
-
allow(klass).to receive(:options).and_return({})
|
8
|
-
klass
|
9
|
-
end
|
10
|
-
|
11
|
-
before :all do
|
12
|
-
@status = status_from_fixture('status.json')
|
13
|
-
end
|
14
|
-
|
15
|
-
before do
|
16
|
-
T::RCFile.instance.path = fixture_path + '/.trc'
|
17
|
-
@streaming_client = double('Twitter::Streaming::Client').as_null_object
|
18
|
-
@stream = T::Stream.new
|
19
|
-
allow(@stream).to receive(:streaming_client) { @streaming_client }
|
20
|
-
allow(@stream).to receive(:say)
|
21
|
-
allow(STDOUT).to receive(:tty?).and_return(true)
|
22
|
-
end
|
23
|
-
|
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
|
32
|
-
context '--csv' do
|
33
|
-
before do
|
34
|
-
@stream.options = @stream.options.merge('csv' => true)
|
35
|
-
end
|
36
|
-
it 'outputs headings when the stream initializes' do
|
37
|
-
allow(@streaming_client).to receive(:before_request).and_yield
|
38
|
-
allow(@streaming_client).to receive(:sample)
|
39
|
-
expect(@stream).to receive(:say).with("ID,Posted at,Screen name,Text\n")
|
40
|
-
@stream.all
|
41
|
-
end
|
42
|
-
it 'outputs in CSV format' do
|
43
|
-
allow(@streaming_client).to receive(:before_request)
|
44
|
-
allow(@streaming_client).to receive(:sample).and_yield(@status)
|
45
|
-
expect(@stream).to receive(:print_csv_tweet).with(any_args)
|
46
|
-
@stream.all
|
47
|
-
end
|
48
|
-
end
|
49
|
-
context '--long' do
|
50
|
-
before do
|
51
|
-
@stream.options = @stream.options.merge('long' => true)
|
52
|
-
end
|
53
|
-
it 'outputs headings when the stream initializes' do
|
54
|
-
allow(@streaming_client).to receive(:before_request).and_yield
|
55
|
-
allow(@streaming_client).to receive(:sample)
|
56
|
-
expect(@stream).to receive(:print_table).with(any_args)
|
57
|
-
@stream.all
|
58
|
-
end
|
59
|
-
it 'outputs in long text format' do
|
60
|
-
allow(@streaming_client).to receive(:before_request)
|
61
|
-
allow(@streaming_client).to receive(:sample).and_yield(@status)
|
62
|
-
expect(@stream).to receive(:print_table).with(any_args)
|
63
|
-
@stream.all
|
64
|
-
end
|
65
|
-
end
|
66
|
-
it 'invokes Twitter::Streaming::Client#sample' do
|
67
|
-
allow(@streaming_client).to receive(:before_request)
|
68
|
-
allow(@streaming_client).to receive(:sample)
|
69
|
-
expect(@streaming_client).to receive(:sample)
|
70
|
-
@stream.all
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
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'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
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)
|
90
|
-
end
|
91
|
-
it 'outputs in CSV format' do
|
92
|
-
allow(@streaming_client).to receive(:before_request)
|
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
|
100
|
-
end
|
101
|
-
end
|
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)
|
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)
|
120
|
-
allow(T::List).to receive(:new).and_return(t_class)
|
121
|
-
expect(t_class).to receive(:timeline)
|
122
|
-
@stream.list('presidents')
|
123
|
-
end
|
124
|
-
it 'invokes Twitter::Streaming::Client#userstream' do
|
125
|
-
allow(@streaming_client).to receive(:filter)
|
126
|
-
expect(@streaming_client).to receive(:filter)
|
127
|
-
@stream.list('presidents')
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
|
-
describe '#matrix' do
|
132
|
-
before do
|
133
|
-
stub_get('/1.1/search/tweets.json').with(:query => {:q => 'lang:ja', :count => 100, :include_entities => 'false'}).to_return(:body => fixture('empty_cursor.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
134
|
-
end
|
135
|
-
it 'outputs the tweet status' do
|
136
|
-
allow(@streaming_client).to receive(:before_request)
|
137
|
-
allow(@streaming_client).to receive(:sample).and_yield(@status)
|
138
|
-
expect(@stream).to receive(:say).with(any_args)
|
139
|
-
@stream.matrix
|
140
|
-
end
|
141
|
-
it 'invokes Twitter::Streaming::Client#sample' do
|
142
|
-
allow(@streaming_client).to receive(:before_request)
|
143
|
-
allow(@streaming_client).to receive(:sample).and_yield(@status)
|
144
|
-
expect(@streaming_client).to receive(:sample)
|
145
|
-
@stream.matrix
|
146
|
-
end
|
147
|
-
it 'requests the correct resource' do
|
148
|
-
allow(@streaming_client).to receive(:before_request).and_yield
|
149
|
-
@stream.matrix
|
150
|
-
expect(a_get('/1.1/search/tweets.json').with(:query => {:q => 'lang:ja', :count => 100, :include_entities => 'false'})).to have_been_made
|
151
|
-
end
|
152
|
-
end
|
153
|
-
|
154
|
-
describe '#search' do
|
155
|
-
before do
|
156
|
-
allow(@streaming_client).to receive(:filter).with(:track => 'twitter,gem').and_yield(@status)
|
157
|
-
end
|
158
|
-
it 'prints the tweet status' do
|
159
|
-
expect(@stream).to receive(:print_message)
|
160
|
-
@stream.search(%w[twitter gem])
|
161
|
-
end
|
162
|
-
context '--csv' do
|
163
|
-
before do
|
164
|
-
@stream.options = @stream.options.merge('csv' => true)
|
165
|
-
end
|
166
|
-
it 'outputs in CSV format' do
|
167
|
-
allow(@streaming_client).to receive(:before_request)
|
168
|
-
expect(@stream).to receive(:print_csv_tweet).with(any_args)
|
169
|
-
@stream.search(%w[twitter gem])
|
170
|
-
end
|
171
|
-
end
|
172
|
-
context '--long' do
|
173
|
-
before do
|
174
|
-
@stream.options = @stream.options.merge('long' => true)
|
175
|
-
end
|
176
|
-
it 'outputs in long text format' do
|
177
|
-
allow(@streaming_client).to receive(:before_request)
|
178
|
-
allow(@streaming_client).to receive(:filter).with(:track => 'twitter,gem').and_yield(@status)
|
179
|
-
expect(@stream).to receive(:print_table).with(any_args)
|
180
|
-
@stream.search(%w[twitter gem])
|
181
|
-
end
|
182
|
-
end
|
183
|
-
it 'performs a REST search when the stream initializes' do
|
184
|
-
allow(@streaming_client).to receive(:before_request).and_yield
|
185
|
-
allow(@streaming_client).to receive(:filter)
|
186
|
-
allow(T::Search).to receive(:new).and_return(t_class)
|
187
|
-
expect(t_class).to receive(:all).with('t OR gem')
|
188
|
-
@stream.search('t', 'gem')
|
189
|
-
end
|
190
|
-
it 'invokes Twitter::Streaming::Client#filter' do
|
191
|
-
allow(@streaming_client).to receive(:filter)
|
192
|
-
expect(@streaming_client).to receive(:filter).with(:track => 'twitter,gem')
|
193
|
-
@stream.search(%w[twitter gem])
|
194
|
-
end
|
195
|
-
end
|
196
|
-
|
197
|
-
describe '#timeline' do
|
198
|
-
before do
|
199
|
-
allow(@streaming_client).to receive(:user).and_yield(@status)
|
200
|
-
end
|
201
|
-
it 'prints the tweet status' do
|
202
|
-
expect(@stream).to receive(:print_message)
|
203
|
-
@stream.timeline
|
204
|
-
end
|
205
|
-
context '--csv' do
|
206
|
-
before do
|
207
|
-
@stream.options = @stream.options.merge('csv' => true)
|
208
|
-
end
|
209
|
-
it 'outputs in CSV format' do
|
210
|
-
allow(@streaming_client).to receive(:before_request)
|
211
|
-
expect(@stream).to receive(:print_csv_tweet).with(any_args)
|
212
|
-
@stream.timeline
|
213
|
-
end
|
214
|
-
end
|
215
|
-
context '--long' do
|
216
|
-
before do
|
217
|
-
@stream.options = @stream.options.merge('long' => true)
|
218
|
-
end
|
219
|
-
it 'outputs in long text format' do
|
220
|
-
allow(@streaming_client).to receive(:before_request)
|
221
|
-
expect(@stream).to receive(:print_table).with(any_args)
|
222
|
-
@stream.timeline
|
223
|
-
end
|
224
|
-
end
|
225
|
-
it 'performs a REST search when the stream initializes' do
|
226
|
-
allow(@streaming_client).to receive(:before_request).and_yield
|
227
|
-
allow(@streaming_client).to receive(:user)
|
228
|
-
allow(T::CLI).to receive(:new).and_return(t_class)
|
229
|
-
expect(t_class).to receive(:timeline)
|
230
|
-
@stream.timeline
|
231
|
-
end
|
232
|
-
it 'invokes Twitter::Streaming::Client#userstream' do
|
233
|
-
allow(@streaming_client).to receive(:user)
|
234
|
-
expect(@streaming_client).to receive(:user)
|
235
|
-
@stream.timeline
|
236
|
-
end
|
237
|
-
end
|
238
|
-
|
239
|
-
describe '#users' do
|
240
|
-
before do
|
241
|
-
allow(@streaming_client).to receive(:filter).and_yield(@status)
|
242
|
-
end
|
243
|
-
it 'prints the tweet status' do
|
244
|
-
expect(@stream).to receive(:print_message)
|
245
|
-
@stream.users('123')
|
246
|
-
end
|
247
|
-
context '--csv' do
|
248
|
-
before do
|
249
|
-
@stream.options = @stream.options.merge('csv' => true)
|
250
|
-
end
|
251
|
-
it 'outputs headings when the stream initializes' do
|
252
|
-
allow(@streaming_client).to receive(:before_request).and_yield
|
253
|
-
allow(@streaming_client).to receive(:filter)
|
254
|
-
expect(@stream).to receive(:say).with("ID,Posted at,Screen name,Text\n")
|
255
|
-
@stream.users('123')
|
256
|
-
end
|
257
|
-
it 'outputs in CSV format' do
|
258
|
-
allow(@streaming_client).to receive(:before_request)
|
259
|
-
expect(@stream).to receive(:print_csv_tweet).with(any_args)
|
260
|
-
@stream.users('123')
|
261
|
-
end
|
262
|
-
end
|
263
|
-
context '--long' do
|
264
|
-
before do
|
265
|
-
@stream.options = @stream.options.merge('long' => true)
|
266
|
-
end
|
267
|
-
it 'outputs headings when the stream initializes' do
|
268
|
-
allow(@streaming_client).to receive(:before_request).and_yield
|
269
|
-
allow(@streaming_client).to receive(:filter)
|
270
|
-
expect(@stream).to receive(:print_table).with(any_args)
|
271
|
-
@stream.users('123')
|
272
|
-
end
|
273
|
-
it 'outputs in long text format' do
|
274
|
-
allow(@streaming_client).to receive(:before_request)
|
275
|
-
allow(@streaming_client).to receive(:filter).and_yield(@status)
|
276
|
-
expect(@stream).to receive(:print_table).with(any_args)
|
277
|
-
@stream.users('123')
|
278
|
-
end
|
279
|
-
end
|
280
|
-
it 'invokes Twitter::Streaming::Client#follow' do
|
281
|
-
allow(@streaming_client).to receive(:filter)
|
282
|
-
expect(@streaming_client).to receive(:filter).with(:follow => '123,456,789')
|
283
|
-
@stream.users('123', '456', '789')
|
284
|
-
end
|
285
|
-
end
|
286
|
-
end
|
data/spec/utils_spec.rb
DELETED
@@ -1,96 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require 'helper'
|
3
|
-
|
4
|
-
describe T::Utils do
|
5
|
-
|
6
|
-
before :all do
|
7
|
-
Timecop.freeze(Time.utc(2011, 11, 24, 16, 20, 0))
|
8
|
-
T.utc_offset = -28_800
|
9
|
-
class Test; end
|
10
|
-
end
|
11
|
-
|
12
|
-
before do
|
13
|
-
@test = Test.new
|
14
|
-
@test.extend(T::Utils)
|
15
|
-
end
|
16
|
-
|
17
|
-
after :all do
|
18
|
-
T.utc_offset = nil
|
19
|
-
Timecop.return
|
20
|
-
end
|
21
|
-
|
22
|
-
describe '#distance_of_time_in_words' do
|
23
|
-
it "returns \"a split second\" if difference is less than a second" do
|
24
|
-
expect(@test.send(:distance_of_time_in_words, (Time.utc(2011, 11, 24, 16, 20, 0)))).to eq 'a split second'
|
25
|
-
end
|
26
|
-
it "returns \"a second\" if difference is a second" do
|
27
|
-
expect(@test.send(:distance_of_time_in_words, (Time.utc(2011, 11, 24, 16, 20, 1)))).to eq 'a second'
|
28
|
-
end
|
29
|
-
it "returns \"2 seconds\" if difference is 2 seconds" do
|
30
|
-
expect(@test.send(:distance_of_time_in_words, (Time.utc(2011, 11, 24, 16, 20, 2)))).to eq '2 seconds'
|
31
|
-
end
|
32
|
-
it "returns \"59 seconds\" if difference is just shy of 1 minute" do
|
33
|
-
expect(@test.send(:distance_of_time_in_words, (Time.utc(2011, 11, 24, 16, 20, 59.9)))).to eq '59 seconds'
|
34
|
-
end
|
35
|
-
it "returns \"a minute\" if difference is 1 minute" do
|
36
|
-
expect(@test.send(:distance_of_time_in_words, (Time.utc(2011, 11, 24, 16, 21, 0)))).to eq 'a minute'
|
37
|
-
end
|
38
|
-
it "returns \"2 minutes\" if difference is 2 minutes" do
|
39
|
-
expect(@test.send(:distance_of_time_in_words, (Time.utc(2011, 11, 24, 16, 22, 0)))).to eq '2 minutes'
|
40
|
-
end
|
41
|
-
it "returns \"59 minutes\" if difference is just shy of 1 hour" do
|
42
|
-
expect(@test.send(:distance_of_time_in_words, (Time.utc(2011, 11, 24, 17, 19, 59.9)))).to eq '59 minutes'
|
43
|
-
end
|
44
|
-
it "returns \"an hour\" if difference is 1 hour" do
|
45
|
-
expect(@test.send(:distance_of_time_in_words, (Time.utc(2011, 11, 24, 17, 20, 0)))).to eq 'an hour'
|
46
|
-
end
|
47
|
-
it "returns \"2 hours\" if difference is 2 hours" do
|
48
|
-
expect(@test.send(:distance_of_time_in_words, (Time.utc(2011, 11, 24, 18, 20, 0)))).to eq '2 hours'
|
49
|
-
end
|
50
|
-
it "returns \"23 hours\" if difference is just shy of 23.5 hours" do
|
51
|
-
expect(@test.send(:distance_of_time_in_words, (Time.utc(2011, 11, 25, 15, 49, 59.9)))).to eq '23 hours'
|
52
|
-
end
|
53
|
-
it "returns \"a day\" if difference is 23.5 hours" do
|
54
|
-
expect(@test.send(:distance_of_time_in_words, (Time.utc(2011, 11, 25, 15, 50, 0)))).to eq 'a day'
|
55
|
-
end
|
56
|
-
it "returns \"2 days\" if difference is 2 days" do
|
57
|
-
expect(@test.send(:distance_of_time_in_words, (Time.utc(2011, 11, 26, 16, 20, 0)))).to eq '2 days'
|
58
|
-
end
|
59
|
-
it "returns \"29 days\" if difference is just shy of 29.5 days" do
|
60
|
-
expect(@test.send(:distance_of_time_in_words, (Time.utc(2011, 12, 24, 4, 19, 59.9)))).to eq '29 days'
|
61
|
-
end
|
62
|
-
it "returns \"a month\" if difference is 29.5 days" do
|
63
|
-
expect(@test.send(:distance_of_time_in_words, (Time.utc(2011, 12, 24, 4, 20, 0)))).to eq 'a month'
|
64
|
-
end
|
65
|
-
it "returns \"2 months\" if difference is 2 months" do
|
66
|
-
expect(@test.send(:distance_of_time_in_words, (Time.utc(2012, 1, 24, 16, 20, 0)))).to eq '2 months'
|
67
|
-
end
|
68
|
-
it "returns \"11 months\" if difference is just shy of 11.5 months" do
|
69
|
-
expect(@test.send(:distance_of_time_in_words, (Time.utc(2012, 11, 8, 11, 19, 59.9)))).to eq '11 months'
|
70
|
-
end
|
71
|
-
it "returns \"a year\" if difference is 11.5 months" do
|
72
|
-
expect(@test.send(:distance_of_time_in_words, (Time.utc(2012, 11, 8, 11, 20, 0)))).to eq 'a year'
|
73
|
-
end
|
74
|
-
it "returns \"2 years\" if difference is 2 years" do
|
75
|
-
expect(@test.send(:distance_of_time_in_words, (Time.utc(2013, 11, 24, 16, 20, 0)))).to eq '2 years'
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
describe '#strip_tags' do
|
80
|
-
it 'returns string sans tags' do
|
81
|
-
expect(@test.send(:strip_tags, '<a href="http://twitter.com/#!/download/iphone" rel="nofollow">Twitter for iPhone</a>')).to eq 'Twitter for iPhone'
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
describe '#number_with_delimiter' do
|
86
|
-
it 'returns number with delimiter' do
|
87
|
-
expect(@test.send(:number_with_delimiter, 1_234_567_890)).to eq '1,234,567,890'
|
88
|
-
end
|
89
|
-
context 'with custom delimiter' do
|
90
|
-
it 'returns number with custom delimiter' do
|
91
|
-
expect(@test.send(:number_with_delimiter, 1_234_567_890, '.')).to eq '1.234.567.890'
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
end
|