defmastership 1.0.19 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -0
- data/.gitlab-ci.yml +27 -0
- data/Gemfile +27 -16
- data/LICENSE +1 -1
- data/README.adoc +24 -0
- data/Rakefile +0 -1
- data/bin/defmastership +5 -5
- data/config/mutant.yml +18 -16
- data/config/rubocop.yml +5 -10
- data/defmastership.gemspec +3 -3
- data/lib/defmastership/batch_modifier.rb +23 -5
- data/lib/defmastership/comment_filter.rb +2 -1
- data/lib/defmastership/definition.rb +24 -4
- data/lib/defmastership/definition_parser.rb +2 -2
- data/lib/defmastership/document.rb +39 -19
- data/lib/defmastership/export/body_formatter.rb +55 -0
- data/lib/defmastership/export/csv/formatter.rb +64 -0
- data/lib/defmastership/export/header_formatter.rb +51 -0
- data/lib/defmastership/filters.rb +15 -12
- data/lib/defmastership/matching_line.rb +3 -2
- data/lib/defmastership/modifier/change_ref.rb +117 -0
- data/lib/defmastership/modifier/factory.rb +17 -0
- data/lib/defmastership/modifier/modifier_common.rb +71 -0
- data/lib/defmastership/modifier/rename_included_files.rb +223 -0
- data/lib/defmastership/modifier/update_def.rb +72 -0
- data/lib/defmastership/modifier/update_def_checksum.rb +17 -0
- data/lib/defmastership/modifier/update_def_version.rb +110 -0
- data/lib/defmastership/set_join_hack.rb +2 -0
- data/lib/defmastership/version.rb +3 -2
- data/lib/defmastership.rb +6 -8
- data/spec/unit/{def_mastership → defmastership}/batch_modifier_spec.rb +13 -13
- data/spec/unit/{def_mastership → defmastership}/definition_parser_spec.rb +1 -1
- data/spec/unit/{def_mastership → defmastership}/definition_spec.rb +1 -1
- data/spec/unit/{def_mastership → defmastership}/document_spec.rb +57 -57
- data/spec/unit/{def_mastership/csv_formatter_body_spec.rb → defmastership/export/body_formatter_spec.rb} +4 -4
- data/spec/unit/{def_mastership/csv_formatter_spec.rb → defmastership/export/csv/formatter_spec.rb} +13 -8
- data/spec/unit/{def_mastership/csv_formatter_header_spec.rb → defmastership/export/header_formatter_spec.rb} +3 -3
- data/spec/unit/{def_mastership → defmastership}/matching_line_spec.rb +1 -1
- data/spec/unit/{def_mastership/change_ref_modifier_spec.rb → defmastership/modifier/change_ref_spec.rb} +19 -44
- data/spec/unit/defmastership/modifier/factory_spec.rb +45 -0
- data/spec/unit/{def_mastership/modifier_spec.rb → defmastership/modifier/modifier_common_spec.rb} +3 -12
- data/spec/unit/{def_mastership/rename_included_files_modifier_spec.rb → defmastership/modifier/rename_included_files_spec.rb} +3 -3
- data/spec/unit/{def_mastership/update_def_checksum_modifier_spec.rb → defmastership/modifier/update_def_checksum_spec.rb} +10 -10
- data/spec/unit/{def_mastership/update_def_modifier_spec.rb → defmastership/modifier/update_def_spec.rb} +22 -20
- data/spec/unit/{def_mastership/update_def_version_modifier_spec.rb → defmastership/modifier/update_def_version_spec.rb} +38 -38
- data/spec/unit/{def_mastership_spec.rb → defmastership_spec.rb} +2 -2
- data/tasks/documentation.rake +19 -0
- data/tasks/package.rake +4 -0
- metadata +63 -43
- data/README.rdoc +0 -6
- data/defmastership.rdoc +0 -5
- data/lib/defmastership/change_ref_modifier.rb +0 -99
- data/lib/defmastership/constants.rb +0 -91
- data/lib/defmastership/csv_formatter.rb +0 -53
- data/lib/defmastership/csv_formatter_body.rb +0 -46
- data/lib/defmastership/csv_formatter_header.rb +0 -41
- data/lib/defmastership/modifier.rb +0 -42
- data/lib/defmastership/modifier_factory.rb +0 -12
- data/lib/defmastership/parsing_state.rb +0 -31
- data/lib/defmastership/rename_included_files_modifier.rb +0 -182
- data/lib/defmastership/update_def_checksum_modifier.rb +0 -16
- data/lib/defmastership/update_def_modifier.rb +0 -49
- data/lib/defmastership/update_def_version_modifier.rb +0 -91
- data/spec/unit/def_mastership/modifier_factory_spec.rb +0 -38
- data/spec/unit/def_mastership/parsing_state_spec.rb +0 -62
- data/tasks/package.task +0 -9
- /data/spec/unit/{def_mastership → defmastership}/string_spec.rb +0 -0
@@ -3,7 +3,7 @@
|
|
3
3
|
|
4
4
|
require('defmastership/document')
|
5
5
|
|
6
|
-
RSpec.describe(
|
6
|
+
RSpec.describe(Defmastership::Document) do
|
7
7
|
subject(:document) { described_class.new }
|
8
8
|
|
9
9
|
describe '.new' do
|
@@ -27,12 +27,12 @@ RSpec.describe(DefMastership::Document) do
|
|
27
27
|
it { expect(document.respond_to?(:not_implemented_random_method)).to(be(false)) }
|
28
28
|
end
|
29
29
|
|
30
|
-
describe '#
|
30
|
+
describe '#do_parse' do
|
31
31
|
context 'with valid definitions' do
|
32
|
-
let(:definition) { instance_double(
|
32
|
+
let(:definition) { instance_double(Defmastership::Definition, 'definition') }
|
33
33
|
|
34
34
|
before do
|
35
|
-
allow(
|
35
|
+
allow(Defmastership::Definition).to(receive(:new).and_return(definition))
|
36
36
|
allow(definition).to(
|
37
37
|
receive_messages(
|
38
38
|
labels: Set.new,
|
@@ -47,16 +47,16 @@ RSpec.describe(DefMastership::Document) do
|
|
47
47
|
let(:input_lines) { ['[define, requirement, TOTO-0001]'] }
|
48
48
|
|
49
49
|
before do
|
50
|
-
allow(
|
50
|
+
allow(Defmastership::Definition).to(
|
51
51
|
receive(:new).with(
|
52
52
|
matchdata_including(type: 'requirement', reference: 'TOTO-0001')
|
53
53
|
).and_return(definition)
|
54
54
|
)
|
55
|
-
document.
|
55
|
+
document.__send__(:do_parse, input_lines)
|
56
56
|
end
|
57
57
|
|
58
58
|
it do
|
59
|
-
expect(
|
59
|
+
expect(Defmastership::Definition).to(
|
60
60
|
have_received(:new).with(
|
61
61
|
matchdata_including(type: 'requirement', reference: 'TOTO-0001')
|
62
62
|
)
|
@@ -71,16 +71,16 @@ RSpec.describe(DefMastership::Document) do
|
|
71
71
|
let(:input_lines) { ['[define, requirement, TOTO-0001(~ab12)]'] }
|
72
72
|
|
73
73
|
before do
|
74
|
-
allow(
|
74
|
+
allow(Defmastership::Definition).to(
|
75
75
|
receive(:new).with(
|
76
76
|
matchdata_including(type: 'requirement', reference: 'TOTO-0001', explicit_checksum: '~ab12')
|
77
77
|
).and_return(definition)
|
78
78
|
)
|
79
|
-
document.
|
79
|
+
document.__send__(:do_parse, input_lines)
|
80
80
|
end
|
81
81
|
|
82
82
|
it do
|
83
|
-
expect(
|
83
|
+
expect(Defmastership::Definition).to(
|
84
84
|
have_received(:new).with(
|
85
85
|
matchdata_including(type: 'requirement', reference: 'TOTO-0001', explicit_checksum: '~ab12')
|
86
86
|
)
|
@@ -92,16 +92,16 @@ RSpec.describe(DefMastership::Document) do
|
|
92
92
|
let(:input_lines) { ['[define, requirement, TOTO-0001(pouet)]'] }
|
93
93
|
|
94
94
|
before do
|
95
|
-
allow(
|
95
|
+
allow(Defmastership::Definition).to(
|
96
96
|
receive(:new).with(
|
97
97
|
matchdata_including(type: 'requirement', reference: 'TOTO-0001', explicit_version: 'pouet')
|
98
98
|
).and_return(definition)
|
99
99
|
)
|
100
|
-
document.
|
100
|
+
document.__send__(:do_parse, input_lines)
|
101
101
|
end
|
102
102
|
|
103
103
|
it do
|
104
|
-
expect(
|
104
|
+
expect(Defmastership::Definition).to(
|
105
105
|
have_received(:new).with(
|
106
106
|
matchdata_including(type: 'requirement', reference: 'TOTO-0001', explicit_version: 'pouet')
|
107
107
|
)
|
@@ -123,7 +123,7 @@ RSpec.describe(DefMastership::Document) do
|
|
123
123
|
|
124
124
|
before do
|
125
125
|
allow(definition).to(receive(:<<).and_return(definition))
|
126
|
-
document.
|
126
|
+
document.__send__(:do_parse, input_lines)
|
127
127
|
end
|
128
128
|
|
129
129
|
it { expect(definition).to(have_received(:<<).with('a')) }
|
@@ -147,7 +147,7 @@ RSpec.describe(DefMastership::Document) do
|
|
147
147
|
|
148
148
|
before do
|
149
149
|
allow(definition).to(receive(:<<).and_return(definition))
|
150
|
-
document.
|
150
|
+
document.__send__(:do_parse, input_lines)
|
151
151
|
end
|
152
152
|
|
153
153
|
it { expect(definition).to(have_received(:<<).twice.with('----')) }
|
@@ -168,7 +168,7 @@ RSpec.describe(DefMastership::Document) do
|
|
168
168
|
|
169
169
|
before do
|
170
170
|
allow(definition).to(receive(:<<).and_return(definition))
|
171
|
-
document.
|
171
|
+
document.__send__(:do_parse, input_lines)
|
172
172
|
end
|
173
173
|
|
174
174
|
it { expect(definition).to(have_received(:<<).with('// comment')) }
|
@@ -187,7 +187,7 @@ RSpec.describe(DefMastership::Document) do
|
|
187
187
|
|
188
188
|
before do
|
189
189
|
allow(definition).to(receive(:<<).and_return(definition))
|
190
|
-
document.
|
190
|
+
document.__send__(:do_parse, input_lines)
|
191
191
|
end
|
192
192
|
|
193
193
|
it { expect(definition).to(have_received(:<<).with('one line')) }
|
@@ -207,7 +207,7 @@ RSpec.describe(DefMastership::Document) do
|
|
207
207
|
]
|
208
208
|
end
|
209
209
|
|
210
|
-
before { document.
|
210
|
+
before { document.__send__(:do_parse, input_lines) }
|
211
211
|
|
212
212
|
it { expect(definition).not_to(have_received(:<<).with('not included')) }
|
213
213
|
end
|
@@ -216,7 +216,7 @@ RSpec.describe(DefMastership::Document) do
|
|
216
216
|
let(:input_lines) { ['--', 'first line', '--'] }
|
217
217
|
|
218
218
|
it do
|
219
|
-
document.
|
219
|
+
document.__send__(:do_parse, input_lines)
|
220
220
|
expect(document.definitions).to(eq([]))
|
221
221
|
end
|
222
222
|
end
|
@@ -232,11 +232,11 @@ RSpec.describe(DefMastership::Document) do
|
|
232
232
|
|
233
233
|
before do
|
234
234
|
allow(definition).to(receive(:labels).and_return(Set['bla1', 'bla2']))
|
235
|
-
document.
|
235
|
+
document.__send__(:do_parse, input_lines)
|
236
236
|
end
|
237
237
|
|
238
238
|
it do
|
239
|
-
expect(
|
239
|
+
expect(Defmastership::Definition).to(
|
240
240
|
have_received(:new).with(
|
241
241
|
matchdata_including(type: 'requirement', reference: 'TOTO-0001', labels: 'label1, label2')
|
242
242
|
)
|
@@ -257,11 +257,11 @@ RSpec.describe(DefMastership::Document) do
|
|
257
257
|
|
258
258
|
before do
|
259
259
|
allow(definition).to(receive(:labels).and_return(Set['bla1', 'bla2']))
|
260
|
-
document.
|
260
|
+
document.__send__(:do_parse, input_lines)
|
261
261
|
end
|
262
262
|
|
263
263
|
it do
|
264
|
-
expect(
|
264
|
+
expect(Defmastership::Definition).to(
|
265
265
|
have_received(:new).with(
|
266
266
|
matchdata_including(type: 'requirement', reference: 'TOTO-0001', labels: 'label1,label2')
|
267
267
|
)
|
@@ -281,7 +281,7 @@ RSpec.describe(DefMastership::Document) do
|
|
281
281
|
]
|
282
282
|
end
|
283
283
|
|
284
|
-
before { document.
|
284
|
+
before { document.__send__(:do_parse, input_lines) }
|
285
285
|
|
286
286
|
it { expect(document.eref[:implements]).to(eq(prefix: 'Participate to:', url: './other_document.html')) }
|
287
287
|
end
|
@@ -296,7 +296,7 @@ RSpec.describe(DefMastership::Document) do
|
|
296
296
|
end
|
297
297
|
|
298
298
|
it do
|
299
|
-
document.
|
299
|
+
document.__send__(:do_parse, input_lines)
|
300
300
|
expect(document.eref[:implements])
|
301
301
|
.to(eq(prefix: 'Participate to:'))
|
302
302
|
end
|
@@ -316,7 +316,7 @@ RSpec.describe(DefMastership::Document) do
|
|
316
316
|
receive(:add_eref).with(:implements, 'SYSTEM-0012, SYSTEM-0014')
|
317
317
|
.and_return(definition)
|
318
318
|
)
|
319
|
-
document.
|
319
|
+
document.__send__(:do_parse, input_lines)
|
320
320
|
end
|
321
321
|
|
322
322
|
it { expect(definition).to(have_received(:add_eref).with(:implements, 'SYSTEM-0012, SYSTEM-0014')) }
|
@@ -333,7 +333,7 @@ RSpec.describe(DefMastership::Document) do
|
|
333
333
|
|
334
334
|
before do
|
335
335
|
allow(definition).to(receive(:add_iref))
|
336
|
-
document.
|
336
|
+
document.__send__(:do_parse, input_lines)
|
337
337
|
end
|
338
338
|
|
339
339
|
it { expect(definition).to(have_received(:add_iref).with('toto')) }
|
@@ -350,7 +350,7 @@ RSpec.describe(DefMastership::Document) do
|
|
350
350
|
]
|
351
351
|
end
|
352
352
|
|
353
|
-
before { document.
|
353
|
+
before { document.__send__(:do_parse, input_lines) }
|
354
354
|
|
355
355
|
it { expect(document.attributes).to(eq(myattribute: 'My attribute:', myotherone: 'My other attribute:')) }
|
356
356
|
end
|
@@ -365,7 +365,7 @@ RSpec.describe(DefMastership::Document) do
|
|
365
365
|
|
366
366
|
before do
|
367
367
|
allow(definition).to(receive(:set_attribute).with(:myattribute, 'My value'))
|
368
|
-
document.
|
368
|
+
document.__send__(:do_parse, input_lines)
|
369
369
|
end
|
370
370
|
|
371
371
|
it { expect(definition).to(have_received(:set_attribute).with(:myattribute, 'My value')) }
|
@@ -380,7 +380,7 @@ RSpec.describe(DefMastership::Document) do
|
|
380
380
|
end
|
381
381
|
|
382
382
|
it do
|
383
|
-
document.
|
383
|
+
document.__send__(:do_parse, input_lines)
|
384
384
|
expect(document.iref).to(be(false))
|
385
385
|
end
|
386
386
|
end
|
@@ -394,16 +394,16 @@ RSpec.describe(DefMastership::Document) do
|
|
394
394
|
end
|
395
395
|
|
396
396
|
before do
|
397
|
-
allow(
|
397
|
+
allow(Defmastership::Definition).to(
|
398
398
|
receive(:new).with(
|
399
399
|
matchdata_including(type: 'requirement', reference: 'TOTO-0001')
|
400
400
|
).and_return(definition)
|
401
401
|
)
|
402
|
-
document.
|
402
|
+
document.__send__(:do_parse, input_lines)
|
403
403
|
end
|
404
404
|
|
405
405
|
it do
|
406
|
-
expect(
|
406
|
+
expect(Defmastership::Definition).to(
|
407
407
|
have_received(:new).with(
|
408
408
|
matchdata_including(type: 'requirement', reference: 'TOTO-0001')
|
409
409
|
)
|
@@ -413,17 +413,17 @@ RSpec.describe(DefMastership::Document) do
|
|
413
413
|
end
|
414
414
|
|
415
415
|
context 'when variables replacement' do
|
416
|
-
let(:definition) { instance_double(
|
416
|
+
let(:definition) { instance_double(Defmastership::Definition, 'definition') }
|
417
417
|
|
418
418
|
before do
|
419
|
-
allow(
|
419
|
+
allow(Defmastership::Definition).to(receive(:new).and_return(definition))
|
420
420
|
allow(definition).to(
|
421
421
|
receive_messages(
|
422
422
|
labels: Set.new,
|
423
423
|
'<<': definition
|
424
424
|
)
|
425
425
|
)
|
426
|
-
document.
|
426
|
+
document.__send__(:do_parse, input_lines)
|
427
427
|
end
|
428
428
|
|
429
429
|
context 'when defined variable' do
|
@@ -488,13 +488,13 @@ RSpec.describe(DefMastership::Document) do
|
|
488
488
|
end
|
489
489
|
|
490
490
|
before do
|
491
|
-
allow(
|
491
|
+
allow(Defmastership::Definition).to(
|
492
492
|
receive(:new).and_raise('not a valide definition')
|
493
493
|
)
|
494
494
|
end
|
495
495
|
|
496
496
|
it do
|
497
|
-
document.
|
497
|
+
document.__send__(:do_parse, input_lines)
|
498
498
|
expect(document).to(have_attributes(definitions: []))
|
499
499
|
end
|
500
500
|
end
|
@@ -509,13 +509,13 @@ RSpec.describe(DefMastership::Document) do
|
|
509
509
|
end
|
510
510
|
|
511
511
|
before do
|
512
|
-
allow(
|
512
|
+
allow(Defmastership::Definition).to(
|
513
513
|
receive(:new).and_raise('not a valide definition')
|
514
514
|
)
|
515
515
|
end
|
516
516
|
|
517
517
|
it do
|
518
|
-
document.
|
518
|
+
document.__send__(:do_parse, input_lines)
|
519
519
|
expect(document).to(have_attributes(definitions: []))
|
520
520
|
end
|
521
521
|
end
|
@@ -523,7 +523,7 @@ RSpec.describe(DefMastership::Document) do
|
|
523
523
|
end
|
524
524
|
|
525
525
|
describe '#parse_file_with_preprocessor' do
|
526
|
-
let(:definition) { instance_double(
|
526
|
+
let(:definition) { instance_double(Defmastership::Definition, 'definition') }
|
527
527
|
let(:input_lines) { ['[define, requirement, TOTO-0001]'] }
|
528
528
|
let(:adoc_doc) { instance_double(Asciidoctor::Document, 'adoc_doc') }
|
529
529
|
let(:adoc_reader) { instance_double(Asciidoctor::Reader, 'adoc_reader') }
|
@@ -534,7 +534,7 @@ RSpec.describe(DefMastership::Document) do
|
|
534
534
|
)
|
535
535
|
allow(adoc_doc).to(receive(:reader).and_return(adoc_reader))
|
536
536
|
allow(adoc_reader).to(receive(:read_lines).and_return(input_lines))
|
537
|
-
allow(
|
537
|
+
allow(Defmastership::Definition).to(receive(:new).and_return(definition))
|
538
538
|
allow(definition).to(
|
539
539
|
receive_messages(
|
540
540
|
'<<': definition,
|
@@ -549,7 +549,7 @@ RSpec.describe(DefMastership::Document) do
|
|
549
549
|
it { expect(adoc_reader).to(have_received(:read_lines).with(no_args)) }
|
550
550
|
|
551
551
|
it do
|
552
|
-
expect(
|
552
|
+
expect(Defmastership::Definition).to(
|
553
553
|
have_received(:new).with(
|
554
554
|
matchdata_including(type: 'requirement', reference: 'TOTO-0001')
|
555
555
|
)
|
@@ -560,8 +560,8 @@ RSpec.describe(DefMastership::Document) do
|
|
560
560
|
describe '#wrong_explicit_checksum?' do
|
561
561
|
let(:defs) do
|
562
562
|
[
|
563
|
-
instance_double(
|
564
|
-
instance_double(
|
563
|
+
instance_double(Defmastership::Definition, 'definition'),
|
564
|
+
instance_double(Defmastership::Definition, 'definition')
|
565
565
|
]
|
566
566
|
end
|
567
567
|
let(:input_lines) do
|
@@ -575,7 +575,7 @@ RSpec.describe(DefMastership::Document) do
|
|
575
575
|
end
|
576
576
|
|
577
577
|
before do
|
578
|
-
allow(
|
578
|
+
allow(Defmastership::Definition).to(receive(:new).twice.and_return(defs.first, defs[1]))
|
579
579
|
defs.each do |definition|
|
580
580
|
allow(definition).to(receive(:labels)).and_return([])
|
581
581
|
allow(definition).to(receive(:<<)).and_return(definition)
|
@@ -585,7 +585,7 @@ RSpec.describe(DefMastership::Document) do
|
|
585
585
|
context 'when no wrong explicit checksum' do
|
586
586
|
before do
|
587
587
|
defs.each { |definition| allow(definition).to(receive(:wrong_explicit_checksum)).and_return(nil) }
|
588
|
-
document.
|
588
|
+
document.__send__(:do_parse, input_lines)
|
589
589
|
document.wrong_explicit_checksum?
|
590
590
|
end
|
591
591
|
|
@@ -598,7 +598,7 @@ RSpec.describe(DefMastership::Document) do
|
|
598
598
|
before do
|
599
599
|
allow(defs.first).to(receive(:wrong_explicit_checksum)).and_return('toto')
|
600
600
|
allow(defs[1]).to(receive(:wrong_explicit_checksum)).and_return(nil)
|
601
|
-
document.
|
601
|
+
document.__send__(:do_parse, input_lines)
|
602
602
|
document.wrong_explicit_checksum?
|
603
603
|
end
|
604
604
|
|
@@ -609,8 +609,8 @@ RSpec.describe(DefMastership::Document) do
|
|
609
609
|
describe '#explicit_version?' do
|
610
610
|
let(:defs) do
|
611
611
|
[
|
612
|
-
instance_double(
|
613
|
-
instance_double(
|
612
|
+
instance_double(Defmastership::Definition, 'definition'),
|
613
|
+
instance_double(Defmastership::Definition, 'definition')
|
614
614
|
]
|
615
615
|
end
|
616
616
|
let(:input_lines) do
|
@@ -624,7 +624,7 @@ RSpec.describe(DefMastership::Document) do
|
|
624
624
|
end
|
625
625
|
|
626
626
|
before do
|
627
|
-
allow(
|
627
|
+
allow(Defmastership::Definition).to(receive(:new).twice.and_return(defs.first, defs[1]))
|
628
628
|
allow(defs.first).to(receive(:labels)).and_return([])
|
629
629
|
allow(defs[1]).to(receive(:labels)).and_return([])
|
630
630
|
allow(defs.first).to(receive(:<<).and_return(defs.first))
|
@@ -635,7 +635,7 @@ RSpec.describe(DefMastership::Document) do
|
|
635
635
|
before do
|
636
636
|
allow(defs.first).to(receive(:explicit_version)).and_return(nil)
|
637
637
|
allow(defs[1]).to(receive(:explicit_version)).and_return(nil)
|
638
|
-
document.
|
638
|
+
document.__send__(:do_parse, input_lines)
|
639
639
|
document.explicit_version?
|
640
640
|
end
|
641
641
|
|
@@ -648,7 +648,7 @@ RSpec.describe(DefMastership::Document) do
|
|
648
648
|
before do
|
649
649
|
allow(defs.first).to(receive(:explicit_version)).and_return('toto')
|
650
650
|
allow(defs[1]).to(receive(:explicit_version)).and_return(nil)
|
651
|
-
document.
|
651
|
+
document.__send__(:do_parse, input_lines)
|
652
652
|
document.explicit_version?
|
653
653
|
end
|
654
654
|
|
@@ -659,8 +659,8 @@ RSpec.describe(DefMastership::Document) do
|
|
659
659
|
describe '#ref_to_def?' do
|
660
660
|
let(:definitions) do
|
661
661
|
[
|
662
|
-
instance_double(
|
663
|
-
instance_double(
|
662
|
+
instance_double(Defmastership::Definition, 'def1'),
|
663
|
+
instance_double(Defmastership::Definition, 'def2')
|
664
664
|
]
|
665
665
|
end
|
666
666
|
let(:input_lines) do
|
@@ -674,7 +674,7 @@ RSpec.describe(DefMastership::Document) do
|
|
674
674
|
end
|
675
675
|
|
676
676
|
before do
|
677
|
-
allow(
|
677
|
+
allow(Defmastership::Definition).to(receive(:new).twice.and_return(definitions.first, definitions[1]))
|
678
678
|
allow(definitions.first).to(
|
679
679
|
receive_messages(
|
680
680
|
labels: [],
|
@@ -689,7 +689,7 @@ RSpec.describe(DefMastership::Document) do
|
|
689
689
|
reference: 'TOTO-0002'
|
690
690
|
)
|
691
691
|
)
|
692
|
-
document.
|
692
|
+
document.__send__(:do_parse, input_lines)
|
693
693
|
end
|
694
694
|
|
695
695
|
it { expect(document.ref_to_def('TOTO-0001')).to(eq(definitions.first)) }
|
@@ -1,13 +1,13 @@
|
|
1
1
|
# Copyright (c) 2020 Jerome Arbez-Gindre
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
require('defmastership/
|
4
|
+
require('defmastership/export/body_formatter')
|
5
5
|
|
6
|
-
RSpec.describe(
|
6
|
+
RSpec.describe(Defmastership::Export::BodyFormatter) do
|
7
7
|
subject(:formatter) { described_class.new(document, definition) }
|
8
8
|
|
9
|
-
let(:document) { instance_double(
|
10
|
-
let(:definition) { instance_double(
|
9
|
+
let(:document) { instance_double(Defmastership::Document, 'document') }
|
10
|
+
let(:definition) { instance_double(Defmastership::Definition, 'definition') }
|
11
11
|
|
12
12
|
describe '.new' do
|
13
13
|
it { is_expected.not_to(be_nil) }
|
data/spec/unit/{def_mastership/csv_formatter_spec.rb → defmastership/export/csv/formatter_spec.rb}
RENAMED
@@ -2,24 +2,24 @@
|
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
require('csv')
|
5
|
-
require('defmastership/
|
5
|
+
require('defmastership/export/csv/formatter')
|
6
6
|
require('ostruct')
|
7
7
|
|
8
|
-
RSpec.describe(
|
8
|
+
RSpec.describe(Defmastership::Export::CSV::Formatter) do
|
9
9
|
subject(:formatter) { described_class.new(document, ';') }
|
10
10
|
|
11
|
-
let(:document) { instance_double(
|
11
|
+
let(:document) { instance_double(Defmastership::Document, 'document') }
|
12
12
|
|
13
13
|
describe '.new' do
|
14
14
|
it { is_expected.not_to(be_nil) }
|
15
15
|
end
|
16
16
|
|
17
17
|
describe '#export_to' do
|
18
|
-
let(:header) { instance_double(
|
18
|
+
let(:header) { instance_double(Defmastership::Export::HeaderFormatter, 'header') }
|
19
19
|
let(:bodies) do
|
20
20
|
[
|
21
|
-
instance_double(
|
22
|
-
instance_double(
|
21
|
+
instance_double(Defmastership::Export::BodyFormatter, 'bodies[0]'),
|
22
|
+
instance_double(Defmastership::Export::BodyFormatter, 'bodies[1]')
|
23
23
|
]
|
24
24
|
end
|
25
25
|
let(:csv) { instance_double(CSV, 'csv') }
|
@@ -27,9 +27,14 @@ RSpec.describe(DefMastership::CSVFormatter) do
|
|
27
27
|
before do
|
28
28
|
allow(CSV).to(receive(:open).with('whatever', 'w:ISO-8859-1', col_sep: ';').and_yield(csv))
|
29
29
|
allow(csv).to(receive(:<<))
|
30
|
-
allow(
|
30
|
+
allow(Defmastership::Export::HeaderFormatter).to(receive(:new).with(document).and_return(header))
|
31
31
|
bodies.each_with_index do |body, index|
|
32
|
-
allow(
|
32
|
+
allow(Defmastership::Export::BodyFormatter).to(
|
33
|
+
receive(:new).with(
|
34
|
+
document,
|
35
|
+
:"def#{index}"
|
36
|
+
).and_return(body)
|
37
|
+
)
|
33
38
|
end
|
34
39
|
allow(document).to(receive(:definitions).and_return(%i[def0 def1]))
|
35
40
|
allow(document).to(receive(:wrong_explicit_checksum?).with(no_args).and_return(false))
|
@@ -1,12 +1,12 @@
|
|
1
1
|
# Copyright (c) 2020 Jerome Arbez-Gindre
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
require('defmastership/
|
4
|
+
require('defmastership/export/header_formatter')
|
5
5
|
|
6
|
-
RSpec.describe(
|
6
|
+
RSpec.describe(Defmastership::Export::HeaderFormatter) do
|
7
7
|
subject(:formatter) { described_class.new(document) }
|
8
8
|
|
9
|
-
let(:document) { instance_double(
|
9
|
+
let(:document) { instance_double(Defmastership::Document, 'document') }
|
10
10
|
|
11
11
|
describe '.new' do
|
12
12
|
it { is_expected.not_to(be_nil) }
|
@@ -1,13 +1,13 @@
|
|
1
1
|
# Copyright (c) 2020 Jerome Arbez-Gindre
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
require('defmastership/
|
4
|
+
require('defmastership/modifier/change_ref')
|
5
5
|
|
6
|
-
RSpec.describe(
|
6
|
+
RSpec.describe(Defmastership::Modifier::ChangeRef) do
|
7
7
|
subject(:refchanger) { described_class.new({}) }
|
8
8
|
|
9
9
|
describe '.new' do
|
10
|
-
it { expect(described_class.ancestors).to(include(
|
10
|
+
it { expect(described_class.ancestors).to(include(Defmastership::Modifier::ModifierCommon)) }
|
11
11
|
it { is_expected.not_to(be_nil) }
|
12
12
|
it { is_expected.to(have_attributes(from_regexp: '')) }
|
13
13
|
it { is_expected.to(have_attributes(to_template: '')) }
|
@@ -28,7 +28,7 @@ RSpec.describe(DefMastership::ChangeRefModifier) do
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
-
describe '#
|
31
|
+
describe '#replace_refdef' do
|
32
32
|
context 'when really simple rule' do
|
33
33
|
subject(:refchanger) do
|
34
34
|
described_class.new(
|
@@ -42,6 +42,21 @@ RSpec.describe(DefMastership::ChangeRefModifier) do
|
|
42
42
|
expect(refchanger.replace_refdef('[define, whatever, TEMP]'))
|
43
43
|
.to(eq('[define, whatever, TUTU]'))
|
44
44
|
end
|
45
|
+
|
46
|
+
it do
|
47
|
+
expect(refchanger.replace_refdef('[define, whatever, TEMP(a~12345678)]'))
|
48
|
+
.to(eq('[define, whatever, TUTU(a~12345678)]'))
|
49
|
+
end
|
50
|
+
|
51
|
+
it do
|
52
|
+
expect(refchanger.replace_refdef('[define, whatever, TEMP(~12345678)]'))
|
53
|
+
.to(eq('[define, whatever, TUTU(~12345678)]'))
|
54
|
+
end
|
55
|
+
|
56
|
+
it do
|
57
|
+
expect(refchanger.replace_refdef('[define, whatever, TEMP(a)]'))
|
58
|
+
.to(eq('[define, whatever, TUTU(a)]'))
|
59
|
+
end
|
45
60
|
end
|
46
61
|
|
47
62
|
context 'when no valid definition' do
|
@@ -178,44 +193,4 @@ RSpec.describe(DefMastership::ChangeRefModifier) do
|
|
178
193
|
).to(eq('defs:iref[TOTO-0132] defs:iref[TOTO-0132] bla'))
|
179
194
|
end
|
180
195
|
end
|
181
|
-
|
182
|
-
describe '#replace' do
|
183
|
-
subject(:refchanger) do
|
184
|
-
described_class.new(
|
185
|
-
from_regexp: 'TEMP',
|
186
|
-
to_template: 'TUTU'
|
187
|
-
)
|
188
|
-
end
|
189
|
-
|
190
|
-
it do
|
191
|
-
expect(refchanger.replace(:refdef, '[define, whatever, TEMP]'))
|
192
|
-
.to(eq('[define, whatever, TUTU]'))
|
193
|
-
end
|
194
|
-
|
195
|
-
it do
|
196
|
-
expect(refchanger.replace(:refdef, '[define, whatever, TEMP(a~12345678)]'))
|
197
|
-
.to(eq('[define, whatever, TUTU(a~12345678)]'))
|
198
|
-
end
|
199
|
-
|
200
|
-
it do
|
201
|
-
expect(refchanger.replace(:refdef, '[define, whatever, TEMP(~12345678)]'))
|
202
|
-
.to(eq('[define, whatever, TUTU(~12345678)]'))
|
203
|
-
end
|
204
|
-
|
205
|
-
it do
|
206
|
-
expect(refchanger.replace(:refdef, '[define, whatever, TEMP(a)]'))
|
207
|
-
.to(eq('[define, whatever, TUTU(a)]'))
|
208
|
-
end
|
209
|
-
|
210
|
-
it do
|
211
|
-
refchanger.replace(:refdef, '[define, whatever, TEMP]')
|
212
|
-
expect(refchanger.replace(:irefs, 'defs:iref[TEMP] defs:iref[TEMP]'))
|
213
|
-
.to(eq('defs:iref[TUTU] defs:iref[TUTU]'))
|
214
|
-
end
|
215
|
-
|
216
|
-
it do
|
217
|
-
expect { refchanger.replace(:pouet, 'whatever') }
|
218
|
-
.to(raise_error(NoMethodError))
|
219
|
-
end
|
220
|
-
end
|
221
196
|
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# Copyright (c) 2023 Jerome Arbez-Gindre
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require('defmastership/modifier/factory')
|
5
|
+
|
6
|
+
module Defmastership
|
7
|
+
module Modifier
|
8
|
+
# Modifier example
|
9
|
+
class Toto
|
10
|
+
include ModifierCommon
|
11
|
+
end
|
12
|
+
|
13
|
+
# Modifier example
|
14
|
+
class TuTu
|
15
|
+
include ModifierCommon
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
RSpec.describe(Defmastership::Modifier::Factory) do
|
21
|
+
describe('.from_config') do
|
22
|
+
let(:toto) { instance_double(Defmastership::Modifier::Toto, 'toto') }
|
23
|
+
let(:toto_config) { { type: 'toto', config: { p: 'whatever' } } }
|
24
|
+
let(:tutu) { instance_double(Defmastership::Modifier::TuTu, 'tutu') }
|
25
|
+
let(:tutu_config) { { type: 'tu_tu', config: { p: 'whatever' } } }
|
26
|
+
|
27
|
+
before do
|
28
|
+
allow(Defmastership::Modifier::Toto).to(receive(:new).with(toto_config[:config]).and_return(toto))
|
29
|
+
allow(Defmastership::Modifier::TuTu).to(receive(:new).with(tutu_config[:config]).and_return(tutu))
|
30
|
+
end
|
31
|
+
|
32
|
+
it { expect(described_class.from_config(toto_config)).to(be(toto)) }
|
33
|
+
it { expect(described_class.from_config(tutu_config)).to(be(tutu)) }
|
34
|
+
|
35
|
+
it do
|
36
|
+
described_class.from_config(toto_config)
|
37
|
+
expect(Defmastership::Modifier::Toto).to(have_received(:new).with(toto_config[:config]))
|
38
|
+
end
|
39
|
+
|
40
|
+
it do
|
41
|
+
described_class.from_config(tutu_config)
|
42
|
+
expect(Defmastership::Modifier::TuTu).to(have_received(:new).with(tutu_config[:config]))
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|