defmastership 1.0.5 → 1.0.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -1
  3. data/bin/defmastership +33 -22
  4. data/cucumber.yml +1 -1
  5. data/defmastership.gemspec +12 -6
  6. data/features/changeref.feature +82 -129
  7. data/features/definition_checksum.feature +298 -0
  8. data/features/definition_version.feature +204 -0
  9. data/features/export.feature +35 -34
  10. data/features/modify.feature +165 -0
  11. data/features/rename_included_files.feature +121 -0
  12. data/lib/defmastership.rb +17 -3
  13. data/lib/defmastership/batch_modifier.rb +35 -0
  14. data/lib/defmastership/{ref_changer.rb → change_ref_line_modifier.rb} +18 -35
  15. data/lib/defmastership/change_ref_modifier.rb +15 -0
  16. data/lib/defmastership/constants.rb +14 -1
  17. data/lib/defmastership/csv_formatter.rb +22 -17
  18. data/lib/defmastership/csv_formatter_body.rb +19 -11
  19. data/lib/defmastership/csv_formatter_header.rb +15 -10
  20. data/lib/defmastership/definition.rb +14 -3
  21. data/lib/defmastership/definition_parser.rb +46 -0
  22. data/lib/defmastership/document.rb +59 -85
  23. data/lib/defmastership/filters.rb +30 -0
  24. data/lib/defmastership/line_modifier_base.rb +29 -0
  25. data/lib/defmastership/modifier_base.rb +29 -0
  26. data/lib/defmastership/rename_included_files_line_modifier.rb +126 -0
  27. data/lib/defmastership/rename_included_files_modifier.rb +15 -0
  28. data/lib/defmastership/update_def_checksum_line_modifier.rb +38 -0
  29. data/lib/defmastership/update_def_checksum_modifier.rb +21 -0
  30. data/lib/defmastership/update_def_version_line_modifier.rb +58 -0
  31. data/lib/defmastership/update_def_version_modifier.rb +25 -0
  32. data/lib/defmastership/version.rb +1 -1
  33. data/spec/spec_helper.rb +1 -0
  34. data/spec/unit/defmastership/batch_modifier_spec.rb +123 -0
  35. data/spec/unit/defmastership/{ref_changer_spec.rb → change_ref_line_modifier_spec.rb} +48 -26
  36. data/spec/unit/defmastership/change_ref_modifier_spec.rb +76 -0
  37. data/spec/unit/defmastership/comment_filter_spec.rb +8 -4
  38. data/spec/unit/defmastership/csv_formatter_body_spec.rb +88 -82
  39. data/spec/unit/defmastership/csv_formatter_header_spec.rb +68 -22
  40. data/spec/unit/defmastership/csv_formatter_spec.rb +207 -109
  41. data/spec/unit/defmastership/definition_parser_spec.rb +63 -0
  42. data/spec/unit/defmastership/definition_spec.rb +45 -4
  43. data/spec/unit/defmastership/document_spec.rb +236 -35
  44. data/spec/unit/defmastership/rename_included_files_line_modifier_spec.rb +203 -0
  45. data/spec/unit/defmastership/rename_included_files_modifier_spec.rb +67 -0
  46. data/spec/unit/defmastership/update_def_checksum_line_modifier_spec.rb +78 -0
  47. data/spec/unit/defmastership/update_def_checksum_modifier_spec.rb +75 -0
  48. data/spec/unit/defmastership/update_def_version_line_modifier_spec.rb +127 -0
  49. data/spec/unit/defmastership/update_def_version_modifier_spec.rb +80 -0
  50. metadata +44 -9
  51. data/lib/defmastership/batch_changer.rb +0 -41
  52. data/lib/defmastership/project_ref_changer.rb +0 -28
  53. data/spec/unit/defmastership/batch_changer_spec.rb +0 -109
  54. data/spec/unit/defmastership/project_ref_changer_spec.rb +0 -80
@@ -0,0 +1,298 @@
1
+ Feature: definition checksum
2
+ As a Responsible of definitions for a given document
3
+ In order to detect modifications of defintiions
4
+ I want defmastership to export and update checksum in definitions
5
+
6
+ Scenario: Extract one definition with WRONG explicit checksum to CSV
7
+ Given a file named "thedoc.adoc" with:
8
+ """
9
+ [define, requirement, TOTO-0001(~babe1234)]
10
+ def one
11
+ """
12
+ When I run `defmastership export thedoc.adoc`
13
+ Then it should fail with:
14
+ """
15
+ warning: TOTO-0001 has a wrong explicit checksum (should be ~d27cb5c3)
16
+ """
17
+ And the file "thedoc.csv" should contain:
18
+ """
19
+ Type,Reference,Value,Checksum,Wrong explicit checksum
20
+ requirement,TOTO-0001,def one,~d27cb5c3,~babe1234
21
+ """
22
+ And the stdout should not contain anything
23
+
24
+ Scenario: Extract two definitions with one WRONG explicit checksum to CSV
25
+ Given a file named "thedoc.adoc" with:
26
+ """
27
+ [define, requirement, TOTO-0001(~d27cb5c3)]
28
+ def one
29
+
30
+ [define, requirement, TOTO-0002(~babe1234)]
31
+ def two
32
+ """
33
+ When I run `defmastership export thedoc.adoc`
34
+ Then it should fail with:
35
+ """
36
+ warning: TOTO-0002 has a wrong explicit checksum (should be ~b80e1be5)
37
+ """
38
+ Then the file "thedoc.csv" should contain:
39
+ """
40
+ Type,Reference,Value,Checksum,Wrong explicit checksum
41
+ requirement,TOTO-0001,def one,~d27cb5c3,\"\"
42
+ requirement,TOTO-0002,def two,~b80e1be5,~babe1234
43
+ """
44
+ And the stdout should not contain anything
45
+
46
+ Scenario: Export not failing even if WRONG explicit checksum
47
+ Given a file named "thedoc.adoc" with:
48
+ """
49
+ [define, requirement, TOTO-0001(~d27cb5c3)]
50
+ def one
51
+
52
+ [define, requirement, TOTO-0002(~babe1234)]
53
+ def two
54
+ """
55
+ When I successfully run `defmastership export --no-fail thedoc.adoc`
56
+ Then the file "thedoc.csv" should contain:
57
+ """
58
+ Type,Reference,Value,Checksum,Wrong explicit checksum
59
+ requirement,TOTO-0001,def one,~d27cb5c3,\"\"
60
+ requirement,TOTO-0002,def two,~b80e1be5,~babe1234
61
+ """
62
+ And the stdout should not contain anything
63
+ And the stderr should contain:
64
+ """
65
+ warning: TOTO-0002 has a wrong explicit checksum (should be ~b80e1be5)
66
+ """
67
+
68
+ Scenario: Extract one definition with explicit checksum to CSV
69
+ Given a file named "thedoc.adoc" with:
70
+ """
71
+ [define, requirement, TOTO-0001(~b86dcbde)]
72
+ --
73
+ Exemple of multiline requirement.
74
+ Second line.
75
+ --
76
+ """
77
+ When I successfully run `defmastership export thedoc.adoc`
78
+ Then the file "thedoc.csv" should contain:
79
+ """
80
+ Type,Reference,Value,Checksum
81
+ requirement,TOTO-0001,"Exemple of multiline requirement.
82
+ Second line.",~b86dcbde
83
+ """
84
+ And the stdout should not contain anything
85
+ And the stderr should not contain anything
86
+
87
+ Scenario: Change one modifier
88
+ Given a file named "modifications.yml" with:
89
+ """
90
+ ---
91
+ :update_requirement_checksum:
92
+ :type: update_def_checksum
93
+ :config:
94
+ :def_type: requirement
95
+ """
96
+ And a file named "thedoc.adoc" with:
97
+ """
98
+ [define, requirement, TOTO-TEMP-XXX1]
99
+ --
100
+ the requirement value.
101
+ --
102
+ """
103
+ When I successfully run `defmastership modify --modifications update_requirement_checksum thedoc.adoc`
104
+ Then the stdout should not contain anything
105
+ And the stderr should not contain anything
106
+ And the file "thedoc.adoc" should contain:
107
+ """
108
+ [define, requirement, TOTO-TEMP-XXX1(~244eed18)]
109
+ --
110
+ the requirement value.
111
+ --
112
+ """
113
+
114
+ Scenario: Change one modifier with already set checksum
115
+ Given a file named "modifications.yml" with:
116
+ """
117
+ ---
118
+ :update_requirement_checksum:
119
+ :type: update_def_checksum
120
+ :config:
121
+ :def_type: requirement
122
+ """
123
+ And a file named "thedoc.adoc" with:
124
+ """
125
+ [define, requirement, TOTO-TEMP-XXX1(~abcd1234)]
126
+ --
127
+ the requirement value.
128
+ --
129
+ """
130
+ When I successfully run `defmastership modify --modifications update_requirement_checksum thedoc.adoc`
131
+ Then the stdout should not contain anything
132
+ And the stderr should not contain anything
133
+ And the file "thedoc.adoc" should contain:
134
+ """
135
+ [define, requirement, TOTO-TEMP-XXX1(~244eed18)]
136
+ --
137
+ the requirement value.
138
+ --
139
+ """
140
+
141
+ Scenario: Checksum is calculated on included file for export
142
+ Given a file named "thedoc.adoc" with:
143
+ """
144
+ [define, requirement, TOTO-0001]
145
+ --
146
+ include::included.txt[]
147
+ --
148
+ """
149
+ And a file named "included.txt" with:
150
+ """
151
+ Exemple of multiline requirement.
152
+ Second line.
153
+ """
154
+ When I successfully run `defmastership export thedoc.adoc`
155
+ Then the file "thedoc.csv" should contain:
156
+ """
157
+ Type,Reference,Value,Checksum
158
+ requirement,TOTO-0001,"Exemple of multiline requirement.
159
+ Second line.",~b86dcbde
160
+ """
161
+ And the stdout should not contain anything
162
+ And the stderr should not contain anything
163
+
164
+ Scenario: Checksum is calculated on included file in ref modification
165
+ Given a file named "modifications.yml" with:
166
+ """
167
+ ---
168
+ :update_requirement_checksum:
169
+ :type: update_def_checksum
170
+ :config:
171
+ :def_type: requirement
172
+ """
173
+ And a file named "thedoc.adoc" with:
174
+ """
175
+ [define, requirement, TOTO-0001]
176
+ --
177
+ include::included.txt[]
178
+ --
179
+ """
180
+ And a file named "included.txt" with:
181
+ """
182
+ Exemple of multiline requirement.
183
+ Second line.
184
+ """
185
+ When I successfully run `defmastership modify --modifications update_requirement_checksum thedoc.adoc`
186
+ Then the file "thedoc.adoc" should contain:
187
+ """
188
+ [define, requirement, TOTO-0001(~b86dcbde)]
189
+ --
190
+ include::included.txt[]
191
+ --
192
+ """
193
+ And the stdout should not contain anything
194
+ And the stderr should not contain anything
195
+
196
+ Scenario: Checksum take into account variables in CSV export
197
+ Given a file named "thedoc.adoc" with:
198
+ """
199
+ :variable: multiline
200
+ [define, requirement, TOTO-0001]
201
+ --
202
+ Exemple of {variable} requirement.
203
+ Second line.
204
+ --
205
+ """
206
+ When I successfully run `defmastership export thedoc.adoc`
207
+ Then the file "thedoc.csv" should contain:
208
+ """
209
+ Type,Reference,Value,Checksum
210
+ requirement,TOTO-0001,"Exemple of multiline requirement.
211
+ Second line.",~b86dcbde
212
+ """
213
+ And the stdout should not contain anything
214
+ And the stderr should not contain anything
215
+
216
+ Scenario: Checksum take into account variables in ref modification
217
+ Given a file named "modifications.yml" with:
218
+ """
219
+ ---
220
+ :update_requirement_checksum:
221
+ :type: update_def_checksum
222
+ :config:
223
+ :def_type: requirement
224
+ """
225
+ And a file named "thedoc.adoc" with:
226
+ """
227
+ :variable: multiline
228
+ [define, requirement, TOTO-0001]
229
+ --
230
+ Exemple of {variable} requirement.
231
+ Second line.
232
+ --
233
+ """
234
+ When I successfully run `defmastership modify --modifications update_requirement_checksum thedoc.adoc`
235
+ Then the file "thedoc.adoc" should contain:
236
+ """
237
+ [define, requirement, TOTO-0001(~b86dcbde)]
238
+ --
239
+ Exemple of {variable} requirement.
240
+ Second line.
241
+ --
242
+ """
243
+ And the stdout should not contain anything
244
+ And the stderr should not contain anything
245
+
246
+ Scenario: Checksum keep explicit version in ref modification
247
+ Given a file named "modifications.yml" with:
248
+ """
249
+ ---
250
+ :update_requirement_checksum:
251
+ :type: update_def_checksum
252
+ :config:
253
+ :def_type: requirement
254
+ """
255
+ And a file named "thedoc.adoc" with:
256
+ """
257
+ [define, requirement, TOTO-TEMP-XXX1(toto~abcd1234)]
258
+ --
259
+ the requirement value.
260
+ --
261
+ """
262
+ When I successfully run `defmastership modify --modifications update_requirement_checksum thedoc.adoc`
263
+ Then the stdout should not contain anything
264
+ And the stderr should not contain anything
265
+ And the file "thedoc.adoc" should contain:
266
+ """
267
+ [define, requirement, TOTO-TEMP-XXX1(toto~244eed18)]
268
+ --
269
+ the requirement value.
270
+ --
271
+ """
272
+
273
+ Scenario: Checksum keep explicit version in ref setting
274
+ Given a file named "modifications.yml" with:
275
+ """
276
+ ---
277
+ :update_requirement_checksum:
278
+ :type: update_def_checksum
279
+ :config:
280
+ :def_type: requirement
281
+ """
282
+ And a file named "thedoc.adoc" with:
283
+ """
284
+ [define, requirement, TOTO-TEMP-XXX1(toto)]
285
+ --
286
+ the requirement value.
287
+ --
288
+ """
289
+ When I successfully run `defmastership modify --modifications update_requirement_checksum thedoc.adoc`
290
+ Then the stdout should not contain anything
291
+ And the stderr should not contain anything
292
+ And the file "thedoc.adoc" should contain:
293
+ """
294
+ [define, requirement, TOTO-TEMP-XXX1(toto~244eed18)]
295
+ --
296
+ the requirement value.
297
+ --
298
+ """
@@ -0,0 +1,204 @@
1
+ Feature: definitions version
2
+ As a Responsible of definitions for a given document
3
+ In order to detect handle versions definitions
4
+ I want defmastership to export explicit versions in definitions
5
+
6
+ Scenario: Extract one definition with explicit version to CSV
7
+ Given a file named "thedoc.adoc" with:
8
+ """
9
+ [define, requirement, TOTO-0001(pouet)]
10
+ --
11
+ Exemple of multiline requirement.
12
+ Second line.
13
+ --
14
+ """
15
+ When I successfully run `defmastership export thedoc.adoc`
16
+ Then the file "thedoc.csv" should contain:
17
+ """
18
+ Type,Reference,Value,Checksum,Version
19
+ requirement,TOTO-0001,"Exemple of multiline requirement.
20
+ Second line.",~b86dcbde,pouet
21
+ """
22
+ And the stdout should not contain anything
23
+ And the stderr should not contain anything
24
+
25
+ Scenario: Set initial explicit version when definition has changed
26
+ Given a file named "ref_doc.adoc" with:
27
+ """
28
+ [define, requirement, TOTO-0001]
29
+ --
30
+ initial text.
31
+ --
32
+ """
33
+ Given a file named "thedoc.adoc" with:
34
+ """
35
+ [define, requirement, TOTO-0001(whatever)]
36
+ --
37
+ modified text.
38
+ --
39
+ """
40
+ And a file named "modifications.yml" with:
41
+ """
42
+ ---
43
+ :update_requirement_version:
44
+ :type: update_def_version
45
+ :config:
46
+ :def_type: requirement
47
+ :first_version: a
48
+ :ref_document: ./ref_doc.adoc
49
+ """
50
+ When I successfully run `defmastership modify --modifications update_requirement_version thedoc.adoc`
51
+ And the stdout should not contain anything
52
+ And the stderr should not contain anything
53
+ Then the file "thedoc.adoc" should contain:
54
+ """
55
+ [define, requirement, TOTO-0001(a)]
56
+ --
57
+ modified text.
58
+ --
59
+ """
60
+
61
+ Scenario: Do not set initial explicit version when definition has NOT changed
62
+ Given a file named "ref_doc.adoc" with:
63
+ """
64
+ [define, requirement, TOTO-0001]
65
+ --
66
+ initial text.
67
+ --
68
+ """
69
+ Given a file named "thedoc.adoc" with:
70
+ """
71
+ [define, requirement, TOTO-0001(whatever)]
72
+ --
73
+ initial text.
74
+ --
75
+ """
76
+ And a file named "modifications.yml" with:
77
+ """
78
+ ---
79
+ :update_requirement_version:
80
+ :type: update_def_version
81
+ :config:
82
+ :def_type: requirement
83
+ :first_version: a
84
+ :ref_document: ./ref_doc.adoc
85
+ """
86
+ When I successfully run `defmastership modify --modifications update_requirement_version thedoc.adoc`
87
+ And the stdout should not contain anything
88
+ And the stderr should not contain anything
89
+ Then the file "thedoc.adoc" should contain:
90
+ """
91
+ [define, requirement, TOTO-0001]
92
+ --
93
+ initial text.
94
+ --
95
+ """
96
+
97
+ Scenario: Set initial explicit version when definition has changed and ref is not an initial version
98
+ Given a file named "ref_doc.adoc" with:
99
+ """
100
+ [define, requirement, TOTO-0001(3)]
101
+ --
102
+ initial text.
103
+ --
104
+ """
105
+ Given a file named "thedoc.adoc" with:
106
+ """
107
+ [define, requirement, TOTO-0001(whatever)]
108
+ --
109
+ modified text.
110
+ --
111
+ """
112
+ And a file named "modifications.yml" with:
113
+ """
114
+ ---
115
+ :update_requirement_version:
116
+ :type: update_def_version
117
+ :config:
118
+ :def_type: requirement
119
+ :first_version: 1
120
+ :ref_document: ./ref_doc.adoc
121
+ """
122
+ When I successfully run `defmastership modify --modifications update_requirement_version thedoc.adoc`
123
+ And the stdout should not contain anything
124
+ And the stderr should not contain anything
125
+ Then the file "thedoc.adoc" should contain:
126
+ """
127
+ [define, requirement, TOTO-0001(4)]
128
+ --
129
+ modified text.
130
+ --
131
+ """
132
+
133
+ Scenario: No initial explicit version when definition is new
134
+ Given a file named "ref_doc.adoc" with:
135
+ """
136
+ [define, requirement, TOTO-0002]
137
+ --
138
+ initial text.
139
+ --
140
+ """
141
+ Given a file named "thedoc.adoc" with:
142
+ """
143
+ [define, requirement, TOTO-0001(whatever)]
144
+ --
145
+ modified text.
146
+ --
147
+ """
148
+ And a file named "modifications.yml" with:
149
+ """
150
+ ---
151
+ :update_requirement_version:
152
+ :type: update_def_version
153
+ :config:
154
+ :def_type: requirement
155
+ :first_version: 1
156
+ :ref_document: ./ref_doc.adoc
157
+ """
158
+ When I successfully run `defmastership modify --modifications update_requirement_version thedoc.adoc`
159
+ And the stdout should not contain anything
160
+ And the stderr should not contain anything
161
+ Then the file "thedoc.adoc" should contain:
162
+ """
163
+ [define, requirement, TOTO-0001]
164
+ --
165
+ modified text.
166
+ --
167
+ """
168
+
169
+ Scenario: update explicit version whith explicit checksum
170
+ Given a file named "ref_doc.adoc" with:
171
+ """
172
+ [define, requirement, TOTO-0001]
173
+ --
174
+ initial text.
175
+ --
176
+ """
177
+ Given a file named "thedoc.adoc" with:
178
+ """
179
+ [define, requirement, TOTO-0001(whatever~abcd1234)]
180
+ --
181
+ modified text.
182
+ --
183
+ """
184
+ And a file named "modifications.yml" with:
185
+ """
186
+ ---
187
+ :update_requirement_version:
188
+ :type: update_def_version
189
+ :config:
190
+ :def_type: requirement
191
+ :first_version: a
192
+ :ref_document: ./ref_doc.adoc
193
+ """
194
+ When I successfully run `defmastership modify --modifications update_requirement_version thedoc.adoc`
195
+ And the stdout should not contain anything
196
+ And the stderr should not contain anything
197
+ Then the file "thedoc.adoc" should contain:
198
+ """
199
+ [define, requirement, TOTO-0001(a~abcd1234)]
200
+ --
201
+ modified text.
202
+ --
203
+ """
204
+