defmastership 1.0.18 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +4 -0
  3. data/.gitlab-ci.yml +42 -1
  4. data/Gemfile +49 -18
  5. data/Guardfile +44 -0
  6. data/LICENSE +1 -1
  7. data/README.adoc +24 -0
  8. data/Rakefile +0 -1
  9. data/bin/defmastership +5 -5
  10. data/config/cucumber.yml +3 -0
  11. data/config/mutant.yml +22 -16
  12. data/config/reek.yml +129 -105
  13. data/config/rubocop.yml +67 -28
  14. data/defmastership.gemspec +8 -6
  15. data/features/changeref.feature +0 -8
  16. data/features/definition_checksum.feature +0 -10
  17. data/features/definition_version.feature +168 -10
  18. data/features/export.feature +23 -18
  19. data/features/modify.feature +1 -5
  20. data/features/rename_included_files.feature +0 -5
  21. data/features/step_definitions/git_steps.rb +19 -0
  22. data/lib/defmastership/batch_modifier.rb +23 -5
  23. data/lib/defmastership/comment_filter.rb +2 -1
  24. data/lib/defmastership/definition.rb +26 -6
  25. data/lib/defmastership/definition_parser.rb +2 -2
  26. data/lib/defmastership/document.rb +45 -33
  27. data/lib/defmastership/export/body_formatter.rb +55 -0
  28. data/lib/defmastership/export/csv/formatter.rb +64 -0
  29. data/lib/defmastership/export/header_formatter.rb +51 -0
  30. data/lib/defmastership/filters.rb +15 -12
  31. data/lib/defmastership/matching_line.rb +3 -2
  32. data/lib/defmastership/modifier/change_ref.rb +117 -0
  33. data/lib/defmastership/modifier/factory.rb +17 -0
  34. data/lib/defmastership/modifier/modifier_common.rb +71 -0
  35. data/lib/defmastership/modifier/rename_included_files.rb +223 -0
  36. data/lib/defmastership/modifier/update_def.rb +72 -0
  37. data/lib/defmastership/modifier/update_def_checksum.rb +17 -0
  38. data/lib/defmastership/modifier/update_def_version.rb +110 -0
  39. data/lib/defmastership/set_join_hack.rb +2 -0
  40. data/lib/defmastership/version.rb +3 -2
  41. data/lib/defmastership.rb +6 -8
  42. data/spec/unit/{def_mastership → defmastership}/batch_modifier_spec.rb +15 -13
  43. data/spec/unit/{def_mastership → defmastership}/definition_parser_spec.rb +1 -1
  44. data/spec/unit/{def_mastership → defmastership}/definition_spec.rb +1 -1
  45. data/spec/unit/{def_mastership → defmastership}/document_spec.rb +57 -57
  46. data/spec/unit/{def_mastership/csv_formatter_body_spec.rb → defmastership/export/body_formatter_spec.rb} +4 -4
  47. data/spec/unit/{def_mastership/csv_formatter_spec.rb → defmastership/export/csv/formatter_spec.rb} +13 -8
  48. data/spec/unit/{def_mastership/csv_formatter_header_spec.rb → defmastership/export/header_formatter_spec.rb} +3 -3
  49. data/spec/unit/{def_mastership → defmastership}/matching_line_spec.rb +1 -1
  50. data/spec/unit/{def_mastership/change_ref_modifier_spec.rb → defmastership/modifier/change_ref_spec.rb} +19 -44
  51. data/spec/unit/defmastership/modifier/factory_spec.rb +45 -0
  52. data/spec/unit/{def_mastership/modifier_spec.rb → defmastership/modifier/modifier_common_spec.rb} +11 -18
  53. data/spec/unit/{def_mastership/rename_included_files_modifier_spec.rb → defmastership/modifier/rename_included_files_spec.rb} +3 -3
  54. data/spec/unit/{def_mastership/update_def_checksum_modifier_spec.rb → defmastership/modifier/update_def_checksum_spec.rb} +10 -10
  55. data/spec/unit/{def_mastership/update_def_modifier_spec.rb → defmastership/modifier/update_def_spec.rb} +22 -18
  56. data/spec/unit/defmastership/modifier/update_def_version_spec.rb +351 -0
  57. data/spec/unit/{def_mastership_spec.rb → defmastership_spec.rb} +2 -2
  58. data/tasks/code_quality.rake +74 -0
  59. data/tasks/documentation.rake +19 -0
  60. data/tasks/package.rake +4 -0
  61. data/tasks/test.rake +6 -21
  62. metadata +96 -51
  63. data/.rubocop.yml +0 -76
  64. data/README.rdoc +0 -6
  65. data/config/devtools.yml +0 -2
  66. data/config/flay.yml +0 -3
  67. data/config/flog.yml +0 -2
  68. data/config/yardstick.yml +0 -2
  69. data/cucumber.yml +0 -2
  70. data/defmastership.rdoc +0 -5
  71. data/lib/defmastership/change_ref_modifier.rb +0 -99
  72. data/lib/defmastership/constants.rb +0 -89
  73. data/lib/defmastership/csv_formatter.rb +0 -53
  74. data/lib/defmastership/csv_formatter_body.rb +0 -46
  75. data/lib/defmastership/csv_formatter_header.rb +0 -41
  76. data/lib/defmastership/modifier.rb +0 -42
  77. data/lib/defmastership/modifier_factory.rb +0 -12
  78. data/lib/defmastership/parsing_state.rb +0 -31
  79. data/lib/defmastership/rename_included_files_modifier.rb +0 -182
  80. data/lib/defmastership/update_def_checksum_modifier.rb +0 -16
  81. data/lib/defmastership/update_def_modifier.rb +0 -49
  82. data/lib/defmastership/update_def_version_modifier.rb +0 -66
  83. data/spec/unit/def_mastership/modifier_factory_spec.rb +0 -37
  84. data/spec/unit/def_mastership/parsing_state_spec.rb +0 -62
  85. data/spec/unit/def_mastership/update_def_version_modifier_spec.rb +0 -159
  86. data/tasks/package.task +0 -9
  87. data/tasks/smelling_code.rake +0 -38
  88. /data/{.rspec → config/rspec} +0 -0
  89. /data/spec/unit/{def_mastership → defmastership}/string_spec.rb +0 -0
@@ -0,0 +1,351 @@
1
+ # Copyright (c) 2020 Jerome Arbez-Gindre
2
+ # frozen_string_literal: true
3
+
4
+ require('defmastership/modifier/update_def_version')
5
+ require('git')
6
+
7
+ RSpec.describe(Defmastership::Modifier::UpdateDefVersion) do
8
+ subject(:modifier) { described_class.new({}) }
9
+
10
+ describe '.new' do
11
+ it { expect(described_class.ancestors).to(include(Defmastership::Modifier::ModifierCommon)) }
12
+ it { is_expected.not_to(be_nil) }
13
+ it { is_expected.to(have_attributes(def_type: '')) }
14
+ it { is_expected.to(have_attributes(ref_document: [])) }
15
+ it { is_expected.to(have_attributes(first_version: '')) }
16
+ end
17
+
18
+ describe '.replacement_methods' do
19
+ it { expect(described_class.replacement_methods).to(eq(%i[replace_reference])) }
20
+ end
21
+
22
+ describe '#do_modifications' do
23
+ context 'when only one ref document' do
24
+ subject(:modifier) do
25
+ described_class.new(
26
+ ref_document: 'ref_doc.adoc',
27
+ def_type: 'req',
28
+ first_version: 'a'
29
+ )
30
+ end
31
+
32
+ let(:document) { instance_double(Defmastership::Document, 'document') }
33
+ let(:ref_document) { instance_double(Defmastership::Document, 'ref_document') }
34
+ let(:definition) { instance_double(Defmastership::Definition, 'definition') }
35
+ let(:ref_definition) { instance_double(Defmastership::Definition, 'ref_definitions') }
36
+ let(:adoc_sources) do
37
+ {
38
+ 'file1.adoc' => "[define,req,REFERENCE]\nfile1 line2",
39
+ 'file2.adoc' => "file2 line1\nfile2 line2"
40
+ }
41
+ end
42
+
43
+ before do
44
+ allow(Defmastership::Document).to(receive(:new).twice.and_return(ref_document, document))
45
+ allow(document).to(receive(:parse_file_with_preprocessor).with('file1.adoc'))
46
+ allow(document).to(receive(:parse_file_with_preprocessor).with('file2.adoc'))
47
+ allow(ref_document).to(receive(:parse_file_with_preprocessor).with('ref_doc.adoc'))
48
+ allow(document).to(receive(:ref_to_def).with('REFERENCE').and_return(definition))
49
+ allow(ref_document).to(receive(:ref_to_def).with('REFERENCE').and_return(ref_definition))
50
+ allow(ref_definition).to(receive(:explicit_version).with(no_args).and_return(nil))
51
+ allow(definition).to(receive(:sha256_short).with(no_args).and_return('something'))
52
+ allow(ref_definition).to(receive(:sha256_short).with(no_args).and_return('something_else'))
53
+
54
+ modifier.do_modifications(adoc_sources)
55
+ end
56
+
57
+ it { is_expected.to(have_attributes(ref_document: ['ref_doc.adoc'])) }
58
+ it { expect(Defmastership::Document).to(have_received(:new).twice) }
59
+ it { expect(document).to(have_received(:parse_file_with_preprocessor).twice) }
60
+ it { expect(ref_document).to(have_received(:parse_file_with_preprocessor).with('ref_doc.adoc')) }
61
+
62
+ it do
63
+ expect(modifier.do_modifications(adoc_sources).fetch('file1.adoc')).to(include('REFERENCE(a)'))
64
+ end
65
+ end
66
+
67
+ context 'when more ref document' do
68
+ subject(:modifier) do
69
+ described_class.new(
70
+ ref_document: ['ref_doc1.adoc', 'ref_doc2.adoc'],
71
+ def_type: 'req',
72
+ first_version: 'a'
73
+ )
74
+ end
75
+
76
+ let(:document) { instance_double(Defmastership::Document, 'document') }
77
+ let(:ref_document) { instance_double(Defmastership::Document, 'ref_document') }
78
+ let(:definition) { instance_double(Defmastership::Definition, 'definition') }
79
+ let(:ref_definition) { instance_double(Defmastership::Definition, 'ref_definitions') }
80
+ let(:adoc_sources) do
81
+ {
82
+ 'file1.adoc' => "[define,req,REFERENCE]\nfile1 line2",
83
+ 'file2.adoc' => "file2 line1\nfile2 line2"
84
+ }
85
+ end
86
+
87
+ before do
88
+ allow(Defmastership::Document).to(receive(:new).twice.and_return(ref_document, document))
89
+ allow(document).to(receive(:parse_file_with_preprocessor).with('file1.adoc'))
90
+ allow(document).to(receive(:parse_file_with_preprocessor).with('file2.adoc'))
91
+ allow(ref_document).to(receive(:parse_file_with_preprocessor).with('ref_doc1.adoc'))
92
+ allow(ref_document).to(receive(:parse_file_with_preprocessor).with('ref_doc2.adoc'))
93
+ allow(document).to(receive(:ref_to_def).with('REFERENCE').and_return(definition))
94
+ allow(ref_document).to(receive(:ref_to_def).with('REFERENCE').and_return(ref_definition))
95
+ allow(ref_definition).to(receive(:explicit_version).with(no_args).and_return(nil))
96
+ allow(definition).to(receive(:sha256_short).with(no_args).and_return('something'))
97
+ allow(ref_definition).to(receive(:sha256_short).with(no_args).and_return('something_else'))
98
+
99
+ modifier.do_modifications(adoc_sources)
100
+ end
101
+
102
+ it { expect(Defmastership::Document).to(have_received(:new).twice) }
103
+ it { expect(document).to(have_received(:parse_file_with_preprocessor).twice) }
104
+ it { expect(ref_document).to(have_received(:parse_file_with_preprocessor).with('ref_doc1.adoc')) }
105
+ it { expect(ref_document).to(have_received(:parse_file_with_preprocessor).with('ref_doc2.adoc')) }
106
+ end
107
+
108
+ context 'when ref_tag is provided' do
109
+ subject(:modifier) do
110
+ described_class.new(
111
+ ref_tag: 'THE_TAG',
112
+ def_type: 'req',
113
+ first_version: 'a'
114
+ )
115
+ end
116
+
117
+ let(:document) { instance_double(Defmastership::Document, 'document') }
118
+ let(:ref_document) { instance_double(Defmastership::Document, 'ref_document') }
119
+ let(:definition) { instance_double(Defmastership::Definition, 'definition') }
120
+ let(:ref_definition) { instance_double(Defmastership::Definition, 'ref_definitions') }
121
+ let(:adoc_sources) do
122
+ {
123
+ 'file1.adoc' => "[define,req,REFERENCE]\nfile1 line2",
124
+ 'file2.adoc' => "file2 line1\nfile2 line2"
125
+ }
126
+ end
127
+
128
+ before do
129
+ allow(Dir).to(receive(:mktmpdir).and_yield('tmp'))
130
+ allow(Git).to(receive(:clone))
131
+ allow(Defmastership::Document).to(receive(:new).twice.and_return(ref_document, document))
132
+ allow(document).to(receive(:parse_file_with_preprocessor).with('file1.adoc'))
133
+ allow(document).to(receive(:parse_file_with_preprocessor).with('file2.adoc'))
134
+ allow(ref_document).to(receive(:parse_file_with_preprocessor).with('tmp/file1.adoc'))
135
+ allow(ref_document).to(receive(:parse_file_with_preprocessor).with('tmp/file2.adoc'))
136
+ allow(document).to(receive(:ref_to_def).with('REFERENCE').and_return(definition))
137
+ allow(ref_document).to(receive(:ref_to_def).with('REFERENCE').and_return(ref_definition))
138
+ allow(ref_definition).to(receive(:explicit_version).with(no_args).and_return(nil))
139
+ allow(definition).to(receive(:sha256_short).with(no_args).and_return('something'))
140
+ allow(ref_definition).to(receive(:sha256_short).with(no_args).and_return('something_else'))
141
+
142
+ modifier.do_modifications(adoc_sources)
143
+ end
144
+
145
+ it { expect(Dir).to(have_received(:mktmpdir).with('defmastership')) }
146
+ it { expect(Git).to(have_received(:clone).with('.', 'tmp', branch: 'THE_TAG')) }
147
+ it { expect(Defmastership::Document).to(have_received(:new).twice) }
148
+ it { expect(ref_document).to(have_received(:parse_file_with_preprocessor).with('tmp/file1.adoc')) }
149
+ it { expect(ref_document).to(have_received(:parse_file_with_preprocessor).with('tmp/file2.adoc')) }
150
+ it { expect(ref_document).to(have_received(:parse_file_with_preprocessor).twice) }
151
+
152
+ it do
153
+ expect(modifier.do_modifications(adoc_sources).fetch('file1.adoc')).to(include('REFERENCE(a)'))
154
+ end
155
+ end
156
+
157
+ context 'when ref_tag and ref_repo is provided' do
158
+ subject(:modifier) do
159
+ described_class.new(
160
+ ref_tag: 'THE_TAG',
161
+ ref_repo: 'not dot',
162
+ def_type: 'req',
163
+ first_version: 'a'
164
+ )
165
+ end
166
+
167
+ let(:document) { instance_double(Defmastership::Document, 'document') }
168
+ let(:ref_document) { instance_double(Defmastership::Document, 'ref_document') }
169
+ let(:definition) { instance_double(Defmastership::Definition, 'definition') }
170
+ let(:ref_definition) { instance_double(Defmastership::Definition, 'ref_definitions') }
171
+ let(:adoc_sources) do
172
+ {
173
+ 'file1.adoc' => "[define,req,REFERENCE]\nfile1 line2",
174
+ 'file2.adoc' => "file2 line1\nfile2 line2"
175
+ }
176
+ end
177
+
178
+ before do
179
+ allow(Dir).to(receive(:mktmpdir).and_yield('tmp'))
180
+ allow(Git).to(receive(:clone))
181
+ allow(Defmastership::Document).to(receive(:new).twice.and_return(ref_document, document))
182
+ allow(document).to(receive(:parse_file_with_preprocessor).with('file1.adoc'))
183
+ allow(document).to(receive(:parse_file_with_preprocessor).with('file2.adoc'))
184
+ allow(ref_document).to(receive(:parse_file_with_preprocessor).with('tmp/file1.adoc'))
185
+ allow(ref_document).to(receive(:parse_file_with_preprocessor).with('tmp/file2.adoc'))
186
+ allow(document).to(receive(:ref_to_def).with('REFERENCE').and_return(definition))
187
+ allow(ref_document).to(receive(:ref_to_def).with('REFERENCE').and_return(ref_definition))
188
+ allow(ref_definition).to(receive(:explicit_version).with(no_args).and_return(nil))
189
+ allow(definition).to(receive(:sha256_short).with(no_args).and_return('something'))
190
+ allow(ref_definition).to(receive(:sha256_short).with(no_args).and_return('something_else'))
191
+
192
+ modifier.do_modifications(adoc_sources)
193
+ end
194
+
195
+ it { expect(Dir).to(have_received(:mktmpdir).with('defmastership')) }
196
+ it { expect(Git).to(have_received(:clone).with('not dot', 'tmp', branch: 'THE_TAG')) }
197
+ it { expect(Defmastership::Document).to(have_received(:new).twice) }
198
+ it { expect(ref_document).to(have_received(:parse_file_with_preprocessor).with('tmp/file1.adoc')) }
199
+ it { expect(ref_document).to(have_received(:parse_file_with_preprocessor).with('tmp/file2.adoc')) }
200
+ it { expect(ref_document).to(have_received(:parse_file_with_preprocessor).twice) }
201
+
202
+ it do
203
+ expect(modifier.do_modifications(adoc_sources).fetch('file1.adoc')).to(include('REFERENCE(a)'))
204
+ end
205
+ end
206
+
207
+ context 'when both ref_tag and ref_document are provided' do
208
+ subject(:modifier) do
209
+ described_class.new(
210
+ ref_tag: 'THE_TAG',
211
+ ref_document: './another/doc.adoc',
212
+ def_type: 'req',
213
+ first_version: 'a'
214
+ )
215
+ end
216
+
217
+ let(:document) { instance_double(Defmastership::Document, 'document') }
218
+ let(:ref_document) { instance_double(Defmastership::Document, 'ref_document') }
219
+ let(:definition) { instance_double(Defmastership::Definition, 'definition') }
220
+ let(:ref_definition) { instance_double(Defmastership::Definition, 'ref_definitions') }
221
+ let(:adoc_sources) do
222
+ {
223
+ 'file1.adoc' => "[define,req,REFERENCE]\nfile1 line2",
224
+ 'file2.adoc' => "file2 line1\nfile2 line2"
225
+ }
226
+ end
227
+
228
+ before do
229
+ allow(Dir).to(receive(:mktmpdir).and_yield('tmp'))
230
+ allow(Git).to(receive(:clone))
231
+ allow(Defmastership::Document).to(receive(:new).twice.and_return(ref_document, document))
232
+ allow(document).to(receive(:parse_file_with_preprocessor).with('file1.adoc'))
233
+ allow(document).to(receive(:parse_file_with_preprocessor).with('file2.adoc'))
234
+ allow(ref_document).to(receive(:parse_file_with_preprocessor))
235
+ allow(document).to(receive(:ref_to_def).with('REFERENCE').and_return(definition))
236
+ allow(ref_document).to(receive(:ref_to_def).with('REFERENCE').and_return(ref_definition))
237
+ allow(ref_definition).to(receive(:explicit_version).with(no_args).and_return(nil))
238
+ allow(definition).to(receive(:sha256_short).with(no_args).and_return('something'))
239
+ allow(ref_definition).to(receive(:sha256_short).with(no_args).and_return('something_else'))
240
+
241
+ modifier.do_modifications(adoc_sources)
242
+ end
243
+
244
+ it { expect(Dir).to(have_received(:mktmpdir).with('defmastership')) }
245
+ it { expect(Git).to(have_received(:clone).with('.', 'tmp', branch: 'THE_TAG')) }
246
+ it { expect(Defmastership::Document).to(have_received(:new).twice) }
247
+ it { expect(ref_document).to(have_received(:parse_file_with_preprocessor).with('tmp/./another/doc.adoc')) }
248
+ it { expect(ref_document).to(have_received(:parse_file_with_preprocessor).once) }
249
+
250
+ it do
251
+ expect(modifier.do_modifications(adoc_sources).fetch('file1.adoc')).to(include('REFERENCE(a)'))
252
+ end
253
+ end
254
+ end
255
+
256
+ describe '#replace_reference' do
257
+ subject(:modifier) do
258
+ described_class.new(
259
+ def_type: 'requirement',
260
+ first_version: 'a'
261
+ )
262
+ end
263
+
264
+ let(:document) { instance_double(Defmastership::Document, 'document') }
265
+ let(:ref_document) { instance_double(Defmastership::Document, 'ref_document') }
266
+ let(:definition) { instance_double(Defmastership::Definition, 'definition') }
267
+ let(:ref_definition) { instance_double(Defmastership::Definition, 'ref_definitions') }
268
+
269
+ before do
270
+ allow(File).to(receive(:rename))
271
+ allow(Defmastership::Document).to(receive(:new).with(no_args).and_return(ref_document, document))
272
+ end
273
+
274
+ context 'when definition has not the good type' do
275
+ it do
276
+ expect(modifier.replace_reference('[define,req,REFERENCE]'))
277
+ .to(eq('[define,req,REFERENCE]'))
278
+ end
279
+ end
280
+
281
+ context 'when definition has the good type' do
282
+ before do
283
+ allow(document).to(receive(:ref_to_def).with('REFERENCE').and_return(definition))
284
+ allow(definition).to(receive(:sha256_short).and_return('~abcd1234'))
285
+ end
286
+
287
+ context 'when definition has NOT changed' do
288
+ before do
289
+ allow(ref_document).to(receive(:ref_to_def).with('REFERENCE').and_return(ref_definition))
290
+ allow(ref_definition).to(receive(:sha256_short).and_return('~abcd1234'))
291
+ end
292
+
293
+ it do
294
+ allow(ref_definition).to(receive(:explicit_version).and_return(nil))
295
+ expect(modifier.replace_reference('[define,requirement,REFERENCE]'))
296
+ .to(eq('[define,requirement,REFERENCE]'))
297
+ end
298
+
299
+ it do
300
+ allow(ref_definition).to(receive(:explicit_version).and_return('c'))
301
+ expect(modifier.replace_reference('[define,requirement,REFERENCE]'))
302
+ .to(eq('[define,requirement,REFERENCE(c)]'))
303
+ end
304
+
305
+ it do
306
+ allow(ref_definition).to(receive(:explicit_version).and_return('c'))
307
+ expect(modifier.replace_reference('[define,requirement,REFERENCE(tyty~1234)]'))
308
+ .to(eq('[define,requirement,REFERENCE(c~1234)]'))
309
+ end
310
+ end
311
+
312
+ context 'when definition has changed' do
313
+ before do
314
+ allow(ref_document).to(receive(:ref_to_def).with('REFERENCE').and_return(ref_definition))
315
+ allow(ref_definition).to(receive(:sha256_short).and_return('~4321aaaa'))
316
+ end
317
+
318
+ [
319
+ [nil, '', '(a)'],
320
+ ['c', '', '(d)'],
321
+ ['c', '(tyty~1234)', '(d~1234)'],
322
+ ['2', '', '(3)'],
323
+ ['1222', '', '(1223)'],
324
+ ['abb', '', '(abc)']
325
+ ].each do |ref, from, to|
326
+ it do
327
+ allow(ref_definition).to(receive(:explicit_version).and_return(ref))
328
+ expect(modifier.replace_reference("[define,requirement,REFERENCE#{from}]"))
329
+ .to(eq("[define,requirement,REFERENCE#{to}]"))
330
+ end
331
+ end
332
+ end
333
+
334
+ context 'when definition is new' do
335
+ before do
336
+ allow(ref_document).to(receive(:ref_to_def).with('REFERENCE').and_return(nil))
337
+ end
338
+
339
+ it do
340
+ expect(modifier.replace_reference('[define,requirement,REFERENCE(whatever)]'))
341
+ .to(eq('[define,requirement,REFERENCE]'))
342
+ end
343
+
344
+ it do
345
+ expect(modifier.replace_reference('[define,requirement,REFERENCE(~1234)]'))
346
+ .to(eq('[define,requirement,REFERENCE(~1234)]'))
347
+ end
348
+ end
349
+ end
350
+ end
351
+ end
@@ -1,8 +1,8 @@
1
1
  # Copyright (c) 2020 Jerome Arbez-Gindre
2
2
  # frozen_string_literal: true
3
3
 
4
- RSpec.describe(DefMastership) do
4
+ RSpec.describe(Defmastership) do
5
5
  it 'has a version number' do
6
- expect(DefMastership::VERSION).not_to(be_nil)
6
+ expect(Defmastership::VERSION).not_to(be_nil)
7
7
  end
8
8
  end
@@ -0,0 +1,74 @@
1
+ # Copyright (c) 2023 Jerome Arbez-Gindre
2
+ # frozen_string_literal: true
3
+
4
+ # rubocop:disable Metrics/BlockLength
5
+ namespace 'quality' do
6
+ begin
7
+ require('rubocop/rake_task')
8
+
9
+ RuboCop::RakeTask.new do |task|
10
+ task.options << '--display-cop-names'
11
+ task.options << '--config=config/rubocop.yml'
12
+ end
13
+ rescue LoadError
14
+ task(:rubocop) do
15
+ puts('Install rubocop to run its rake tasks')
16
+ end
17
+ end
18
+
19
+ begin
20
+ require('reek/rake/task')
21
+
22
+ Reek::Rake::Task.new do |task|
23
+ task.fail_on_error = true
24
+ task.source_files = '{lib,spec}/**/*.rb'
25
+ task.reek_opts = '--config config/reek.yml --single-line'
26
+ end
27
+ rescue LoadError
28
+ task(:reek) do
29
+ puts('Install reek to run its rake tasks')
30
+ end
31
+ end
32
+
33
+ begin
34
+ require('flay_task')
35
+
36
+ FlayTask.new(:flay, 200, %w[bin lib]) do |task|
37
+ task.verbose = true
38
+ end
39
+ rescue LoadError
40
+ task(:flay) do
41
+ puts('Install flay to run its rake tasks')
42
+ end
43
+ end
44
+
45
+ begin
46
+ require('rubycritic/rake_task')
47
+
48
+ RubyCritic::RakeTask.new do |task|
49
+ task.verbose = true
50
+ task.options = '--no-browser'
51
+ end
52
+ rescue LoadError
53
+ task(:rubycritic) do
54
+ puts('Install rubycritic to run its rake tasks')
55
+ end
56
+ end
57
+
58
+ desc 'Runs all quality code check'
59
+ task(
60
+ all: [
61
+ 'quality:rubocop',
62
+ 'quality:reek',
63
+ 'quality:flay',
64
+ 'quality:rubycritic'
65
+ ]
66
+ )
67
+ end
68
+ # rubocop:enable Metrics/BlockLength
69
+
70
+ desc 'Synonym for quality:rubocop'
71
+ task(rubocop: 'quality:rubocop')
72
+
73
+ desc 'Synonym for quality:reek'
74
+ task(reek: 'quality:reek')
@@ -0,0 +1,19 @@
1
+ # Copyright (c) 2024 Jerome Arbez-Gindre
2
+ # frozen_string_literal: true
3
+
4
+ namespace 'documentation' do
5
+ require('yard')
6
+
7
+ YARD::Rake::YardocTask.new do |task|
8
+ task.files = ['lib/**/*.rb']
9
+ task.options = ['--fail-on-warning', '--verbose']
10
+ task.stats_options = ['--list-undoc']
11
+ end
12
+ rescue LoadError
13
+ task(:yard) do
14
+ puts('Install Yard to run its rake tasks')
15
+ end
16
+ end
17
+
18
+ desc 'Synonym for documentation:yard'
19
+ task(yard: 'documentation:yard')
@@ -0,0 +1,4 @@
1
+ # Copyright (c) 2024 Jerome Arbez-Gindre
2
+ # frozen_string_literal: true
3
+
4
+ require('bundler/gem_tasks')
data/tasks/test.rake CHANGED
@@ -5,30 +5,15 @@ require('cucumber/rake/task')
5
5
  require('rspec/core/rake_task')
6
6
 
7
7
  namespace 'test' do
8
- RSpec::Core::RakeTask.new(:spec)
9
-
10
- cuke_results = 'features_results.html'
11
- CLEAN << cuke_results
12
-
13
- Cucumber::Rake::Task.new(:features) do |t|
14
- opts = ['features'] +
15
- ['--format', 'html'] +
16
- ['-o', cuke_results] +
17
- ['--format', 'progress'] +
18
- ['-x']
19
-
20
- opts += ['--tags', ENV.fetch('TAGS').split.join(' or ')] if ENV['TAGS']
21
- t.cucumber_opts = opts
8
+ RSpec::Core::RakeTask.new(:spec) do |t|
9
+ t.rspec_opts = ['--options config/rspec']
22
10
  end
23
11
 
12
+ CLEAN << 'features_results.html'
13
+
14
+ Cucumber::Rake::Task.new(:features)
24
15
  Cucumber::Rake::Task.new('features:wip') do |t|
25
- t.cucumber_opts = ['features'] +
26
- ['--format', 'html'] +
27
- ['-o', cuke_results] +
28
- ['--format', 'pretty'] +
29
- ['-x'] +
30
- ['-s'] +
31
- ['--tags', '@wip and not @pending']
16
+ t.cucumber_opts = ['--profile wip']
32
17
  end
33
18
 
34
19
  desc 'Runs all unit tests and acceptance tests'