stickyflag 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/TODO.md +2 -1
- data/lib/stickyflag/version.rb +1 -1
- data/stickyflag.gemspec +5 -4
- metadata +8 -116
- data/.gitignore +0 -7
- data/.rspec +0 -4
- data/.simplecov +0 -9
- data/.travis.yml +0 -13
- data/features/clear.feature +0 -14
- data/features/clear_quietly.feature +0 -23
- data/features/configuration.feature +0 -14
- data/features/get.feature +0 -14
- data/features/get_quietly.feature +0 -23
- data/features/set.feature +0 -14
- data/features/set_quietly.feature +0 -22
- data/features/step_definitions/configuration_steps.rb +0 -31
- data/features/step_definitions/database_steps.rb +0 -41
- data/features/step_definitions/pending_steps.rb +0 -5
- data/features/step_definitions/tag_steps.rb +0 -62
- data/features/support/cukegem.rb +0 -82
- data/features/support/env.rb +0 -37
- data/features/tags.feature +0 -18
- data/features/unset.feature +0 -14
- data/features/unset_quietly.feature +0 -23
- data/spec/spec_helper.rb +0 -22
- data/spec/stickyflag/configuration_spec.rb +0 -132
- data/spec/stickyflag/database_spec.rb +0 -331
- data/spec/stickyflag/external_cmds_spec.rb +0 -175
- data/spec/stickyflag/patches/tempfile_encoding_spec.rb +0 -26
- data/spec/stickyflag/patches/tmpnam_spec.rb +0 -35
- data/spec/stickyflag/paths_spec.rb +0 -29
- data/spec/stickyflag/tag_factory_spec.rb +0 -126
- data/spec/stickyflag/tags/c_spec.rb +0 -14
- data/spec/stickyflag/tags/mkv_spec.rb +0 -54
- data/spec/stickyflag/tags/mmd_spec.rb +0 -40
- data/spec/stickyflag/tags/pdf_spec.rb +0 -39
- data/spec/stickyflag/tags/png_spec.rb +0 -6
- data/spec/stickyflag/tags/tex_spec.rb +0 -6
- data/spec/stickyflag_spec.rb +0 -482
- data/spec/support/examples.rb +0 -32
- data/spec/support/examples/c_all_comments.c +0 -3
- data/spec/support/examples/c_no_tags.c +0 -5
- data/spec/support/examples/c_with_tag.c +0 -6
- data/spec/support/examples/mkv_no_tags.mkv +0 -0
- data/spec/support/examples/mkv_with_tag.mkv +0 -0
- data/spec/support/examples/mmd_all_meta.mmd +0 -6
- data/spec/support/examples/mmd_crazy_keys.mmd +0 -8
- data/spec/support/examples/mmd_crazy_tags.mmd +0 -9
- data/spec/support/examples/mmd_no_tags.mmd +0 -1
- data/spec/support/examples/mmd_with_tag.mmd +0 -3
- data/spec/support/examples/pdf_no_tags.pdf +0 -0
- data/spec/support/examples/pdf_with_tag.pdf +0 -0
- data/spec/support/examples/png_no_tags.png +0 -0
- data/spec/support/examples/png_with_tag.png +0 -0
- data/spec/support/examples/tex_no_tags.tex +0 -10
- data/spec/support/examples/tex_with_tag.tex +0 -11
- data/spec/support/examples/untaggable.txt +0 -0
- data/spec/support/run_with_args.rb +0 -36
- data/spec/support/silence_stream.rb +0 -12
- data/spec/support/tag_handler_behavior.rb +0 -125
@@ -1,40 +0,0 @@
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
2
|
-
require 'stickyflag/tags/mmd'
|
3
|
-
|
4
|
-
describe StickyFlag::Tags::MMD do
|
5
|
-
it_behaves_like 'a tag handler'
|
6
|
-
|
7
|
-
it 'handles multiline metadata documents' do
|
8
|
-
StickyFlag::Tags::MMD.get(example_path('mmd_crazy_keys.mmd')).should include('test')
|
9
|
-
end
|
10
|
-
|
11
|
-
it 'handles multiline tag documents' do
|
12
|
-
StickyFlag::Tags::MMD.get(example_path('mmd_crazy_tags.mmd')).should include('sdfg')
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'handles all-metadata documents' do
|
16
|
-
StickyFlag::Tags::MMD.get(example_path('mmd_all_meta.mmd')).should be_empty
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'can edit multiline metadata documents' do
|
20
|
-
path = copy_example('mmd_crazy_keys.mmd')
|
21
|
-
|
22
|
-
StickyFlag::Tags::MMD.set(path, 'test2')
|
23
|
-
StickyFlag::Tags::MMD.get(path).should include('test2')
|
24
|
-
|
25
|
-
File.open(path, 'r:UTF-8').each_line.to_a.should include("Tags: test, test2 \n")
|
26
|
-
|
27
|
-
File.delete path
|
28
|
-
end
|
29
|
-
|
30
|
-
it 'can edit multiline tag documents' do
|
31
|
-
path = copy_example('mmd_crazy_tags.mmd')
|
32
|
-
|
33
|
-
StickyFlag::Tags::MMD.set(path, 'test2')
|
34
|
-
StickyFlag::Tags::MMD.get(path).should include('test2')
|
35
|
-
|
36
|
-
File.open(path, 'r:UTF-8').each_line.to_a.should include("Tags: asdf, sdfg, dfgh, fghj, qwer, test2 \n")
|
37
|
-
|
38
|
-
File.delete path
|
39
|
-
end
|
40
|
-
end
|
@@ -1,39 +0,0 @@
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
2
|
-
require 'stickyflag/tags/pdf'
|
3
|
-
require 'stickyflag/paths'
|
4
|
-
require 'stickyflag/configuration'
|
5
|
-
require 'stickyflag/external_cmds'
|
6
|
-
|
7
|
-
class GetConfiguration
|
8
|
-
include StickyFlag::Paths
|
9
|
-
include StickyFlag::Configuration
|
10
|
-
include StickyFlag::ExternalCmds
|
11
|
-
end
|
12
|
-
|
13
|
-
describe StickyFlag::Tags::PDF do
|
14
|
-
it_behaves_like 'a tag handler' do
|
15
|
-
let(:params) {
|
16
|
-
config = GetConfiguration.new
|
17
|
-
config.stub(:load_config!) { }
|
18
|
-
config.stub(:save_config!) { }
|
19
|
-
|
20
|
-
config.find_external_cmds
|
21
|
-
|
22
|
-
[ config.get_config(:pdftk_path) ]
|
23
|
-
}
|
24
|
-
end
|
25
|
-
|
26
|
-
context 'with a bad pdftk path' do
|
27
|
-
it 'raises errors for everything' do
|
28
|
-
expect { StickyFlag::Tags::PDF.get(example_path("pdf_with_tag.pdf"), '/wut/bad') }.to raise_error(Thor::Error)
|
29
|
-
expect { StickyFlag::Tags::PDF.clear(example_path("pdf_with_tag.pdf"), '/wut/bad') }.to raise_error(Thor::Error)
|
30
|
-
|
31
|
-
# If get doesn't succeed, we won't get all the way into set or unset
|
32
|
-
# with the bad pdftk path.
|
33
|
-
StickyFlag::Tags::PDF.stub(:get) { [ 'test' ] }
|
34
|
-
expect { StickyFlag::Tags::PDF.set(example_path("pdf_with_tag.pdf"), 'test2', '/wut/bad') }.to raise_error(Thor::Error)
|
35
|
-
expect { StickyFlag::Tags::PDF.unset(example_path("pdf_with_tag.pdf"), 'test', '/wut/bad') }.to raise_error(Thor::Error)
|
36
|
-
StickyFlag::Tags::PDF.unstub(:get)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
data/spec/stickyflag_spec.rb
DELETED
@@ -1,482 +0,0 @@
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
2
|
-
require 'thor'
|
3
|
-
require 'stickyflag'
|
4
|
-
|
5
|
-
describe 'StickyFlag' do
|
6
|
-
describe '#config' do
|
7
|
-
context 'without any further parameters' do
|
8
|
-
it 'prints out the configuration' do
|
9
|
-
run_with_args('config') do |sf|
|
10
|
-
sf.should_receive(:dump_config)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
context 'with --reset' do
|
16
|
-
it 'resets the configuration' do
|
17
|
-
run_with_args('config', '--reset') do |sf|
|
18
|
-
sf.should_receive(:reset_config!)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
context 'with --list' do
|
24
|
-
it 'prints out the configuration' do
|
25
|
-
run_with_args('config', '--list') do |sf|
|
26
|
-
sf.should_receive(:dump_config)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
it 'prints out the configuration with --quiet' do
|
31
|
-
run_with_args('config', '--list', '--quiet') do |sf|
|
32
|
-
sf.should_receive(:dump_config)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
context 'with a key but no value' do
|
38
|
-
it 'prints the value for that configuration item' do
|
39
|
-
run_with_args('config', '--key', 'root') do |sf|
|
40
|
-
sf.set_config :root, "/usr"
|
41
|
-
sf.should_receive(:say).with("root: '/usr'")
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
context 'with a value but no key' do
|
47
|
-
it 'raises an error' do
|
48
|
-
expect {
|
49
|
-
run_with_args('config', 'asdf')
|
50
|
-
}.to raise_error
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
context 'with a key and a value' do
|
55
|
-
it 'sets the configuration value' do
|
56
|
-
run_with_args('config', '--key', 'root', '/usr') do |sf|
|
57
|
-
sf.set_config :root, ''
|
58
|
-
sf.should_receive(:set_config).with('root', '/usr')
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
it 'prints the new value' do
|
63
|
-
run_with_args('config', '--key', 'root', '/usr') do |sf|
|
64
|
-
sf.set_config :root, ''
|
65
|
-
sf.should_receive(:say).with("'root' set to '/usr'")
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
it "doesn't print out if we're given --quiet" do
|
70
|
-
run_with_args('config', '--key', 'root', '/usr', '--quiet') do |sf|
|
71
|
-
sf.set_config :root, ''
|
72
|
-
sf.should_not_receive(:say)
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
describe '#get' do
|
79
|
-
context 'with no arguments' do
|
80
|
-
it 'raises an error' do
|
81
|
-
expect {
|
82
|
-
run_with_args('get')
|
83
|
-
}.to raise_error
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
context 'with a missing file' do
|
88
|
-
it 'prints an error message' do
|
89
|
-
run_with_args('get', 'bad.pdf') do |sf|
|
90
|
-
sf.should_receive(:say_status).with(:error, /bad\.pdf/, kind_of(Symbol))
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
it 'does not print an error message with --quiet' do
|
95
|
-
run_with_args('get', 'bad.pdf', '--quiet') do |sf|
|
96
|
-
sf.should_not_receive(:say)
|
97
|
-
sf.should_not_receive(:say_status)
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
it 'does not print an error message with --force' do
|
102
|
-
run_with_args('get', 'bad.pdf', '--force') do |sf|
|
103
|
-
sf.should_not_receive(:say)
|
104
|
-
sf.should_not_receive(:say_status)
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
context 'with a file without tags' do
|
110
|
-
it 'prints a no-tags message' do
|
111
|
-
run_with_args('get', example_path('c_no_tags.c')) do |sf|
|
112
|
-
sf.should_receive(:say).with(/.*c_no_tags.c: no tags/)
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
it 'does not print a no-tags message with --quiet' do
|
117
|
-
run_with_args('get', example_path('c_no_tags.c'), '--quiet') do |sf|
|
118
|
-
sf.should_not_receive(:say)
|
119
|
-
sf.should_not_receive(:say_status)
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
|
-
it 'does not print a no-tags message with --force' do
|
124
|
-
run_with_args('get', example_path('c_no_tags.c'), '--force') do |sf|
|
125
|
-
sf.should_not_receive(:say)
|
126
|
-
sf.should_not_receive(:say_status)
|
127
|
-
end
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
|
-
context 'with a file with tags' do
|
132
|
-
it 'prints the tags' do
|
133
|
-
run_with_args('get', example_path('mmd_crazy_tags.mmd')) do |sf|
|
134
|
-
sf.should_receive(:say).with(/ asdf, /)
|
135
|
-
end
|
136
|
-
end
|
137
|
-
|
138
|
-
it 'prints the tags with --quiet' do
|
139
|
-
run_with_args('get', example_path('mmd_crazy_tags.mmd'), '--quiet') do |sf|
|
140
|
-
sf.should_receive(:say).with(/ asdf, /)
|
141
|
-
end
|
142
|
-
end
|
143
|
-
|
144
|
-
it 'prints the tags with --force' do
|
145
|
-
run_with_args('get', example_path('mmd_crazy_tags.mmd'), '--force') do |sf|
|
146
|
-
sf.should_receive(:say).with(/ asdf, /)
|
147
|
-
end
|
148
|
-
end
|
149
|
-
end
|
150
|
-
|
151
|
-
context 'with multiple files with tags' do
|
152
|
-
it 'prints all the files' do
|
153
|
-
run_with_args('get', example_path('mmd_crazy_tags.mmd'), example_path('c_with_tag.c')) do |sf|
|
154
|
-
sf.should_receive(:say).with(/mmd_crazy_tags\.mmd/)
|
155
|
-
sf.should_receive(:say).with(/c_with_tag\.c/)
|
156
|
-
end
|
157
|
-
end
|
158
|
-
end
|
159
|
-
end
|
160
|
-
|
161
|
-
describe '#set' do
|
162
|
-
context 'with no parameters' do
|
163
|
-
it 'raises an error' do
|
164
|
-
expect {
|
165
|
-
run_with_args('set')
|
166
|
-
}.to raise_error
|
167
|
-
end
|
168
|
-
end
|
169
|
-
|
170
|
-
context 'with just a file' do
|
171
|
-
it 'raises an error' do
|
172
|
-
expect {
|
173
|
-
run_with_args('set', 'bad.pdf')
|
174
|
-
}.to raise_error
|
175
|
-
end
|
176
|
-
end
|
177
|
-
|
178
|
-
context 'with a good file and an invalid tag' do
|
179
|
-
it 'raises an error' do
|
180
|
-
expect {
|
181
|
-
run_with_args('set', __FILE__, 'asdf,asdf')
|
182
|
-
}.to raise_error
|
183
|
-
end
|
184
|
-
|
185
|
-
it 'also raises on blank tags' do
|
186
|
-
expect {
|
187
|
-
run_with_args('set', __FILE__, '')
|
188
|
-
}.to raise_error
|
189
|
-
end
|
190
|
-
end
|
191
|
-
|
192
|
-
context 'with a missing file and a good tag' do
|
193
|
-
it 'prints an error message' do
|
194
|
-
run_with_args('set', 'bad.pdf', 'asdf') do |sf|
|
195
|
-
sf.should_receive(:say_status).with(:error, /bad\.pdf/, :red)
|
196
|
-
end
|
197
|
-
end
|
198
|
-
|
199
|
-
it 'does not print an error message with --quiet' do
|
200
|
-
run_with_args('set', 'bad.pdf', 'asdf', '--quiet') do |sf|
|
201
|
-
sf.should_not_receive(:say)
|
202
|
-
sf.should_not_receive(:say_status)
|
203
|
-
end
|
204
|
-
end
|
205
|
-
end
|
206
|
-
|
207
|
-
context 'with a good file and a good tag' do
|
208
|
-
before(:each) do
|
209
|
-
@path = copy_example('c_with_tag.c')
|
210
|
-
end
|
211
|
-
after(:each) do
|
212
|
-
File.unlink(@path)
|
213
|
-
end
|
214
|
-
|
215
|
-
it 'sets the tags' do
|
216
|
-
run_with_args('set', @path, 'test2')
|
217
|
-
run_with_args('get', @path) do |sf|
|
218
|
-
sf.should_receive(:say).with(/ test2/)
|
219
|
-
end
|
220
|
-
end
|
221
|
-
|
222
|
-
it 'prints all the tags' do
|
223
|
-
run_with_args('set', @path, 'test2') do |sf|
|
224
|
-
sf.should_receive(:say_status).with(:success, /: test, test2/, :green)
|
225
|
-
end
|
226
|
-
end
|
227
|
-
|
228
|
-
it 'prints nothing with --quiet' do
|
229
|
-
run_with_args('set', @path, 'test2', '--quiet') do |sf|
|
230
|
-
sf.should_not_receive(:say)
|
231
|
-
sf.should_not_receive(:say_status)
|
232
|
-
end
|
233
|
-
end
|
234
|
-
end
|
235
|
-
end
|
236
|
-
|
237
|
-
describe '#unset' do
|
238
|
-
context 'with no parameters' do
|
239
|
-
it 'raises an error' do
|
240
|
-
expect {
|
241
|
-
run_with_args('unset')
|
242
|
-
}.to raise_error
|
243
|
-
end
|
244
|
-
end
|
245
|
-
|
246
|
-
context 'with just a file' do
|
247
|
-
it 'raises an error' do
|
248
|
-
expect {
|
249
|
-
run_with_args('unset', 'bad.pdf')
|
250
|
-
}.to raise_error
|
251
|
-
end
|
252
|
-
end
|
253
|
-
|
254
|
-
context 'with a good file and an invalid tag' do
|
255
|
-
it 'raises an error' do
|
256
|
-
expect {
|
257
|
-
run_with_args('unset', __FILE__, 'asdf,asdf')
|
258
|
-
}.to raise_error
|
259
|
-
end
|
260
|
-
end
|
261
|
-
|
262
|
-
context 'with a missing file and a good tag' do
|
263
|
-
it 'prints an error message' do
|
264
|
-
run_with_args('unset', 'bad.pdf', 'asdf') do |sf|
|
265
|
-
sf.should_receive(:say_status).with(:error, /bad\.pdf/, :red)
|
266
|
-
end
|
267
|
-
end
|
268
|
-
|
269
|
-
it 'does not print an error message with --quiet' do
|
270
|
-
run_with_args('unset', 'bad.pdf', 'asdf', '--quiet') do |sf|
|
271
|
-
sf.should_not_receive(:say)
|
272
|
-
sf.should_not_receive(:say_status)
|
273
|
-
end
|
274
|
-
end
|
275
|
-
end
|
276
|
-
|
277
|
-
context 'with a good file and a good tag' do
|
278
|
-
before(:each) do
|
279
|
-
@path = copy_example('c_with_tag.c')
|
280
|
-
end
|
281
|
-
after(:each) do
|
282
|
-
File.unlink(@path)
|
283
|
-
end
|
284
|
-
|
285
|
-
it 'sets the tags' do
|
286
|
-
run_with_args('unset', @path, 'test')
|
287
|
-
run_with_args('get', @path) do |sf|
|
288
|
-
sf.should_receive(:say).with(/ no tags/)
|
289
|
-
end
|
290
|
-
end
|
291
|
-
|
292
|
-
it 'prints no tags' do
|
293
|
-
run_with_args('unset', @path, 'test') do |sf|
|
294
|
-
sf.should_receive(:say_status).with(:success, /: no tags/, :green)
|
295
|
-
end
|
296
|
-
end
|
297
|
-
|
298
|
-
it 'prints nothing with --quiet' do
|
299
|
-
run_with_args('unset', @path, 'test', '--quiet') do |sf|
|
300
|
-
sf.should_not_receive(:say)
|
301
|
-
sf.should_not_receive(:say_status)
|
302
|
-
end
|
303
|
-
end
|
304
|
-
end
|
305
|
-
|
306
|
-
context 'with a file with multiple tags' do
|
307
|
-
before(:each) do
|
308
|
-
@path = copy_example('mmd_crazy_tags.mmd')
|
309
|
-
end
|
310
|
-
after(:each) do
|
311
|
-
File.unlink(@path)
|
312
|
-
end
|
313
|
-
|
314
|
-
it 'prints the remaining tags' do
|
315
|
-
run_with_args('unset', @path, 'asdf') do |sf|
|
316
|
-
sf.should_receive(:say_status).with(:success, /: sdfg/, :green)
|
317
|
-
end
|
318
|
-
end
|
319
|
-
end
|
320
|
-
end
|
321
|
-
|
322
|
-
describe '#clear' do
|
323
|
-
context 'with no parameters' do
|
324
|
-
it 'raises an error' do
|
325
|
-
expect {
|
326
|
-
run_with_args('clear')
|
327
|
-
}.to raise_error
|
328
|
-
end
|
329
|
-
end
|
330
|
-
|
331
|
-
context 'with a missing file' do
|
332
|
-
it 'prints an error message' do
|
333
|
-
run_with_args('clear', 'bad.pdf') do |sf|
|
334
|
-
sf.should_receive(:say_status).with(:error, /bad\.pdf/, :red)
|
335
|
-
end
|
336
|
-
end
|
337
|
-
|
338
|
-
it 'does not print an error message with --quiet' do
|
339
|
-
run_with_args('clear', 'bad.pdf', '--quiet') do |sf|
|
340
|
-
sf.should_not_receive(:say)
|
341
|
-
sf.should_not_receive(:say_status)
|
342
|
-
end
|
343
|
-
end
|
344
|
-
|
345
|
-
it 'does not print an error message with --force' do
|
346
|
-
run_with_args('clear', 'bad.pdf', '--force') do |sf|
|
347
|
-
sf.should_not_receive(:say)
|
348
|
-
sf.should_not_receive(:say_status)
|
349
|
-
end
|
350
|
-
end
|
351
|
-
end
|
352
|
-
|
353
|
-
context 'with a good file' do
|
354
|
-
before(:each) do
|
355
|
-
@path = copy_example('c_with_tag.c')
|
356
|
-
end
|
357
|
-
after(:each) do
|
358
|
-
File.unlink(@path)
|
359
|
-
end
|
360
|
-
|
361
|
-
it 'clears the tags' do
|
362
|
-
run_with_args('clear', @path)
|
363
|
-
run_with_args('get', @path) do |sf|
|
364
|
-
sf.should_receive(:say).with(/ no tags/)
|
365
|
-
end
|
366
|
-
end
|
367
|
-
|
368
|
-
it 'prints a success message' do
|
369
|
-
run_with_args('clear', @path) do |sf|
|
370
|
-
sf.should_receive(:say_status).with(:success, /Tags cleared for /, :green)
|
371
|
-
end
|
372
|
-
end
|
373
|
-
|
374
|
-
it 'prints nothing with --quiet' do
|
375
|
-
run_with_args('unset', @path, 'test', '--quiet') do |sf|
|
376
|
-
sf.should_not_receive(:say)
|
377
|
-
sf.should_not_receive(:say_status)
|
378
|
-
end
|
379
|
-
end
|
380
|
-
end
|
381
|
-
end
|
382
|
-
|
383
|
-
describe '#update' do
|
384
|
-
it 'updates in the current directory by default' do
|
385
|
-
run_with_args('update') do |sf|
|
386
|
-
sf.set_config(:root, '')
|
387
|
-
sf.should_receive(:update_database_from_files).with('.')
|
388
|
-
end
|
389
|
-
end
|
390
|
-
|
391
|
-
it 'updates from the configured root dir' do
|
392
|
-
run_with_args('update') do |sf|
|
393
|
-
sf.set_config(:root, '/usr/')
|
394
|
-
sf.should_receive(:update_database_from_files).with('/usr/')
|
395
|
-
end
|
396
|
-
end
|
397
|
-
end
|
398
|
-
|
399
|
-
describe '#tags' do
|
400
|
-
context 'with --quiet' do
|
401
|
-
it 'just prints all the tags, with no padding' do
|
402
|
-
run_with_args('tags', '--quiet') do |sf|
|
403
|
-
sf.update_database_from_files example_root
|
404
|
-
sf.should_receive(:say).with('asdf').once
|
405
|
-
sf.should_receive(:say).with(kind_of(String)).any_number_of_times
|
406
|
-
end
|
407
|
-
end
|
408
|
-
end
|
409
|
-
|
410
|
-
context 'without --quiet' do
|
411
|
-
it 'prints an intro message and padded tags' do
|
412
|
-
run_with_args('tags') do |sf|
|
413
|
-
sf.update_database_from_files example_root
|
414
|
-
sf.should_receive(:say).with('Tags currently in use:').once
|
415
|
-
sf.should_receive(:say).with(/ ?test/).once
|
416
|
-
sf.should_receive(:say).with(kind_of(String)).any_number_of_times
|
417
|
-
end
|
418
|
-
end
|
419
|
-
end
|
420
|
-
end
|
421
|
-
|
422
|
-
describe '#find' do
|
423
|
-
context 'with no tags' do
|
424
|
-
it 'raises an error' do
|
425
|
-
expect {
|
426
|
-
run_with_args('find')
|
427
|
-
}.to raise_error
|
428
|
-
end
|
429
|
-
end
|
430
|
-
|
431
|
-
context 'with an invalid tag' do
|
432
|
-
it 'raises an error' do
|
433
|
-
expect {
|
434
|
-
run_with_args('find', 'asdf,wut')
|
435
|
-
}.to raise_error
|
436
|
-
end
|
437
|
-
end
|
438
|
-
|
439
|
-
context 'with a missing tag' do
|
440
|
-
it 'prints a warning message' do
|
441
|
-
run_with_args('find', 'zuzzax') do |sf|
|
442
|
-
sf.update_database_from_files example_root
|
443
|
-
sf.should_receive(:say_status).with(:warning, /not present/, :yellow)
|
444
|
-
end
|
445
|
-
end
|
446
|
-
|
447
|
-
it 'prints nothing with --quiet' do
|
448
|
-
run_with_args('find', 'zuzzax', '--quiet') do |sf|
|
449
|
-
sf.update_database_from_files example_root
|
450
|
-
sf.should_not_receive(:say)
|
451
|
-
sf.should_not_receive(:say_status)
|
452
|
-
end
|
453
|
-
end
|
454
|
-
end
|
455
|
-
|
456
|
-
context 'with a bad boolean combo' do
|
457
|
-
it 'prints a warning message' do
|
458
|
-
run_with_args('find', 'test', 'asdf') do |sf|
|
459
|
-
sf.update_database_from_files example_root
|
460
|
-
sf.should_receive(:say_status).with(:warning, /not found/, :yellow)
|
461
|
-
end
|
462
|
-
end
|
463
|
-
|
464
|
-
it 'prints nothing with --quiet' do
|
465
|
-
run_with_args('find', 'test', 'asdf', '--quiet') do |sf|
|
466
|
-
sf.update_database_from_files example_root
|
467
|
-
sf.should_not_receive(:say)
|
468
|
-
sf.should_not_receive(:say_status)
|
469
|
-
end
|
470
|
-
end
|
471
|
-
end
|
472
|
-
|
473
|
-
context 'with a good tag' do
|
474
|
-
it 'prints some filenames' do
|
475
|
-
run_with_args('find', 'test') do |sf|
|
476
|
-
sf.update_database_from_files example_root
|
477
|
-
sf.should_receive(:say).with(/#{example_root}/).at_least(:once)
|
478
|
-
end
|
479
|
-
end
|
480
|
-
end
|
481
|
-
end
|
482
|
-
end
|