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.tar.gz.sig +0 -0
- data/CONTRIBUTING.md +1 -1
- data/README.md +12 -12
- data/Rakefile +11 -1
- data/bin/t +11 -11
- data/lib/t.rb +7 -9
- data/lib/t/cli.rb +299 -360
- data/lib/t/collectable.rb +2 -4
- data/lib/t/core_ext/kernel.rb +3 -5
- data/lib/t/core_ext/string.rb +4 -6
- data/lib/t/delete.rb +27 -29
- data/lib/t/editor.rb +1 -3
- data/lib/t/list.rb +44 -45
- data/lib/t/printable.rb +43 -44
- data/lib/t/rcfile.rb +4 -5
- data/lib/t/requestable.rb +1 -3
- data/lib/t/search.rb +42 -55
- data/lib/t/set.rb +11 -12
- data/lib/t/stream.rb +24 -20
- data/lib/t/utils.rb +20 -28
- data/lib/t/version.rb +1 -3
- data/spec/cli_spec.rb +1241 -1242
- data/spec/delete_spec.rb +122 -122
- data/spec/editor_spec.rb +42 -42
- data/spec/fixtures/lists.json +1 -1
- data/spec/fixtures/locations.json +1 -1
- data/spec/helper.rb +17 -13
- data/spec/list_spec.rb +202 -202
- data/spec/rcfile_spec.rb +73 -73
- data/spec/search_spec.rb +398 -398
- data/spec/set_spec.rb +72 -72
- data/spec/stream_spec.rb +56 -56
- data/spec/utils_spec.rb +29 -29
- data/t.gemspec +1 -1
- metadata +56 -32
- metadata.gz.sig +0 -0
- checksums.yaml +0 -7
- checksums.yaml.gz.sig +0 -0
data/spec/delete_spec.rb
CHANGED
@@ -4,7 +4,7 @@ require 'helper'
|
|
4
4
|
describe T::Delete do
|
5
5
|
|
6
6
|
before :each do
|
7
|
-
T::RCFile.instance.path = fixture_path +
|
7
|
+
T::RCFile.instance.path = fixture_path + '/.trc'
|
8
8
|
@delete = T::Delete.new
|
9
9
|
@old_stderr = $stderr
|
10
10
|
$stderr = StringIO.new
|
@@ -18,218 +18,218 @@ describe T::Delete do
|
|
18
18
|
$stdout = @old_stdout
|
19
19
|
end
|
20
20
|
|
21
|
-
describe
|
21
|
+
describe '#block' do
|
22
22
|
before do
|
23
|
-
@delete.options = @delete.options.merge(
|
24
|
-
stub_post(
|
23
|
+
@delete.options = @delete.options.merge('profile' => fixture_path + '/.trc')
|
24
|
+
stub_post('/1.1/blocks/destroy.json').with(:body => {:screen_name => 'sferik'}).to_return(:body => fixture('sferik.json'))
|
25
25
|
end
|
26
|
-
it
|
27
|
-
@delete.block(
|
28
|
-
expect(a_post(
|
26
|
+
it 'requests the correct resource' do
|
27
|
+
@delete.block('sferik')
|
28
|
+
expect(a_post('/1.1/blocks/destroy.json').with(:body => {:screen_name => 'sferik'})).to have_been_made
|
29
29
|
end
|
30
|
-
it
|
31
|
-
@delete.block(
|
30
|
+
it 'has the correct output' do
|
31
|
+
@delete.block('sferik')
|
32
32
|
expect($stdout.string).to match /^@testcli unblocked 1 user\.$/
|
33
33
|
end
|
34
|
-
context
|
34
|
+
context '--id' do
|
35
35
|
before do
|
36
|
-
@delete.options = @delete.options.merge(
|
37
|
-
stub_post(
|
36
|
+
@delete.options = @delete.options.merge('id' => true)
|
37
|
+
stub_post('/1.1/blocks/destroy.json').with(:body => {:user_id => '7505382'}).to_return(:body => fixture('sferik.json'))
|
38
38
|
end
|
39
|
-
it
|
40
|
-
@delete.block(
|
41
|
-
expect(a_post(
|
39
|
+
it 'requests the correct resource' do
|
40
|
+
@delete.block('7505382')
|
41
|
+
expect(a_post('/1.1/blocks/destroy.json').with(:body => {:user_id => '7505382'})).to have_been_made
|
42
42
|
end
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
|
-
describe
|
46
|
+
describe '#dm' do
|
47
47
|
before do
|
48
|
-
@delete.options = @delete.options.merge(
|
49
|
-
stub_get(
|
50
|
-
stub_post(
|
48
|
+
@delete.options = @delete.options.merge('profile' => fixture_path + '/.trc')
|
49
|
+
stub_get('/1.1/direct_messages/show.json').with(:query => {:id => '1773478249'}).to_return(:body => fixture('direct_message.json'))
|
50
|
+
stub_post('/1.1/direct_messages/destroy.json').with(:body => {:id => '1773478249'}).to_return(:body => fixture('direct_message.json'))
|
51
51
|
end
|
52
|
-
it
|
52
|
+
it 'requests the correct resource' do
|
53
53
|
expect($stdout).to receive(:print).with("Are you sure you want to permanently delete the direct message to @pengwynn: \"Creating a fixture for the Twitter gem\"? [y/N] ")
|
54
|
-
expect($stdin).to receive(:gets).and_return(
|
55
|
-
@delete.dm(
|
56
|
-
expect(a_get(
|
57
|
-
expect(a_post(
|
54
|
+
expect($stdin).to receive(:gets).and_return('yes')
|
55
|
+
@delete.dm('1773478249')
|
56
|
+
expect(a_get('/1.1/direct_messages/show.json').with(:query => {:id => '1773478249'})).to have_been_made
|
57
|
+
expect(a_post('/1.1/direct_messages/destroy.json').with(:body => {:id => '1773478249'})).to have_been_made
|
58
58
|
end
|
59
|
-
context
|
60
|
-
it
|
59
|
+
context 'yes' do
|
60
|
+
it 'has the correct output' do
|
61
61
|
expect($stdout).to receive(:print).with("Are you sure you want to permanently delete the direct message to @pengwynn: \"Creating a fixture for the Twitter gem\"? [y/N] ")
|
62
|
-
expect($stdin).to receive(:gets).and_return(
|
63
|
-
@delete.dm(
|
62
|
+
expect($stdin).to receive(:gets).and_return('yes')
|
63
|
+
@delete.dm('1773478249')
|
64
64
|
expect($stdout.string.chomp).to eq "@testcli deleted the direct message sent to @pengwynn: \"Creating a fixture for the Twitter gem\""
|
65
65
|
end
|
66
66
|
end
|
67
|
-
context
|
68
|
-
it
|
67
|
+
context 'no' do
|
68
|
+
it 'has the correct output' do
|
69
69
|
expect($stdout).to receive(:print).with("Are you sure you want to permanently delete the direct message to @pengwynn: \"Creating a fixture for the Twitter gem\"? [y/N] ")
|
70
|
-
expect($stdin).to receive(:gets).and_return(
|
71
|
-
@delete.dm(
|
70
|
+
expect($stdin).to receive(:gets).and_return('no')
|
71
|
+
@delete.dm('1773478249')
|
72
72
|
expect($stdout.string.chomp).to be_empty
|
73
73
|
end
|
74
74
|
end
|
75
|
-
context
|
75
|
+
context '--force' do
|
76
76
|
before do
|
77
|
-
@delete.options = @delete.options.merge(
|
77
|
+
@delete.options = @delete.options.merge('force' => true)
|
78
78
|
end
|
79
|
-
it
|
80
|
-
@delete.dm(
|
81
|
-
expect(a_post(
|
79
|
+
it 'requests the correct resource' do
|
80
|
+
@delete.dm('1773478249')
|
81
|
+
expect(a_post('/1.1/direct_messages/destroy.json').with(:body => {:id => '1773478249'})).to have_been_made
|
82
82
|
end
|
83
|
-
it
|
84
|
-
@delete.dm(
|
83
|
+
it 'has the correct output' do
|
84
|
+
@delete.dm('1773478249')
|
85
85
|
expect($stdout.string.chomp).to eq "@testcli deleted the direct message sent to @pengwynn: \"Creating a fixture for the Twitter gem\""
|
86
86
|
end
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
90
|
-
describe
|
90
|
+
describe '#favorite' do
|
91
91
|
before do
|
92
|
-
@delete.options = @delete.options.merge(
|
93
|
-
stub_get(
|
94
|
-
stub_post(
|
92
|
+
@delete.options = @delete.options.merge('profile' => fixture_path + '/.trc')
|
93
|
+
stub_get('/1.1/statuses/show/28439861609.json').with(:query => {:include_my_retweet => 'false'}).to_return(:body => fixture('status.json'))
|
94
|
+
stub_post('/1.1/favorites/destroy.json').with(:body => {:id => '28439861609'}).to_return(:body => fixture('status.json'))
|
95
95
|
end
|
96
|
-
it
|
96
|
+
it 'requests the correct resource' do
|
97
97
|
expect($stdout).to receive(:print).with("Are you sure you want to remove @sferik's status: \"The problem with your code is that it's doing exactly what you told it to do.\" from your favorites? [y/N] ")
|
98
|
-
expect($stdin).to receive(:gets).and_return(
|
99
|
-
@delete.favorite(
|
100
|
-
expect(a_get(
|
101
|
-
expect(a_post(
|
98
|
+
expect($stdin).to receive(:gets).and_return('yes')
|
99
|
+
@delete.favorite('28439861609')
|
100
|
+
expect(a_get('/1.1/statuses/show/28439861609.json').with(:query => {:include_my_retweet => 'false'})).to have_been_made
|
101
|
+
expect(a_post('/1.1/favorites/destroy.json').with(:body => {:id => '28439861609'})).to have_been_made
|
102
102
|
end
|
103
|
-
context
|
104
|
-
it
|
103
|
+
context 'yes' do
|
104
|
+
it 'has the correct output' do
|
105
105
|
expect($stdout).to receive(:print).with("Are you sure you want to remove @sferik's status: \"The problem with your code is that it's doing exactly what you told it to do.\" from your favorites? [y/N] ")
|
106
|
-
expect($stdin).to receive(:gets).and_return(
|
107
|
-
@delete.favorite(
|
106
|
+
expect($stdin).to receive(:gets).and_return('yes')
|
107
|
+
@delete.favorite('28439861609')
|
108
108
|
expect($stdout.string).to match /^@testcli unfavorited @sferik's status: "The problem with your code is that it's doing exactly what you told it to do\."$/
|
109
109
|
end
|
110
110
|
end
|
111
|
-
context
|
112
|
-
it
|
111
|
+
context 'no' do
|
112
|
+
it 'has the correct output' do
|
113
113
|
expect($stdout).to receive(:print).with("Are you sure you want to remove @sferik's status: \"The problem with your code is that it's doing exactly what you told it to do.\" from your favorites? [y/N] ")
|
114
|
-
expect($stdin).to receive(:gets).and_return(
|
115
|
-
@delete.favorite(
|
114
|
+
expect($stdin).to receive(:gets).and_return('no')
|
115
|
+
@delete.favorite('28439861609')
|
116
116
|
expect($stdout.string.chomp).to be_empty
|
117
117
|
end
|
118
118
|
end
|
119
|
-
context
|
119
|
+
context '--force' do
|
120
120
|
before do
|
121
|
-
@delete.options = @delete.options.merge(
|
121
|
+
@delete.options = @delete.options.merge('force' => true)
|
122
122
|
end
|
123
|
-
it
|
124
|
-
@delete.favorite(
|
125
|
-
expect(a_post(
|
123
|
+
it 'requests the correct resource' do
|
124
|
+
@delete.favorite('28439861609')
|
125
|
+
expect(a_post('/1.1/favorites/destroy.json').with(:body => {:id => '28439861609'})).to have_been_made
|
126
126
|
end
|
127
|
-
it
|
128
|
-
@delete.favorite(
|
127
|
+
it 'has the correct output' do
|
128
|
+
@delete.favorite('28439861609')
|
129
129
|
expect($stdout.string).to match /^@testcli unfavorited @sferik's status: "The problem with your code is that it's doing exactly what you told it to do\."$/
|
130
130
|
end
|
131
131
|
end
|
132
132
|
end
|
133
133
|
|
134
|
-
describe
|
134
|
+
describe '#list' do
|
135
135
|
before do
|
136
|
-
@delete.options = @delete.options.merge(
|
137
|
-
stub_get(
|
138
|
-
stub_get(
|
139
|
-
stub_post(
|
136
|
+
@delete.options = @delete.options.merge('profile' => fixture_path + '/.trc')
|
137
|
+
stub_get('/1.1/account/verify_credentials.json').to_return(:body => fixture('sferik.json'))
|
138
|
+
stub_get('/1.1/lists/show.json').with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents'}).to_return(:body => fixture('list.json'))
|
139
|
+
stub_post('/1.1/lists/destroy.json').with(:body => {:owner_id => '7505382', :list_id => '8863586'}).to_return(:body => fixture('list.json'))
|
140
140
|
end
|
141
|
-
it
|
141
|
+
it 'requests the correct resource' do
|
142
142
|
expect($stdout).to receive(:print).with("Are you sure you want to permanently delete the list \"presidents\"? [y/N] ")
|
143
|
-
expect($stdin).to receive(:gets).and_return(
|
144
|
-
@delete.list(
|
145
|
-
expect(a_get(
|
146
|
-
expect(a_post(
|
143
|
+
expect($stdin).to receive(:gets).and_return('yes')
|
144
|
+
@delete.list('presidents')
|
145
|
+
expect(a_get('/1.1/account/verify_credentials.json')).to have_been_made
|
146
|
+
expect(a_post('/1.1/lists/destroy.json').with(:body => {:owner_id => '7505382', :list_id => '8863586'})).to have_been_made
|
147
147
|
end
|
148
|
-
context
|
149
|
-
it
|
148
|
+
context 'yes' do
|
149
|
+
it 'has the correct output' do
|
150
150
|
expect($stdout).to receive(:print).with("Are you sure you want to permanently delete the list \"presidents\"? [y/N] ")
|
151
|
-
expect($stdin).to receive(:gets).and_return(
|
152
|
-
@delete.list(
|
151
|
+
expect($stdin).to receive(:gets).and_return('yes')
|
152
|
+
@delete.list('presidents')
|
153
153
|
expect($stdout.string.chomp).to eq "@testcli deleted the list \"presidents\"."
|
154
154
|
end
|
155
155
|
end
|
156
|
-
context
|
157
|
-
it
|
156
|
+
context 'no' do
|
157
|
+
it 'has the correct output' do
|
158
158
|
expect($stdout).to receive(:print).with("Are you sure you want to permanently delete the list \"presidents\"? [y/N] ")
|
159
|
-
expect($stdin).to receive(:gets).and_return(
|
160
|
-
@delete.list(
|
159
|
+
expect($stdin).to receive(:gets).and_return('no')
|
160
|
+
@delete.list('presidents')
|
161
161
|
expect($stdout.string.chomp).to be_empty
|
162
162
|
end
|
163
163
|
end
|
164
|
-
context
|
164
|
+
context '--force' do
|
165
165
|
before do
|
166
|
-
@delete.options = @delete.options.merge(
|
166
|
+
@delete.options = @delete.options.merge('force' => true)
|
167
167
|
end
|
168
|
-
it
|
169
|
-
@delete.list(
|
170
|
-
expect(a_get(
|
171
|
-
expect(a_post(
|
168
|
+
it 'requests the correct resource' do
|
169
|
+
@delete.list('presidents')
|
170
|
+
expect(a_get('/1.1/account/verify_credentials.json')).to have_been_made
|
171
|
+
expect(a_post('/1.1/lists/destroy.json').with(:body => {:owner_id => '7505382', :list_id => '8863586'})).to have_been_made
|
172
172
|
end
|
173
|
-
it
|
174
|
-
@delete.list(
|
173
|
+
it 'has the correct output' do
|
174
|
+
@delete.list('presidents')
|
175
175
|
expect($stdout.string.chomp).to eq "@testcli deleted the list \"presidents\"."
|
176
176
|
end
|
177
177
|
end
|
178
|
-
context
|
178
|
+
context '--id' do
|
179
179
|
before do
|
180
|
-
@delete.options = @delete.options.merge(
|
181
|
-
stub_get(
|
180
|
+
@delete.options = @delete.options.merge('id' => true)
|
181
|
+
stub_get('/1.1/lists/show.json').with(:query => {:owner_screen_name => 'sferik', :list_id => '8863586'}).to_return(:body => fixture('list.json'))
|
182
182
|
end
|
183
|
-
it
|
183
|
+
it 'requests the correct resource' do
|
184
184
|
expect($stdout).to receive(:print).with("Are you sure you want to permanently delete the list \"presidents\"? [y/N] ")
|
185
|
-
expect($stdin).to receive(:gets).and_return(
|
186
|
-
@delete.list(
|
187
|
-
expect(a_get(
|
188
|
-
expect(a_get(
|
189
|
-
expect(a_post(
|
185
|
+
expect($stdin).to receive(:gets).and_return('yes')
|
186
|
+
@delete.list('8863586')
|
187
|
+
expect(a_get('/1.1/lists/show.json').with(:query => {:owner_screen_name => 'sferik', :list_id => '8863586'})).to have_been_made
|
188
|
+
expect(a_get('/1.1/account/verify_credentials.json')).to have_been_made
|
189
|
+
expect(a_post('/1.1/lists/destroy.json').with(:body => {:owner_id => '7505382', :list_id => '8863586'})).to have_been_made
|
190
190
|
end
|
191
191
|
end
|
192
192
|
end
|
193
193
|
|
194
|
-
describe
|
194
|
+
describe '#status' do
|
195
195
|
before do
|
196
|
-
@delete.options = @delete.options.merge(
|
197
|
-
stub_get(
|
198
|
-
stub_post(
|
196
|
+
@delete.options = @delete.options.merge('profile' => fixture_path + '/.trc')
|
197
|
+
stub_get('/1.1/statuses/show/26755176471724032.json').with(:query => {:include_my_retweet => 'false'}).to_return(:body => fixture('status.json'))
|
198
|
+
stub_post('/1.1/statuses/destroy/26755176471724032.json').with(:body => {:trim_user => 'true'}).to_return(:body => fixture('status.json'))
|
199
199
|
end
|
200
|
-
it
|
200
|
+
it 'requests the correct resource' do
|
201
201
|
expect($stdout).to receive(:print).with("Are you sure you want to permanently delete @sferik's status: \"The problem with your code is that it's doing exactly what you told it to do.\"? [y/N] ")
|
202
|
-
expect($stdin).to receive(:gets).and_return(
|
203
|
-
@delete.status(
|
204
|
-
expect(a_get(
|
205
|
-
expect(a_post(
|
202
|
+
expect($stdin).to receive(:gets).and_return('yes')
|
203
|
+
@delete.status('26755176471724032')
|
204
|
+
expect(a_get('/1.1/statuses/show/26755176471724032.json').with(:query => {:include_my_retweet => 'false'})).to have_been_made
|
205
|
+
expect(a_post('/1.1/statuses/destroy/26755176471724032.json').with(:body => {:trim_user => 'true'})).to have_been_made
|
206
206
|
end
|
207
|
-
context
|
208
|
-
it
|
207
|
+
context 'yes' do
|
208
|
+
it 'has the correct output' do
|
209
209
|
expect($stdout).to receive(:print).with("Are you sure you want to permanently delete @sferik's status: \"The problem with your code is that it's doing exactly what you told it to do.\"? [y/N] ")
|
210
|
-
expect($stdin).to receive(:gets).and_return(
|
211
|
-
@delete.status(
|
210
|
+
expect($stdin).to receive(:gets).and_return('yes')
|
211
|
+
@delete.status('26755176471724032')
|
212
212
|
expect($stdout.string.chomp).to eq "@testcli deleted the Tweet: \"The problem with your code is that it's doing exactly what you told it to do.\""
|
213
213
|
end
|
214
214
|
end
|
215
|
-
context
|
216
|
-
it
|
215
|
+
context 'no' do
|
216
|
+
it 'has the correct output' do
|
217
217
|
expect($stdout).to receive(:print).with("Are you sure you want to permanently delete @sferik's status: \"The problem with your code is that it's doing exactly what you told it to do.\"? [y/N] ")
|
218
|
-
expect($stdin).to receive(:gets).and_return(
|
219
|
-
@delete.status(
|
218
|
+
expect($stdin).to receive(:gets).and_return('no')
|
219
|
+
@delete.status('26755176471724032')
|
220
220
|
expect($stdout.string.chomp).to be_empty
|
221
221
|
end
|
222
222
|
end
|
223
|
-
context
|
223
|
+
context '--force' do
|
224
224
|
before do
|
225
|
-
@delete.options = @delete.options.merge(
|
225
|
+
@delete.options = @delete.options.merge('force' => true)
|
226
226
|
end
|
227
|
-
it
|
228
|
-
@delete.status(
|
229
|
-
expect(a_post(
|
227
|
+
it 'requests the correct resource' do
|
228
|
+
@delete.status('26755176471724032')
|
229
|
+
expect(a_post('/1.1/statuses/destroy/26755176471724032.json').with(:body => {:trim_user => 'true'})).to have_been_made
|
230
230
|
end
|
231
|
-
it
|
232
|
-
@delete.status(
|
231
|
+
it 'has the correct output' do
|
232
|
+
@delete.status('26755176471724032')
|
233
233
|
expect($stdout.string.chomp).to eq "@testcli deleted the Tweet: \"The problem with your code is that it's doing exactly what you told it to do.\""
|
234
234
|
end
|
235
235
|
end
|
data/spec/editor_spec.rb
CHANGED
@@ -3,98 +3,98 @@ require 'helper'
|
|
3
3
|
|
4
4
|
describe T::Editor do
|
5
5
|
|
6
|
-
context
|
6
|
+
context 'when editing a file' do
|
7
7
|
before do
|
8
8
|
T::Editor.stub(:edit) do |path|
|
9
|
-
File.open(path,
|
10
|
-
f.write(
|
9
|
+
File.open(path, 'wb') do |f|
|
10
|
+
f.write('A tweet!!!!')
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
-
it
|
16
|
-
expect(T::Editor.gets).to eq(
|
15
|
+
it 'fetches your tweet content without comments' do
|
16
|
+
expect(T::Editor.gets).to eq('A tweet!!!!')
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
-
context
|
21
|
-
context
|
20
|
+
context 'when fetching the editor to write in' do
|
21
|
+
context 'no $VISUAL or $EDITOR set' do
|
22
22
|
before do
|
23
|
-
ENV[
|
23
|
+
ENV['EDITOR'] = ENV['VISUAL'] = nil
|
24
24
|
end
|
25
25
|
|
26
|
-
context
|
27
|
-
it
|
28
|
-
RbConfig::CONFIG['host_os'] =
|
29
|
-
expect(T::Editor.editor).to eq(
|
26
|
+
context 'host_os is Mac OSX' do
|
27
|
+
it 'returns the system editor' do
|
28
|
+
RbConfig::CONFIG['host_os'] = 'darwin12.2.0'
|
29
|
+
expect(T::Editor.editor).to eq('vi')
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
-
context
|
34
|
-
it
|
35
|
-
RbConfig::CONFIG['host_os'] =
|
36
|
-
expect(T::Editor.editor).to eq(
|
33
|
+
context 'host_os is Linux' do
|
34
|
+
it 'returns the system editor' do
|
35
|
+
RbConfig::CONFIG['host_os'] = '3.2.0-4-amd64'
|
36
|
+
expect(T::Editor.editor).to eq('vi')
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
|
-
context
|
41
|
-
it
|
42
|
-
RbConfig::CONFIG['host_os'] =
|
43
|
-
expect(T::Editor.editor).to eq(
|
40
|
+
context 'host_os is Windows' do
|
41
|
+
it 'returns the system editor' do
|
42
|
+
RbConfig::CONFIG['host_os'] = 'mswin'
|
43
|
+
expect(T::Editor.editor).to eq('notepad')
|
44
44
|
end
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
|
-
context
|
48
|
+
context '$VISUAL is set' do
|
49
49
|
before do
|
50
|
-
ENV[
|
51
|
-
ENV[
|
50
|
+
ENV['EDITOR'] = nil
|
51
|
+
ENV['VISUAL'] = '/my/vim/install'
|
52
52
|
end
|
53
53
|
|
54
|
-
it
|
55
|
-
expect(T::Editor.editor).to eq(
|
54
|
+
it 'returns the system editor' do
|
55
|
+
expect(T::Editor.editor).to eq('/my/vim/install')
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
|
-
context
|
59
|
+
context '$EDITOR is set' do
|
60
60
|
before do
|
61
|
-
ENV[
|
62
|
-
ENV[
|
61
|
+
ENV['EDITOR'] = '/usr/bin/subl'
|
62
|
+
ENV['VISUAL'] = nil
|
63
63
|
end
|
64
64
|
|
65
|
-
it
|
66
|
-
expect(T::Editor.editor).to eq(
|
65
|
+
it 'returns the system editor' do
|
66
|
+
expect(T::Editor.editor).to eq('/usr/bin/subl')
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
70
|
-
context
|
70
|
+
context '$VISUAL and $EDITOR are set' do
|
71
71
|
before do
|
72
|
-
ENV[
|
73
|
-
ENV[
|
72
|
+
ENV['EDITOR'] = '/my/vastly/superior/editor'
|
73
|
+
ENV['VISUAL'] = '/usr/bin/emacs'
|
74
74
|
end
|
75
75
|
|
76
|
-
it
|
77
|
-
expect(T::Editor.editor).to eq(
|
76
|
+
it 'returns the system editor' do
|
77
|
+
expect(T::Editor.editor).to eq('/usr/bin/emacs')
|
78
78
|
end
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
82
|
-
context
|
83
|
-
context
|
82
|
+
context 'when fetching system editor' do
|
83
|
+
context 'on a mac' do
|
84
84
|
before do
|
85
|
-
RbConfig::CONFIG['host_os'] =
|
85
|
+
RbConfig::CONFIG['host_os'] = 'darwin12.2.0'
|
86
86
|
end
|
87
87
|
it "returns 'vi' on a unix machine" do
|
88
|
-
expect(T::Editor.system_editor).to eq(
|
88
|
+
expect(T::Editor.system_editor).to eq('vi')
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
92
|
-
context
|
92
|
+
context 'on a Windows POC' do
|
93
93
|
before do
|
94
|
-
RbConfig::CONFIG['host_os'] =
|
94
|
+
RbConfig::CONFIG['host_os'] = 'mswin'
|
95
95
|
end
|
96
96
|
it "returns 'notepad' on a windows box" do
|
97
|
-
expect(T::Editor.system_editor).to eq(
|
97
|
+
expect(T::Editor.system_editor).to eq('notepad')
|
98
98
|
end
|
99
99
|
end
|
100
100
|
end
|