defmastership 1.1.1 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c4ed160f247162499c3dfbc553d75056a65f3e597d89d4943c68c52bfeff0afe
4
- data.tar.gz: 747484788ddb69600e47cb9594c4751aebb401ce3f71cabc14ebe88854aff23b
3
+ metadata.gz: a0108caf9fe5e03e882cd80fda5c2221698cc468ffb1153f4a1dbbfcfb0d3ca7
4
+ data.tar.gz: b8fe780478f0b8a060beddb40e9fb1eb105e634f60d92467845fc1d122d8bd62
5
5
  SHA512:
6
- metadata.gz: fc437e7d4ab2aea08436dac424c6d5f265126628b789a3c786d1e531550ee9d42c389320e67a50de6e7794547dba5cb3fdae96af8b8cfe626d99ce7d488895e2
7
- data.tar.gz: ab375620466f0c23efe0149b9ce76735e64e586f40541edb182cf045f0a9d3bb6a23eb4b5cb6d2a1291e7f95010cd629e19fb89ab9998dbc81abddca10e13a2a
6
+ metadata.gz: 6a4c2cf44ad08ddb72a5f83b58ca19de4049970b81fae449870cc376ab294887dd239a82f190a67821b7ecd493195a5287931024f1e85d0ea2cd61d4e5e20b45
7
+ data.tar.gz: 51a482a53c38481d2c494842962675948477ea245f7bc1a4d2c9c4d45c4bef38185670caad69d7ebc88d61ab44af2647bab396ddd6df817ea8d6ee0190dc9fc5
@@ -34,7 +34,7 @@ Gem::Specification.new do |spec|
34
34
  spec.add_dependency('aasm', '~> 5')
35
35
  spec.add_dependency('asciidoctor', '~> 2')
36
36
  spec.add_dependency('csv', '~> 3')
37
- spec.add_dependency('defmastership-core', '>= 1.2.0')
37
+ spec.add_dependency('defmastership-core', '~> 1.3.0')
38
38
  spec.add_dependency('git', '~> 1')
39
39
  spec.add_dependency('gli', '~> 2')
40
40
  spec.add_dependency('ostruct', '~> 0')
@@ -236,6 +236,62 @@ Feature: definition checksum
236
236
  """
237
237
  And the stdout should not contain anything
238
238
 
239
+ Scenario: Checksum takes into account definition summary in ref modification
240
+ Given a file named "modifications.yml" with:
241
+ """
242
+ ---
243
+ :update_requirement_checksum:
244
+ :type: update_def_checksum
245
+ :config:
246
+ :def_type: requirement
247
+ """
248
+ And a file named "thedoc.adoc" with:
249
+ """
250
+ [define, requirement, TOTO-0001]
251
+ --
252
+ A nice summary
253
+ Exemple of multiline requirement.
254
+ Second line.
255
+ --
256
+
257
+ [define, requirement, TOTO-0002, A nice summary]
258
+ --
259
+ Exemple of multiline requirement.
260
+ Second line.
261
+ --
262
+
263
+ :a_variable: summary
264
+ [define, requirement, TOTO-0003, A nice {a_variable}]
265
+ --
266
+ Exemple of multiline requirement.
267
+ Second line.
268
+ --
269
+ """
270
+ When I successfully run `defmastership modify --modifications update_requirement_checksum thedoc.adoc`
271
+ Then the file "thedoc.adoc" should contain:
272
+ """
273
+ [define, requirement, TOTO-0001(~f8092f4e)]
274
+ --
275
+ A nice summary
276
+ Exemple of multiline requirement.
277
+ Second line.
278
+ --
279
+
280
+ [define, requirement, TOTO-0002(~f8092f4e), A nice summary]
281
+ --
282
+ Exemple of multiline requirement.
283
+ Second line.
284
+ --
285
+
286
+ :a_variable: summary
287
+ [define, requirement, TOTO-0003(~f8092f4e), A nice {a_variable}]
288
+ --
289
+ Exemple of multiline requirement.
290
+ Second line.
291
+ --
292
+ """
293
+ And the stdout should not contain anything
294
+
239
295
  Scenario: Checksum does not take into account bad variables definition
240
296
  Given a file named "modifications.yml" with:
241
297
  """
@@ -56,6 +56,41 @@ Feature: definitions version
56
56
  --
57
57
  """
58
58
 
59
+ Scenario: Set initial explicit version when definition summary has changed
60
+ Given a file named "ref_doc.adoc" with:
61
+ """
62
+ [define, requirement, TOTO-0001, a nice summary]
63
+ --
64
+ Some text.
65
+ --
66
+ """
67
+ Given a file named "thedoc.adoc" with:
68
+ """
69
+ [define, requirement, TOTO-0001(whatever), a really nice summary]
70
+ --
71
+ Some text.
72
+ --
73
+ """
74
+ And a file named "modifications.yml" with:
75
+ """
76
+ ---
77
+ :update_requirement_version:
78
+ :type: update_def_version
79
+ :config:
80
+ :def_type: requirement
81
+ :first_version: a
82
+ :ref_document: ./ref_doc.adoc
83
+ """
84
+ When I successfully run `defmastership modify --modifications update_requirement_version thedoc.adoc`
85
+ And the stdout should not contain anything
86
+ Then the file "thedoc.adoc" should contain:
87
+ """
88
+ [define, requirement, TOTO-0001(a), a really nice summary]
89
+ --
90
+ Some text.
91
+ --
92
+ """
93
+
59
94
  Scenario: Set initial explicit version when definition has changed with multiple ref_files
60
95
  Given a file named "ref_doc1.adoc" with:
61
96
  """
@@ -174,6 +174,43 @@ Feature: The extract command
174
174
  """
175
175
  And the stdout should not contain anything
176
176
 
177
+ Scenario: Extract definition with summary
178
+ Given a file named "toto.adoc" with:
179
+ """
180
+ [define, requirement, TOTO-0001, A nice summary]
181
+ --
182
+ Exemple of multiline requirement.
183
+ Second line.
184
+ --
185
+ """
186
+ When I successfully run `defmastership export toto.adoc`
187
+ Then the file "toto.csv" should contain:
188
+ """
189
+ Type,Reference,Summary,Value,Checksum
190
+ requirement,TOTO-0001,A nice summary,"Exemple of multiline requirement.
191
+ Second line.",~f8092f4e
192
+ """
193
+ And the stdout should not contain anything
194
+
195
+ Scenario: Extract definition with summary with variable
196
+ Given a file named "toto.adoc" with:
197
+ """
198
+ :a_variable: summary
199
+ [define, requirement, TOTO-0001, A nice {a_variable}]
200
+ --
201
+ Exemple of multiline requirement.
202
+ Second line.
203
+ --
204
+ """
205
+ When I successfully run `defmastership export toto.adoc`
206
+ Then the file "toto.csv" should contain:
207
+ """
208
+ Type,Reference,Summary,Value,Checksum
209
+ requirement,TOTO-0001,A nice summary,"Exemple of multiline requirement.
210
+ Second line.",~f8092f4e
211
+ """
212
+ And the stdout should not contain anything
213
+
177
214
  Scenario: Extract definition with labels
178
215
  Given a file named "toto.adoc" with:
179
216
  """
@@ -8,6 +8,7 @@ module Defmastership
8
8
  BUILD_FROM_MATCH = {
9
9
  type: ->(match) { match[:type] },
10
10
  reference: ->(match) { match[:reference] },
11
+ summary: ->(match) { match[:summary] },
11
12
  lines: ->(_) { [] },
12
13
  labels: lambda do |match|
13
14
  labels = Set.new
@@ -27,6 +28,7 @@ module Defmastership
27
28
  DefinitionData = Struct.new(
28
29
  :type,
29
30
  :reference,
31
+ :summary,
30
32
  :lines,
31
33
  :labels,
32
34
  :eref,
@@ -44,6 +46,7 @@ module Defmastership
44
46
  def_delegators :@data,
45
47
  :type,
46
48
  :reference,
49
+ :summary,
47
50
  :lines,
48
51
  :labels,
49
52
  :eref,
@@ -78,7 +81,9 @@ module Defmastership
78
81
 
79
82
  # @return [String] short representation (8 last characters) of the sha256 of the definition's value
80
83
  def sha256_short
81
- "~#{Digest::SHA2.hexdigest(value).chars.last(8).join}"
84
+ return "~#{Digest::SHA2.hexdigest(value).chars.last(8).join}" unless summary
85
+
86
+ "~#{Digest::SHA2.hexdigest("#{summary}\n#{value}").chars.last(8).join}"
82
87
  end
83
88
 
84
89
  # @return [String] the explicit checsum if wrong or nil
@@ -22,7 +22,9 @@ module Defmastership
22
22
 
23
23
  PARSER_ACTIONS = {
24
24
  add_new_definition: lambda { |matching_line|
25
- definition = Definition.new(matching_line.match)
25
+ # rebuild the match to take into account eventual variable substitutions
26
+ match = matching_line.line.match(Core::DMRegexp::DEFINITION)
27
+ definition = Definition.new(match)
26
28
  labels.merge(definition.labels)
27
29
  definitions << definition
28
30
  },
@@ -88,6 +90,13 @@ module Defmastership
88
90
  do_parse(Asciidoctor.load_file(adoc_file, safe: :unsafe, parse: false).reader.read_lines)
89
91
  end
90
92
 
93
+ # @return [Boolean] true if the document has definitions with summary
94
+ def summaries?
95
+ definitions.reduce(false) do |res, definition|
96
+ res || !!definition.summary
97
+ end
98
+ end
99
+
91
100
  # @return [Boolean] true if the document has definitions with wrong explicit checksum
92
101
  def wrong_explicit_checksum?
93
102
  definitions.reduce(false) do |res, definition|
@@ -174,5 +183,6 @@ module Defmastership
174
183
  end
175
184
  end
176
185
  end
186
+ private_constant :Helper
177
187
  end
178
188
  end
@@ -14,9 +14,15 @@ module Defmastership
14
14
  @definition = definition
15
15
  end
16
16
 
17
- # @return [Array<String>] list of always available columns values
18
- def fixed
19
- [@definition.type, @definition.reference, @definition.value, @definition.sha256_short]
17
+ %i[type reference summary value].each do |method_symbol|
18
+ define_method(method_symbol) do
19
+ [@definition.public_send(method_symbol)]
20
+ end
21
+ end
22
+
23
+ # @return [Array<String>] checksum column value
24
+ def checksum
25
+ [@definition.sha256_short]
20
26
  end
21
27
 
22
28
  # @return [Array<String>] Optional wrong_explicit_checksum column value
@@ -32,6 +32,38 @@ module Defmastership
32
32
 
33
33
  private
34
34
 
35
+ # Helper functions
36
+ module Helper
37
+ # @return [Array<Symbol>] the array of methods for columns inclusion
38
+ #
39
+ # @param column_spec [MethodSpec] the method to include or not with its guard
40
+ # @param doc [Document] the Document to export
41
+ def self.column_method(column_spec, doc)
42
+ column_spec.guard.call(doc) ? [column_spec.column_method] : []
43
+ end
44
+
45
+ # 2-uplet with one method to include or not depending of a lambda guard
46
+ MethodSpec = Struct.new(:column_method, :guard)
47
+ public_constant :MethodSpec
48
+ end
49
+ private_constant :Helper
50
+
51
+ COLUMNS_METHODS_SPECIFICATIONS =
52
+ [
53
+ Helper::MethodSpec.new(:type, ->(_) { true }),
54
+ Helper::MethodSpec.new(:reference, ->(_) { true }),
55
+ Helper::MethodSpec.new(:summary, lambda(&:summaries?)),
56
+ Helper::MethodSpec.new(:value, ->(_) { true }),
57
+ Helper::MethodSpec.new(:checksum, ->(_) { true }),
58
+ Helper::MethodSpec.new(:wrong_explicit_checksum, lambda(&:wrong_explicit_checksum?)),
59
+ Helper::MethodSpec.new(:explicit_version, lambda(&:explicit_version?)),
60
+ Helper::MethodSpec.new(:labels, ->(doc) { !doc.labels.empty? }),
61
+ Helper::MethodSpec.new(:eref, ->(doc) { !doc.eref.empty? }),
62
+ Helper::MethodSpec.new(:iref, lambda(&:iref)),
63
+ Helper::MethodSpec.new(:attributes, ->(doc) { !doc.attributes.empty? })
64
+ ].freeze
65
+ private_constant :COLUMNS_METHODS_SPECIFICATIONS
66
+
35
67
  def export_definitions_in(csv, column_list)
36
68
  @doc.definitions.each { |definition| csv << body(definition, column_list) }
37
69
  end
@@ -49,14 +81,9 @@ module Defmastership
49
81
  end
50
82
 
51
83
  def build_column_list
52
- [
53
- [:wrong_explicit_checksum, @doc.wrong_explicit_checksum?],
54
- [:explicit_version, @doc.explicit_version?],
55
- [:labels, !@doc.labels.empty?],
56
- [:eref, !@doc.eref.empty?],
57
- [:iref, @doc.iref],
58
- [:attributes, !@doc.attributes.empty?]
59
- ].reduce([:fixed]) { |acc, elem| acc + (elem.fetch(1) ? [elem.first] : []) }
84
+ COLUMNS_METHODS_SPECIFICATIONS.reduce([]) do |acc, column|
85
+ acc + Helper.column_method(column, @doc)
86
+ end
60
87
  end
61
88
  end
62
89
  end
@@ -12,9 +12,10 @@ module Defmastership
12
12
  @doc = doc
13
13
  end
14
14
 
15
- # @return [Array<String>] list of always available columns
16
- def fixed
17
- %w[Type Reference Value Checksum]
15
+ %i[type reference summary value checksum].each do |method_symbol|
16
+ define_method(method_symbol) do
17
+ [method_symbol.to_s.capitalize]
18
+ end
18
19
  end
19
20
 
20
21
  # @return [Array<String>] Optional wrong_explicit_checksum column caption
@@ -11,14 +11,43 @@ module Defmastership
11
11
  class ChangeRef
12
12
  include ModifierCommon
13
13
 
14
+ # [Regexp] match all text before the definition's reference
15
+ DEF_BEFORE_REF = <<~"BEF"
16
+ ^
17
+ \\s*
18
+ \\[
19
+ #{Core::DMRegexp::DEF_KEYWORD}
20
+ #{Core::DMRegexp::DEF_TYPE}
21
+ ,
22
+ \\s*
23
+ BEF
24
+ private_constant :DEF_BEFORE_REF
25
+
26
+ # [Regexp] match all text after the definition's reference
27
+ DEF_AFTER_REF = <<~"AFT"
28
+ \\s*
29
+ #{Core::DMRegexp::DEF_SUMMARY}
30
+ #{Core::DMRegexp::DEF_LABELS}
31
+ \\s*
32
+ \\]
33
+ AFT
34
+ private_constant :DEF_AFTER_REF
35
+
36
+ # [Regexp] match the begining of an internal cross reference
37
+ IREF_DEF_BEF = 'defs:iref\[\s*'
38
+ private_constant :IREF_DEF_BEF
39
+ # [Regexp] match the end of an internal cross reference
40
+ IREF_DEF_AFT = '\s*\]'
41
+ private_constant :IREF_DEF_AFT
42
+
14
43
  REGEXP_FROM = {
15
44
  definition: {
16
- before: Core::DMRegexp::DEF_BEFORE_REF,
17
- after: Core::DMRegexp::DEF_AFTER_REF
45
+ before: DEF_BEFORE_REF,
46
+ after: DEF_AFTER_REF
18
47
  },
19
48
  iref: {
20
- before: Core::DMRegexp::IREF_DEF_BEF,
21
- after: Core::DMRegexp::IREF_DEF_AFT
49
+ before: IREF_DEF_BEF,
50
+ after: IREF_DEF_AFT
22
51
  }
23
52
  }.freeze
24
53
 
@@ -112,6 +141,7 @@ module Defmastership
112
141
  match[:before] + replacement + (match[:version_and_checksum] || '') + match[:after]
113
142
  end
114
143
  end
144
+ private_constant :Helper
115
145
  end
116
146
  end
117
147
  end
@@ -108,8 +108,6 @@ module Defmastership
108
108
  end
109
109
 
110
110
  def concerned_line?(line)
111
- return false if line.commented?
112
-
113
111
  parse(line)
114
112
 
115
113
  return false if @definition_parser.idle?
@@ -218,6 +216,7 @@ module Defmastership
218
216
  end
219
217
  end
220
218
  end
219
+ private_constant :Helper
221
220
  end
222
221
  end
223
222
  end
@@ -105,6 +105,7 @@ module Defmastership
105
105
  config[:ref_document] = [ref_docs] if ref_docs.instance_of?(String)
106
106
  end
107
107
  end
108
+ private_constant :Helper
108
109
  end
109
110
  end
110
111
  end
@@ -3,6 +3,6 @@
3
3
 
4
4
  module Defmastership
5
5
  # [String] Gem version
6
- VERSION = '1.1.1'
6
+ VERSION = '1.2.0'
7
7
  public_constant :VERSION
8
8
  end
@@ -112,6 +112,26 @@ RSpec.describe(Defmastership::Definition) do
112
112
  end
113
113
  end
114
114
 
115
+ describe '#sha256_short' do
116
+ context 'when definition has no summary' do
117
+ subject(:definition) { described_class.new(type: 'req') }
118
+
119
+ it 'calculates sha256_short of value' do
120
+ definition << 'first line' << 'second line'
121
+ expect(definition.sha256_short).to(eq('~beb0535a'))
122
+ end
123
+ end
124
+
125
+ context 'when definition has a summary' do
126
+ subject(:definition) { described_class.new(type: 'req', summary: 'first line') }
127
+
128
+ it 'calculates sha256_short of value' do
129
+ definition << 'second line'
130
+ expect(definition.sha256_short).to(eq('~beb0535a'))
131
+ end
132
+ end
133
+ end
134
+
115
135
  describe '#add_eref' do
116
136
  subject(:definition) do
117
137
  described_class.new(
@@ -475,6 +475,23 @@ RSpec.describe(Defmastership::Document) do
475
475
 
476
476
  it { expect(definition).to(have_received(:<<).with('bef one two aft')) }
477
477
  end
478
+
479
+ context 'when variable in definition summary' do
480
+ let(:input_lines) do
481
+ [
482
+ ':one_variable: the substituted variable',
483
+ '[define, requirement, TOTO-0001, a summary with {one_variable}]'
484
+ ]
485
+ end
486
+
487
+ it do
488
+ expect(Defmastership::Definition).to(
489
+ have_received(:new).with(
490
+ matchdata_including(summary: 'a summary with the substituted variable')
491
+ )
492
+ )
493
+ end
494
+ end
478
495
  end
479
496
 
480
497
  context 'with invalid definitions' do
@@ -557,6 +574,55 @@ RSpec.describe(Defmastership::Document) do
557
574
  end
558
575
  end
559
576
 
577
+ describe '#summaries?' do
578
+ let(:defs) do
579
+ [
580
+ instance_double(Defmastership::Definition, 'definition'),
581
+ instance_double(Defmastership::Definition, 'definition')
582
+ ]
583
+ end
584
+
585
+ let(:input_lines) do
586
+ [
587
+ '[define, requirement, TOTO-0001]',
588
+ 'def one',
589
+ '',
590
+ '[define, requirement, TOTO-0002]',
591
+ 'def two'
592
+ ]
593
+ end
594
+
595
+ before do
596
+ allow(Defmastership::Definition).to(receive(:new).twice.and_return(defs.first, defs[1]))
597
+ defs.each do |definition|
598
+ allow(definition).to(receive(:labels)).and_return([])
599
+ allow(definition).to(receive(:<<)).and_return(definition)
600
+ end
601
+ end
602
+
603
+ context 'when no summary' do
604
+ before do
605
+ defs.each { |definition| allow(definition).to(receive(:summary)).and_return(nil) }
606
+ document.__send__(:do_parse, input_lines)
607
+ document.summaries?
608
+ end
609
+
610
+ it { expect(defs.first).to(have_received(:summary)) }
611
+ it { expect(defs[1]).to(have_received(:summary)) }
612
+ it { expect(document.summaries?).to(be(false)) }
613
+ end
614
+
615
+ context 'when at least one summary' do
616
+ before do
617
+ allow(defs.first).to(receive(:summary)).and_return('something')
618
+ allow(defs[1]).to(receive(:summary)).and_return(nil)
619
+ document.__send__(:do_parse, input_lines)
620
+ end
621
+
622
+ it { expect(document.summaries?).to(be(true)) }
623
+ end
624
+ end
625
+
560
626
  describe '#wrong_explicit_checksum?' do
561
627
  let(:defs) do
562
628
  [
@@ -13,20 +13,54 @@ RSpec.describe(Defmastership::Export::BodyFormatter) do
13
13
  it { is_expected.not_to(be_nil) }
14
14
  end
15
15
 
16
- describe '#fixed' do
16
+ describe '#type' do
17
17
  before do
18
18
  allow(definition).to(receive(:type).with(no_args).and_return('a'))
19
- allow(definition).to(receive(:reference).with(no_args).and_return('b'))
20
- allow(definition).to(receive(:value).with(no_args).and_return('c'))
21
- allow(definition).to(receive(:sha256_short).with(no_args).and_return('d'))
22
- formatter.fixed
19
+ formatter.type
23
20
  end
24
21
 
25
22
  it { expect(definition).to(have_received(:type).with(no_args)) }
23
+ it { expect(formatter.type).to(eq(['a'])) }
24
+ end
25
+
26
+ describe '#reference' do
27
+ before do
28
+ allow(definition).to(receive(:reference).with(no_args).and_return('b'))
29
+ formatter.reference
30
+ end
31
+
26
32
  it { expect(definition).to(have_received(:reference).with(no_args)) }
33
+ it { expect(formatter.reference).to(eq(['b'])) }
34
+ end
35
+
36
+ describe '#summary' do
37
+ before do
38
+ allow(definition).to(receive(:summary).with(no_args).and_return('b'))
39
+ formatter.summary
40
+ end
41
+
42
+ it { expect(definition).to(have_received(:summary).with(no_args)) }
43
+ it { expect(formatter.summary).to(eq(['b'])) }
44
+ end
45
+
46
+ describe '#value' do
47
+ before do
48
+ allow(definition).to(receive(:value).with(no_args).and_return('c'))
49
+ formatter.value
50
+ end
51
+
27
52
  it { expect(definition).to(have_received(:value).with(no_args)) }
53
+ it { expect(formatter.value).to(eq(['c'])) }
54
+ end
55
+
56
+ describe '#checksum' do
57
+ before do
58
+ allow(definition).to(receive(:sha256_short).with(no_args).and_return('d'))
59
+ formatter.checksum
60
+ end
61
+
28
62
  it { expect(definition).to(have_received(:sha256_short).with(no_args)) }
29
- it { expect(formatter.fixed).to(eq(%w[a b c d])) }
63
+ it { expect(formatter.checksum).to(eq(['d'])) }
30
64
  end
31
65
 
32
66
  describe '#wrong_explicit_checksum' do
@@ -37,6 +37,7 @@ RSpec.describe(Defmastership::Export::CSV::Formatter) do
37
37
  )
38
38
  end
39
39
  allow(document).to(receive(:definitions).and_return(%i[def0 def1]))
40
+ allow(document).to(receive(:summaries?).with(no_args).and_return(false))
40
41
  allow(document).to(receive(:wrong_explicit_checksum?).with(no_args).and_return(false))
41
42
  allow(document).to(receive(:explicit_version?).with(no_args).and_return(false))
42
43
  allow(document).to(receive(:labels).with(no_args).and_return([]))
@@ -46,7 +47,7 @@ RSpec.describe(Defmastership::Export::CSV::Formatter) do
46
47
  end
47
48
 
48
49
  context 'when no variable columns' do
49
- methods = %i[fixed]
50
+ methods = %i[type reference value checksum]
50
51
 
51
52
  before do
52
53
  methods.each do |method|
@@ -73,8 +74,35 @@ RSpec.describe(Defmastership::Export::CSV::Formatter) do
73
74
  it { expect(csv).to(have_received(:<<).with(methods.map { |method| "#{method} def1 body" })) }
74
75
  end
75
76
 
77
+ context 'when summary' do
78
+ methods = %i[type reference summary value checksum]
79
+
80
+ before do
81
+ methods.each do |method|
82
+ allow(header).to(receive(method).with(no_args).and_return(["#{method} header"]))
83
+ bodies.each_with_index do |body, index|
84
+ allow(body).to(receive(method).with(no_args).and_return(["#{method} def#{index} body"]))
85
+ end
86
+ end
87
+ allow(document).to(receive(:summaries?).with(no_args).and_return([:whatever]))
88
+ formatter.export_to('whatever')
89
+ end
90
+
91
+ methods.each do |method|
92
+ it { expect(header).to(have_received(method).with(no_args)) }
93
+
94
+ 2.times do |index|
95
+ it { expect(bodies[index]).to(have_received(method).with(no_args)) }
96
+ end
97
+ end
98
+
99
+ it { expect(csv).to(have_received(:<<).with(methods.map { |method| "#{method} header" })) }
100
+ it { expect(csv).to(have_received(:<<).with(methods.map { |method| "#{method} def0 body" })) }
101
+ it { expect(csv).to(have_received(:<<).with(methods.map { |method| "#{method} def1 body" })) }
102
+ end
103
+
76
104
  context 'when wrong_explicit_checksum' do
77
- methods = %i[fixed wrong_explicit_checksum]
105
+ methods = %i[type reference value checksum wrong_explicit_checksum]
78
106
 
79
107
  before do
80
108
  methods.each do |method|
@@ -101,7 +129,7 @@ RSpec.describe(Defmastership::Export::CSV::Formatter) do
101
129
  end
102
130
 
103
131
  context 'when explicit_version' do
104
- methods = %i[fixed explicit_version]
132
+ methods = %i[type reference value checksum explicit_version]
105
133
 
106
134
  before do
107
135
  methods.each do |method|
@@ -128,7 +156,7 @@ RSpec.describe(Defmastership::Export::CSV::Formatter) do
128
156
  end
129
157
 
130
158
  context 'when labels' do
131
- methods = %i[fixed labels]
159
+ methods = %i[type reference value checksum labels]
132
160
 
133
161
  before do
134
162
  methods.each do |method|
@@ -155,7 +183,7 @@ RSpec.describe(Defmastership::Export::CSV::Formatter) do
155
183
  end
156
184
 
157
185
  context 'when eref' do
158
- methods = %i[fixed eref]
186
+ methods = %i[type reference value checksum eref]
159
187
 
160
188
  before do
161
189
  methods.each do |method|
@@ -182,7 +210,7 @@ RSpec.describe(Defmastership::Export::CSV::Formatter) do
182
210
  end
183
211
 
184
212
  context 'when iref' do
185
- methods = %i[fixed iref]
213
+ methods = %i[type reference value checksum iref]
186
214
 
187
215
  before do
188
216
  methods.each do |method|
@@ -209,7 +237,7 @@ RSpec.describe(Defmastership::Export::CSV::Formatter) do
209
237
  end
210
238
 
211
239
  context 'when attributes' do
212
- methods = %i[fixed attributes]
240
+ methods = %i[type reference value checksum attributes]
213
241
 
214
242
  before do
215
243
  methods.each do |method|
@@ -236,7 +264,19 @@ RSpec.describe(Defmastership::Export::CSV::Formatter) do
236
264
  end
237
265
 
238
266
  context 'when every colums' do
239
- methods = %i[fixed wrong_explicit_checksum explicit_version labels eref iref attributes]
267
+ methods = %i[
268
+ type
269
+ reference
270
+ summary
271
+ value
272
+ checksum
273
+ wrong_explicit_checksum
274
+ explicit_version
275
+ labels
276
+ eref
277
+ iref
278
+ attributes
279
+ ]
240
280
 
241
281
  before do
242
282
  methods.each do |method|
@@ -245,6 +285,7 @@ RSpec.describe(Defmastership::Export::CSV::Formatter) do
245
285
  allow(body).to(receive(method).with(no_args).and_return(["#{method} def#{index} body"]))
246
286
  end
247
287
  end
288
+ allow(document).to(receive(:summaries?).with(no_args).and_return(true))
248
289
  allow(document).to(receive(:wrong_explicit_checksum?).with(no_args).and_return(true))
249
290
  allow(document).to(receive(:explicit_version?).with(no_args).and_return(true))
250
291
  allow(document).to(receive(:labels).with(no_args).and_return([:whatever]))
@@ -13,8 +13,24 @@ RSpec.describe(Defmastership::Export::HeaderFormatter) do
13
13
  end
14
14
 
15
15
  describe '#header' do
16
- describe '#fixed' do
17
- it { expect(formatter.fixed).to(eq(%w[Type Reference Value Checksum])) }
16
+ describe '#type' do
17
+ it { expect(formatter.type).to(eq(['Type'])) }
18
+ end
19
+
20
+ describe '#reference' do
21
+ it { expect(formatter.reference).to(eq(['Reference'])) }
22
+ end
23
+
24
+ describe '#summary' do
25
+ it { expect(formatter.summary).to(eq(['Summary'])) }
26
+ end
27
+
28
+ describe '#value' do
29
+ it { expect(formatter.value).to(eq(['Value'])) }
30
+ end
31
+
32
+ describe '#checksum' do
33
+ it { expect(formatter.checksum).to(eq(['Checksum'])) }
18
34
  end
19
35
 
20
36
  describe '#explicit_version' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: defmastership
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jérôme Arbez-Gindre
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-11-16 00:00:00.000000000 Z
11
+ date: 2024-12-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aasm
@@ -56,16 +56,16 @@ dependencies:
56
56
  name: defmastership-core
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 1.2.0
61
+ version: 1.3.0
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 1.2.0
68
+ version: 1.3.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: git
71
71
  requirement: !ruby/object:Gem::Requirement