defmastership 1.3.2 → 1.3.4
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/Gemfile +9 -9
- data/Guardfile +2 -5
- data/Rakefile +1 -1
- data/config/mutant.yml +2 -1
- data/config/rubocop.yml +20 -8
- data/defmastership.gemspec +6 -15
- data/features/changeref.feature +108 -0
- data/features/definition_checksum.feature +118 -0
- data/features/definition_version.feature +168 -0
- data/features/export.feature +122 -22
- data/features/external_ref_checksum.feature +169 -0
- data/features/external_ref_version.feature +173 -0
- data/features/internal_ref_checksum.feature +77 -0
- data/features/internal_ref_version.feature +81 -0
- data/features/rename_included_files.feature +55 -0
- data/features/step_definitions/git_steps.rb +3 -0
- data/lib/defmastership/app.rb +35 -8
- data/lib/defmastership/comment_filter.rb +2 -0
- data/lib/defmastership/def_type_list.rb +25 -0
- data/lib/defmastership/definition_parser.rb +2 -6
- data/lib/defmastership/document.rb +6 -9
- data/lib/defmastership/export/csv/formatter.rb +8 -60
- data/lib/defmastership/export/formatter.rb +88 -0
- data/lib/defmastership/export/json/formatter.rb +34 -0
- data/lib/defmastership/export/xlsx/formatter.rb +87 -0
- data/lib/defmastership/export/yaml/formatter.rb +34 -0
- data/lib/defmastership/modifier/change_ref.rb +24 -39
- data/lib/defmastership/modifier/factory.rb +5 -1
- data/lib/defmastership/modifier/modifier_common.rb +4 -4
- data/lib/defmastership/modifier/rename_included_files.rb +16 -5
- data/lib/defmastership/modifier/replacement_formatter.rb +37 -0
- data/lib/defmastership/modifier/update_def.rb +7 -2
- data/lib/defmastership/modifier/update_eref_checksum.rb +46 -0
- data/lib/defmastership/modifier/update_eref_common.rb +78 -0
- data/lib/defmastership/modifier/update_eref_version.rb +46 -0
- data/lib/defmastership/modifier/update_iref_checksum.rb +52 -0
- data/lib/defmastership/modifier/update_iref_common.rb +45 -0
- data/lib/defmastership/modifier/update_iref_version.rb +59 -0
- data/lib/defmastership/version.rb +1 -1
- data/spec/spec_helper.rb +11 -10
- data/spec/unit/defmastership/app_spec.rb +57 -20
- data/spec/unit/defmastership/batch_modifier_spec.rb +9 -7
- data/spec/unit/defmastership/def_type_list_spec.rb +22 -0
- data/spec/unit/defmastership/definition_spec.rb +8 -51
- data/spec/unit/defmastership/document_spec.rb +12 -36
- data/spec/unit/defmastership/export/body_formatter_spec.rb +5 -18
- data/spec/unit/defmastership/export/csv/formatter_spec.rb +45 -231
- data/spec/unit/defmastership/export/formatter_spec.rb +97 -0
- data/spec/unit/defmastership/export/header_formatter_spec.rb +2 -6
- data/spec/unit/defmastership/export/json/formatter_spec.rb +85 -0
- data/spec/unit/defmastership/export/xlsx/formatter_spec.rb +82 -0
- data/spec/unit/defmastership/export/yaml/formatter_spec.rb +85 -0
- data/spec/unit/defmastership/hash_spec.rb +2 -0
- data/spec/unit/defmastership/modifier/change_ref_spec.rb +66 -97
- data/spec/unit/defmastership/modifier/factory_spec.rb +40 -17
- data/spec/unit/defmastership/modifier/modifier_common_spec.rb +7 -5
- data/spec/unit/defmastership/modifier/rename_included_files_spec.rb +105 -85
- data/spec/unit/defmastership/modifier/update_def_checksum_spec.rb +6 -13
- data/spec/unit/defmastership/modifier/update_def_spec.rb +79 -22
- data/spec/unit/defmastership/modifier/update_def_version_spec.rb +13 -37
- data/spec/unit/defmastership/modifier/update_eref_checksum_spec.rb +209 -0
- data/spec/unit/defmastership/modifier/update_eref_version_spec.rb +227 -0
- data/spec/unit/defmastership/modifier/update_iref_checksum_spec.rb +133 -0
- data/spec/unit/defmastership/modifier/update_iref_version_spec.rb +162 -0
- data/tasks/code_quality.rake +1 -8
- data/tasks/test.rake +15 -0
- metadata +59 -6
|
@@ -19,7 +19,7 @@ RSpec.describe(Defmastership::App) do
|
|
|
19
19
|
context('when "--version" option') do
|
|
20
20
|
it {
|
|
21
21
|
expect { described_class.run(['--version']) }
|
|
22
|
-
.to(output(/version/).
|
|
22
|
+
.to(output(/version/).to_stdout_from_any_process)
|
|
23
23
|
}
|
|
24
24
|
end
|
|
25
25
|
|
|
@@ -28,10 +28,12 @@ RSpec.describe(Defmastership::App) do
|
|
|
28
28
|
|
|
29
29
|
[
|
|
30
30
|
/Export\s+the\s+definition\s+database\s+in\s+CSV$/,
|
|
31
|
-
/\bexport\b.*\basciidoctor_file\b
|
|
31
|
+
/\bexport\b.*\basciidoctor_file\b\s+\[asciidoctor_file\]\.\.\.$/,
|
|
32
32
|
/--separator, --sep, -s arg.*CSV\s+separator\s+\(default: ,\)$/,
|
|
33
33
|
/--\[no-\]no-fail.*Exit\s+success\s+even\s+in\s+
|
|
34
|
-
case\s+of\s+wrong\s+explicit\s+checksum$/mx
|
|
34
|
+
case\s+of\s+wrong\s+explicit\s+checksum$/mx,
|
|
35
|
+
/--output-file, -o arg.*CSV\s+output\s+filename\s+\(default:\s+none\)$/,
|
|
36
|
+
/--format, -f arg.*Output\s+format\s+\(default: csv\)$/
|
|
35
37
|
].each do |content|
|
|
36
38
|
it do
|
|
37
39
|
expect { described_class.run(['export', '--help']) }
|
|
@@ -40,22 +42,6 @@ RSpec.describe(Defmastership::App) do
|
|
|
40
42
|
end
|
|
41
43
|
end
|
|
42
44
|
|
|
43
|
-
context('when "export" with more than one argument') do
|
|
44
|
-
it { expect(described_class.run(%w[export arg1 arg2])).to(be(64)) }
|
|
45
|
-
|
|
46
|
-
it do
|
|
47
|
-
expect { described_class.run(%w[export arg1 arg2]) }
|
|
48
|
-
.to(output(/error: export expected only 1 arguments, but received 2/).to_stderr_from_any_process)
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
it { expect(described_class.run(['export'])).to(be(64)) }
|
|
52
|
-
|
|
53
|
-
it do
|
|
54
|
-
expect { described_class.run(['export']) }
|
|
55
|
-
.to(output(/error: export expected at least 1 arguments, but was given only 0/).to_stderr_from_any_process)
|
|
56
|
-
end
|
|
57
|
-
end
|
|
58
|
-
|
|
59
45
|
context('when "export toto.adoc" subcommand') do
|
|
60
46
|
let(:document) { instance_double(Defmastership::Document, 'document') }
|
|
61
47
|
let(:formatter) { instance_double(Defmastership::Export::CSV::Formatter, 'formatter') }
|
|
@@ -91,7 +77,7 @@ RSpec.describe(Defmastership::App) do
|
|
|
91
77
|
|
|
92
78
|
it { expect(Defmastership::Document).to(have_received(:new).with(no_args)) }
|
|
93
79
|
it { expect(document).to(have_received(:parse_file_with_preprocessor).once.with('toto.adoc')) }
|
|
94
|
-
it { expect(Defmastership::Export::CSV::Formatter).to(have_received(:new).with(document, ',')) }
|
|
80
|
+
it { expect(Defmastership::Export::CSV::Formatter).to(have_received(:new).with(document, separator: ',')) }
|
|
95
81
|
it { expect(formatter).to(have_received(:export_to).once.with('toto.csv')) }
|
|
96
82
|
it { expect(document).to(have_received(:wrong_explicit_checksum?)) }
|
|
97
83
|
|
|
@@ -115,6 +101,57 @@ RSpec.describe(Defmastership::App) do
|
|
|
115
101
|
end
|
|
116
102
|
end
|
|
117
103
|
|
|
104
|
+
context('when "export --format=xslx toto.adoc" subcommand') do
|
|
105
|
+
let(:document) { instance_double(Defmastership::Document, 'document') }
|
|
106
|
+
let(:formatter) { instance_double(Defmastership::Export::XLSX::Formatter, 'formatter') }
|
|
107
|
+
let(:defs) do
|
|
108
|
+
[
|
|
109
|
+
instance_double(Defmastership::Definition, 'def1'),
|
|
110
|
+
instance_double(Defmastership::Definition, 'def2')
|
|
111
|
+
]
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
before do
|
|
115
|
+
allow(Defmastership::Document).to(receive(:new).and_return(document))
|
|
116
|
+
allow(Defmastership::Export::XLSX::Formatter).to(receive(:new).and_return(formatter))
|
|
117
|
+
allow(formatter).to(receive(:export_to).with(an_instance_of(String)))
|
|
118
|
+
allow(document).to(receive(:parse_file_with_preprocessor).with(an_instance_of(String)))
|
|
119
|
+
allow(document).to(receive_messages(definitions: defs, wrong_explicit_checksum?: nil))
|
|
120
|
+
described_class.run(['export', '--format=xlsx', 'toto.adoc'])
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
it { expect(Defmastership::Export::XLSX::Formatter).to(have_received(:new).with(document)) }
|
|
124
|
+
it { expect(formatter).to(have_received(:export_to).once.with('toto.xlsx')) }
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
context('when "export" with more than one argument') do
|
|
128
|
+
let(:document) { instance_double(Defmastership::Document, 'document') }
|
|
129
|
+
let(:formatter) { instance_double(Defmastership::Export::CSV::Formatter, 'formatter') }
|
|
130
|
+
let(:defs) do
|
|
131
|
+
[
|
|
132
|
+
instance_double(Defmastership::Definition, 'def1'),
|
|
133
|
+
instance_double(Defmastership::Definition, 'def2')
|
|
134
|
+
]
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
before do
|
|
138
|
+
allow(Defmastership::Document).to(receive(:new).and_return(document))
|
|
139
|
+
allow(Defmastership::Export::CSV::Formatter).to(receive(:new).and_return(formatter))
|
|
140
|
+
allow(formatter).to(receive(:export_to).with(an_instance_of(String)))
|
|
141
|
+
allow(document).to(receive(:parse_file_with_preprocessor).with(an_instance_of(String)))
|
|
142
|
+
allow(document).to(receive_messages(definitions: defs, wrong_explicit_checksum?: nil))
|
|
143
|
+
|
|
144
|
+
described_class.run(['export', '--output-file=pouet.csv', 'toto.adoc', 'tutu.adoc'])
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
it { expect(Defmastership::Document).to(have_received(:new).with(no_args)) }
|
|
148
|
+
it { expect(document).to(have_received(:parse_file_with_preprocessor).once.with('toto.adoc')) }
|
|
149
|
+
it { expect(document).to(have_received(:parse_file_with_preprocessor).once.with('tutu.adoc')) }
|
|
150
|
+
it { expect(Defmastership::Export::CSV::Formatter).to(have_received(:new).with(document, separator: ',')) }
|
|
151
|
+
it { expect(formatter).to(have_received(:export_to).once.with('pouet.csv')) }
|
|
152
|
+
it { expect(described_class.run(['export', '--output-file=pouet.csv', 'toto.adoc', 'tutu.adoc'])).to(be(0)) }
|
|
153
|
+
end
|
|
154
|
+
|
|
118
155
|
context('when "modify --help" subcommand') do
|
|
119
156
|
it { expect(described_class.run(['modify', '--help'])).to(be(0)) }
|
|
120
157
|
|
|
@@ -4,14 +4,16 @@
|
|
|
4
4
|
require('defmastership/batch_modifier')
|
|
5
5
|
|
|
6
6
|
module Defmastership
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
module Modifier
|
|
8
|
+
# Modifier example
|
|
9
|
+
class Toto
|
|
10
|
+
include ModifierCommon
|
|
11
|
+
end
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
# Modifier example
|
|
14
|
+
class TuTu
|
|
15
|
+
include ModifierCommon
|
|
16
|
+
end
|
|
15
17
|
end
|
|
16
18
|
end
|
|
17
19
|
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Copyright (c) 2025 Jerome Arbez-Gindre
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require('defmastership/def_type_list')
|
|
5
|
+
|
|
6
|
+
RSpec.describe(Defmastership::DefTypeList) do
|
|
7
|
+
subject(:def_type_list) { described_class.new('') }
|
|
8
|
+
|
|
9
|
+
describe '.new' do
|
|
10
|
+
it { is_expected.not_to(be_nil) }
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
describe '#include?' do
|
|
14
|
+
it { expect(described_class.new('').include?('whatever')).to(be(true)) }
|
|
15
|
+
it { expect(described_class.new('all').include?('whatever')).to(be(true)) }
|
|
16
|
+
it { expect(described_class.new('one_type').include?('whatever')).to(be(false)) }
|
|
17
|
+
it { expect(described_class.new('one_type').include?('one_type')).to(be(true)) }
|
|
18
|
+
it { expect(described_class.new('one_type_more').include?('one_type')).to(be(false)) }
|
|
19
|
+
it { expect(described_class.new(%w[one_type another_type]).include?('one_type')).to(be(true)) }
|
|
20
|
+
it { expect(described_class.new(%w[one_type another_type]).include?('whatever')).to(be(false)) }
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -6,12 +6,7 @@ require('defmastership/definition')
|
|
|
6
6
|
RSpec.describe(Defmastership::Definition) do
|
|
7
7
|
describe '.new' do
|
|
8
8
|
context 'when minimal' do
|
|
9
|
-
subject
|
|
10
|
-
described_class.new(
|
|
11
|
-
type: 'req',
|
|
12
|
-
reference: 'TUTU-001'
|
|
13
|
-
)
|
|
14
|
-
end
|
|
9
|
+
subject { described_class.new(type: 'req', reference: 'TUTU-001') }
|
|
15
10
|
|
|
16
11
|
it { is_expected.not_to(be_nil) }
|
|
17
12
|
it { is_expected.to(have_attributes(type: 'req')) }
|
|
@@ -27,25 +22,13 @@ RSpec.describe(Defmastership::Definition) do
|
|
|
27
22
|
end
|
|
28
23
|
|
|
29
24
|
context 'with labels' do
|
|
30
|
-
subject
|
|
31
|
-
described_class.new(
|
|
32
|
-
type: 'req',
|
|
33
|
-
reference: 'TUTU-001',
|
|
34
|
-
labels: 'something'
|
|
35
|
-
)
|
|
36
|
-
end
|
|
25
|
+
subject { described_class.new(type: 'req', reference: 'TUTU-001', labels: 'something') }
|
|
37
26
|
|
|
38
27
|
it { is_expected.to(have_attributes(labels: Set['something'])) }
|
|
39
28
|
end
|
|
40
29
|
|
|
41
30
|
context 'with explicit_checksum' do
|
|
42
|
-
subject(:definition)
|
|
43
|
-
described_class.new(
|
|
44
|
-
type: 'req',
|
|
45
|
-
reference: 'TUTU-001',
|
|
46
|
-
explicit_checksum: '~8cc259e6'
|
|
47
|
-
)
|
|
48
|
-
end
|
|
31
|
+
subject(:definition) { described_class.new(type: 'req', reference: 'TUTU-001', explicit_checksum: '~8cc259e6') }
|
|
49
32
|
|
|
50
33
|
it do
|
|
51
34
|
definition << 'def value with a checksum != ~8cc259e6'
|
|
@@ -59,13 +42,7 @@ RSpec.describe(Defmastership::Definition) do
|
|
|
59
42
|
end
|
|
60
43
|
|
|
61
44
|
context 'with explicit_version' do
|
|
62
|
-
subject(:definition)
|
|
63
|
-
described_class.new(
|
|
64
|
-
type: 'req',
|
|
65
|
-
reference: 'TUTU-001',
|
|
66
|
-
explicit_version: 'pouet'
|
|
67
|
-
)
|
|
68
|
-
end
|
|
45
|
+
subject(:definition) { described_class.new(type: 'req', reference: 'TUTU-001', explicit_version: 'pouet') }
|
|
69
46
|
|
|
70
47
|
it do
|
|
71
48
|
expect(definition).to(have_attributes(explicit_version: 'pouet'))
|
|
@@ -74,12 +51,7 @@ RSpec.describe(Defmastership::Definition) do
|
|
|
74
51
|
end
|
|
75
52
|
|
|
76
53
|
describe '#<<' do
|
|
77
|
-
subject(:definition)
|
|
78
|
-
described_class.new(
|
|
79
|
-
type: 'req',
|
|
80
|
-
reference: 'TUTU-001'
|
|
81
|
-
)
|
|
82
|
-
end
|
|
54
|
+
subject(:definition) { described_class.new(type: 'req', reference: 'TUTU-001') }
|
|
83
55
|
|
|
84
56
|
it 'has value when one line is added' do
|
|
85
57
|
definition << 'first line'
|
|
@@ -133,12 +105,7 @@ RSpec.describe(Defmastership::Definition) do
|
|
|
133
105
|
end
|
|
134
106
|
|
|
135
107
|
describe '#add_eref' do
|
|
136
|
-
subject(:definition)
|
|
137
|
-
described_class.new(
|
|
138
|
-
type: 'req',
|
|
139
|
-
reference: 'TUTU-001'
|
|
140
|
-
)
|
|
141
|
-
end
|
|
108
|
+
subject(:definition) { described_class.new(type: 'req', reference: 'TUTU-001') }
|
|
142
109
|
|
|
143
110
|
[
|
|
144
111
|
'tutu,titi,pouet',
|
|
@@ -152,12 +119,7 @@ RSpec.describe(Defmastership::Definition) do
|
|
|
152
119
|
end
|
|
153
120
|
|
|
154
121
|
describe '#add_iref' do
|
|
155
|
-
subject(:definition)
|
|
156
|
-
described_class.new(
|
|
157
|
-
type: 'req',
|
|
158
|
-
reference: 'TUTU-001'
|
|
159
|
-
)
|
|
160
|
-
end
|
|
122
|
+
subject(:definition) { described_class.new(type: 'req', reference: 'TUTU-001') }
|
|
161
123
|
|
|
162
124
|
it 'shall accept to add multiple iref' do
|
|
163
125
|
definition.add_iref('toto')
|
|
@@ -167,12 +129,7 @@ RSpec.describe(Defmastership::Definition) do
|
|
|
167
129
|
end
|
|
168
130
|
|
|
169
131
|
describe '#set_attribute' do
|
|
170
|
-
subject(:definition)
|
|
171
|
-
described_class.new(
|
|
172
|
-
type: 'req',
|
|
173
|
-
reference: 'TUTU-001'
|
|
174
|
-
)
|
|
175
|
-
end
|
|
132
|
+
subject(:definition) { described_class.new(type: 'req', reference: 'TUTU-001') }
|
|
176
133
|
|
|
177
134
|
it 'shall accept to set attribute' do
|
|
178
135
|
definition.set_attribute(:whatever, 'value')
|
|
@@ -297,8 +297,7 @@ RSpec.describe(Defmastership::Document) do
|
|
|
297
297
|
|
|
298
298
|
it do
|
|
299
299
|
document.__send__(:do_parse, input_lines)
|
|
300
|
-
expect(document.eref[:implements])
|
|
301
|
-
.to(eq(prefix: 'Participate to:'))
|
|
300
|
+
expect(document.eref[:implements]).to(eq(prefix: 'Participate to:'))
|
|
302
301
|
end
|
|
303
302
|
end
|
|
304
303
|
|
|
@@ -326,7 +325,8 @@ RSpec.describe(Defmastership::Document) do
|
|
|
326
325
|
let(:input_lines) do
|
|
327
326
|
[
|
|
328
327
|
'[define, requirement, TOTO-0001]',
|
|
329
|
-
'defs:iref[toto] defs:iref[tutu]',
|
|
328
|
+
'defs:iref[toto] defs:iref[tutu(a)]',
|
|
329
|
+
'defs:iref[titi(a)], defs:iref[tata(a~12345678)]',
|
|
330
330
|
'defs:iref[pouet]'
|
|
331
331
|
]
|
|
332
332
|
end
|
|
@@ -337,7 +337,9 @@ RSpec.describe(Defmastership::Document) do
|
|
|
337
337
|
end
|
|
338
338
|
|
|
339
339
|
it { expect(definition).to(have_received(:add_iref).with('toto')) }
|
|
340
|
-
it { expect(definition).to(have_received(:add_iref).with('tutu')) }
|
|
340
|
+
it { expect(definition).to(have_received(:add_iref).with('tutu(a)')) }
|
|
341
|
+
it { expect(definition).to(have_received(:add_iref).with('titi(a)')) }
|
|
342
|
+
it { expect(definition).to(have_received(:add_iref).with('tata(a~12345678)')) }
|
|
341
343
|
it { expect(definition).to(have_received(:add_iref).with('pouet')) }
|
|
342
344
|
it { expect(document.iref).to(be(true)) }
|
|
343
345
|
end
|
|
@@ -417,12 +419,7 @@ RSpec.describe(Defmastership::Document) do
|
|
|
417
419
|
|
|
418
420
|
before do
|
|
419
421
|
allow(Defmastership::Definition).to(receive(:new).and_return(definition))
|
|
420
|
-
allow(definition).to(
|
|
421
|
-
receive_messages(
|
|
422
|
-
labels: Set.new,
|
|
423
|
-
'<<': definition
|
|
424
|
-
)
|
|
425
|
-
)
|
|
422
|
+
allow(definition).to(receive_messages(labels: Set.new, '<<': definition))
|
|
426
423
|
document.__send__(:do_parse, input_lines)
|
|
427
424
|
end
|
|
428
425
|
|
|
@@ -522,9 +519,7 @@ RSpec.describe(Defmastership::Document) do
|
|
|
522
519
|
end
|
|
523
520
|
|
|
524
521
|
before do
|
|
525
|
-
allow(Defmastership::Definition).to(
|
|
526
|
-
receive(:new).and_raise('not a valide definition')
|
|
527
|
-
)
|
|
522
|
+
allow(Defmastership::Definition).to(receive(:new).and_raise('not a valide definition'))
|
|
528
523
|
end
|
|
529
524
|
|
|
530
525
|
it do
|
|
@@ -543,9 +538,7 @@ RSpec.describe(Defmastership::Document) do
|
|
|
543
538
|
end
|
|
544
539
|
|
|
545
540
|
before do
|
|
546
|
-
allow(Defmastership::Definition).to(
|
|
547
|
-
receive(:new).and_raise('not a valide definition')
|
|
548
|
-
)
|
|
541
|
+
allow(Defmastership::Definition).to(receive(:new).and_raise('not a valide definition'))
|
|
549
542
|
end
|
|
550
543
|
|
|
551
544
|
it do
|
|
@@ -569,12 +562,7 @@ RSpec.describe(Defmastership::Document) do
|
|
|
569
562
|
allow(adoc_doc).to(receive(:reader).and_return(adoc_reader))
|
|
570
563
|
allow(adoc_reader).to(receive(:read_lines).and_return(input_lines))
|
|
571
564
|
allow(Defmastership::Definition).to(receive(:new).and_return(definition))
|
|
572
|
-
allow(definition).to(
|
|
573
|
-
receive_messages(
|
|
574
|
-
'<<': definition,
|
|
575
|
-
labels: Set.new
|
|
576
|
-
)
|
|
577
|
-
)
|
|
565
|
+
allow(definition).to(receive_messages('<<': definition, labels: Set.new))
|
|
578
566
|
document.parse_file_with_preprocessor('the_file.adoc')
|
|
579
567
|
end
|
|
580
568
|
|
|
@@ -758,20 +746,8 @@ RSpec.describe(Defmastership::Document) do
|
|
|
758
746
|
|
|
759
747
|
before do
|
|
760
748
|
allow(Defmastership::Definition).to(receive(:new).twice.and_return(definitions.first, definitions[1]))
|
|
761
|
-
allow(definitions.first).to(
|
|
762
|
-
|
|
763
|
-
labels: [],
|
|
764
|
-
'<<': definitions.first,
|
|
765
|
-
reference: 'TOTO-0001'
|
|
766
|
-
)
|
|
767
|
-
)
|
|
768
|
-
allow(definitions[1]).to(
|
|
769
|
-
receive_messages(
|
|
770
|
-
labels: [],
|
|
771
|
-
'<<': definitions[1],
|
|
772
|
-
reference: 'TOTO-0002'
|
|
773
|
-
)
|
|
774
|
-
)
|
|
749
|
+
allow(definitions.first).to(receive_messages(labels: [], '<<': definitions.first, reference: 'TOTO-0001'))
|
|
750
|
+
allow(definitions[1]).to(receive_messages(labels: [], '<<': definitions[1], reference: 'TOTO-0002'))
|
|
775
751
|
document.__send__(:do_parse, input_lines)
|
|
776
752
|
end
|
|
777
753
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# Copyright (c) 2020 Jerome Arbez-Gindre
|
|
2
2
|
# frozen_string_literal: true
|
|
3
3
|
|
|
4
|
+
require('defmastership/document')
|
|
4
5
|
require('defmastership/export/body_formatter')
|
|
5
6
|
|
|
6
7
|
RSpec.describe(Defmastership::Export::BodyFormatter) do
|
|
@@ -142,11 +143,7 @@ RSpec.describe(Defmastership::Export::BodyFormatter) do
|
|
|
142
143
|
|
|
143
144
|
context 'when eref on the document' do
|
|
144
145
|
before do
|
|
145
|
-
allow(document).to(
|
|
146
|
-
receive(:eref).with(no_args).and_return(
|
|
147
|
-
a: 'whatever', b: 'whatever', c: 'whatever'
|
|
148
|
-
)
|
|
149
|
-
)
|
|
146
|
+
allow(document).to(receive(:eref).with(no_args).and_return(a: 'whatever', b: 'whatever', c: 'whatever'))
|
|
150
147
|
allow(definition).to(receive(:eref).with(no_args).and_return(a: %w[A B], b: [], c: ['C']))
|
|
151
148
|
formatter.eref
|
|
152
149
|
end
|
|
@@ -157,11 +154,7 @@ RSpec.describe(Defmastership::Export::BodyFormatter) do
|
|
|
157
154
|
|
|
158
155
|
context 'when missing eref on the definition' do
|
|
159
156
|
before do
|
|
160
|
-
allow(document).to(
|
|
161
|
-
receive(:eref).with(no_args).and_return(
|
|
162
|
-
a: 'whatever', b: 'whatever'
|
|
163
|
-
)
|
|
164
|
-
)
|
|
157
|
+
allow(document).to(receive(:eref).with(no_args).and_return(a: 'whatever', b: 'whatever'))
|
|
165
158
|
allow(definition).to(receive(:eref).with(no_args).and_return(b: ['B']))
|
|
166
159
|
formatter.eref
|
|
167
160
|
end
|
|
@@ -208,10 +201,7 @@ RSpec.describe(Defmastership::Export::BodyFormatter) do
|
|
|
208
201
|
|
|
209
202
|
context 'when attributes on the document' do
|
|
210
203
|
before do
|
|
211
|
-
allow(document).to(
|
|
212
|
-
receive(:attributes).with(no_args)
|
|
213
|
-
.and_return(a: 'whatever', b: 'whatever', c: 'whatever')
|
|
214
|
-
)
|
|
204
|
+
allow(document).to(receive(:attributes).with(no_args).and_return(a: 'whatever', b: 'whatever', c: 'whatever'))
|
|
215
205
|
allow(definition).to(receive(:attributes).and_return(a: 'X', b: '', c: 'Y'))
|
|
216
206
|
formatter.attributes
|
|
217
207
|
end
|
|
@@ -222,10 +212,7 @@ RSpec.describe(Defmastership::Export::BodyFormatter) do
|
|
|
222
212
|
|
|
223
213
|
context 'when miing attribute on the definition' do
|
|
224
214
|
before do
|
|
225
|
-
allow(document).to(
|
|
226
|
-
receive(:attributes).with(no_args)
|
|
227
|
-
.and_return(a: 'whatever', b: 'whatever', c: 'whatever')
|
|
228
|
-
)
|
|
215
|
+
allow(document).to(receive(:attributes).with(no_args).and_return(a: 'whatever', b: 'whatever', c: 'whatever'))
|
|
229
216
|
allow(definition).to(receive(:attributes).and_return(a: 'X', b: ''))
|
|
230
217
|
formatter.attributes
|
|
231
218
|
end
|