t 2.0.1 → 2.0.2

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/set_spec.rb CHANGED
@@ -4,7 +4,7 @@ require 'helper'
4
4
  describe T::Set do
5
5
 
6
6
  before :each do
7
- T::RCFile.instance.path = fixture_path + "/.trc"
7
+ T::RCFile.instance.path = fixture_path + '/.trc'
8
8
  @set = T::Set.new
9
9
  @old_stderr = $stderr
10
10
  $stderr = StringIO.new
@@ -18,135 +18,135 @@ describe T::Set do
18
18
  $stdout = @old_stdout
19
19
  end
20
20
 
21
- describe "#active" do
21
+ describe '#active' do
22
22
  before do
23
- @set.options = @set.options.merge("profile" => fixture_path + "/.trc_set")
23
+ @set.options = @set.options.merge('profile' => fixture_path + '/.trc_set')
24
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."
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
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."
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
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."
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
36
  end
37
- it "raises an error if username is ambiguous" do
37
+ it 'raises an error if username is ambiguous' do
38
38
  expect do
39
- @set.active("test", "abc123")
39
+ @set.active('test', 'abc123')
40
40
  end.to raise_error(ArgumentError, /Username test is ambiguous/)
41
41
  end
42
- it "raises an error if the username is not found" do
42
+ it 'raises an error if the username is not found' do
43
43
  expect do
44
- @set.active("clitest")
44
+ @set.active('clitest')
45
45
  end.to raise_error(ArgumentError, /Username clitest is not found/)
46
46
  end
47
47
  end
48
48
 
49
- describe "#bio" do
49
+ describe '#bio' do
50
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"))
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'))
53
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
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
57
  end
58
- it "has the correct output" do
59
- @set.bio("Vagabond.")
58
+ it 'has the correct output' do
59
+ @set.bio('Vagabond.')
60
60
  expect($stdout.string.chomp).to eq "@testcli's bio has been updated."
61
61
  end
62
62
  end
63
63
 
64
- describe "#language" do
64
+ describe '#language' do
65
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"))
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'))
68
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
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
72
  end
73
- it "has the correct output" do
74
- @set.language("en")
73
+ it 'has the correct output' do
74
+ @set.language('en')
75
75
  expect($stdout.string.chomp).to eq "@testcli's language has been updated."
76
76
  end
77
77
  end
78
78
 
79
- describe "#location" do
79
+ describe '#location' do
80
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"))
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'))
83
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
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
87
  end
88
- it "has the correct output" do
89
- @set.location("San Francisco")
88
+ it 'has the correct output' do
89
+ @set.location('San Francisco')
90
90
  expect($stdout.string.chomp).to eq "@testcli's location has been updated."
91
91
  end
92
92
  end
93
93
 
94
- describe "#name" do
94
+ describe '#name' do
95
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"))
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'))
98
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
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
102
  end
103
- it "has the correct output" do
104
- @set.name("Erik Michaels-Ober")
103
+ it 'has the correct output' do
104
+ @set.name('Erik Michaels-Ober')
105
105
  expect($stdout.string.chomp).to eq "@testcli's name has been updated."
106
106
  end
107
107
  end
108
108
 
109
- describe "#profile_background_image" do
109
+ describe '#profile_background_image' do
110
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"))
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'))
113
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
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
117
  end
118
- it "has the correct output" do
119
- @set.profile_background_image(fixture_path + "/we_concept_bg2.png")
118
+ it 'has the correct output' do
119
+ @set.profile_background_image(fixture_path + '/we_concept_bg2.png')
120
120
  expect($stdout.string.chomp).to eq "@testcli's background image has been updated."
121
121
  end
122
122
  end
123
123
 
124
- describe "#profile_image" do
124
+ describe '#profile_image' do
125
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"))
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'))
128
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
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
132
  end
133
- it "has the correct output" do
134
- @set.profile_image(fixture_path + "/me.jpg")
133
+ it 'has the correct output' do
134
+ @set.profile_image(fixture_path + '/me.jpg')
135
135
  expect($stdout.string.chomp).to eq "@testcli's image has been updated."
136
136
  end
137
137
  end
138
138
 
139
- describe "#website" do
139
+ describe '#website' do
140
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"))
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'))
143
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
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
147
  end
148
- it "has the correct output" do
149
- @set.website("https://github.com/sferik")
148
+ it 'has the correct output' do
149
+ @set.website('https://github.com/sferik')
150
150
  expect($stdout.string.chomp).to eq "@testcli's website has been updated."
151
151
  end
152
152
  end
data/spec/stream_spec.rb CHANGED
@@ -1,19 +1,19 @@
1
1
  require 'helper'
2
2
 
3
3
  describe T::Stream do
4
- let(:t_class) {
4
+ let(:t_class) do
5
5
  klass = Class.new
6
6
  allow(klass).to receive(:options=).and_return
7
7
  allow(klass).to receive(:options).and_return({})
8
8
  klass
9
- }
9
+ end
10
10
 
11
11
  before :all do
12
- @status = status_from_fixture("status.json")
12
+ @status = status_from_fixture('status.json')
13
13
  end
14
14
 
15
15
  before :each do
16
- T::RCFile.instance.path = fixture_path + "/.trc"
16
+ T::RCFile.instance.path = fixture_path + '/.trc'
17
17
  @client = double('Twitter::Streaming::Client').as_null_object
18
18
  @stream = T::Stream.new
19
19
  allow(@stream).to receive(:client) { @client }
@@ -21,18 +21,18 @@ describe T::Stream do
21
21
  allow(STDOUT).to receive(:tty?).and_return(true)
22
22
  end
23
23
 
24
- describe "#all" do
25
- context "--csv" do
24
+ describe '#all' do
25
+ context '--csv' do
26
26
  before :each do
27
- @stream.options = @stream.options.merge("csv" => true)
27
+ @stream.options = @stream.options.merge('csv' => true)
28
28
  end
29
- it "outputs headings when the stream initializes" do
29
+ it 'outputs headings when the stream initializes' do
30
30
  allow(@client).to receive(:sample).and_return
31
31
  allow(@client).to receive(:before_request).and_yield
32
32
  expect(@stream).to receive(:say).with("ID,Posted at,Screen name,Text\n")
33
33
  @stream.all
34
34
  end
35
- it "outputs in CSV format" do
35
+ it 'outputs in CSV format' do
36
36
  allow(@client).to receive(:before_request).and_return
37
37
  allow(@client).to receive(:sample).
38
38
  and_yield(@status)
@@ -41,19 +41,19 @@ describe T::Stream do
41
41
  end
42
42
  end
43
43
 
44
- context "--long" do
44
+ context '--long' do
45
45
  before :each do
46
- @stream.options = @stream.options.merge("long" => true)
46
+ @stream.options = @stream.options.merge('long' => true)
47
47
  end
48
48
 
49
- it "outputs headings when the stream initializes" do
49
+ it 'outputs headings when the stream initializes' do
50
50
  allow(@client).to receive(:before_request).and_yield
51
51
  allow(@client).to receive(:sample).and_return
52
52
  expect(@stream).to receive(:print_table).with(any_args)
53
53
  @stream.all
54
54
  end
55
55
 
56
- it "outputs in long text format" do
56
+ it 'outputs in long text format' do
57
57
  allow(@client).to receive(:before_request).and_return
58
58
  allow(@client).to receive(:sample).
59
59
  and_yield(@status)
@@ -62,85 +62,85 @@ describe T::Stream do
62
62
  end
63
63
  end
64
64
 
65
- context "normal usage" do
65
+ context 'normal usage' do
66
66
  before :each do
67
67
  allow(@client).to receive(:sample).
68
68
  and_yield(@status)
69
69
  end
70
70
 
71
- it "prints the tweet status" do
71
+ it 'prints the tweet status' do
72
72
  expect(@stream).to receive(:print_message)
73
73
  @stream.all
74
74
  end
75
75
  end
76
76
 
77
- it "invokes Twitter::Streaming::Client#sample" do
77
+ it 'invokes Twitter::Streaming::Client#sample' do
78
78
  expect(@client).to receive(:sample)
79
79
  @stream.all
80
80
  end
81
81
  end
82
82
 
83
- describe "#matrix" do
83
+ describe '#matrix' do
84
84
  before :each do
85
85
  allow(@client).to receive(:sample).
86
86
  and_yield(@status)
87
87
  end
88
88
 
89
- it "outputs the tweet status" do
89
+ it 'outputs the tweet status' do
90
90
  expect(@stream).to receive(:say).with(any_args)
91
91
  @stream.matrix
92
92
  end
93
93
 
94
- it "invokes Twitter::Streaming::Client.sample" do
94
+ it 'invokes Twitter::Streaming::Client.sample' do
95
95
  expect(@client).to receive(:sample)
96
96
  @stream.matrix
97
97
  end
98
98
  end
99
99
 
100
- describe "#search" do
100
+ describe '#search' do
101
101
  before :each do
102
- allow(@client).to receive(:filter).with(:track => ["gem"]).
102
+ allow(@client).to receive(:filter).with(:track => ['gem']).
103
103
  and_yield(@status)
104
104
  end
105
105
 
106
- context "--csv" do
106
+ context '--csv' do
107
107
  before :each do
108
- @stream.options = @stream.options.merge("csv" => true)
108
+ @stream.options = @stream.options.merge('csv' => true)
109
109
  end
110
110
 
111
- it "outputs in CSV format" do
111
+ it 'outputs in CSV format' do
112
112
  allow(@client).to receive(:before_request).and_return
113
113
  expect(@stream).to receive(:print_csv_tweet).with(any_args)
114
114
  @stream.search('gem')
115
115
  end
116
116
  end
117
117
 
118
- context "--long" do
118
+ context '--long' do
119
119
  before :each do
120
- @stream.options = @stream.options.merge("long" => true)
120
+ @stream.options = @stream.options.merge('long' => true)
121
121
  end
122
122
 
123
- it "outputs in long text format" do
123
+ it 'outputs in long text format' do
124
124
  allow(@client).to receive(:before_request).and_return
125
- allow(@client).to receive(:filter).with(:track => ["gem"]).
125
+ allow(@client).to receive(:filter).with(:track => ['gem']).
126
126
  and_yield(@status)
127
127
  expect(@stream).to receive(:print_table).with(any_args)
128
128
  @stream.search('gem')
129
129
  end
130
130
  end
131
131
 
132
- context "normal usage" do
132
+ context 'normal usage' do
133
133
  before :each do
134
- allow(@client).to receive(:filter).with(:track => ["gem"]).
134
+ allow(@client).to receive(:filter).with(:track => ['gem']).
135
135
  and_yield(@status)
136
136
  end
137
- it "prints the tweet status" do
137
+ it 'prints the tweet status' do
138
138
  expect(@stream).to receive(:print_message)
139
139
  @stream.search('gem')
140
140
  end
141
141
  end
142
142
 
143
- it "performs a REST search when the stream initializes" do
143
+ it 'performs a REST search when the stream initializes' do
144
144
  allow(@client).to receive(:filter).and_return
145
145
  allow(@client).to receive(:before_request).and_yield
146
146
  allow(T::Search).to receive(:new).and_return(t_class)
@@ -148,37 +148,37 @@ describe T::Stream do
148
148
  @stream.search('t', 'gem')
149
149
  end
150
150
 
151
- it "invokes Twitter::Streaming::Client#filter" do
151
+ it 'invokes Twitter::Streaming::Client#filter' do
152
152
  allow(@client).to receive(:filter).and_return
153
153
  expect(@client).to receive(:filter).with(:track => ['gem'])
154
154
  @stream.search('gem')
155
155
  end
156
156
  end
157
157
 
158
- describe "#timeline" do
158
+ describe '#timeline' do
159
159
  before :each do
160
160
  allow(@client).to receive(:user).
161
161
  and_yield(@status)
162
162
  end
163
163
 
164
- context "--csv" do
164
+ context '--csv' do
165
165
  before :each do
166
- @stream.options = @stream.options.merge("csv" => true)
166
+ @stream.options = @stream.options.merge('csv' => true)
167
167
  end
168
168
 
169
- it "outputs in CSV format" do
169
+ it 'outputs in CSV format' do
170
170
  allow(@client).to receive(:before_request).and_return
171
171
  expect(@stream).to receive(:print_csv_tweet).with(any_args)
172
172
  @stream.timeline
173
173
  end
174
174
  end
175
175
 
176
- context "--long" do
176
+ context '--long' do
177
177
  before :each do
178
- @stream.options = @stream.options.merge("long" => true)
178
+ @stream.options = @stream.options.merge('long' => true)
179
179
  end
180
180
 
181
- it "outputs in long text format" do
181
+ it 'outputs in long text format' do
182
182
  allow(@client).to receive(:before_request).and_return
183
183
  allow(@client).to receive(:user).
184
184
  and_yield(@status)
@@ -187,19 +187,19 @@ describe T::Stream do
187
187
  end
188
188
  end
189
189
 
190
- context "normal usage" do
190
+ context 'normal usage' do
191
191
  before :each do
192
192
  allow(@client).to receive(:user).
193
193
  and_yield(@status)
194
194
  end
195
195
 
196
- it "prints the tweet status" do
196
+ it 'prints the tweet status' do
197
197
  expect(@stream).to receive(:print_message)
198
198
  @stream.timeline
199
199
  end
200
200
  end
201
201
 
202
- it "performs a REST search when the stream initializes" do
202
+ it 'performs a REST search when the stream initializes' do
203
203
  allow(@client).to receive(:user).and_return
204
204
  allow(@client).to receive(:before_request).and_yield
205
205
  allow(T::CLI).to receive(:new).and_return(t_class)
@@ -208,51 +208,51 @@ describe T::Stream do
208
208
  @stream.timeline
209
209
  end
210
210
 
211
- it "invokes Twitter::Streaming::Client#userstream" do
211
+ it 'invokes Twitter::Streaming::Client#userstream' do
212
212
  allow(@client).to receive(:user).and_return
213
213
  expect(@client).to receive(:user)
214
214
  @stream.timeline
215
215
  end
216
216
  end
217
217
 
218
- describe "#users" do
218
+ describe '#users' do
219
219
  before :each do
220
220
  allow(@client).to receive(:follow).
221
221
  and_yield(@status)
222
222
  end
223
223
 
224
- context "--csv" do
224
+ context '--csv' do
225
225
  before :each do
226
- @stream.options = @stream.options.merge("csv" => true)
226
+ @stream.options = @stream.options.merge('csv' => true)
227
227
  end
228
228
 
229
- it "outputs headings when the stream initializes" do
229
+ it 'outputs headings when the stream initializes' do
230
230
  allow(@client).to receive(:follow).and_return
231
231
  allow(@client).to receive(:before_request).and_yield
232
232
  expect(@stream).to receive(:say).with("ID,Posted at,Screen name,Text\n")
233
233
  @stream.users('123')
234
234
  end
235
235
 
236
- it "outputs in CSV format" do
236
+ it 'outputs in CSV format' do
237
237
  allow(@client).to receive(:before_request).and_return
238
238
  expect(@stream).to receive(:print_csv_tweet).with(any_args)
239
239
  @stream.users('123')
240
240
  end
241
241
  end
242
242
 
243
- context "--long" do
243
+ context '--long' do
244
244
  before :each do
245
- @stream.options = @stream.options.merge("long" => true)
245
+ @stream.options = @stream.options.merge('long' => true)
246
246
  end
247
247
 
248
- it "outputs headings when the stream initializes" do
248
+ it 'outputs headings when the stream initializes' do
249
249
  allow(@client).to receive(:before_request).and_yield
250
250
  allow(@client).to receive(:follow).and_return
251
251
  expect(@stream).to receive(:print_table).with(any_args)
252
252
  @stream.users('123')
253
253
  end
254
254
 
255
- it "outputs in long text format" do
255
+ it 'outputs in long text format' do
256
256
  allow(@client).to receive(:before_request).and_return
257
257
  allow(@client).to receive(:follow).
258
258
  and_yield(@status)
@@ -261,19 +261,19 @@ describe T::Stream do
261
261
  end
262
262
  end
263
263
 
264
- context "normal usage" do
264
+ context 'normal usage' do
265
265
  before :each do
266
266
  allow(@client).to receive(:follow).
267
267
  and_yield(@status)
268
268
  end
269
269
 
270
- it "prints the tweet status" do
270
+ it 'prints the tweet status' do
271
271
  expect(@stream).to receive(:print_message)
272
272
  @stream.users('123')
273
273
  end
274
274
  end
275
275
 
276
- it "invokes Twitter::Streaming::Client#follow" do
276
+ it 'invokes Twitter::Streaming::Client#follow' do
277
277
  allow(@client).to receive(:follow).and_return
278
278
  expect(@client).to receive(:follow).with([123, 456, 789])
279
279
  @stream.users('123', '456', '789')