delta_test 0.2.0 → 1.0.0
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +22 -34
- data/Rakefile +5 -2
- data/bin/delta_test +1 -1
- data/circle.yml +5 -1
- data/delta_test.gemspec +1 -1
- data/lib/delta_test/cli/command_base.rb +114 -0
- data/lib/delta_test/cli/exec_command.rb +95 -0
- data/lib/delta_test/cli/help_command.rb +38 -0
- data/lib/delta_test/cli/specs_command.rb +43 -0
- data/lib/delta_test/cli/stats_clean_command.rb +20 -0
- data/lib/delta_test/cli/stats_save_command.rb +67 -0
- data/lib/delta_test/cli/stats_show_command.rb +46 -0
- data/lib/delta_test/cli/version_command.rb +13 -0
- data/lib/delta_test/cli.rb +22 -296
- data/lib/delta_test/configuration.rb +57 -42
- data/lib/delta_test/errors.rb +24 -0
- data/lib/delta_test/generator.rb +4 -24
- data/lib/delta_test/git.rb +161 -80
- data/lib/delta_test/profiler.rb +8 -0
- data/lib/delta_test/related_spec_list.rb +14 -9
- data/lib/delta_test/stats.rb +41 -0
- data/lib/delta_test/version.rb +2 -2
- data/lib/delta_test.rb +14 -9
- data/spec/lib/delta_test/cli/command_base_spec.rb +164 -0
- data/spec/lib/delta_test/cli/exec_command_spec.rb +128 -0
- data/spec/lib/delta_test/cli/help_command_spec.rb +17 -0
- data/spec/lib/delta_test/cli/specs_command_spec.rb +54 -0
- data/spec/lib/delta_test/cli/stats_clean_command_spec.rb +39 -0
- data/spec/lib/delta_test/cli/stats_save_command_spec.rb +207 -0
- data/spec/lib/delta_test/cli/stats_show_command_spec.rb +52 -0
- data/spec/lib/delta_test/cli/version_command_spec.rb +17 -0
- data/spec/lib/delta_test/cli_spec.rb +47 -386
- data/spec/lib/delta_test/configuration_spec.rb +99 -47
- data/spec/lib/delta_test/dependencies_table_spec.rb +1 -1
- data/spec/lib/delta_test/generator_spec.rb +3 -3
- data/spec/lib/delta_test/git_spec.rb +291 -50
- data/spec/lib/delta_test/profiler_spec.rb +3 -3
- data/spec/lib/delta_test/related_spec_list_spec.rb +12 -14
- data/spec/lib/delta_test/stats_spec.rb +89 -0
- data/spec/lib/delta_test/utils_spec.rb +4 -4
- data/spec/lib/delta_test_spec.rb +13 -4
- data/spec/rails/Gemfile.lock +5 -2
- data/spec/rails/app/models/category.rb +4 -0
- data/spec/rails/delta_test.yml +4 -3
- data/spec/rails/spec/models/category_spec.rb +4 -0
- data/spec/spec_helper.rb +9 -2
- data/spec/supports/create_table_file.rb +11 -1
- data/visual.jpg +0 -0
- metadata +32 -4
@@ -2,13 +2,14 @@ describe DeltaTest::Configuration do
|
|
2
2
|
|
3
3
|
let(:configuration) { DeltaTest::Configuration.new }
|
4
4
|
|
5
|
-
describe '
|
5
|
+
describe '.new' do
|
6
6
|
|
7
7
|
let(:options) do
|
8
8
|
%i[
|
9
9
|
base_path
|
10
|
-
|
10
|
+
stats_path
|
11
11
|
files
|
12
|
+
stats_life
|
12
13
|
]
|
13
14
|
end
|
14
15
|
|
@@ -40,21 +41,21 @@ describe DeltaTest::Configuration do
|
|
40
41
|
|
41
42
|
end
|
42
43
|
|
43
|
-
describe '#
|
44
|
+
describe '#stats_path, #stats_path=' do
|
44
45
|
|
45
46
|
it 'should return an instance of Pathname' do
|
46
|
-
expect(configuration.
|
47
|
+
expect(configuration.stats_path).to be_a(Pathname)
|
47
48
|
end
|
48
49
|
|
49
50
|
it 'should store an instance of Pathname from a string in the setter' do
|
50
51
|
path = 'foo/bar'
|
51
52
|
|
52
53
|
expect {
|
53
|
-
configuration.
|
54
|
+
configuration.stats_path = path
|
54
55
|
}.not_to raise_error
|
55
56
|
|
56
|
-
expect(configuration.
|
57
|
-
expect(configuration.
|
57
|
+
expect(configuration.stats_path).to be_a(Pathname)
|
58
|
+
expect(configuration.stats_path.to_s).to eq(path)
|
58
59
|
end
|
59
60
|
|
60
61
|
end
|
@@ -64,7 +65,7 @@ describe DeltaTest::Configuration do
|
|
64
65
|
describe '#base_path' do
|
65
66
|
|
66
67
|
it 'should raise an error if `base_path` is a relative path' do
|
67
|
-
configuration.base_path =
|
68
|
+
configuration.base_path = 'relative/path'
|
68
69
|
|
69
70
|
expect {
|
70
71
|
configuration.validate!
|
@@ -72,13 +73,71 @@ describe DeltaTest::Configuration do
|
|
72
73
|
end
|
73
74
|
|
74
75
|
it 'should not raise if `base_path` is a absolute path' do
|
75
|
-
configuration.base_path =
|
76
|
+
configuration.base_path = '/absolute/path'
|
76
77
|
|
77
78
|
expect {
|
78
79
|
configuration.validate!
|
79
80
|
}.not_to raise_error
|
80
81
|
end
|
81
82
|
|
83
|
+
it 'should raise if `base_path` is not managed by git' do
|
84
|
+
configuration.base_path = '/absolute/path'
|
85
|
+
allow_any_instance_of(DeltaTest::Git).to receive(:git_repo?).and_return(false)
|
86
|
+
|
87
|
+
expect {
|
88
|
+
configuration.validate!
|
89
|
+
}.to raise_error
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
93
|
+
|
94
|
+
describe '#stats_path' do
|
95
|
+
|
96
|
+
it 'should raise an error if `stats_path` is a relative path' do
|
97
|
+
configuration.stats_path = 'relative/path'
|
98
|
+
|
99
|
+
expect {
|
100
|
+
configuration.validate!
|
101
|
+
}.to raise_error(/stats_path/)
|
102
|
+
end
|
103
|
+
|
104
|
+
it 'should not raise if `stats_path` is a absolute path' do
|
105
|
+
configuration.stats_path= '/absolute/path'
|
106
|
+
|
107
|
+
expect {
|
108
|
+
configuration.validate!
|
109
|
+
}.not_to raise_error
|
110
|
+
end
|
111
|
+
|
112
|
+
it 'should raise if `stats_path` is not managed by git' do
|
113
|
+
configuration.stats_path = '/absolute/path'
|
114
|
+
allow_any_instance_of(DeltaTest::Git).to receive(:git_repo?).and_return(false)
|
115
|
+
|
116
|
+
expect {
|
117
|
+
configuration.validate!
|
118
|
+
}.to raise_error
|
119
|
+
end
|
120
|
+
|
121
|
+
end
|
122
|
+
|
123
|
+
describe '#stats_life' do
|
124
|
+
|
125
|
+
it 'should raise an error if `stats_life` is not an integer' do
|
126
|
+
configuration.stats_life = '100'
|
127
|
+
|
128
|
+
expect {
|
129
|
+
configuration.validate!
|
130
|
+
}.to raise_error(/stats_life/)
|
131
|
+
end
|
132
|
+
|
133
|
+
it 'should raise an error if `stats_life` is not a real number' do
|
134
|
+
configuration.stats_life = -100
|
135
|
+
|
136
|
+
expect {
|
137
|
+
configuration.validate!
|
138
|
+
}.to raise_error(/stats_life/)
|
139
|
+
end
|
140
|
+
|
82
141
|
end
|
83
142
|
|
84
143
|
describe '#files' do
|
@@ -200,40 +259,41 @@ describe DeltaTest::Configuration do
|
|
200
259
|
|
201
260
|
end
|
202
261
|
|
203
|
-
describe '#
|
262
|
+
describe '#stats_path' do
|
204
263
|
|
205
|
-
it 'should return an absolute path to the table file if `
|
264
|
+
it 'should return an absolute path to the table file if `stats_path` is a relative' do
|
206
265
|
configuration.base_path = '/base_path'
|
207
|
-
configuration.
|
266
|
+
configuration.stats_path = 'somewhere/stats_path'
|
208
267
|
|
209
268
|
configuration.precalculate!
|
210
|
-
expect(configuration.
|
269
|
+
expect(configuration.stats_path).to eq(Pathname.new('/base_path/somewhere/stats_path'))
|
211
270
|
end
|
212
271
|
|
213
|
-
it 'should return the same value to the table file if `
|
272
|
+
it 'should return the same value to the table file if `stats_path` is a absolute' do
|
214
273
|
configuration.base_path = '/base_path'
|
215
|
-
configuration.
|
274
|
+
configuration.stats_path = '/somewhere/stats_path'
|
216
275
|
|
217
276
|
configuration.precalculate!
|
218
|
-
expect(configuration.
|
277
|
+
expect(configuration.stats_path).to eq(Pathname.new('/somewhere/stats_path'))
|
219
278
|
end
|
220
279
|
|
221
|
-
|
280
|
+
end
|
281
|
+
|
282
|
+
end
|
222
283
|
|
223
|
-
|
224
|
-
configuration.base_path = '/base_path'
|
225
|
-
configuration.table_file = 'somewhere/table_file'
|
284
|
+
describe '#tmp_table_file' do
|
226
285
|
|
227
|
-
|
228
|
-
|
229
|
-
|
286
|
+
it 'should return a path with a part extension' do
|
287
|
+
configuration.base_path = '/base_path'
|
288
|
+
configuration.stats_path = 'somewhere/stats_path'
|
289
|
+
tmp_table_file = Pathname.new('%s/%s/tmp/%s' % [configuration.base_path, configuration.stats_path, DeltaTest.tester_id])
|
230
290
|
|
291
|
+
configuration.precalculate!
|
292
|
+
expect(configuration.tmp_table_file).to eq(tmp_table_file)
|
231
293
|
end
|
232
294
|
|
233
295
|
end
|
234
296
|
|
235
|
-
end
|
236
|
-
|
237
297
|
describe '#update' do
|
238
298
|
|
239
299
|
it 'should call `validate!` and `precalculate!` after the block' do
|
@@ -241,10 +301,10 @@ describe DeltaTest::Configuration do
|
|
241
301
|
allow(dummy).to receive(:not_yet_called)
|
242
302
|
allow(dummy).to receive(:already_called)
|
243
303
|
|
244
|
-
expect(dummy).to receive(:not_yet_called).
|
245
|
-
expect(configuration).to receive(:validate!).
|
246
|
-
expect(configuration).to receive(:precalculate!).
|
247
|
-
expect(dummy).to receive(:already_called).
|
304
|
+
expect(dummy).to receive(:not_yet_called).once.ordered
|
305
|
+
expect(configuration).to receive(:validate!).once.ordered
|
306
|
+
expect(configuration).to receive(:precalculate!).once.ordered
|
307
|
+
expect(dummy).to receive(:already_called).once.ordered
|
248
308
|
|
249
309
|
configuration.update do |config|
|
250
310
|
dummy.not_yet_called
|
@@ -263,9 +323,9 @@ describe DeltaTest::Configuration do
|
|
263
323
|
allow(configuration).to receive(:load_from_file!).and_return(true)
|
264
324
|
allow(configuration).to receive(:retrive_files_from_git_index!).and_return(true)
|
265
325
|
|
266
|
-
expect(configuration).to receive(:load_from_file!).
|
267
|
-
expect(configuration).to receive(:retrive_files_from_git_index!).
|
268
|
-
expect(configuration).to receive(:update).
|
326
|
+
expect(configuration).to receive(:load_from_file!).once.ordered
|
327
|
+
expect(configuration).to receive(:retrive_files_from_git_index!).once.ordered
|
328
|
+
expect(configuration).to receive(:update).once.ordered
|
269
329
|
|
270
330
|
configuration.auto_configure!
|
271
331
|
end
|
@@ -274,15 +334,15 @@ describe DeltaTest::Configuration do
|
|
274
334
|
|
275
335
|
describe '#load_from_file!' do
|
276
336
|
|
277
|
-
let(:pwd)
|
278
|
-
let(:yaml_file_path)
|
279
|
-
let(:
|
337
|
+
let(:pwd) { '/path/to/pwd' }
|
338
|
+
let(:yaml_file_path) { '/path/to/delta_test.yml' }
|
339
|
+
let(:stats_path) { '/path/to/stats_path' }
|
280
340
|
|
281
341
|
let(:yaml_file) do
|
282
342
|
file = FakeFS::FakeFile.new
|
283
343
|
|
284
344
|
file.content = <<-YAML
|
285
|
-
|
345
|
+
stats_path: #{stats_path}
|
286
346
|
YAML
|
287
347
|
|
288
348
|
file
|
@@ -316,7 +376,7 @@ describe DeltaTest::Configuration do
|
|
316
376
|
configuration.load_from_file!
|
317
377
|
}.not_to raise_error
|
318
378
|
|
319
|
-
expect(configuration.
|
379
|
+
expect(configuration.stats_path).to eq(Pathname.new(stats_path))
|
320
380
|
end
|
321
381
|
|
322
382
|
it 'should raise an error if there is invalid option in yaml' do
|
@@ -334,22 +394,14 @@ describe DeltaTest::Configuration do
|
|
334
394
|
|
335
395
|
describe 'retrive_files_from_git_index!' do
|
336
396
|
|
337
|
-
it 'should raise an error if not in git repo' do
|
338
|
-
allow(DeltaTest::Git).to receive(:git_repo?).with(no_args).and_return(false)
|
339
|
-
|
340
|
-
expect {
|
341
|
-
configuration.retrive_files_from_git_index!
|
342
|
-
}.to raise_error(DeltaTest::NotInGitRepositoryError)
|
343
|
-
end
|
344
|
-
|
345
397
|
it 'should set `files` from the file indices of git' do
|
346
398
|
files = [
|
347
399
|
'a/file_1',
|
348
400
|
'a/file_2',
|
349
401
|
]
|
350
402
|
|
351
|
-
|
352
|
-
|
403
|
+
allow_any_instance_of(DeltaTest::Git).to receive(:git_repo?).and_return(true)
|
404
|
+
allow_any_instance_of(DeltaTest::Git).to receive(:ls_files).and_return(files)
|
353
405
|
|
354
406
|
expect {
|
355
407
|
configuration.retrive_files_from_git_index!
|
@@ -22,8 +22,8 @@ describe DeltaTest::Generator do
|
|
22
22
|
before do
|
23
23
|
DeltaTest.configure do |config|
|
24
24
|
config.base_path = base_path
|
25
|
-
config.table_file = table_file_path
|
26
25
|
config.files = files
|
26
|
+
config.stats_path = stats_path
|
27
27
|
end
|
28
28
|
|
29
29
|
DeltaTest.active = true
|
@@ -187,11 +187,11 @@ describe DeltaTest::Generator do
|
|
187
187
|
generator.stop!
|
188
188
|
|
189
189
|
expect(generator.table).not_to be_empty
|
190
|
-
expect(
|
190
|
+
expect(tmp_stats_file.content).to be_empty
|
191
191
|
|
192
192
|
generator.teardown!
|
193
193
|
|
194
|
-
expect(
|
194
|
+
expect(tmp_stats_file.content).not_to be_empty
|
195
195
|
end
|
196
196
|
|
197
197
|
end
|