defmastership 1.0.6 → 1.0.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/bin/defmastership +12 -7
  3. data/features/changeref.feature +33 -0
  4. data/features/definition_checksum.feature +298 -0
  5. data/features/definition_version.feature +204 -0
  6. data/features/export.feature +21 -74
  7. data/features/modify.feature +23 -1
  8. data/lib/defmastership.rb +6 -0
  9. data/lib/defmastership/batch_modifier.rb +2 -0
  10. data/lib/defmastership/change_ref_line_modifier.rb +2 -1
  11. data/lib/defmastership/change_ref_modifier.rb +2 -2
  12. data/lib/defmastership/constants.rb +4 -2
  13. data/lib/defmastership/csv_formatter.rb +12 -6
  14. data/lib/defmastership/csv_formatter_body.rb +8 -5
  15. data/lib/defmastership/csv_formatter_header.rb +5 -1
  16. data/lib/defmastership/definition.rb +4 -4
  17. data/lib/defmastership/document.rb +33 -27
  18. data/lib/defmastership/modifier_base.rb +1 -1
  19. data/lib/defmastership/rename_included_files_modifier.rb +2 -17
  20. data/lib/defmastership/update_def_checksum_line_modifier.rb +38 -0
  21. data/lib/defmastership/update_def_checksum_modifier.rb +21 -0
  22. data/lib/defmastership/update_def_version_line_modifier.rb +58 -0
  23. data/lib/defmastership/update_def_version_modifier.rb +25 -0
  24. data/lib/defmastership/version.rb +1 -1
  25. data/spec/unit/defmastership/batch_modifier_spec.rb +8 -0
  26. data/spec/unit/defmastership/change_ref_line_modifier_spec.rb +15 -0
  27. data/spec/unit/defmastership/csv_formatter_body_spec.rb +42 -60
  28. data/spec/unit/defmastership/csv_formatter_header_spec.rb +23 -1
  29. data/spec/unit/defmastership/csv_formatter_spec.rb +204 -67
  30. data/spec/unit/defmastership/definition_spec.rb +19 -4
  31. data/spec/unit/defmastership/document_spec.rb +129 -5
  32. data/spec/unit/defmastership/update_def_checksum_line_modifier_spec.rb +78 -0
  33. data/spec/unit/defmastership/update_def_checksum_modifier_spec.rb +75 -0
  34. data/spec/unit/defmastership/update_def_version_line_modifier_spec.rb +127 -0
  35. data/spec/unit/defmastership/update_def_version_modifier_spec.rb +80 -0
  36. metadata +12 -2
@@ -0,0 +1,80 @@
1
+ # Copyright (c) 2020 Jerome Arbez-Gindre
2
+ # frozen_string_literal: true
3
+
4
+ require('defmastership')
5
+
6
+ RSpec.describe(DefMastership::UpdateDefVersionModifier) do
7
+ subject(:modifier) do
8
+ described_class.new(
9
+ ref_document: 'ref.adoc'
10
+ )
11
+ end
12
+
13
+ let(:adoc_texts) do
14
+ {
15
+ 'file1.adoc' => "file1 line1\nfile1 line2",
16
+ 'file2.adoc' => "file2 line1\nfile2 line2"
17
+ }
18
+ end
19
+
20
+ describe '.new' do
21
+ it { is_expected.not_to(be(nil)) }
22
+ it { is_expected.to(have_attributes(config: { ref_document: 'ref.adoc' })) }
23
+ it { is_expected.to(have_attributes(changes: [])) }
24
+ end
25
+
26
+ describe '#do_modifications' do
27
+ let(:line_modifier) { instance_double(DefMastership::UpdateDefVersionLineModifier, 'lineModifier') }
28
+ let(:document) { instance_double(DefMastership::Document, 'document') }
29
+ let(:ref_document) { instance_double(DefMastership::Document, 'ref_document') }
30
+
31
+ before do
32
+ allow(DefMastership::UpdateDefVersionLineModifier).to(
33
+ receive(:from_config).with(ref_document: 'ref.adoc').and_return(line_modifier)
34
+ )
35
+ allow(DefMastership::Document).to(receive(:new).and_return(document, ref_document))
36
+ allow(document).to(receive(:parse_file_with_preprocessor))
37
+ allow(ref_document).to(receive(:parse_file_with_preprocessor))
38
+ allow(line_modifier).to(receive(:'document=').with(document))
39
+ allow(line_modifier).to(receive(:'ref_document=').with(ref_document))
40
+ allow(line_modifier).to(receive(:replace).with("file1 line1\n").and_return("new file1 line1\n"))
41
+ allow(line_modifier).to(receive(:replace).with('file1 line2').and_return('new file1 line2'))
42
+ allow(line_modifier).to(receive(:replace).with("file2 line1\n").and_return("new file2 line1\n"))
43
+ allow(line_modifier).to(receive(:replace).with('file2 line2').and_return('new file2 line2'))
44
+ allow(line_modifier).to(receive(:config).and_return(ref_document: 'ref.adoc'))
45
+ allow(line_modifier).to(receive(:changes).and_return([%w[from1 to1], %w[from2 to2]]))
46
+ end
47
+
48
+ context 'when detailed expectations' do
49
+ before { modifier.do_modifications(adoc_texts) }
50
+
51
+ it do
52
+ expect(DefMastership::UpdateDefVersionLineModifier).to(
53
+ have_received(:from_config).with(ref_document: 'ref.adoc')
54
+ )
55
+ end
56
+
57
+ it { expect(document).to(have_received(:parse_file_with_preprocessor).with('file1.adoc')) }
58
+ it { expect(document).to(have_received(:parse_file_with_preprocessor).with('file2.adoc')) }
59
+ it { expect(ref_document).to(have_received(:parse_file_with_preprocessor).with('ref.adoc')) }
60
+ it { expect(line_modifier).to(have_received(:'document=').with(document)) }
61
+ it { expect(line_modifier).to(have_received(:'ref_document=').with(ref_document)) }
62
+ it { expect(line_modifier).to(have_received(:replace).with("file1 line1\n")) }
63
+ it { expect(line_modifier).to(have_received(:replace).with('file1 line2')) }
64
+ it { expect(line_modifier).to(have_received(:replace).with("file2 line1\n")) }
65
+ it { expect(line_modifier).to(have_received(:replace).with('file2 line2')) }
66
+ it { expect(line_modifier).to(have_received(:config)) }
67
+ it { expect(line_modifier).to(have_received(:changes)) }
68
+ it { is_expected.to(have_attributes(config: { ref_document: 'ref.adoc' })) }
69
+ it { is_expected.to(have_attributes(changes: [%w[from1 to1], %w[from2 to2]])) }
70
+ end
71
+
72
+ it do
73
+ expected_adoc = {
74
+ 'file1.adoc' => "new file1 line1\nnew file1 line2",
75
+ 'file2.adoc' => "new file2 line1\nnew file2 line2"
76
+ }
77
+ expect(modifier.do_modifications(adoc_texts)).to(eq(expected_adoc))
78
+ end
79
+ end
80
+ end
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.0.6
4
+ version: 1.0.11
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: 2021-02-22 00:00:00.000000000 Z
11
+ date: 2021-04-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aruba
@@ -193,6 +193,8 @@ files:
193
193
  - defmastership.gemspec
194
194
  - defmastership.rdoc
195
195
  - features/changeref.feature
196
+ - features/definition_checksum.feature
197
+ - features/definition_version.feature
196
198
  - features/defmastership.feature
197
199
  - features/export.feature
198
200
  - features/modify.feature
@@ -216,6 +218,10 @@ files:
216
218
  - lib/defmastership/modifier_base.rb
217
219
  - lib/defmastership/rename_included_files_line_modifier.rb
218
220
  - lib/defmastership/rename_included_files_modifier.rb
221
+ - lib/defmastership/update_def_checksum_line_modifier.rb
222
+ - lib/defmastership/update_def_checksum_modifier.rb
223
+ - lib/defmastership/update_def_version_line_modifier.rb
224
+ - lib/defmastership/update_def_version_modifier.rb
219
225
  - lib/defmastership/version.rb
220
226
  - spec/spec_helper.rb
221
227
  - spec/unit/defmastership/batch_modifier_spec.rb
@@ -230,6 +236,10 @@ files:
230
236
  - spec/unit/defmastership/document_spec.rb
231
237
  - spec/unit/defmastership/rename_included_files_line_modifier_spec.rb
232
238
  - spec/unit/defmastership/rename_included_files_modifier_spec.rb
239
+ - spec/unit/defmastership/update_def_checksum_line_modifier_spec.rb
240
+ - spec/unit/defmastership/update_def_checksum_modifier_spec.rb
241
+ - spec/unit/defmastership/update_def_version_line_modifier_spec.rb
242
+ - spec/unit/defmastership/update_def_version_modifier_spec.rb
233
243
  - spec/unit/defmastership_spec.rb
234
244
  homepage: https://gitlab.com/jjag/defmastership/
235
245
  licenses: