defmastership 1.0.18 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +4 -0
- data/.gitlab-ci.yml +42 -1
- data/Gemfile +49 -18
- data/Guardfile +44 -0
- data/LICENSE +1 -1
- data/README.adoc +24 -0
- data/Rakefile +0 -1
- data/bin/defmastership +5 -5
- data/config/cucumber.yml +3 -0
- data/config/mutant.yml +22 -16
- data/config/reek.yml +129 -105
- data/config/rubocop.yml +67 -28
- data/defmastership.gemspec +8 -6
- data/features/changeref.feature +0 -8
- data/features/definition_checksum.feature +0 -10
- data/features/definition_version.feature +168 -10
- data/features/export.feature +23 -18
- data/features/modify.feature +1 -5
- data/features/rename_included_files.feature +0 -5
- data/features/step_definitions/git_steps.rb +19 -0
- data/lib/defmastership/batch_modifier.rb +23 -5
- data/lib/defmastership/comment_filter.rb +2 -1
- data/lib/defmastership/definition.rb +26 -6
- data/lib/defmastership/definition_parser.rb +2 -2
- data/lib/defmastership/document.rb +45 -33
- 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 +15 -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} +11 -18
- 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 -18
- data/spec/unit/defmastership/modifier/update_def_version_spec.rb +351 -0
- data/spec/unit/{def_mastership_spec.rb → defmastership_spec.rb} +2 -2
- data/tasks/code_quality.rake +74 -0
- data/tasks/documentation.rake +19 -0
- data/tasks/package.rake +4 -0
- data/tasks/test.rake +6 -21
- metadata +96 -51
- data/.rubocop.yml +0 -76
- data/README.rdoc +0 -6
- data/config/devtools.yml +0 -2
- data/config/flay.yml +0 -3
- data/config/flog.yml +0 -2
- data/config/yardstick.yml +0 -2
- data/cucumber.yml +0 -2
- data/defmastership.rdoc +0 -5
- data/lib/defmastership/change_ref_modifier.rb +0 -99
- data/lib/defmastership/constants.rb +0 -89
- 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 -66
- data/spec/unit/def_mastership/modifier_factory_spec.rb +0 -37
- data/spec/unit/def_mastership/parsing_state_spec.rb +0 -62
- data/spec/unit/def_mastership/update_def_version_modifier_spec.rb +0 -159
- data/tasks/package.task +0 -9
- data/tasks/smelling_code.rake +0 -38
- /data/{.rspec → config/rspec} +0 -0
- /data/spec/unit/{def_mastership → defmastership}/string_spec.rb +0 -0
@@ -3,17 +3,19 @@
|
|
3
3
|
|
4
4
|
require('defmastership/batch_modifier')
|
5
5
|
|
6
|
-
module
|
7
|
-
|
6
|
+
module Defmastership
|
7
|
+
# Modifier example
|
8
|
+
class Toto
|
8
9
|
include Modifier
|
9
10
|
end
|
10
11
|
|
11
|
-
|
12
|
+
# Modifier example
|
13
|
+
class TuTu
|
12
14
|
include Modifier
|
13
15
|
end
|
14
16
|
end
|
15
17
|
|
16
|
-
RSpec.describe(
|
18
|
+
RSpec.describe(Defmastership::BatchModifier) do
|
17
19
|
subject(:batchmodifier) do
|
18
20
|
described_class.new(config, adoc_sources)
|
19
21
|
end
|
@@ -43,7 +45,7 @@ RSpec.describe(DefMastership::BatchModifier) do
|
|
43
45
|
|
44
46
|
describe '#apply' do
|
45
47
|
context 'with only one modification' do
|
46
|
-
let(:toto1) { instance_double(
|
48
|
+
let(:toto1) { instance_double(Defmastership::Modifier::Toto, 'toto1') }
|
47
49
|
let(:adoc_sources_modified) do
|
48
50
|
{
|
49
51
|
'file1.adoc' => 'some text modified',
|
@@ -60,7 +62,7 @@ RSpec.describe(DefMastership::BatchModifier) do
|
|
60
62
|
end
|
61
63
|
|
62
64
|
before do
|
63
|
-
allow(
|
65
|
+
allow(Defmastership::Modifier::Toto).to(receive(:new).once.and_return(toto1))
|
64
66
|
allow(toto1).to(receive(:do_modifications).once.and_return(adoc_sources_modified))
|
65
67
|
allow(toto1).to(receive(:config).once.and_return(p: 'modified_param'))
|
66
68
|
allow(toto1).to(receive(:changes).once.and_return([%w[from1 to1], %w[from2 to2]]))
|
@@ -68,7 +70,7 @@ RSpec.describe(DefMastership::BatchModifier) do
|
|
68
70
|
end
|
69
71
|
|
70
72
|
it do
|
71
|
-
expect(
|
73
|
+
expect(Defmastership::Modifier::Toto).to(have_received(:new).with(p: 1))
|
72
74
|
end
|
73
75
|
|
74
76
|
it { expect(toto1).to(have_received(:do_modifications).with(adoc_sources)) }
|
@@ -80,8 +82,8 @@ RSpec.describe(DefMastership::BatchModifier) do
|
|
80
82
|
end
|
81
83
|
|
82
84
|
context 'with two modifications' do
|
83
|
-
let(:toto2) { instance_double(
|
84
|
-
let(:tutu3) { instance_double(
|
85
|
+
let(:toto2) { instance_double(Defmastership::Modifier::Toto, 'toto2') }
|
86
|
+
let(:tutu3) { instance_double(Defmastership::Modifier::TuTu, 'tutu3') }
|
85
87
|
|
86
88
|
let(:config_modified) do
|
87
89
|
{
|
@@ -92,10 +94,10 @@ RSpec.describe(DefMastership::BatchModifier) do
|
|
92
94
|
end
|
93
95
|
|
94
96
|
before do
|
95
|
-
allow(
|
97
|
+
allow(Defmastership::Modifier::Toto).to(receive(:new).once.and_return(toto2))
|
96
98
|
allow(toto2).to(receive(:do_modifications).once.and_return(:adoc_sources_modified_mod2))
|
97
99
|
allow(toto2).to(receive(:config).once.and_return(:whatever))
|
98
|
-
allow(
|
100
|
+
allow(Defmastership::Modifier::TuTu).to(receive(:new).once.and_return(tutu3))
|
99
101
|
allow(tutu3).to(receive(:do_modifications).once.and_return(:adoc_sources_modified_mod3))
|
100
102
|
allow(tutu3).to(receive(:config).once.and_return(:pouet))
|
101
103
|
allow(toto2).to(receive(:changes).once.and_return([%w[from1 to1]]))
|
@@ -103,8 +105,8 @@ RSpec.describe(DefMastership::BatchModifier) do
|
|
103
105
|
batchmodifier.apply(%i[modifier2 modifier3])
|
104
106
|
end
|
105
107
|
|
106
|
-
it { expect(
|
107
|
-
it { expect(
|
108
|
+
it { expect(Defmastership::Modifier::Toto).to(have_received(:new).with(p: 'whatever1')) }
|
109
|
+
it { expect(Defmastership::Modifier::TuTu).to(have_received(:new).with(p1: 'whatever2', p2: 'whatever3')) }
|
108
110
|
it { expect(toto2).to(have_received(:do_modifications).with(adoc_sources)) }
|
109
111
|
it { expect(toto2).to(have_received(:config).with(no_args)) }
|
110
112
|
it { expect(tutu3).to(have_received(:do_modifications).with(:adoc_sources_modified_mod2)) }
|
@@ -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) }
|